Skip to content

Commit 80e97a0

Browse files
David Cashmanbader
authored andcommitted
[SYCL] Improve efficiency of stream output of h_item for FPGA.
This is done by creating a loop in writeHItem and ItemToStr, rather than calling the same function multiple times. Because everything is inlined in the FPGA flow, the latter results in many copies of each function in hardware, which costs significant FPGA area. In a loop, the function will be created once on the FPGA, and invoked multiple times. Signed-off-by: David Cashman <[email protected]>
1 parent 1bef172 commit 80e97a0

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

sycl/include/CL/sycl/detail/stream_impl.hpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,6 @@ inline EnableIfFP<T, unsigned> ScalarToStr(const T &Val, char *Buf,
370370
T Neg = -Val;
371371
auto AbsVal = Val < 0 ? Neg : Val;
372372

373-
374373
if (Val < 0) {
375374
Buf[Offset++] = '-';
376375
} else if (Flags & ShowPos) {
@@ -615,10 +614,10 @@ template <int Dimensions>
615614
inline unsigned ItemToStr(char *Buf, const item<Dimensions, false> &Item) {
616615
unsigned Len = 0;
617616
Len += append(Buf, "item(");
618-
Len += append(Buf + Len, "range: ");
619-
Len += ArrayToStr(Buf + Len, Item.get_range());
620-
Len += append(Buf + Len, ", id: ");
621-
Len += ArrayToStr(Buf + Len, Item.get_id());
617+
for (int I = 0; I < 2; ++I) {
618+
Len += append(Buf + Len, I == 0 ? "range: " : ", id: ");
619+
Len += ArrayToStr(Buf + Len, I == 0 ? Item.get_range() : Item.get_id());
620+
}
622621
Buf[Len++] = ')';
623622
return Len;
624623
}
@@ -632,17 +631,18 @@ inline void writeHItem(stream_impl::OffsetAccessorType &OffsetAcc,
632631
char Buf[3 * MAX_ITEM_SIZE + 60];
633632
unsigned Len = 0;
634633
Len += append(Buf, "h_item(");
635-
Len += append(Buf + Len, "\n global ");
636-
Len += ItemToStr(Buf + Len, HItem.get_global());
637-
Len += append(Buf + Len, "\n logical local ");
638-
Len += ItemToStr(Buf + Len, HItem.get_logical_local());
639-
Len += append(Buf + Len, "\n physical local ");
640-
Len += ItemToStr(Buf + Len, HItem.get_physical_local());
634+
for (int I = 0; I < 3; ++I) {
635+
Len += append(Buf + Len, I == 0 ? "\n global "
636+
: I == 1 ? "\n logical local "
637+
: "\n physical local ");
638+
Len += ItemToStr(Buf + Len, I == 0 ? HItem.get_global()
639+
: I == 1 ? HItem.get_logical_local()
640+
: HItem.get_physical_local());
641+
}
641642
Len += append(Buf + Len, "\n)");
642643
write(OffsetAcc, Acc, Len, Buf);
643644
}
644645

645646
} // namespace detail
646647
} // namespace sycl
647648
} // namespace cl
648-

0 commit comments

Comments
 (0)