DPC++ Runtime
Runtime libraries for oneAPI DPC++
builtins_integer.cpp
Go to the documentation of this file.
1 //==---------- builtins_integer.cpp - SYCL built-in integer functions ------==//
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 // This file defines the host versions of functions defined
10 // in SYCL SPEC section - 4.13.4 Integer functions.
11 
12 #include "builtins_helper.hpp"
13 #include <sycl/detail/export.hpp>
14 
15 #include <algorithm>
16 #include <type_traits>
17 
18 namespace s = sycl;
19 namespace d = s::detail;
20 
21 namespace __host_std {
22 namespace {
23 
24 template <typename T> inline T __abs_diff(T x, T y) {
25  static_assert(std::is_integral<T>::value,
26  "Only integral types are supported");
27  return (x > y) ? (x - y) : (y - x);
28 }
29 
30 template <typename T> inline T __u_add_sat(T x, T y) {
31  return (x < (d::max_v<T>() - y) ? x + y : d::max_v<T>());
32 }
33 
34 template <typename T> inline T __s_add_sat(T x, T y) {
35  if (x > 0 && y > 0)
36  return (x < (d::max_v<T>() - y) ? (x + y) : d::max_v<T>());
37  if (x < 0 && y < 0)
38  return (x > (d::min_v<T>() - y) ? (x + y) : d::min_v<T>());
39  return x + y;
40 }
41 
42 template <typename T> inline T __hadd(T x, T y) {
43  const T one = 1;
44  return (x >> one) + (y >> one) + ((y & x) & one);
45 }
46 
47 template <typename T> inline T __rhadd(T x, T y) {
48  const T one = 1;
49  return (x >> one) + (y >> one) + ((y | x) & one);
50 }
51 
52 template <typename T> inline T __clamp(T x, T minval, T maxval) {
53  return std::min(std::max(x, minval), maxval);
54 }
55 
56 template <typename T> inline constexpr T __clz_impl(T x, T m, T n = 0) {
57  return (x & m) ? n : __clz_impl(x, T(m >> 1), ++n);
58 }
59 
60 template <typename T> inline constexpr T __clz(T x) {
61  using UT = typename std::make_unsigned<T>::type;
62  return (x == T(0)) ? sizeof(T) * 8 : __clz_impl<UT>(x, d::msbMask<UT>(x));
63 }
64 
65 template <typename T> inline constexpr T __ctz_impl(T x, T m, T n = 0) {
66  return (x & m) ? n : __ctz_impl(x, T(m << 1), ++n);
67 }
68 
69 template <typename T> inline constexpr T __ctz(T x) {
70  using UT = typename std::make_unsigned<T>::type;
71  return (x == T(0)) ? sizeof(T) * 8 : __ctz_impl<UT>(x, 1);
72 }
73 
74 template <typename T> T __mul_hi(T a, T b) {
75  using UPT = typename d::make_larger<T>::type;
76  UPT a_s = a;
77  UPT b_s = b;
78  UPT mul = a_s * b_s;
79  return (mul >> (sizeof(T) * 8));
80 }
81 
82 // A helper function for mul_hi built-in for long
83 template <typename T> inline T __get_high_half(T a0b0, T a0b1, T a1b0, T a1b1) {
84  constexpr int halfsize = (sizeof(T) * 8) / 2;
85  // To get the upper 64 bits:
86  // 64 bits from a1b1, upper 32 bits from [a1b0 + (a0b1 + a0b0>>32 (carry bit
87  // in 33rd bit))] with carry bit on 64th bit - use of hadd. Add the a1b1 to
88  // the above 32 bit result.
89  return a1b1 + (__hadd(a1b0, (a0b1 + (a0b0 >> halfsize))) >> (halfsize - 1));
90 }
91 
92 // A helper function for mul_hi built-in for long
93 template <typename T>
94 inline void __get_half_products(T a, T b, T &a0b0, T &a0b1, T &a1b0, T &a1b1) {
95  constexpr s::cl_int halfsize = (sizeof(T) * 8) / 2;
96  T a1 = a >> halfsize;
97  T a0 = (a << halfsize) >> halfsize;
98  T b1 = b >> halfsize;
99  T b0 = (b << halfsize) >> halfsize;
100 
101  // a1b1 - for bits - [64-128)
102  // a1b0 a0b1 for bits - [32-96)
103  // a0b0 for bits - [0-64)
104  a1b1 = a1 * b1;
105  a0b1 = a0 * b1;
106  a1b0 = a1 * b0;
107  a0b0 = a0 * b0;
108 }
109 
110 // T is minimum of 64 bits- long or longlong
111 template <typename T> inline T __u_long_mul_hi(T a, T b) {
112  T a0b0, a0b1, a1b0, a1b1;
113  __get_half_products(a, b, a0b0, a0b1, a1b0, a1b1);
114  T result = __get_high_half(a0b0, a0b1, a1b0, a1b1);
115  return result;
116 }
117 
118 template <typename T> inline T __s_long_mul_hi(T a, T b) {
119  using UT = typename std::make_unsigned<T>::type;
120  UT absA = std::abs(a);
121  UT absB = std::abs(b);
122 
123  UT a0b0, a0b1, a1b0, a1b1;
124  __get_half_products(absA, absB, a0b0, a0b1, a1b0, a1b1);
125  T result = __get_high_half(a0b0, a0b1, a1b0, a1b1);
126 
127  bool isResultNegative = (a < 0) != (b < 0);
128  if (isResultNegative) {
129  result = ~result;
130 
131  // Find the low half to see if we need to carry
132  constexpr int halfsize = (sizeof(T) * 8) / 2;
133  UT low = a0b0 + ((a0b1 + a1b0) << halfsize);
134  if (low == 0)
135  ++result;
136  }
137 
138  return result;
139 }
140 
141 template <typename T> inline T __mad_hi(T a, T b, T c) {
142  return __mul_hi(a, b) + c;
143 }
144 
145 template <typename T> inline T __u_long_mad_hi(T a, T b, T c) {
146  return __u_long_mul_hi(a, b) + c;
147 }
148 
149 template <typename T> inline T __s_long_mad_hi(T a, T b, T c) {
150  return __s_long_mul_hi(a, b) + c;
151 }
152 
153 template <typename T> inline T __s_mad_sat(T a, T b, T c) {
154  using UPT = typename d::make_larger<T>::type;
155  UPT mul = UPT(a) * UPT(b);
156  UPT res = mul + UPT(c);
157  const UPT max = d::max_v<T>();
158  const UPT min = d::min_v<T>();
159  res = std::min(std::max(res, min), max);
160  return T(res);
161 }
162 
163 template <typename T> inline T __s_long_mad_sat(T a, T b, T c) {
164  bool neg_prod = (a < 0) ^ (b < 0);
165  T mulhi = __s_long_mul_hi(a, b);
166 
167  // check mul_hi. If it is any value != 0.
168  // if prod is +ve, any value in mulhi means we need to saturate.
169  // if prod is -ve, any value in mulhi besides -1 means we need to saturate.
170  if (!neg_prod && mulhi != 0)
171  return d::max_v<T>();
172  if (neg_prod && mulhi != -1)
173  return d::min_v<T>(); // essentially some other negative value.
174  return __s_add_sat(T(a * b), c);
175 }
176 
177 template <typename T> inline T __u_mad_sat(T a, T b, T c) {
178  using UPT = typename d::make_larger<T>::type;
179  UPT mul = UPT(a) * UPT(b);
180  const UPT min = d::min_v<T>();
181  const UPT max = d::max_v<T>();
182  mul = std::min(std::max(mul, min), max);
183  return __u_add_sat(T(mul), c);
184 }
185 
186 template <typename T> inline T __u_long_mad_sat(T a, T b, T c) {
187  T mulhi = __u_long_mul_hi(a, b);
188  // check mul_hi. If it is any value != 0.
189  if (mulhi != 0)
190  return d::max_v<T>();
191  return __u_add_sat(T(a * b), c);
192 }
193 
194 template <typename T> inline T __rotate(T x, T n) {
195  using UT = typename std::make_unsigned<T>::type;
196  // Shrink the shift width so that it's in the range [0, num_bits(T)). Cast
197  // everything to unsigned to avoid type conversion issues.
198  constexpr UT size = sizeof(x) * 8;
199  UT xu = UT(x);
200  UT nu = UT(n) & (size - 1);
201  return (xu << nu) | (xu >> (size - nu));
202 }
203 
204 template <typename T> inline T __u_sub_sat(T x, T y) {
205  return (y < (x - d::min_v<T>())) ? (x - y) : d::min_v<T>();
206 }
207 
208 template <typename T> inline T __s_sub_sat(T x, T y) {
209  using UT = typename std::make_unsigned<T>::type;
210  T result = UT(x) - UT(y);
211  // Saturate result if (+) - (-) = (-) or (-) - (+) = (+).
212  if (((x < 0) ^ (y < 0)) && ((x < 0) ^ (result < 0)))
213  result = result < 0 ? d::max_v<T>() : d::min_v<T>();
214  return result;
215 }
216 
217 template <typename T1, typename T2>
218 typename d::make_larger<T1>::type inline __upsample(T1 hi, T2 lo) {
219  using UT = typename d::make_larger<T1>::type;
220  return (UT(hi) << (sizeof(T1) * 8)) | lo;
221 }
222 
223 template <typename T> inline constexpr T __popcount_impl(T x, size_t n = 0) {
224  return (x == T(0)) ? n : __popcount_impl(x >> 1, ((x & T(1)) ? ++n : n));
225 }
226 
227 template <typename T> inline constexpr T __popcount(T x) {
228  using UT = typename d::make_unsigned<T>::type;
229  return __popcount_impl(UT(x));
230 }
231 
232 template <typename T> inline T __mad24(T x, T y, T z) { return (x * y) + z; }
233 
234 template <typename T> inline T __mul24(T x, T y) { return (x * y); }
235 
236 } // namespace
237 
238 // --------------- 4.13.4 Integer functions. Host implementations --------------
239 // u_abs
240 __SYCL_EXPORT s::cl_uchar sycl_host_u_abs(s::cl_uchar x) __NOEXC { return x; }
241 __SYCL_EXPORT s::cl_ushort sycl_host_u_abs(s::cl_ushort x) __NOEXC { return x; }
242 __SYCL_EXPORT s::cl_uint sycl_host_u_abs(s::cl_uint x) __NOEXC { return x; }
243 __SYCL_EXPORT s::cl_ulong sycl_host_u_abs(s::cl_ulong x) __NOEXC { return x; }
248 
249 // s_abs
251  return std::abs(x);
252 }
254  return std::abs(x);
255 }
257  return std::abs(x);
258 }
260  return std::abs(x);
261 }
266 
267 // u_abs_diff
269  s::cl_uchar y) __NOEXC {
270  return __abs_diff(x, y);
271 }
273  s::cl_ushort y) __NOEXC {
274  return __abs_diff(x, y);
275 }
277  s::cl_uint y) __NOEXC {
278  return __abs_diff(x, y);
279 }
281  s::cl_ulong y) __NOEXC {
282  return __abs_diff(x, y);
283 }
284 
289 
290 // s_abs_diff
292  s::cl_char y) __NOEXC {
293  return __abs_diff(x, y);
294 }
296  s::cl_short y) __NOEXC {
297  return __abs_diff(x, y);
298 }
300  s::cl_int y) __NOEXC {
301  return __abs_diff(x, y);
302 }
304  s::cl_long y) __NOEXC {
305  return __abs_diff(x, y);
306 }
311 
312 // u_add_sat
314  s::cl_uchar y) __NOEXC {
315  return __u_add_sat(x, y);
316 }
318  s::cl_ushort y) __NOEXC {
319  return __u_add_sat(x, y);
320 }
322  s::cl_uint y) __NOEXC {
323  return __u_add_sat(x, y);
324 }
326  s::cl_ulong y) __NOEXC {
327  return __u_add_sat(x, y);
328 }
333 
334 // s_add_sat
336  s::cl_char y) __NOEXC {
337  return __s_add_sat(x, y);
338 }
340  s::cl_short y) __NOEXC {
341  return __s_add_sat(x, y);
342 }
344  return __s_add_sat(x, y);
345 }
347  s::cl_long y) __NOEXC {
348  return __s_add_sat(x, y);
349 }
354 
355 // u_hadd
357  s::cl_uchar y) __NOEXC {
358  return __hadd(x, y);
359 }
361  s::cl_ushort y) __NOEXC {
362  return __hadd(x, y);
363 }
365  return __hadd(x, y);
366 }
368  s::cl_ulong y) __NOEXC {
369  return __hadd(x, y);
370 }
375 
376 // s_hadd
377 __SYCL_EXPORT s::cl_char sycl_host_s_hadd(s::cl_char x, s::cl_char y) __NOEXC {
378  return __hadd(x, y);
379 }
381  s::cl_short y) __NOEXC {
382  return __hadd(x, y);
383 }
385  return __hadd(x, y);
386 }
388  return __hadd(x, y);
389 }
394 
395 // u_rhadd
397  s::cl_uchar y) __NOEXC {
398  return __rhadd(x, y);
399 }
401  s::cl_ushort y) __NOEXC {
402  return __rhadd(x, y);
403 }
405  return __rhadd(x, y);
406 }
408  s::cl_ulong y) __NOEXC {
409  return __rhadd(x, y);
410 }
415 
416 // s_rhadd
418  return __rhadd(x, y);
419 }
421  s::cl_short y) __NOEXC {
422  return __rhadd(x, y);
423 }
425  return __rhadd(x, y);
426 }
428  return __rhadd(x, y);
429 }
434 
435 // u_clamp
436 __SYCL_EXPORT s::cl_uchar sycl_host_u_clamp(s::cl_uchar x, s::cl_uchar minval,
437  s::cl_uchar maxval) __NOEXC {
438  return __clamp(x, minval, maxval);
439 }
441  s::cl_ushort minval,
442  s::cl_ushort maxval) __NOEXC {
443  return __clamp(x, minval, maxval);
444 }
446  s::cl_uint maxval) __NOEXC {
447  return __clamp(x, minval, maxval);
448 }
450  s::cl_ulong maxval) __NOEXC {
451  return __clamp(x, minval, maxval);
452 }
454  s::cl_uchar)
456  s::cl_ushort)
459  s::cl_ulong)
461  s::cl_uchar)
463  s::cl_ushort)
466  s::cl_ulong)
467 
468 // s_clamp
469 __SYCL_EXPORT s::cl_char sycl_host_s_clamp(s::cl_char x, s::cl_char minval,
470  s::cl_char maxval) __NOEXC {
471  return __clamp(x, minval, maxval);
472 }
474  s::cl_short maxval) __NOEXC {
475  return __clamp(x, minval, maxval);
476 }
478  s::cl_int maxval) __NOEXC {
479  return __clamp(x, minval, maxval);
480 }
482  s::cl_long maxval) __NOEXC {
483  return __clamp(x, minval, maxval);
484 }
487  s::cl_short)
492  s::cl_short)
495 
496 // clz
497 __SYCL_EXPORT s::cl_uchar sycl_host_clz(s::cl_uchar x) __NOEXC {
498  return __clz(x);
499 }
501  return __clz(x);
502 }
504  return __clz(x);
505 }
507  return __clz(x);
508 }
510  return __clz(x);
511 }
512 __SYCL_EXPORT s::cl_int sycl_host_clz(s::cl_int x) __NOEXC { return __clz(x); }
514  return __clz(x);
515 }
517  return __clz(x);
518 }
527 
528 // ctz
529 __SYCL_EXPORT s::cl_uchar sycl_host_ctz(s::cl_uchar x) __NOEXC {
530  return __ctz(x);
531 }
533  return __ctz(x);
534 }
536  return __ctz(x);
537 }
539  return __ctz(x);
540 }
542  return __ctz(x);
543 }
544 __SYCL_EXPORT s::cl_int sycl_host_ctz(s::cl_int x) __NOEXC { return __ctz(x); }
546  return __ctz(x);
547 }
549  return __ctz(x);
550 }
559 
560 // s_mul_hi
561 __SYCL_EXPORT s::cl_char sycl_host_s_mul_hi(s::cl_char a, s::cl_char b) {
562  return __mul_hi(a, b);
563 }
565  return __mul_hi(a, b);
566 }
568  return __mul_hi(a, b);
569 }
571  s::cl_long y) __NOEXC {
572  return __s_long_mul_hi(x, y);
573 }
578 
579 // u_mul_hi
580 __SYCL_EXPORT s::cl_uchar sycl_host_u_mul_hi(s::cl_uchar a, s::cl_uchar b) {
581  return __mul_hi(a, b);
582 }
584  return __mul_hi(a, b);
585 }
587  return __mul_hi(a, b);
588 }
590  s::cl_ulong y) __NOEXC {
591  return __u_long_mul_hi(x, y);
592 }
597 
598 // s_mad_hi
599 __SYCL_EXPORT s::cl_char sycl_host_s_mad_hi(s::cl_char x, s::cl_char minval,
600  s::cl_char maxval) __NOEXC {
601  return __mad_hi(x, minval, maxval);
602 }
604  s::cl_short maxval) __NOEXC {
605  return __mad_hi(x, minval, maxval);
606 }
608  s::cl_int maxval) __NOEXC {
609  return __mad_hi(x, minval, maxval);
610 }
612  s::cl_long maxval) __NOEXC {
613  return __s_long_mad_hi(x, minval, maxval);
614 }
616  s::cl_char)
618  s::cl_short)
621  s::cl_long)
622 
623 // u_mad_hi
624 __SYCL_EXPORT s::cl_uchar sycl_host_u_mad_hi(s::cl_uchar x, s::cl_uchar minval,
625  s::cl_uchar maxval) __NOEXC {
626  return __mad_hi(x, minval, maxval);
627 }
628 __SYCL_EXPORT s::cl_ushort sycl_host_u_mad_hi(s::cl_ushort x,
629  s::cl_ushort minval,
630  s::cl_ushort maxval) __NOEXC {
631  return __mad_hi(x, minval, maxval);
632 }
633 __SYCL_EXPORT s::cl_uint sycl_host_u_mad_hi(s::cl_uint x, s::cl_uint minval,
634  s::cl_uint maxval) __NOEXC {
635  return __mad_hi(x, minval, maxval);
636 }
637 __SYCL_EXPORT s::cl_ulong sycl_host_u_mad_hi(s::cl_ulong x, s::cl_ulong minval,
638  s::cl_ulong maxval) __NOEXC {
639  return __u_long_mad_hi(x, minval, maxval);
640 }
641 MAKE_1V_2V_3V(sycl_host_u_mad_hi, s::cl_uchar, s::cl_uchar, s::cl_uchar,
642  s::cl_uchar)
644  s::cl_ushort)
645 MAKE_1V_2V_3V(sycl_host_u_mad_hi, s::cl_uint, s::cl_uint, s::cl_uint,
646  s::cl_uint)
647 MAKE_1V_2V_3V(sycl_host_u_mad_hi, s::cl_ulong, s::cl_ulong, s::cl_ulong,
648  s::cl_ulong)
649 
650 // s_mad_sat
651 __SYCL_EXPORT s::cl_char sycl_host_s_mad_sat(s::cl_char a, s::cl_char b,
652  s::cl_char c) __NOEXC {
653  return __s_mad_sat(a, b, c);
654 }
655 __SYCL_EXPORT s::cl_short sycl_host_s_mad_sat(s::cl_short a, s::cl_short b,
656  s::cl_short c) __NOEXC {
657  return __s_mad_sat(a, b, c);
658 }
659 __SYCL_EXPORT s::cl_int sycl_host_s_mad_sat(s::cl_int a, s::cl_int b,
660  s::cl_int c) __NOEXC {
661  return __s_mad_sat(a, b, c);
662 }
663 __SYCL_EXPORT s::cl_long sycl_host_s_mad_sat(s::cl_long a, s::cl_long b,
664  s::cl_long c) __NOEXC {
665  return __s_long_mad_sat(a, b, c);
666 }
667 MAKE_1V_2V_3V(sycl_host_s_mad_sat, s::cl_char, s::cl_char, s::cl_char,
668  s::cl_char)
669 MAKE_1V_2V_3V(sycl_host_s_mad_sat, s::cl_short, s::cl_short, s::cl_short,
670  s::cl_short)
671 MAKE_1V_2V_3V(sycl_host_s_mad_sat, s::cl_int, s::cl_int, s::cl_int, s::cl_int)
672 MAKE_1V_2V_3V(sycl_host_s_mad_sat, s::cl_long, s::cl_long, s::cl_long,
673  s::cl_long)
674 
675 // u_mad_sat
676 __SYCL_EXPORT s::cl_uchar sycl_host_u_mad_sat(s::cl_uchar a, s::cl_uchar b,
677  s::cl_uchar c) __NOEXC {
678  return __u_mad_sat(a, b, c);
679 }
680 __SYCL_EXPORT s::cl_ushort sycl_host_u_mad_sat(s::cl_ushort a, s::cl_ushort b,
681  s::cl_ushort c) __NOEXC {
682  return __u_mad_sat(a, b, c);
683 }
684 __SYCL_EXPORT s::cl_uint sycl_host_u_mad_sat(s::cl_uint a, s::cl_uint b,
685  s::cl_uint c) __NOEXC {
686  return __u_mad_sat(a, b, c);
687 }
688 __SYCL_EXPORT s::cl_ulong sycl_host_u_mad_sat(s::cl_ulong a, s::cl_ulong b,
689  s::cl_ulong c) __NOEXC {
690  return __u_long_mad_sat(a, b, c);
691 }
692 MAKE_1V_2V_3V(sycl_host_u_mad_sat, s::cl_uchar, s::cl_uchar, s::cl_uchar,
693  s::cl_uchar)
694 MAKE_1V_2V_3V(sycl_host_u_mad_sat, s::cl_ushort, s::cl_ushort, s::cl_ushort,
695  s::cl_ushort)
696 MAKE_1V_2V_3V(sycl_host_u_mad_sat, s::cl_uint, s::cl_uint, s::cl_uint,
697  s::cl_uint)
698 MAKE_1V_2V_3V(sycl_host_u_mad_sat, s::cl_ulong, s::cl_ulong, s::cl_ulong,
699  s::cl_ulong)
700 
701 // s_max
702 __SYCL_EXPORT s::cl_char sycl_host_s_max(s::cl_char x, s::cl_char y) __NOEXC {
703  return std::max(x, y);
704 }
705 __SYCL_EXPORT s::cl_short sycl_host_s_max(s::cl_short x,
706  s::cl_short y) __NOEXC {
707  return std::max(x, y);
708 }
709 __SYCL_EXPORT s::cl_int sycl_host_s_max(s::cl_int x, s::cl_int y) __NOEXC {
710  return std::max(x, y);
711 }
712 __SYCL_EXPORT s::cl_long sycl_host_s_max(s::cl_long x, s::cl_long y) __NOEXC {
713  return std::max(x, y);
714 }
715 MAKE_1V_2V(sycl_host_s_max, s::cl_char, s::cl_char, s::cl_char)
716 MAKE_1V_2V(sycl_host_s_max, s::cl_short, s::cl_short, s::cl_short)
717 MAKE_1V_2V(sycl_host_s_max, s::cl_int, s::cl_int, s::cl_int)
718 MAKE_1V_2V(sycl_host_s_max, s::cl_long, s::cl_long, s::cl_long)
719 MAKE_1V_2S(sycl_host_s_max, s::cl_char, s::cl_char, s::cl_char)
720 MAKE_1V_2S(sycl_host_s_max, s::cl_short, s::cl_short, s::cl_short)
721 MAKE_1V_2S(sycl_host_s_max, s::cl_int, s::cl_int, s::cl_int)
722 MAKE_1V_2S(sycl_host_s_max, s::cl_long, s::cl_long, s::cl_long)
723 
724 // u_max
725 __SYCL_EXPORT s::cl_uchar sycl_host_u_max(s::cl_uchar x,
726  s::cl_uchar y) __NOEXC {
727  return std::max(x, y);
728 }
729 __SYCL_EXPORT s::cl_ushort sycl_host_u_max(s::cl_ushort x,
730  s::cl_ushort y) __NOEXC {
731  return std::max(x, y);
732 }
733 __SYCL_EXPORT s::cl_uint sycl_host_u_max(s::cl_uint x, s::cl_uint y) __NOEXC {
734  return std::max(x, y);
735 }
736 __SYCL_EXPORT s::cl_ulong sycl_host_u_max(s::cl_ulong x,
737  s::cl_ulong y) __NOEXC {
738  return std::max(x, y);
739 }
740 MAKE_1V_2V(sycl_host_u_max, s::cl_uchar, s::cl_uchar, s::cl_uchar)
742 MAKE_1V_2V(sycl_host_u_max, s::cl_uint, s::cl_uint, s::cl_uint)
743 MAKE_1V_2V(sycl_host_u_max, s::cl_ulong, s::cl_ulong, s::cl_ulong)
744 MAKE_1V_2S(sycl_host_u_max, s::cl_uchar, s::cl_uchar, s::cl_uchar)
746 MAKE_1V_2S(sycl_host_u_max, s::cl_uint, s::cl_uint, s::cl_uint)
747 MAKE_1V_2S(sycl_host_u_max, s::cl_ulong, s::cl_ulong, s::cl_ulong)
748 
749 // s_min
750 __SYCL_EXPORT s::cl_char sycl_host_s_min(s::cl_char x, s::cl_char y) __NOEXC {
751  return std::min(x, y);
752 }
753 __SYCL_EXPORT s::cl_short sycl_host_s_min(s::cl_short x,
754  s::cl_short y) __NOEXC {
755  return std::min(x, y);
756 }
757 __SYCL_EXPORT s::cl_int sycl_host_s_min(s::cl_int x, s::cl_int y) __NOEXC {
758  return std::min(x, y);
759 }
760 __SYCL_EXPORT s::cl_long sycl_host_s_min(s::cl_long x, s::cl_long y) __NOEXC {
761  return std::min(x, y);
762 }
763 MAKE_1V_2V(sycl_host_s_min, s::cl_char, s::cl_char, s::cl_char)
764 MAKE_1V_2V(sycl_host_s_min, s::cl_short, s::cl_short, s::cl_short)
765 MAKE_1V_2V(sycl_host_s_min, s::cl_int, s::cl_int, s::cl_int)
766 MAKE_1V_2V(sycl_host_s_min, s::cl_long, s::cl_long, s::cl_long)
767 MAKE_1V_2S(sycl_host_s_min, s::cl_char, s::cl_char, s::cl_char)
768 MAKE_1V_2S(sycl_host_s_min, s::cl_short, s::cl_short, s::cl_short)
769 MAKE_1V_2S(sycl_host_s_min, s::cl_int, s::cl_int, s::cl_int)
770 MAKE_1V_2S(sycl_host_s_min, s::cl_long, s::cl_long, s::cl_long)
771 
772 // u_min
773 __SYCL_EXPORT s::cl_uchar sycl_host_u_min(s::cl_uchar x,
774  s::cl_uchar y) __NOEXC {
775  return std::min(x, y);
776 }
777 __SYCL_EXPORT s::cl_ushort sycl_host_u_min(s::cl_ushort x,
778  s::cl_ushort y) __NOEXC {
779  return std::min(x, y);
780 }
781 __SYCL_EXPORT s::cl_uint sycl_host_u_min(s::cl_uint x, s::cl_uint y) __NOEXC {
782  return std::min(x, y);
783 }
784 __SYCL_EXPORT s::cl_ulong sycl_host_u_min(s::cl_ulong x,
785  s::cl_ulong y) __NOEXC {
786  return std::min(x, y);
787 }
788 MAKE_1V_2V(sycl_host_u_min, s::cl_uchar, s::cl_uchar, s::cl_uchar)
790 MAKE_1V_2V(sycl_host_u_min, s::cl_uint, s::cl_uint, s::cl_uint)
791 MAKE_1V_2V(sycl_host_u_min, s::cl_ulong, s::cl_ulong, s::cl_ulong)
792 MAKE_1V_2S(sycl_host_u_min, s::cl_uchar, s::cl_uchar, s::cl_uchar)
794 MAKE_1V_2S(sycl_host_u_min, s::cl_uint, s::cl_uint, s::cl_uint)
795 MAKE_1V_2S(sycl_host_u_min, s::cl_ulong, s::cl_ulong, s::cl_ulong)
796 
797 // rotate
798 __SYCL_EXPORT s::cl_uchar sycl_host_rotate(s::cl_uchar x,
799  s::cl_uchar y) __NOEXC {
800  return __rotate(x, y);
801 }
802 __SYCL_EXPORT s::cl_ushort sycl_host_rotate(s::cl_ushort x,
803  s::cl_ushort y) __NOEXC {
804  return __rotate(x, y);
805 }
806 __SYCL_EXPORT s::cl_uint sycl_host_rotate(s::cl_uint x, s::cl_uint y) __NOEXC {
807  return __rotate(x, y);
808 }
809 __SYCL_EXPORT s::cl_ulong sycl_host_rotate(s::cl_ulong x,
810  s::cl_ulong y) __NOEXC {
811  return __rotate(x, y);
812 }
813 __SYCL_EXPORT s::cl_char sycl_host_rotate(s::cl_char x, s::cl_char y) __NOEXC {
814  return __rotate(x, y);
815 }
816 __SYCL_EXPORT s::cl_short sycl_host_rotate(s::cl_short x,
817  s::cl_short y) __NOEXC {
818  return __rotate(x, y);
819 }
820 __SYCL_EXPORT s::cl_int sycl_host_rotate(s::cl_int x, s::cl_int y) __NOEXC {
821  return __rotate(x, y);
822 }
823 __SYCL_EXPORT s::cl_long sycl_host_rotate(s::cl_long x, s::cl_long y) __NOEXC {
824  return __rotate(x, y);
825 }
826 MAKE_1V_2V(sycl_host_rotate, s::cl_uchar, s::cl_uchar, s::cl_uchar)
828 MAKE_1V_2V(sycl_host_rotate, s::cl_uint, s::cl_uint, s::cl_uint)
829 MAKE_1V_2V(sycl_host_rotate, s::cl_ulong, s::cl_ulong, s::cl_ulong)
830 MAKE_1V_2V(sycl_host_rotate, s::cl_char, s::cl_char, s::cl_char)
831 MAKE_1V_2V(sycl_host_rotate, s::cl_short, s::cl_short, s::cl_short)
832 MAKE_1V_2V(sycl_host_rotate, s::cl_int, s::cl_int, s::cl_int)
833 MAKE_1V_2V(sycl_host_rotate, s::cl_long, s::cl_long, s::cl_long)
834 
835 // u_sub_sat
836 __SYCL_EXPORT s::cl_uchar sycl_host_u_sub_sat(s::cl_uchar x,
837  s::cl_uchar y) __NOEXC {
838  return __u_sub_sat(x, y);
839 }
840 __SYCL_EXPORT s::cl_ushort sycl_host_u_sub_sat(s::cl_ushort x,
841  s::cl_ushort y) __NOEXC {
842  return __u_sub_sat(x, y);
843 }
844 __SYCL_EXPORT s::cl_uint sycl_host_u_sub_sat(s::cl_uint x,
845  s::cl_uint y) __NOEXC {
846  return __u_sub_sat(x, y);
847 }
848 __SYCL_EXPORT s::cl_ulong sycl_host_u_sub_sat(s::cl_ulong x,
849  s::cl_ulong y) __NOEXC {
850  return __u_sub_sat(x, y);
851 }
852 MAKE_1V_2V(sycl_host_u_sub_sat, s::cl_uchar, s::cl_uchar, s::cl_uchar)
853 MAKE_1V_2V(sycl_host_u_sub_sat, s::cl_ushort, s::cl_ushort, s::cl_ushort)
854 MAKE_1V_2V(sycl_host_u_sub_sat, s::cl_uint, s::cl_uint, s::cl_uint)
855 MAKE_1V_2V(sycl_host_u_sub_sat, s::cl_ulong, s::cl_ulong, s::cl_ulong)
856 
857 // s_sub_sat
858 __SYCL_EXPORT s::cl_char sycl_host_s_sub_sat(s::cl_char x,
859  s::cl_char y) __NOEXC {
860  return __s_sub_sat(x, y);
861 }
862 __SYCL_EXPORT s::cl_short sycl_host_s_sub_sat(s::cl_short x,
863  s::cl_short y) __NOEXC {
864  return __s_sub_sat(x, y);
865 }
866 __SYCL_EXPORT s::cl_int sycl_host_s_sub_sat(s::cl_int x, s::cl_int y) __NOEXC {
867  return __s_sub_sat(x, y);
868 }
869 __SYCL_EXPORT s::cl_long sycl_host_s_sub_sat(s::cl_long x,
870  s::cl_long y) __NOEXC {
871  return __s_sub_sat(x, y);
872 }
873 MAKE_1V_2V(sycl_host_s_sub_sat, s::cl_char, s::cl_char, s::cl_char)
874 MAKE_1V_2V(sycl_host_s_sub_sat, s::cl_short, s::cl_short, s::cl_short)
875 MAKE_1V_2V(sycl_host_s_sub_sat, s::cl_int, s::cl_int, s::cl_int)
876 MAKE_1V_2V(sycl_host_s_sub_sat, s::cl_long, s::cl_long, s::cl_long)
877 
878 // u_upsample
879 __SYCL_EXPORT s::cl_ushort sycl_host_u_upsample(s::cl_uchar x,
880  s::cl_uchar y) __NOEXC {
881  return __upsample(x, y);
882 }
883 __SYCL_EXPORT s::cl_uint sycl_host_u_upsample(s::cl_ushort x,
884  s::cl_ushort y) __NOEXC {
885  return __upsample(x, y);
886 }
887 __SYCL_EXPORT s::cl_ulong sycl_host_u_upsample(s::cl_uint x,
888  s::cl_uint y) __NOEXC {
889  return __upsample(x, y);
890 }
891 MAKE_1V_2V(sycl_host_u_upsample, s::cl_ushort, s::cl_uchar, s::cl_uchar)
892 MAKE_1V_2V(sycl_host_u_upsample, s::cl_uint, s::cl_ushort, s::cl_ushort)
893 MAKE_1V_2V(sycl_host_u_upsample, s::cl_ulong, s::cl_uint, s::cl_uint)
894 
895 __SYCL_EXPORT s::cl_short sycl_host_s_upsample(s::cl_char x,
896  s::cl_uchar y) __NOEXC {
897  return __upsample(x, y);
898 }
899 __SYCL_EXPORT s::cl_int sycl_host_s_upsample(s::cl_short x,
900  s::cl_ushort y) __NOEXC {
901  return __upsample(x, y);
902 }
903 __SYCL_EXPORT s::cl_long sycl_host_s_upsample(s::cl_int x,
904  s::cl_uint y) __NOEXC {
905  return __upsample(x, y);
906 }
907 MAKE_1V_2V(sycl_host_s_upsample, s::cl_short, s::cl_char, s::cl_uchar)
908 MAKE_1V_2V(sycl_host_s_upsample, s::cl_int, s::cl_short, s::cl_ushort)
909 MAKE_1V_2V(sycl_host_s_upsample, s::cl_long, s::cl_int, s::cl_uint)
910 
911 // popcount
912 __SYCL_EXPORT s::cl_uchar sycl_host_popcount(s::cl_uchar x) __NOEXC {
913  return __popcount(x);
914 }
915 __SYCL_EXPORT s::cl_ushort sycl_host_popcount(s::cl_ushort x) __NOEXC {
916  return __popcount(x);
917 }
918 __SYCL_EXPORT s::cl_uint sycl_host_popcount(s::cl_uint x) __NOEXC {
919  return __popcount(x);
920 }
921 __SYCL_EXPORT s::cl_ulong sycl_host_popcount(s::cl_ulong x) __NOEXC {
922  return __popcount(x);
923 }
924 MAKE_1V(sycl_host_popcount, s::cl_uchar, s::cl_uchar)
925 MAKE_1V(sycl_host_popcount, s::cl_ushort, s::cl_ushort)
926 MAKE_1V(sycl_host_popcount, s::cl_uint, s::cl_uint)
927 MAKE_1V(sycl_host_popcount, s::cl_ulong, s::cl_ulong)
928 
929 __SYCL_EXPORT s::cl_char sycl_host_popcount(s::cl_char x) __NOEXC {
930  return __popcount(x);
931 }
932 __SYCL_EXPORT s::cl_short sycl_host_popcount(s::cl_short x) __NOEXC {
933  return __popcount(x);
934 }
935 __SYCL_EXPORT s::cl_int sycl_host_popcount(s::cl_int x) __NOEXC {
936  return __popcount(x);
937 }
938 __SYCL_EXPORT s::cl_long sycl_host_popcount(s::cl_long x) __NOEXC {
939  return __popcount(x);
940 }
941 MAKE_1V(sycl_host_popcount, s::cl_char, s::cl_char)
942 MAKE_1V(sycl_host_popcount, s::cl_short, s::cl_short)
943 MAKE_1V(sycl_host_popcount, s::cl_int, s::cl_int)
944 MAKE_1V(sycl_host_popcount, s::cl_long, s::cl_long)
945 
946 // u_mad24
947 __SYCL_EXPORT s::cl_uint sycl_host_u_mad24(s::cl_uint x, s::cl_uint y,
948  s::cl_uint z) __NOEXC {
949  return __mad24(x, y, z);
950 }
952 
953 // s_mad24
954 __SYCL_EXPORT s::cl_int sycl_host_s_mad24(s::cl_int x, s::cl_int y,
955  s::cl_int z) __NOEXC {
956  return __mad24(x, y, z);
957 }
958 MAKE_1V_2V_3V(sycl_host_s_mad24, s::cl_int, s::cl_int, s::cl_int, s::cl_int)
959 
960 // u_mul24
961 __SYCL_EXPORT s::cl_uint sycl_host_u_mul24(s::cl_uint x, s::cl_uint y) __NOEXC {
962  return __mul24(x, y);
963 }
964 MAKE_1V_2V(sycl_host_u_mul24, s::cl_uint, s::cl_uint, s::cl_uint)
965 
966 // s_mul24
967 __SYCL_EXPORT s::cl_int sycl_host_s_mul24(s::cl_int x, s::cl_int y) __NOEXC {
968  return __mul24(x, y);
969 }
970 MAKE_1V_2V(sycl_host_s_mul24, s::cl_int, s::cl_int, s::cl_int)
971 
972 } // namespace __host_std
__host_std::sycl_host_s_abs
s::cl_uchar sycl_host_s_abs(s::cl_char x) __NOEXC
Definition: builtins_integer.cpp:250
MAKE_1V_2S
#define MAKE_1V_2S(Fun, Ret, Arg1, Arg2)
Definition: builtins_helper.hpp:160
sycl::_V1::opencl::cl_int
std::int32_t cl_int
Definition: aliases.hpp:136
sycl::_V1::opencl::cl_uint
std::uint32_t cl_uint
Definition: aliases.hpp:137
sycl::_V1::ext::intel::experimental::esimd::bfn_t::z
@ z
sycl::_V1::ext::oneapi::experimental::matrix::matrix_use::a
@ a
__NOEXC
#define __NOEXC
Definition: builtins.hpp:18
__host_std::sycl_host_clz
s::cl_short s::cl_uchar sycl_host_clz(s::cl_uchar x) __NOEXC
Definition: builtins_integer.cpp:497
sycl::_V1::opencl::cl_ushort
std::uint16_t cl_ushort
Definition: aliases.hpp:135
sycl::_V1::opencl::cl_uchar
std::uint8_t cl_uchar
Definition: aliases.hpp:133
sycl::_V1::opencl::cl_ulong
std::uint64_t cl_ulong
Definition: aliases.hpp:139
__host_std::sycl_host_u_rhadd
s::cl_uchar sycl_host_u_rhadd(s::cl_uchar x, s::cl_uchar y) __NOEXC
Definition: builtins_integer.cpp:396
__host_std::sycl_host_u_clamp
s::cl_uchar sycl_host_u_clamp(s::cl_uchar x, s::cl_uchar minval, s::cl_uchar maxval) __NOEXC
Definition: builtins_integer.cpp:436
__host_std::sycl_host_s_hadd
s::cl_char sycl_host_s_hadd(s::cl_char x, s::cl_char y) __NOEXC
Definition: builtins_integer.cpp:377
__host_std
Definition: builtins.hpp:106
sycl::_V1::ext::oneapi::experimental::matrix::matrix_use::b
@ b
__host_std::sycl_host_s_add_sat
s::cl_char sycl_host_s_add_sat(s::cl_char x, s::cl_char y) __NOEXC
Definition: builtins_integer.cpp:335
sycl
---— Error handling, matching OpenCL plugin semantics.
Definition: access.hpp:14
max
simd< _Tp, _Abi > max(const simd< _Tp, _Abi > &, const simd< _Tp, _Abi > &) noexcept
MAKE_1V_2V
#define MAKE_1V_2V(Fun, Ret, Arg1, Arg2)
Definition: builtins_helper.hpp:125
__host_std::sycl_host_u_abs
s::cl_uchar sycl_host_u_abs(s::cl_uchar x) __NOEXC
Definition: builtins_integer.cpp:240
sycl::_V1::detail::min_v
static constexpr T min_v()
Definition: generic_type_traits.hpp:733
sycl::_V1::opencl::cl_short
std::int16_t cl_short
Definition: aliases.hpp:134
export.hpp
sycl::_V1::ext::intel::experimental::esimd::bfn_t::x
@ x
__host_std::sycl_host_s_clamp
s::cl_ushort s::cl_uchar s::cl_ulong s::cl_char sycl_host_s_clamp(s::cl_char x, s::cl_char minval, s::cl_char maxval) __NOEXC
Definition: builtins_integer.cpp:469
sycl::_V1::opencl::cl_char
std::int8_t cl_char
Definition: aliases.hpp:132
sycl::_V1::opencl::cl_long
std::int64_t cl_long
Definition: aliases.hpp:138
__host_std::sycl_host_u_abs_diff
s::cl_uchar sycl_host_u_abs_diff(s::cl_uchar x, s::cl_uchar y) __NOEXC
Definition: builtins_integer.cpp:268
__host_std::MAKE_1V_2V_3V
MAKE_1V_2V_3V(sycl_host_fclamp, s::cl_float, s::cl_float, s::cl_float, s::cl_float) MAKE_1V_2V_3V(sycl_host_fclamp
builtins_helper.hpp
sycl::_V1::ext::intel::experimental::esimd::bfn_t::y
@ y
sycl::_V1::ext::intel::esimd::abs
ESIMD_DETAIL __ESIMD_API std::enable_if_t< !std::is_same< std::remove_const_t< TRes >, std::remove_const_t< TArg > >::value, simd< TRes, SZ > > abs(simd< TArg, SZ > src0)
Get absolute value (vector version)
Definition: math.hpp:127
__host_std::sycl_host_s_mad_hi
s::cl_char sycl_host_s_mad_hi(s::cl_char x, s::cl_char minval, s::cl_char maxval) __NOEXC
Definition: builtins_integer.cpp:599
__host_std::sycl_host_s_mul_hi
s::cl_char sycl_host_s_mul_hi(s::cl_char a, s::cl_char b)
Definition: builtins_integer.cpp:561
__host_std::sycl_host_u_add_sat
s::cl_uchar sycl_host_u_add_sat(s::cl_uchar x, s::cl_uchar y) __NOEXC
Definition: builtins_integer.cpp:313
__host_std::sycl_host_s_rhadd
s::cl_char sycl_host_s_rhadd(s::cl_char x, s::cl_char y) __NOEXC
Definition: builtins_integer.cpp:417
__host_std::sycl_host_ctz
s::cl_uchar sycl_host_ctz(s::cl_uchar x) __NOEXC
Definition: builtins_integer.cpp:529
MAKE_1V
#define MAKE_1V(Fun, Ret, Arg1)
Definition: builtins_helper.hpp:115
__host_std::sycl_host_u_hadd
s::cl_uchar sycl_host_u_hadd(s::cl_uchar x, s::cl_uchar y) __NOEXC
Definition: builtins_integer.cpp:356
__host_std::sycl_host_u_mul_hi
s::cl_uchar sycl_host_u_mul_hi(s::cl_uchar a, s::cl_uchar b)
Definition: builtins_integer.cpp:580
min
simd< _Tp, _Abi > min(const simd< _Tp, _Abi > &, const simd< _Tp, _Abi > &) noexcept
__host_std::sycl_host_s_abs_diff
s::cl_uchar sycl_host_s_abs_diff(s::cl_char x, s::cl_char y) __NOEXC
Definition: builtins_integer.cpp:291
__host_std::MAKE_1V_2S_3S
s::cl_ushort s::cl_uchar MAKE_1V_2S_3S(sycl_host_u_clamp, s::cl_ushort, s::cl_ushort, s::cl_ushort, s::cl_ushort) MAKE_1V_2S_3S(sycl_host_u_clamp