@@ -23,10 +23,97 @@ or, in case of Windows:
23
23
clang++ -fsycl main.obj %SYCL_INSTALL%/lib/libsycl-msvc.o -o a.exe
24
24
25
25
List of supported functions from C standard library:
26
- - assert macro (from <assert.h> or <cassert>)
27
-
28
- NOTE: only the GNU glibc and Microsoft C libraries are currently
29
- supported.
26
+ - assert macro (from <assert.h> or <cassert>)
27
+ - logf, log (from <math.h> or <cmath>)
28
+ - expf, exp (from <math.h> or <cmath>)
29
+ - frexpf, frexp (from <math.h> or <cmath>)
30
+ - ldexpf, ldexp (from <math.h> or <cmath>)
31
+ - log10f, log10 (from <math.h> or <cmath>)
32
+ - modff, modf (from <math.h> or <cmath>)
33
+ - exp2f, exp2 (from <math.h> or <cmath>)
34
+ - expm1f, expm1 (from <math.h> or <cmath>)
35
+ - ilogbf, ilogb (from <math.h> or <cmath>)
36
+ - log1pf, log1p (from <math.h> or <cmath>)
37
+ - log2f, log2 (from <math.h> or <cmath>)
38
+ - logbf, logb (from <math.h> or <cmath>)
39
+ - sqrtf, sqrt (from <math.h> or <cmath>)
40
+ - cbrtf, cbrt (from <math.h> or <cmath>)
41
+ - hypotf, hypot (from <math.h> or <cmath>)
42
+ - erff, erf (from <math.h> or <cmath>)
43
+ - erfcf, erfc (from <math.h> or <cmath>)
44
+ - tgammaf, tgamma (from <math.h> or <cmath>)
45
+ - lgammaf, lgamma (from <math.h> or <cmath>)
46
+ - fmodf, fmod (from <math.h> or <cmath>)
47
+ - remainderf, remainder (from <math.h> or <cmath>)
48
+ - remquof, remquo (from <math.h> or <cmath>)
49
+ - nextafterf, nextafter (from <math.h> or <cmath>)
50
+ - fdimf, fdim (from <math.h> or <cmath>)
51
+ - fmaf, fma (from <math.h> or <cmath>)
52
+ - sinf, sin (from <math.h> or <cmath>)
53
+ - cosf, cos (from <math.h> or <cmath>)
54
+ - tanf, tan (from <math.h> or <cmath>)
55
+ - powf, pow (from <math.h> or <cmath>)
56
+ - acosf, acos (from <math.h> or <cmath>)
57
+ - asinf, asin (from <math.h> or <cmath>)
58
+ - atanf, atan (from <math.h> or <cmath>)
59
+ - atan2f, atan2 (from <math.h> or <cmath>)
60
+ - coshf, cosh (from <math.h> or <cmath>)
61
+ - sinhf, sinh (from <math.h> or <cmath>)
62
+ - tanhf, tanh (from <math.h> or <cmath>)
63
+ - acoshf, acosh (from <math.h> or <cmath>)
64
+ - asinhf, asinh (from <math.h> or <cmath>)
65
+ - atanhf, atanh (from <math.h> or <cmath>)
66
+ - cimagf, cimag (from <complex.h>)
67
+ - crealf, creal (from <complex.h>)
68
+ - cargf, carg (from <complex.h>)
69
+ - cabsf, cabs (from <complex.h>)
70
+ - cprojf, cproj (from <complex.h>)
71
+ - cexpf, cexp (from <complex.h>)
72
+ - clogf, clog (from <complex.h>)
73
+ - cpowf, cpow (from <complex.h>)
74
+ - cpolarf, cpolar (from <complex.h>)
75
+ - csqrtf, csqrt (from <complex.h>)
76
+ - csinhf, csinh (from <complex.h>)
77
+ - ccoshf, ccosh (from <complex.h>)
78
+ - ctanhf, ctanh (from <complex.h>)
79
+ - csinf, csin (from <complex.h>)
80
+ - ccosf, ccos (from <complex.h>)
81
+ - ctanf, ctan (from <complex.h>)
82
+ - casinhf, casinh (from <complex.h>)
83
+ - cacoshf, cacosh (from <complex.h>)
84
+ - catanhf, catanh (from <complex.h>)
85
+ - casinf, casin (from <complex.h>)
86
+ - cacosf, cacos (from <complex.h>)
87
+ - catanf, catan (from <complex.h>)
88
+
89
+ All functions are grouped into different device libraries based on
90
+ functionalities. C and C++ standard library groups functions and
91
+ classes by purpose(e.g. <math.h> for mathematical operations and
92
+ transformations) and device library infrastructure uses this as
93
+ a baseline.
94
+ NOTE: Only the GNU glibc, Microsoft C libraries are currently
95
+ supported. The device libraries for <math.h> and <complex.h> are
96
+ ready for Linux and Windows support will be added in the future.
97
+ Not all functions from <math.h> are supported right now, following
98
+ math functions are not supported now:
99
+ - abs
100
+ - ceilf, ceil
101
+ - copysignf, copysign
102
+ - fabsf, fabs
103
+ - floorf, floor
104
+ - fmaxf, fmax
105
+ - fminf, fmin
106
+ - nextafterf, nextafter
107
+ - rintf, rint
108
+ - roundf, round
109
+ - truncf, trunc
110
+ - scalbnf, scalbn
111
+ - nearbyintf, nearbyint
112
+ - lrintf, lrint
113
+ - nexttowardf, nexttoward
114
+ - nanf, nan
115
+ Device libraries can't support both single and double precision as some
116
+ underlying device may not support double precision.
30
117
31
118
Example of usage
32
119
================
@@ -58,6 +145,31 @@ Example of usage
58
145
deviceQueue.wait_and_throw();
59
146
}
60
147
148
+
149
+ .. code: c++
150
+ #include <math.h>
151
+ #include <CL/sycl.hpp>
152
+
153
+ void device_sin_test() {
154
+ cl::sycl::queue deviceQueue;
155
+ cl::sycl::range<1> numOfItems{1};
156
+ float result_f = -1.f;
157
+ double result_d = -1.d;
158
+ {
159
+ cl::sycl::buffer<float, 1> buffer1(&result_f, numOfItems);
160
+ cl::sycl::buffer<double, 1> buffer2(&result_d, numOfItems);
161
+ deviceQueue.submit([&](cl::sycl::handler &cgh) {
162
+ auto res_access1 = buffer1.get_access<sycl_write>(cgh);
163
+ auto res_access2 = buffer2.get_access<sycl_write>(cgh);
164
+ cgh.single_task<class DeviceSin>([=]() {
165
+ res_access1[0] = sinf(0.f);
166
+ res_access2[0] = sin(0.0);
167
+ });
168
+ });
169
+ }
170
+ assert((result_f == 0.f) && (result_d == 0.0));
171
+ }
172
+
61
173
Frontend
62
174
========
63
175
0 commit comments