DPC++ Runtime
Runtime libraries for oneAPI Data Parallel C++
stream.hpp
Go to the documentation of this file.
1 //==----------------- stream.hpp - SYCL standard header file ---------------==//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #pragma once
10 
11 #include <CL/sycl/builtins.hpp>
14 #include <CL/sycl/handler.hpp>
15 
17 namespace sycl {
18 
19 namespace detail {
20 
21 using FmtFlags = unsigned int;
22 
23 // Mapping from stream_manipulator to FmtFlags. Each manipulator corresponds
24 // to the bit in FmtFlags.
25 static constexpr FmtFlags Dec = 0x0001;
26 static constexpr FmtFlags Hex = 0x0002;
27 static constexpr FmtFlags Oct = 0x0004;
28 static constexpr FmtFlags ShowBase = 0x0008;
29 static constexpr FmtFlags ShowPos = 0x0010;
30 static constexpr FmtFlags Fixed = 0x0020;
31 static constexpr FmtFlags Scientific = 0x0040;
32 
33 // Bitmask made of the combination of the base flags. Base flags are mutually
34 // exclusive, this mask is used to clean base field before setting the new
35 // base flag.
36 static constexpr FmtFlags BaseField = Dec | Hex | Oct;
37 
38 // Bitmask made of the combination of the floating point value format flags.
39 // Thease flags are mutually exclusive, this mask is used to clean float field
40 // before setting the new float flag.
41 static constexpr FmtFlags FloatField = Scientific | Fixed;
42 
43 constexpr size_t MAX_FLOATING_POINT_DIGITS = 24;
44 constexpr size_t MAX_INTEGRAL_DIGITS = 23;
45 constexpr const char *VEC_ELEMENT_DELIMITER = ", ";
46 constexpr char VEC_OPEN_BRACE = '{';
47 constexpr char VEC_CLOSE_BRACE = '}';
48 
49 constexpr size_t MAX_DIMENSIONS = 3;
50 
51 // Space for integrals (up to 3), comma and space between the
52 // integrals and enclosing braces.
53 constexpr size_t MAX_ARRAY_SIZE =
55 
56 // First 2 bytes in each work item's flush buffer are reserved for saving
57 // statement offset.
58 constexpr unsigned FLUSH_BUF_OFFSET_SIZE = 2;
59 
60 template <class F, class T = void>
61 using EnableIfFP =
63  std::is_same<F, double>::value ||
64  std::is_same<F, half>::value,
65  T>;
66 
68  cl::sycl::access::target::global_buffer,
70 
73 using GlobalBufPtrType =
75 constexpr static int GlobalBufDim = 1;
76 
79  cl::sycl::access::target::global_buffer,
81 
84 using GlobalOffsetPtrType =
86 constexpr static int GlobalOffsetDim = 1;
87 
88 // Read first 2 bytes of flush buffer to get buffer offset.
89 // TODO: Should be optimized to the following:
90 // return *reinterpret_cast<uint16_t *>(&GlobalFlushBuf[WIOffset]);
91 // when an issue with device code compilation using this optimization is fixed.
92 inline unsigned GetFlushBufOffset(const GlobalBufAccessorT &GlobalFlushBuf,
93  unsigned WIOffset) {
94  return ((static_cast<unsigned>(static_cast<uint8_t>(GlobalFlushBuf[WIOffset]))
95  << 8) +
96  static_cast<uint8_t>(GlobalFlushBuf[WIOffset + 1]));
97 }
98 
99 // Write flush buffer's offset into first 2 bytes of that buffer.
100 // TODO: Should be optimized to the following:
101 // *reinterpret_cast<uint16_t *>(&GlobalFlushBuf[WIOffset]) =
102 // static_cast<uint16_t>(Offset);
103 // when an issue with device code compilation using this optimization is fixed.
104 inline void SetFlushBufOffset(GlobalBufAccessorT &GlobalFlushBuf,
105  unsigned WIOffset, unsigned Offset) {
106  GlobalFlushBuf[WIOffset] = static_cast<char>((Offset >> 8) & 0xff);
107  GlobalFlushBuf[WIOffset + 1] = static_cast<char>(Offset & 0xff);
108 }
109 
110 inline void write(GlobalBufAccessorT &GlobalFlushBuf, size_t FlushBufferSize,
111  unsigned WIOffset, const char *Str, unsigned Len,
112  unsigned Padding = 0) {
113  unsigned Offset =
114  GetFlushBufOffset(GlobalFlushBuf, WIOffset) + FLUSH_BUF_OFFSET_SIZE;
115 
116  if ((Offset + Len + Padding > FlushBufferSize) ||
117  (WIOffset + Offset + Len + Padding > GlobalFlushBuf.size()))
118  // TODO: flush here
119  return;
120 
121  // Write padding
122  for (size_t I = 0; I < Padding; ++I, ++Offset)
123  GlobalFlushBuf[WIOffset + Offset] = ' ';
124 
125  for (size_t I = 0; I < Len; ++I, ++Offset) {
126  GlobalFlushBuf[WIOffset + Offset] = Str[I];
127  }
128 
129  SetFlushBufOffset(GlobalFlushBuf, WIOffset, Offset - FLUSH_BUF_OFFSET_SIZE);
130 }
131 
132 inline void reverseBuf(char *Buf, unsigned Len) {
133  int I = Len - 1;
134  int J = 0;
135  while (I > J) {
136  int Temp = Buf[I];
137  Buf[I] = Buf[J];
138  Buf[J] = Temp;
139  I--;
140  J++;
141  }
142 }
143 
144 template <typename T>
145 inline typename std::make_unsigned<T>::type getAbsVal(const T Val,
146  const int Base) {
147  return ((Base == 10) && (Val < 0)) ? -Val : Val;
148 }
149 
150 inline char digitToChar(const int Digit) {
151  if (Digit < 10) {
152  return '0' + Digit;
153  } else {
154  return 'a' + Digit - 10;
155  }
156 }
157 
158 template <typename T>
159 inline typename detail::enable_if_t<std::is_integral<T>::value, unsigned>
160 integralToBase(T Val, int Base, char *Digits) {
161  unsigned NumDigits = 0;
162 
163  do {
164  Digits[NumDigits++] = digitToChar(Val % Base);
165  Val /= Base;
166  } while (Val);
167 
168  return NumDigits;
169 }
170 
171 // Returns number of symbols written to the buffer
172 template <typename T>
173 inline typename detail::enable_if_t<std::is_integral<T>::value, unsigned>
174 ScalarToStr(const T &Val, char *Buf, unsigned Flags, int, int Precision = -1) {
175  (void)Precision;
176  int Base = 10;
177 
178  // append base manipulator
179  switch (Flags & BaseField) {
180  case Dec:
181  Base = 10;
182  break;
183  case Hex:
184  Base = 16;
185  break;
186  case Oct:
187  Base = 8;
188  break;
189  default:
190  // default value is 10
191  break;
192  }
193 
194  unsigned Offset = 0;
195 
196  // write '+' to the stream if the base is 10 and the value is non-negative
197  // or write '-' to stream if base is 10 and the value is negative
198  if (Base == 10) {
199  if ((Flags & ShowPos) && Val >= 0)
200  Buf[Offset++] = '+';
201  else if (Val < 0)
202  Buf[Offset++] = '-';
203  }
204 
205  // write 0 or 0x to the stream if base is not 10 and the manipulator is set
206  if (Base != 10 && (Flags & ShowBase)) {
207  Buf[Offset++] = '0';
208  if (Base == 16)
209  Buf[Offset++] = 'x';
210  }
211 
212  auto AbsVal = getAbsVal(Val, Base);
213 
214  const unsigned NumBuf = integralToBase(AbsVal, Base, Buf + Offset);
215 
216  reverseBuf(Buf + Offset, NumBuf);
217  return Offset + NumBuf;
218 }
219 
220 inline unsigned append(char *Dst, const char *Src) {
221  unsigned Len = 0;
222  for (; Src[Len] != '\0'; ++Len)
223  ;
224 
225  for (unsigned I = 0; I < Len; ++I)
226  Dst[I] = Src[I];
227  return Len;
228 }
229 
230 template <typename T>
231 inline typename detail::enable_if_t<
232  std::is_same<T, float>::value || std::is_same<T, double>::value, unsigned>
233 checkForInfNan(char *Buf, T Val) {
234  if (isnan(Val))
235  return append(Buf, "nan");
236  if (isinf(Val)) {
237  if (signbit(Val))
238  return append(Buf, "-inf");
239  return append(Buf, "inf");
240  }
241  return 0;
242 }
243 
244 template <typename T>
245 inline typename detail::enable_if_t<std::is_same<T, half>::value, unsigned>
246 checkForInfNan(char *Buf, T Val) {
247  if (Val != Val)
248  return append(Buf, "nan");
249 
250  // Extract the sign from the bits
251  const uint16_t Sign = reinterpret_cast<uint16_t &>(Val) & 0x8000;
252  // Extract the exponent from the bits
253  const uint16_t Exp16 = (reinterpret_cast<uint16_t &>(Val) & 0x7c00) >> 10;
254 
255  if (Exp16 == 0x1f) {
256  if (Sign)
257  return append(Buf, "-inf");
258  return append(Buf, "inf");
259  }
260  return 0;
261 }
262 
263 template <typename T>
265  int Precision, bool IsSci) {
266  int Exp = 0;
267 
268  // For the case that the value is larger than 10.0
269  while (AbsVal >= 10.0) {
270  ++Exp;
271  AbsVal /= 10.0;
272  }
273  // For the case that the value is less than 1.0
274  while (AbsVal > 0.0 && AbsVal < 1.0) {
275  --Exp;
276  AbsVal *= 10.0;
277  }
278 
279  auto IntegralPart = static_cast<int>(AbsVal);
280  auto FractionPart = AbsVal - IntegralPart;
281 
282  int FractionDigits[MAX_FLOATING_POINT_DIGITS] = {0};
283 
284  // Exponent
285  int P = Precision > 0 ? Precision : 4;
286  size_t FractionLength = Exp + P;
287 
288  // After normalization integral part contains 1 symbol, also there could be
289  // '.', 'e', sign of the exponent and sign of the number, overall 5 symbols.
290  // So, clamp fraction length if required according to maximum size of the
291  // buffer for floating point number.
292  if (FractionLength > MAX_FLOATING_POINT_DIGITS - 5)
293  FractionLength = MAX_FLOATING_POINT_DIGITS - 5;
294 
295  for (unsigned I = 0; I < FractionLength; ++I) {
296  FractionPart *= 10.0;
297  FractionDigits[I] = static_cast<int>(FractionPart);
298  FractionPart -= static_cast<int>(FractionPart);
299  }
300 
301  int Carry = FractionPart > static_cast<T>(0.5) ? 1 : 0;
302 
303  // Propagate the Carry
304  for (int I = FractionLength - 1; I >= 0 && Carry; --I) {
305  auto Digit = FractionDigits[I] + Carry;
306  FractionDigits[I] = Digit % 10;
307  Carry = Digit / 10;
308  }
309 
310  // Carry from the fraction part is propagated to integral part
311  IntegralPart += Carry;
312  if (IntegralPart == 10) {
313  IntegralPart = 1;
314  ++Exp;
315  }
316 
317  unsigned Offset = 0;
318 
319  // Assemble the final string correspondingly
320  if (IsSci) { // scientific mode
321  // Append the integral part
322  Digits[Offset++] = digitToChar(IntegralPart);
323  Digits[Offset++] = '.';
324 
325  // Append all fraction
326  for (unsigned I = 0; I < FractionLength; ++I)
327  Digits[Offset++] = digitToChar(FractionDigits[I]);
328 
329  // Exponent part
330  Digits[Offset++] = 'e';
331  Digits[Offset++] = Exp >= 0 ? '+' : '-';
332  Digits[Offset++] = digitToChar(abs(Exp) / 10);
333  Digits[Offset++] = digitToChar(abs(Exp) % 10);
334  } else { // normal mode
335  if (Exp < 0) {
336  Digits[Offset++] = '0';
337  Digits[Offset++] = '.';
338  while (++Exp)
339  Digits[Offset++] = '0';
340 
341  // Append the integral part
342  Digits[Offset++] = digitToChar(IntegralPart);
343 
344  // Append all fraction
345  for (unsigned I = 0; I < FractionLength; ++I)
346  Digits[Offset++] = digitToChar(FractionDigits[I]);
347  } else {
348  // Append the integral part
349  Digits[Offset++] = digitToChar(IntegralPart);
350  unsigned I = 0;
351  // Append the integral part first
352  for (; I < FractionLength && Exp--; ++I)
353  Digits[Offset++] = digitToChar(FractionDigits[I]);
354 
355  // Put the dot
356  Digits[Offset++] = '.';
357 
358  // Append the rest of fraction part, or the real fraction part
359  for (; I < FractionLength; ++I)
360  Digits[Offset++] = digitToChar(FractionDigits[I]);
361  }
362  // The normal mode requires no tailing zero digit, then we need to first
363  // find the first non-zero digit
364  while (Digits[Offset - 1] == '0')
365  Offset--;
366 
367  // If dot is the last digit, it should be stripped off as well
368  if (Digits[Offset - 1] == '.')
369  Offset--;
370  }
371  return Offset;
372 }
373 
374 // Returns number of symbols written to the buffer
375 template <typename T>
377 ScalarToStr(const T &Val, char *Buf, unsigned Flags, int, int Precision = -1) {
378  unsigned Offset = checkForInfNan(Buf, Val);
379  if (Offset)
380  return Offset;
381 
382  T Neg = -Val;
383  auto AbsVal = Val < 0 ? Neg : Val;
384 
385  if (Val < 0) {
386  Buf[Offset++] = '-';
387  } else if (Flags & ShowPos) {
388  Buf[Offset++] = '+';
389  }
390 
391  bool IsSci = false;
392  if (Flags & detail::Scientific)
393  IsSci = true;
394 
395  // TODO: manipulators for floating-point output - hexfloat, fixed
396  Offset += floatingPointToDecStr(AbsVal, Buf + Offset, Precision, IsSci);
397 
398  return Offset;
399 }
400 
401 template <typename T>
403 writeIntegral(GlobalBufAccessorT &GlobalFlushBuf, size_t FlushBufferSize,
404  unsigned WIOffset, unsigned Flags, int Width, const T &Val) {
405  char Digits[MAX_INTEGRAL_DIGITS] = {0};
406  unsigned Len = ScalarToStr(Val, Digits, Flags, Width);
407  write(GlobalFlushBuf, FlushBufferSize, WIOffset, Digits, Len,
408  (Width > 0 && static_cast<unsigned>(Width) > Len)
409  ? static_cast<unsigned>(Width) - Len
410  : 0);
411 }
412 
413 template <typename T>
414 inline EnableIfFP<T>
415 writeFloatingPoint(GlobalBufAccessorT &GlobalFlushBuf, size_t FlushBufferSize,
416  unsigned WIOffset, unsigned Flags, int Width, int Precision,
417  const T &Val) {
418  char Digits[MAX_FLOATING_POINT_DIGITS] = {0};
419  unsigned Len = ScalarToStr(Val, Digits, Flags, Width, Precision);
420  write(GlobalFlushBuf, FlushBufferSize, WIOffset, Digits, Len,
421  (Width > 0 && static_cast<unsigned>(Width) > Len)
422  ? static_cast<unsigned>(Width) - Len
423  : 0);
424 }
425 
426 // Helper method to update offset in the global buffer atomically according to
427 // the provided size of the data in the flush buffer. Return true if offset is
428 // updated and false in case of overflow.
429 inline bool updateOffset(GlobalOffsetAccessorT &GlobalOffset,
430  GlobalBufAccessorT &GlobalBuf, unsigned Size,
431  unsigned &Cur) {
432  unsigned New;
433  Cur = GlobalOffset[0].load();
434  do {
435  if (GlobalBuf.get_range().size() - Cur < Size)
436  // Overflow
437  return false;
438  New = Cur + Size;
439  } while (!GlobalOffset[0].compare_exchange_strong(Cur, New));
440  return true;
441 }
442 
443 inline void flushBuffer(GlobalOffsetAccessorT &GlobalOffset,
444  GlobalBufAccessorT &GlobalBuf,
445  GlobalBufAccessorT &GlobalFlushBuf, unsigned WIOffset) {
446  unsigned Offset = GetFlushBufOffset(GlobalFlushBuf, WIOffset);
447  if (Offset == 0)
448  return;
449 
450  unsigned Cur = 0;
451  if (!updateOffset(GlobalOffset, GlobalBuf, Offset, Cur))
452  return;
453 
454  unsigned StmtOffset = WIOffset + FLUSH_BUF_OFFSET_SIZE;
455  for (unsigned I = StmtOffset; I < StmtOffset + Offset; I++) {
456  GlobalBuf[Cur++] = GlobalFlushBuf[I];
457  }
458  // Reset the offset in the flush buffer
459  SetFlushBufOffset(GlobalFlushBuf, WIOffset, 0);
460 }
461 
462 template <typename T, int VecLength>
463 typename detail::enable_if_t<(VecLength == 1), unsigned>
464 VecToStr(const vec<T, VecLength> &Vec, char *VecStr, unsigned Flags, int Width,
465  int Precision) {
466  return ScalarToStr(static_cast<T>(Vec.x()), VecStr, Flags, Width, Precision);
467 }
468 
469 template <typename T, int VecLength>
470 typename detail::enable_if_t<(VecLength == 2 || VecLength == 4 ||
471  VecLength == 8 || VecLength == 16),
472  unsigned>
473 VecToStr(const vec<T, VecLength> &Vec, char *VecStr, unsigned Flags, int Width,
474  int Precision) {
475  unsigned Len =
476  VecToStr<T, VecLength / 2>(Vec.lo(), VecStr, Flags, Width, Precision);
477  Len += append(VecStr + Len, VEC_ELEMENT_DELIMITER);
478  Len += VecToStr<T, VecLength / 2>(Vec.hi(), VecStr + Len, Flags, Width,
479  Precision);
480  return Len;
481 }
482 
483 template <typename T, int VecLength>
484 typename detail::enable_if_t<(VecLength == 3), unsigned>
485 VecToStr(const vec<T, VecLength> &Vec, char *VecStr, unsigned Flags, int Width,
486  int Precision) {
487  unsigned Len = VecToStr<T, 2>(Vec.lo(), VecStr, Flags, Width, Precision);
488  Len += append(VecStr + Len, VEC_ELEMENT_DELIMITER);
489  Len += VecToStr<T, 1>(Vec.z(), VecStr + Len, Flags, Width, Precision);
490  return Len;
491 }
492 
493 template <typename T, int VecLength>
494 inline void writeVec(GlobalBufAccessorT &GlobalFlushBuf, size_t FlushBufferSize,
495  unsigned WIOffset, unsigned Flags, int Width,
496  int Precision, const vec<T, VecLength> &Vec) {
497  // Reserve space for vector elements and delimiters
498  constexpr size_t MAX_VEC_SIZE =
499  MAX_FLOATING_POINT_DIGITS * VecLength + (VecLength - 1) * 2;
500  char VecStr[MAX_VEC_SIZE] = {0};
501  unsigned Len = VecToStr<T, VecLength>(Vec, VecStr, Flags, Width, Precision);
502  write(GlobalFlushBuf, FlushBufferSize, WIOffset, VecStr, Len,
503  (Width > 0 && Width > Len) ? Width - Len : 0);
504 }
505 
506 template <int ArrayLength>
507 inline unsigned ArrayToStr(char *Buf, const array<ArrayLength> &Arr) {
508  unsigned Len = 0;
509  Buf[Len++] = VEC_OPEN_BRACE;
510 
511  for (int I = 0; I < ArrayLength; ++I) {
512  Len += ScalarToStr(Arr[I], Buf + Len, 0 /* No flags */, -1, -1);
513  if (I != ArrayLength - 1)
514  Len += append(Buf + Len, VEC_ELEMENT_DELIMITER);
515  }
516 
517  Buf[Len++] = VEC_CLOSE_BRACE;
518 
519  return Len;
520 }
521 
522 template <int ArrayLength>
523 inline void writeArray(GlobalBufAccessorT &GlobalFlushBuf,
524  size_t FlushBufferSize, unsigned WIOffset,
525  const array<ArrayLength> &Arr) {
526  char Buf[MAX_ARRAY_SIZE];
527  unsigned Len = ArrayToStr(Buf, Arr);
528  write(GlobalFlushBuf, FlushBufferSize, WIOffset, Buf, Len);
529 }
530 
531 template <int Dimensions>
532 inline void writeItem(GlobalBufAccessorT &GlobalFlushBuf,
533  size_t FlushBufferSize, unsigned WIOffset,
534  const item<Dimensions> &Item) {
535  // Reserve space for 3 arrays and additional place (40 symbols) for printing
536  // the text
537  char Buf[3 * MAX_ARRAY_SIZE + 40];
538  unsigned Len = 0;
539  Len += append(Buf, "item(");
540  Len += append(Buf + Len, "range: ");
541  Len += ArrayToStr(Buf + Len, Item.get_range());
542  Len += append(Buf + Len, ", id: ");
543  Len += ArrayToStr(Buf + Len, Item.get_id());
544  Len += append(Buf + Len, ", offset: ");
545  Len += ArrayToStr(Buf + Len, Item.get_offset());
546  Buf[Len++] = ')';
547  write(GlobalFlushBuf, FlushBufferSize, WIOffset, Buf, Len);
548 }
549 
550 template <int Dimensions>
551 inline void writeNDRange(GlobalBufAccessorT &GlobalFlushBuf,
552  size_t FlushBufferSize, unsigned WIOffset,
553  const nd_range<Dimensions> &ND_Range) {
554  // Reserve space for 3 arrays and additional place (50 symbols) for printing
555  // the text
556  char Buf[3 * MAX_ARRAY_SIZE + 50];
557  unsigned Len = 0;
558  Len += append(Buf, "nd_range(");
559  Len += append(Buf + Len, "global_range: ");
560  Len += ArrayToStr(Buf + Len, ND_Range.get_global_range());
561  Len += append(Buf + Len, ", local_range: ");
562  Len += ArrayToStr(Buf + Len, ND_Range.get_local_range());
563  Len += append(Buf + Len, ", offset: ");
564  Len += ArrayToStr(Buf + Len, ND_Range.get_offset());
565  Buf[Len++] = ')';
566  write(GlobalFlushBuf, FlushBufferSize, WIOffset, Buf, Len);
567 }
568 
569 template <int Dimensions>
570 inline void writeNDItem(GlobalBufAccessorT &GlobalFlushBuf,
571  size_t FlushBufferSize, unsigned WIOffset,
572  const nd_item<Dimensions> &ND_Item) {
573  // Reserve space for 2 arrays and additional place (40 symbols) for printing
574  // the text
575  char Buf[2 * MAX_ARRAY_SIZE + 40];
576  unsigned Len = 0;
577  Len += append(Buf, "nd_item(");
578  Len += append(Buf + Len, "global_id: ");
579  Len += ArrayToStr(Buf + Len, ND_Item.get_global_id());
580  Len += append(Buf + Len, ", local_id: ");
581  Len += ArrayToStr(Buf + Len, ND_Item.get_local_id());
582  Buf[Len++] = ')';
583  write(GlobalFlushBuf, FlushBufferSize, WIOffset, Buf, Len);
584 }
585 
586 template <int Dimensions>
587 inline void writeGroup(GlobalBufAccessorT &GlobalFlushBuf,
588  size_t FlushBufferSize, unsigned WIOffset,
589  const group<Dimensions> &Group) {
590  // Reserve space for 4 arrays and additional place (60 symbols) for printing
591  // the text
592  char Buf[4 * MAX_ARRAY_SIZE + 60];
593  unsigned Len = 0;
594  Len += append(Buf, "group(");
595  Len += append(Buf + Len, "id: ");
596  Len += ArrayToStr(Buf + Len, Group.get_id());
597  Len += append(Buf + Len, ", global_range: ");
598  Len += ArrayToStr(Buf + Len, Group.get_global_range());
599  Len += append(Buf + Len, ", local_range: ");
600  Len += ArrayToStr(Buf + Len, Group.get_local_range());
601  Len += append(Buf + Len, ", group_range: ");
602  Len += ArrayToStr(Buf + Len, Group.get_group_range());
603  Buf[Len++] = ')';
604  write(GlobalFlushBuf, FlushBufferSize, WIOffset, Buf, Len);
605 }
606 
607 // Space for 2 arrays and additional place (20 symbols) for printing
608 // the text
609 constexpr size_t MAX_ITEM_SIZE = 2 * MAX_ARRAY_SIZE + 20;
610 
611 template <int Dimensions>
612 inline unsigned ItemToStr(char *Buf, const item<Dimensions, false> &Item) {
613  unsigned Len = 0;
614  Len += append(Buf, "item(");
615  for (int I = 0; I < 2; ++I) {
616  Len += append(Buf + Len, I == 0 ? "range: " : ", id: ");
617  Len += ArrayToStr(Buf + Len, I == 0 ? Item.get_range() : Item.get_id());
618  }
619  Buf[Len++] = ')';
620  return Len;
621 }
622 
623 template <int Dimensions>
624 inline void writeHItem(GlobalBufAccessorT &GlobalFlushBuf,
625  size_t FlushBufferSize, unsigned WIOffset,
626  const h_item<Dimensions> &HItem) {
627  // Reserve space for 3 items and additional place (60 symbols) for printing
628  // the text
629  char Buf[3 * MAX_ITEM_SIZE + 60];
630  unsigned Len = 0;
631  Len += append(Buf, "h_item(");
632  for (int I = 0; I < 3; ++I) {
633  Len += append(Buf + Len, I == 0 ? "\n global "
634  : I == 1 ? "\n logical local "
635  : "\n physical local ");
636  Len += ItemToStr(Buf + Len, I == 0 ? HItem.get_global()
637  : I == 1 ? HItem.get_logical_local()
638  : HItem.get_physical_local());
639  }
640  Len += append(Buf + Len, "\n)");
641  write(GlobalFlushBuf, FlushBufferSize, WIOffset, Buf, Len);
642 }
643 
644 template <typename> struct IsSwizzleOp : std::false_type {};
645 
646 template <typename VecT, typename OperationLeftT, typename OperationRightT,
647  template <typename> class OperationCurrentT, int... Indexes>
649  VecT, OperationLeftT, OperationRightT, OperationCurrentT, Indexes...>>
650  : std::true_type {
651  using T = typename VecT::element_type;
652  using Type = typename cl::sycl::vec<T, (sizeof...(Indexes))>;
653 };
654 
655 template <typename T>
656 using EnableIfSwizzleVec =
659 
660 } // namespace detail
661 
662 enum class stream_manipulator {
663  dec = 0,
664  hex = 1,
665  oct = 2,
666  noshowbase = 3,
667  showbase = 4,
668  noshowpos = 5,
669  showpos = 6,
670  endl = 7,
671  flush = 8,
672  fixed = 9,
673  scientific = 10,
674  hexfloat = 11,
675  defaultfloat = 12
676 };
677 
679 
681 
683 
685 
687 
689 
691 
693 
695 
697 
699 
701 
703 
704 class stream;
705 
707  int Precision_;
708 
709 public:
710  __precision_manipulator__(int Precision) : Precision_(Precision) {}
711 
712  int precision() const { return Precision_; }
713 
714  friend const stream &operator<<(const stream &,
715  const __precision_manipulator__ &);
716 };
717 
719  int Width_;
720 
721 public:
722  __width_manipulator__(int Width) : Width_(Width) {}
723 
724  int width() const { return Width_; }
725 
726  friend const stream &operator<<(const stream &,
727  const __width_manipulator__ &);
728 };
729 
731  return __precision_manipulator__(Precision);
732 }
733 
734 inline __width_manipulator__ setw(int Width) {
735  return __width_manipulator__(Width);
736 }
737 
742 class __SYCL_EXPORT __SYCL_SPECIAL_CLASS stream {
743 public:
744 #ifdef __SYCL_DEVICE_ONLY__
745  // Default constructor for objects later initialized with __init member.
746  stream() = default;
747 #endif
748 
749  // Throws exception in case of invalid input parameters
750  stream(size_t BufferSize, size_t MaxStatementSize, handler &CGH);
751 
752  size_t get_size() const;
753 
754  size_t get_max_statement_size() const;
755 
756  size_t get_precision() const { return Precision; }
757 
758  size_t get_width() const { return Width; }
759 
760  stream_manipulator get_stream_mode() const { return Manipulator; }
761 
762  bool operator==(const stream &RHS) const;
763 
764  bool operator!=(const stream &LHS) const;
765 
766 private:
767 #ifdef __SYCL_DEVICE_ONLY__
768  char padding[sizeof(std::shared_ptr<detail::stream_impl>)];
769 #else
770  std::shared_ptr<detail::stream_impl> impl;
771  template <class Obj>
772  friend decltype(Obj::impl) detail::getSyclObjImpl(const Obj &SyclObject);
773 #endif
774 
775  // Accessor to the global stream buffer. Global buffer contains all output
776  // from the kernel.
777  mutable detail::GlobalBufAccessorT GlobalBuf;
778 
779  // Atomic accessor to the global offset variable. It represents an offset in
780  // the global stream buffer. Since work items will flush data to global buffer
781  // in parallel we need atomic access to this offset.
782  mutable detail::GlobalOffsetAccessorT GlobalOffset;
783 
784  // Accessor to the flush buffer. Each work item writes its
785  // output to a designated section of the flush buffer.
786  mutable detail::GlobalBufAccessorT GlobalFlushBuf;
787 
788  // Offset of the WI's flush buffer in the pool.
789  mutable unsigned WIOffset = 0;
790 
791  // Offset in the flush buffer
792  // TODO: This field is not used anymore.
793  // To be removed when API/ABI changes are allowed.
794  mutable unsigned Offset = 0;
795 
796  mutable size_t FlushBufferSize;
797 
798  // Fields and methods to work with manipulators
799  mutable stream_manipulator Manipulator = defaultfloat;
800 
801  // Type used for format flags
802  using FmtFlags = unsigned int;
803 
804  mutable int Precision = -1;
805  mutable int Width = -1;
806  mutable FmtFlags Flags = 0x0;
807 
808  void set_flag(FmtFlags FormatFlag) const { Flags |= FormatFlag; }
809 
810  void unset_flag(FmtFlags FormatFlag) const { Flags &= ~FormatFlag; }
811 
812  FmtFlags get_flags() const { return Flags; }
813 
814  // This method is used to set the flag for base and float manipulators. These
815  // flags are mutually exclusive and base/float field needs to be cleared
816  // before the setting new flag.
817  void set_flag(FmtFlags FormatFlag, FmtFlags Mask) const {
818  unset_flag(Mask);
819  Flags |= FormatFlag & Mask;
820  }
821 
822  // Set the flags which correspond to the input stream manipulator.
823  void set_manipulator(const stream_manipulator SM) const {
824  switch (SM) {
826  set_flag(detail::Dec, detail::BaseField);
827  break;
829  set_flag(detail::Hex, detail::BaseField);
830  break;
832  set_flag(detail::Oct, detail::BaseField);
833  break;
835  unset_flag(detail::ShowBase);
836  break;
838  set_flag(detail::ShowBase);
839  break;
841  unset_flag(detail::ShowPos);
842  break;
844  set_flag(detail::ShowPos);
845  break;
848  break;
851  break;
854  break;
856  unset_flag(detail::FloatField);
857  break;
858  default:
859  // Unknown manipulator
860  break;
861  }
862  }
863 
864 #ifdef __SYCL_DEVICE_ONLY__
865  void __init(detail::GlobalBufPtrType GlobalBufPtr,
866  range<detail::GlobalBufDim> GlobalBufAccRange,
867  range<detail::GlobalBufDim> GlobalBufMemRange,
868  id<detail::GlobalBufDim> GlobalBufId,
869  detail::GlobalOffsetPtrType GlobalOffsetPtr,
870  range<detail::GlobalOffsetDim> GlobalOffsetAccRange,
871  range<detail::GlobalOffsetDim> GlobalOffsetMemRange,
872  id<detail::GlobalOffsetDim> GlobalOffsetId,
873  detail::GlobalBufPtrType GlobalFlushPtr,
874  range<detail::GlobalBufDim> GlobalFlushAccRange,
875  range<detail::GlobalBufDim> GlobalFlushMemRange,
876  id<detail::GlobalBufDim> GlobalFlushId, size_t _FlushBufferSize) {
877  GlobalBuf.__init(GlobalBufPtr, GlobalBufAccRange, GlobalBufMemRange,
878  GlobalBufId);
879  GlobalOffset.__init(GlobalOffsetPtr, GlobalOffsetAccRange,
880  GlobalOffsetMemRange, GlobalOffsetId);
881  GlobalFlushBuf.__init(GlobalFlushPtr, GlobalFlushAccRange,
882  GlobalFlushMemRange, GlobalFlushId);
883  FlushBufferSize = _FlushBufferSize;
884  // Calculate offset in the flush buffer for each work item in the global
885  // work space. We need to avoid calling intrinsics to get global id because
886  // when stream is used in a single_task kernel this could cause some
887  // overhead on FPGA target. That is why use global atomic variable to
888  // calculate offsets.
889  WIOffset = GlobalOffset[1].fetch_add(FlushBufferSize);
890 
891  // Initialize flush subbuffer's offset for each work item on device.
892  // Initialization on host device is performed via submition of additional
893  // host task.
894  SetFlushBufOffset(GlobalFlushBuf, WIOffset, 0);
895  }
896 
897  void __finalize() {
898  // Flush data to global buffer if flush buffer is not empty. This could be
899  // necessary if user hasn't yet flushed data on its own and kernel execution
900  // is finished
901  // NOTE: A call to this function will be generated by compiler
902  // NOTE: In the current implementation user should explicitly flush data on
903  // the host device. Data is not flushed automatically after kernel execution
904  // because of the missing feature in scheduler.
905  flushBuffer(GlobalOffset, GlobalBuf, GlobalFlushBuf, WIOffset);
906  }
907 #endif
908 
909  friend class handler;
910 
911  friend const stream &operator<<(const stream &, const char);
912  friend const stream &operator<<(const stream &, const char *);
913  template <typename ValueType>
915  const stream &>
916  operator<<(const stream &, const ValueType &);
917  friend const stream &operator<<(const stream &, const float &);
918  friend const stream &operator<<(const stream &, const double &);
919  friend const stream &operator<<(const stream &, const half &);
920 
921  friend const stream &operator<<(const stream &, const stream_manipulator);
922 
923  friend const stream &operator<<(const stream &Out,
924  const __precision_manipulator__ &RHS);
925 
926  friend const stream &operator<<(const stream &Out,
927  const __width_manipulator__ &RHS);
928  template <typename T, int Dimensions>
929  friend const stream &operator<<(const stream &Out,
930  const vec<T, Dimensions> &RHS);
931  template <typename T>
932  friend const stream &operator<<(const stream &Out, const T *RHS);
933  template <int Dimensions>
934  friend const stream &operator<<(const stream &Out, const id<Dimensions> &RHS);
935 
936  template <int Dimensions>
937  friend const stream &operator<<(const stream &Out,
938  const range<Dimensions> &RHS);
939 
940  template <int Dimensions>
941  friend const stream &operator<<(const stream &Out,
942  const item<Dimensions> &RHS);
943 
944  template <int Dimensions>
945  friend const stream &operator<<(const stream &Out,
946  const nd_range<Dimensions> &RHS);
947 
948  template <int Dimensions>
949  friend const stream &operator<<(const stream &Out,
950  const nd_item<Dimensions> &RHS);
951 
952  template <int Dimensions>
953  friend const stream &operator<<(const stream &Out,
954  const group<Dimensions> &RHS);
955 
956  template <int Dimensions>
957  friend const stream &operator<<(const stream &Out,
958  const h_item<Dimensions> &RHS);
959 };
960 
961 #if __cplusplus >= 201703L
962 // Byte (has to be converted to a numeric value)
963 template <typename T>
964 inline std::enable_if_t<std::is_same<T, std::byte>::value, const stream &>
965 operator<<(const stream &, const T &) {
966  static_assert(std::is_integral<T>(),
967  "Convert the byte to a numeric value using std::to_integer");
968 }
969 #endif // __cplusplus >= 201703L
970 
971 // Character
972 inline const stream &operator<<(const stream &Out, const char C) {
973  detail::write(Out.GlobalFlushBuf, Out.FlushBufferSize, Out.WIOffset, &C, 1);
974  return Out;
975 }
976 
977 // String
978 inline const stream &operator<<(const stream &Out, const char *Str) {
979  unsigned Len = 0;
980  for (; Str[Len] != '\0'; Len++)
981  ;
982 
983  detail::write(Out.GlobalFlushBuf, Out.FlushBufferSize, Out.WIOffset, Str,
984  Len);
985  return Out;
986 }
987 
988 // Boolean
989 inline const stream &operator<<(const stream &Out, const bool &RHS) {
990  Out << (RHS ? "true" : "false");
991  return Out;
992 }
993 
994 // Integral
995 template <typename ValueType>
996 inline typename detail::enable_if_t<std::is_integral<ValueType>::value,
997  const stream &>
998 operator<<(const stream &Out, const ValueType &RHS) {
999  detail::writeIntegral(Out.GlobalFlushBuf, Out.FlushBufferSize, Out.WIOffset,
1000  Out.get_flags(), Out.get_width(), RHS);
1001  return Out;
1002 }
1003 
1004 // Floating points
1005 
1006 inline const stream &operator<<(const stream &Out, const float &RHS) {
1007  detail::writeFloatingPoint<float>(Out.GlobalFlushBuf, Out.FlushBufferSize,
1008  Out.WIOffset, Out.get_flags(),
1009  Out.get_width(), Out.get_precision(), RHS);
1010  return Out;
1011 }
1012 
1013 inline const stream &operator<<(const stream &Out, const double &RHS) {
1014  detail::writeFloatingPoint<double>(Out.GlobalFlushBuf, Out.FlushBufferSize,
1015  Out.WIOffset, Out.get_flags(),
1016  Out.get_width(), Out.get_precision(), RHS);
1017  return Out;
1018 }
1019 
1020 inline const stream &operator<<(const stream &Out, const half &RHS) {
1021  detail::writeFloatingPoint<half>(Out.GlobalFlushBuf, Out.FlushBufferSize,
1022  Out.WIOffset, Out.get_flags(),
1023  Out.get_width(), Out.get_precision(), RHS);
1024  return Out;
1025 }
1026 
1027 // Pointer
1028 
1029 template <typename ElementType, access::address_space Space>
1030 inline const stream &operator<<(const stream &Out,
1031  const multi_ptr<ElementType, Space> &RHS) {
1032  Out << RHS.get();
1033  return Out;
1034 }
1035 
1036 template <typename T>
1037 const stream &operator<<(const stream &Out, const T *RHS) {
1038  detail::FmtFlags Flags = Out.get_flags();
1039  Flags &= ~detail::BaseField;
1040  Flags |= detail::Hex | detail::ShowBase;
1041  detail::writeIntegral(Out.GlobalFlushBuf, Out.FlushBufferSize, Out.WIOffset,
1042  Flags, Out.get_width(), reinterpret_cast<size_t>(RHS));
1043  return Out;
1044 }
1045 
1046 // Manipulators
1047 
1048 inline const stream &operator<<(const stream &Out,
1049  const __precision_manipulator__ &RHS) {
1050  Out.Precision = RHS.precision();
1051  return Out;
1052 }
1053 
1054 inline const stream &operator<<(const stream &Out,
1055  const __width_manipulator__ &RHS) {
1056  Out.Width = RHS.width();
1057  return Out;
1058 }
1059 
1060 inline const stream &operator<<(const stream &Out,
1061  const stream_manipulator RHS) {
1062  switch (RHS) {
1064  Out << '\n';
1065  flushBuffer(Out.GlobalOffset, Out.GlobalBuf, Out.GlobalFlushBuf,
1066  Out.WIOffset);
1067  break;
1069  flushBuffer(Out.GlobalOffset, Out.GlobalBuf, Out.GlobalFlushBuf,
1070  Out.WIOffset);
1071  break;
1072  default:
1073  Out.set_manipulator(RHS);
1074  break;
1075  }
1076  return Out;
1077 }
1078 
1079 // Vec
1080 
1081 template <typename T, int VectorLength>
1082 const stream &operator<<(const stream &Out, const vec<T, VectorLength> &RHS) {
1083  detail::writeVec<T, VectorLength>(Out.GlobalFlushBuf, Out.FlushBufferSize,
1084  Out.WIOffset, Out.get_flags(),
1085  Out.get_width(), Out.get_precision(), RHS);
1086  return Out;
1087 }
1088 
1089 // SYCL types
1090 
1091 template <int Dimensions>
1092 inline const stream &operator<<(const stream &Out, const id<Dimensions> &RHS) {
1093  detail::writeArray<Dimensions>(Out.GlobalFlushBuf, Out.FlushBufferSize,
1094  Out.WIOffset, RHS);
1095  return Out;
1096 }
1097 
1098 template <int Dimensions>
1099 inline const stream &operator<<(const stream &Out,
1100  const range<Dimensions> &RHS) {
1101  detail::writeArray<Dimensions>(Out.GlobalFlushBuf, Out.FlushBufferSize,
1102  Out.WIOffset, RHS);
1103  return Out;
1104 }
1105 
1106 template <int Dimensions>
1107 inline const stream &operator<<(const stream &Out,
1108  const item<Dimensions> &RHS) {
1109  detail::writeItem<Dimensions>(Out.GlobalFlushBuf, Out.FlushBufferSize,
1110  Out.WIOffset, RHS);
1111  return Out;
1112 }
1113 
1114 template <int Dimensions>
1115 inline const stream &operator<<(const stream &Out,
1116  const nd_range<Dimensions> &RHS) {
1117  detail::writeNDRange<Dimensions>(Out.GlobalFlushBuf, Out.FlushBufferSize,
1118  Out.WIOffset, RHS);
1119  return Out;
1120 }
1121 
1122 template <int Dimensions>
1123 inline const stream &operator<<(const stream &Out,
1124  const nd_item<Dimensions> &RHS) {
1125  detail::writeNDItem<Dimensions>(Out.GlobalFlushBuf, Out.FlushBufferSize,
1126  Out.WIOffset, RHS);
1127  return Out;
1128 }
1129 
1130 template <int Dimensions>
1131 inline const stream &operator<<(const stream &Out,
1132  const group<Dimensions> &RHS) {
1133  detail::writeGroup<Dimensions>(Out.GlobalFlushBuf, Out.FlushBufferSize,
1134  Out.WIOffset, RHS);
1135  return Out;
1136 }
1137 
1138 template <int Dimensions>
1139 inline const stream &operator<<(const stream &Out,
1140  const h_item<Dimensions> &RHS) {
1141  detail::writeHItem<Dimensions>(Out.GlobalFlushBuf, Out.FlushBufferSize,
1142  Out.WIOffset, RHS);
1143  return Out;
1144 }
1145 
1146 template <typename T, typename RT = detail::EnableIfSwizzleVec<T>>
1147 inline const stream &operator<<(const stream &Out, const T &RHS) {
1148  RT V = RHS;
1149  Out << V;
1150  return Out;
1151 }
1152 
1153 } // namespace sycl
1154 } // __SYCL_INLINE_NAMESPACE(cl)
1155 namespace std {
1156 template <> struct hash<cl::sycl::stream> {
1157  size_t operator()(const cl::sycl::stream &S) const {
1158 #ifdef __SYCL_DEVICE_ONLY__
1159  (void)S;
1160  return 0;
1161 #else
1162  return hash<std::shared_ptr<cl::sycl::detail::stream_impl>>()(
1164 #endif
1165  }
1166 };
1167 } // namespace std
cl::sycl::nd_range
Defines the iteration domain of both the work-groups and the overall dispatch.
Definition: nd_range.hpp:23
cl::sycl::detail::writeNDItem
void writeNDItem(GlobalBufAccessorT &GlobalFlushBuf, size_t FlushBufferSize, unsigned WIOffset, const nd_item< Dimensions > &ND_Item)
Definition: stream.hpp:570
cl::sycl::detail::writeVec
void writeVec(GlobalBufAccessorT &GlobalFlushBuf, size_t FlushBufferSize, unsigned WIOffset, unsigned Flags, int Width, int Precision, const vec< T, VecLength > &Vec)
Definition: stream.hpp:494
cl::sycl::detail::FLUSH_BUF_OFFSET_SIZE
constexpr unsigned FLUSH_BUF_OFFSET_SIZE
Definition: stream.hpp:58
cl::sycl::detail::VEC_OPEN_BRACE
constexpr char VEC_OPEN_BRACE
Definition: stream.hpp:46
cl::sycl::detail::FmtFlags
unsigned int FmtFlags
Definition: stream.hpp:21
T
cl::sycl::item
Identifies an instance of the function object executing at each point in a range.
Definition: helpers.hpp:28
cl::sycl::stream::get_precision
size_t get_precision() const
Definition: stream.hpp:756
cl::sycl::multi_ptr::get
pointer_t get() const
Definition: multi_ptr.hpp:213
cl::sycl::operator!=
bool operator!=(const multi_ptr< ElementType, Space > &lhs, const multi_ptr< ElementType, Space > &rhs)
Definition: multi_ptr.hpp:601
cl::sycl::id< Dimensions >
cl::sycl::detail::digitToChar
char digitToChar(const int Digit)
Definition: stream.hpp:150
cl::sycl::fixed
constexpr stream_manipulator fixed
Definition: stream.hpp:696
cl::sycl::stream::get_stream_mode
stream_manipulator get_stream_mode() const
Definition: stream.hpp:760
cl::sycl::group
Encapsulates all functionality required to represent a particular work-group within a parallel execut...
Definition: helpers.hpp:29
cl::sycl::detail::MAX_DIMENSIONS
constexpr size_t MAX_DIMENSIONS
Definition: stream.hpp:49
cl::sycl::detail::Scientific
static constexpr FmtFlags Scientific
Definition: stream.hpp:31
cl::sycl::group::get_id
id< Dimensions > get_id() const
Definition: group.hpp:107
cl::sycl::detail::floatingPointToDecStr
EnableIfFP< T, unsigned > floatingPointToDecStr(T AbsVal, char *Digits, int Precision, bool IsSci)
Definition: stream.hpp:264
cl::sycl::hexfloat
constexpr stream_manipulator hexfloat
Definition: stream.hpp:700
cl::sycl::detail::Dec
static constexpr FmtFlags Dec
Definition: stream.hpp:25
cl::sycl::__width_manipulator__::width
int width() const
Definition: stream.hpp:724
cl::sycl::operator<<
const stream & operator<<(const stream &Out, const T &RHS)
Definition: stream.hpp:1147
cl::sycl::noshowpos
constexpr stream_manipulator noshowpos
Definition: stream.hpp:688
cl::sycl::defaultfloat
constexpr stream_manipulator defaultfloat
Definition: stream.hpp:702
cl::sycl::detail::Fixed
static constexpr FmtFlags Fixed
Definition: stream.hpp:30
cl::sycl::detail::VEC_CLOSE_BRACE
constexpr char VEC_CLOSE_BRACE
Definition: stream.hpp:47
cl::sycl::access::mode::atomic
@ atomic
cl::sycl::accessor::get_range
range< Dimensions > get_range() const
Definition: accessor.hpp:1527
cl::sycl::showbase
constexpr stream_manipulator showbase
Definition: stream.hpp:686
cl::sycl::detail::writeIntegral
detail::enable_if_t< std::is_integral< T >::value > writeIntegral(GlobalBufAccessorT &GlobalFlushBuf, size_t FlushBufferSize, unsigned WIOffset, unsigned Flags, int Width, const T &Val)
Definition: stream.hpp:403
cl::sycl::multi_ptr
Provides constructors for address space qualified and non address space qualified pointers to allow i...
Definition: atomic.hpp:32
__SYCL_SPECIAL_CLASS
#define __SYCL_SPECIAL_CLASS
Definition: defines.hpp:27
cl::sycl::detail::EnableIfSwizzleVec
typename detail::enable_if_t< IsSwizzleOp< T >::value, typename IsSwizzleOp< T >::Type > EnableIfSwizzleVec
Definition: stream.hpp:658
cl::sycl::h_item::get_physical_local
item< dimensions, false > get_physical_local() const
Definition: h_item.hpp:43
operator==
bool operator==(const Slab &Lhs, const Slab &Rhs)
Definition: usm_allocator.cpp:343
cl::sycl::isnan
detail::common_rel_ret_t< T > isnan(T x) __NOEXC
Definition: builtins.hpp:1213
cl::sycl::detail::ItemToStr
unsigned ItemToStr(char *Buf, const item< Dimensions, false > &Item)
Definition: stream.hpp:612
cl::sycl::detail::write
void write(GlobalBufAccessorT &GlobalFlushBuf, size_t FlushBufferSize, unsigned WIOffset, const char *Str, unsigned Len, unsigned Padding=0)
Definition: stream.hpp:110
cl::sycl::range< Dimensions >
cl::sycl::detail::SwizzleOp
Definition: types.hpp:118
cl::sycl::detail::EnableIfFP
typename detail::enable_if_t< std::is_same< F, float >::value||std::is_same< F, double >::value||std::is_same< F, half >::value, T > EnableIfFP
Definition: stream.hpp:65
cl::sycl::showpos
constexpr stream_manipulator showpos
Definition: stream.hpp:690
cl::sycl::access::placeholder::false_t
@ false_t
cl::sycl::detail::GlobalOffsetDim
constexpr static int GlobalOffsetDim
Definition: stream.hpp:86
std::hash< cl::sycl::stream >::operator()
size_t operator()(const cl::sycl::stream &S) const
Definition: stream.hpp:1157
cl::sycl::range::size
size_t size() const
Definition: range.hpp:50
cl::sycl::detail::MAX_ARRAY_SIZE
constexpr size_t MAX_ARRAY_SIZE
Definition: stream.hpp:53
export.hpp
char
cl::sycl::h_item
Identifies an instance of a group::parallel_for_work_item function object executing at each point in ...
Definition: helpers.hpp:33
cl::sycl::__precision_manipulator__
Definition: stream.hpp:706
cl::sycl::setprecision
__precision_manipulator__ setprecision(int Precision)
Definition: stream.hpp:730
cl::sycl::detail::half_impl::half
Definition: half_type.hpp:319
cl::sycl::detail::MAX_INTEGRAL_DIGITS
constexpr size_t MAX_INTEGRAL_DIGITS
Definition: stream.hpp:44
cl::sycl::abs
detail::enable_if_t< detail::is_genfloat< T >::value, T > abs(T x) __NOEXC
Definition: builtins.hpp:523
cl::sycl::nd_range::get_offset
id< dimensions > get_offset() const
Definition: nd_range.hpp:47
cl::sycl::stream_manipulator
stream_manipulator
Definition: stream.hpp:662
cl::sycl::detail::updateOffset
bool updateOffset(GlobalOffsetAccessorT &GlobalOffset, GlobalBufAccessorT &GlobalBuf, unsigned Size, unsigned &Cur)
Definition: stream.hpp:429
cl::sycl::detail::MAX_FLOATING_POINT_DIGITS
constexpr size_t MAX_FLOATING_POINT_DIGITS
Definition: stream.hpp:43
cl::sycl::__precision_manipulator__::precision
int precision() const
Definition: stream.hpp:712
cl::sycl::endl
constexpr stream_manipulator endl
Definition: stream.hpp:692
cl::sycl::h_item::get_logical_local
item< dimensions, false > get_logical_local() const
Definition: h_item.hpp:41
cl::sycl::detail::BaseField
static constexpr FmtFlags BaseField
Definition: stream.hpp:36
cl::sycl::detail::GetFlushBufOffset
unsigned GetFlushBufOffset(const GlobalBufAccessorT &GlobalFlushBuf, unsigned WIOffset)
Definition: stream.hpp:92
cl::sycl::detail::TargetToAS
Definition: access.hpp:134
cl::sycl::accessor
Buffer accessor.
Definition: accessor.hpp:225
defines.hpp
cl::sycl::nd_item::get_local_id
id< dimensions > get_local_id() const
Definition: nd_item.hpp:54
cl::sycl::detail::MAX_ITEM_SIZE
constexpr size_t MAX_ITEM_SIZE
Definition: stream.hpp:609
cl
We provide new interfaces for matrix muliply in this patch:
Definition: access.hpp:13
cl::sycl::signbit
detail::common_rel_ret_t< T > signbit(T x) __NOEXC
Definition: builtins.hpp:1261
cl::sycl::__precision_manipulator__::__precision_manipulator__
__precision_manipulator__(int Precision)
Definition: stream.hpp:710
cl::sycl::detail::ScalarToStr
EnableIfFP< T, unsigned > ScalarToStr(const T &Val, char *Buf, unsigned Flags, int, int Precision=-1)
Definition: stream.hpp:377
cl::sycl::oct
constexpr stream_manipulator oct
Definition: stream.hpp:682
cl::sycl::detail::Oct
static constexpr FmtFlags Oct
Definition: stream.hpp:27
cl::sycl::item::get_offset
detail::enable_if_t< has_offset, id< dimensions > > get_offset() const
Definition: item.hpp:76
cl::sycl::detail::append
unsigned append(char *Dst, const char *Src)
Definition: stream.hpp:220
cl::sycl::detail::array
Definition: array.hpp:21
cl::sycl::isinf
detail::common_rel_ret_t< T > isinf(T x) __NOEXC
Definition: builtins.hpp:1201
cl::sycl::detail::GlobalOffsetAS
constexpr static access::address_space GlobalOffsetAS
Definition: stream.hpp:82
cl::sycl::handler
Command group handler class.
Definition: handler.hpp:361
cl::sycl::detail::writeArray
void writeArray(GlobalBufAccessorT &GlobalFlushBuf, size_t FlushBufferSize, unsigned WIOffset, const array< ArrayLength > &Arr)
Definition: stream.hpp:523
cl::sycl::item::get_id
id< dimensions > get_id() const
Definition: item.hpp:50
cl::sycl::detail::VecToStr
detail::enable_if_t<(VecLength==3), unsigned > VecToStr(const vec< T, VecLength > &Vec, char *VecStr, unsigned Flags, int Width, int Precision)
Definition: stream.hpp:485
cl::sycl::h_item::get_global
item< dimensions, false > get_global() const
Definition: h_item.hpp:37
cl::sycl::access::address_space
address_space
Definition: access.hpp:45
cl::sycl::detail::IsSwizzleOp< cl::sycl::detail::SwizzleOp< VecT, OperationLeftT, OperationRightT, OperationCurrentT, Indexes... > >::Type
typename cl::sycl::vec< T,(sizeof...(Indexes))> Type
Definition: stream.hpp:652
cl::sycl::detail::IsSwizzleOp
Definition: stream.hpp:644
cl::sycl::detail::Hex
static constexpr FmtFlags Hex
Definition: stream.hpp:26
builtins.hpp
cl::sycl::detail::checkForInfNan
detail::enable_if_t< std::is_same< T, half >::value, unsigned > checkForInfNan(char *Buf, T Val)
Definition: stream.hpp:246
cl::sycl::group::get_local_range
range< Dimensions > get_local_range() const
Definition: group.hpp:117
cl::sycl::detail::GlobalBufAS
constexpr static access::address_space GlobalBufAS
Definition: stream.hpp:71
cl::sycl::detail::ShowBase
static constexpr FmtFlags ShowBase
Definition: stream.hpp:28
cl::sycl::nd_item::get_global_id
id< dimensions > get_global_id() const
Definition: nd_item.hpp:40
cl::sycl::detail::writeItem
void writeItem(GlobalBufAccessorT &GlobalFlushBuf, size_t FlushBufferSize, unsigned WIOffset, const item< Dimensions > &Item)
Definition: stream.hpp:532
cl::sycl::group::get_group_range
range< Dimensions > get_group_range() const
Definition: group.hpp:121
cl::sycl::detail::getSyclObjImpl
decltype(Obj::impl) getSyclObjImpl(const Obj &SyclObject)
Definition: common.hpp:182
cl::sycl::vec
Provides a cross-patform vector class template that works efficiently on SYCL devices as well as in h...
Definition: aliases.hpp:18
cl::sycl::accessor::size
size_t size() const noexcept
Definition: accessor.hpp:1524
cl::sycl::nd_item
Identifies an instance of the function object executing at each point in an nd_range.
Definition: helpers.hpp:32
handler.hpp
cl::sycl::__width_manipulator__
Definition: stream.hpp:718
std
Definition: accessor.hpp:2358
cl::sycl::group::get_global_range
range< Dimensions > get_global_range() const
Definition: group.hpp:111
cl::sycl::detail::pi
Definition: pi.hpp:51
uint16_t
cl::sycl::nd_range::get_global_range
range< dimensions > get_global_range() const
Definition: nd_range.hpp:40
cl::sycl::detail::reverseBuf
void reverseBuf(char *Buf, unsigned Len)
Definition: stream.hpp:132
cl::sycl::detail::GlobalOffsetPtrType
typename detail::DecoratedType< unsigned, GlobalBufAS >::type * GlobalOffsetPtrType
Definition: stream.hpp:85
cl::sycl::detail::FloatField
static constexpr FmtFlags FloatField
Definition: stream.hpp:41
cl::sycl::stream::get_width
size_t get_width() const
Definition: stream.hpp:758
cl::sycl::setw
__width_manipulator__ setw(int Width)
Definition: stream.hpp:734
cl::sycl::detail::writeGroup
void writeGroup(GlobalBufAccessorT &GlobalFlushBuf, size_t FlushBufferSize, unsigned WIOffset, const group< Dimensions > &Group)
Definition: stream.hpp:587
cl::sycl::access::mode::read_write
@ read_write
P
#define P(n)
cl::sycl::dec
constexpr stream_manipulator dec
Definition: stream.hpp:678
cl::sycl::detail::GlobalBufDim
constexpr static int GlobalBufDim
Definition: stream.hpp:75
cl::sycl::detail::ArrayToStr
unsigned ArrayToStr(char *Buf, const array< ArrayLength > &Arr)
Definition: stream.hpp:507
cl::sycl::detail::ShowPos
static constexpr FmtFlags ShowPos
Definition: stream.hpp:29
cl::sycl::hex
constexpr stream_manipulator hex
Definition: stream.hpp:680
cl::sycl::__width_manipulator__::__width_manipulator__
__width_manipulator__(int Width)
Definition: stream.hpp:722
cl::sycl::flush
constexpr stream_manipulator flush
Definition: stream.hpp:694
cl::sycl::detail::writeHItem
void writeHItem(GlobalBufAccessorT &GlobalFlushBuf, size_t FlushBufferSize, unsigned WIOffset, const h_item< Dimensions > &HItem)
Definition: stream.hpp:624
cl::sycl::stream
A buffered output stream that allows outputting the values of built-in, vector and SYCL types to the ...
Definition: stream.hpp:742
cl::sycl::detail::flushBuffer
void flushBuffer(GlobalOffsetAccessorT &GlobalOffset, GlobalBufAccessorT &GlobalBuf, GlobalBufAccessorT &GlobalFlushBuf, unsigned WIOffset)
Definition: stream.hpp:443
cl::sycl::detail::enable_if_t
typename std::enable_if< B, T >::type enable_if_t
Definition: stl_type_traits.hpp:24
cl::sycl::detail::SetFlushBufOffset
void SetFlushBufOffset(GlobalBufAccessorT &GlobalFlushBuf, unsigned WIOffset, unsigned Offset)
Definition: stream.hpp:104
cl::sycl::detail::GlobalBufPtrType
typename detail::DecoratedType< char, GlobalBufAS >::type * GlobalBufPtrType
Definition: stream.hpp:74
cl::sycl::detail::writeNDRange
void writeNDRange(GlobalBufAccessorT &GlobalFlushBuf, size_t FlushBufferSize, unsigned WIOffset, const nd_range< Dimensions > &ND_Range)
Definition: stream.hpp:551
cl::sycl::noshowbase
constexpr stream_manipulator noshowbase
Definition: stream.hpp:684
cl::sycl::detail::getAbsVal
std::make_unsigned< T >::type getAbsVal(const T Val, const int Base)
Definition: stream.hpp:145
cl::sycl::item::get_range
range< dimensions > get_range() const
Definition: item.hpp:64
cl::sycl::detail::integralToBase
detail::enable_if_t< std::is_integral< T >::value, unsigned > integralToBase(T Val, int Base, char *Digits)
Definition: stream.hpp:160
cl::sycl::scientific
constexpr stream_manipulator scientific
Definition: stream.hpp:698
cl::sycl::detail::VEC_ELEMENT_DELIMITER
constexpr const char * VEC_ELEMENT_DELIMITER
Definition: stream.hpp:45
cl::sycl::detail::writeFloatingPoint
EnableIfFP< T > writeFloatingPoint(GlobalBufAccessorT &GlobalFlushBuf, size_t FlushBufferSize, unsigned WIOffset, unsigned Flags, int Width, int Precision, const T &Val)
Definition: stream.hpp:415
cl::sycl::nd_range::get_local_range
range< dimensions > get_local_range() const
Definition: nd_range.hpp:42
cl::sycl::detail::DecoratedType
Definition: access.hpp:157
__SYCL_INLINE_NAMESPACE
#define __SYCL_INLINE_NAMESPACE(X)
Definition: defines_elementary.hpp:12