diff --git a/sycl/include/sycl/builtins.hpp b/sycl/include/sycl/builtins.hpp index 92814bdafd7d4..bfa4bd6dfb5ca 100644 --- a/sycl/include/sycl/builtins.hpp +++ b/sycl/include/sycl/builtins.hpp @@ -15,98 +15,8 @@ #include #include -// We don't use the same exception specifier as so we get warnings if -// our code is processed before STL's . -// TODO: We should remove this dependency alltogether in a subsequent patch. -#include - #ifdef __SYCL_DEVICE_ONLY__ extern "C" { -extern __DPCPP_SYCL_EXTERNAL int abs(int x); -extern __DPCPP_SYCL_EXTERNAL long int labs(long int x); -extern __DPCPP_SYCL_EXTERNAL long long int llabs(long long int x); - -extern __DPCPP_SYCL_EXTERNAL div_t div(int x, int y); -extern __DPCPP_SYCL_EXTERNAL ldiv_t ldiv(long int x, long int y); -extern __DPCPP_SYCL_EXTERNAL lldiv_t lldiv(long long int x, long long int y); -extern __DPCPP_SYCL_EXTERNAL float scalbnf(float x, int n); -extern __DPCPP_SYCL_EXTERNAL double scalbn(double x, int n); -extern __DPCPP_SYCL_EXTERNAL float logf(float x); -extern __DPCPP_SYCL_EXTERNAL double log(double x); -extern __DPCPP_SYCL_EXTERNAL float expf(float x); -extern __DPCPP_SYCL_EXTERNAL double exp(double x); -extern __DPCPP_SYCL_EXTERNAL float log10f(float x); -extern __DPCPP_SYCL_EXTERNAL double log10(double x); -extern __DPCPP_SYCL_EXTERNAL float modff(float x, float *intpart); -extern __DPCPP_SYCL_EXTERNAL double modf(double x, double *intpart); -extern __DPCPP_SYCL_EXTERNAL float exp2f(float x); -extern __DPCPP_SYCL_EXTERNAL double exp2(double x); -extern __DPCPP_SYCL_EXTERNAL float expm1f(float x); -extern __DPCPP_SYCL_EXTERNAL double expm1(double x); -extern __DPCPP_SYCL_EXTERNAL int ilogbf(float x); -extern __DPCPP_SYCL_EXTERNAL int ilogb(double x); -extern __DPCPP_SYCL_EXTERNAL float log1pf(float x); -extern __DPCPP_SYCL_EXTERNAL double log1p(double x); -extern __DPCPP_SYCL_EXTERNAL float log2f(float x); -extern __DPCPP_SYCL_EXTERNAL double log2(double x); -extern __DPCPP_SYCL_EXTERNAL float logbf(float x); -extern __DPCPP_SYCL_EXTERNAL double logb(double x); -extern __DPCPP_SYCL_EXTERNAL float sqrtf(float x); -extern __DPCPP_SYCL_EXTERNAL double sqrt(double x); -extern __DPCPP_SYCL_EXTERNAL float cbrtf(float x); -extern __DPCPP_SYCL_EXTERNAL double cbrt(double x); -extern __DPCPP_SYCL_EXTERNAL float erff(float x); -extern __DPCPP_SYCL_EXTERNAL double erf(double x); -extern __DPCPP_SYCL_EXTERNAL float erfcf(float x); -extern __DPCPP_SYCL_EXTERNAL double erfc(double x); -extern __DPCPP_SYCL_EXTERNAL float tgammaf(float x); -extern __DPCPP_SYCL_EXTERNAL double tgamma(double x); -extern __DPCPP_SYCL_EXTERNAL float lgammaf(float x); -extern __DPCPP_SYCL_EXTERNAL double lgamma(double x); -extern __DPCPP_SYCL_EXTERNAL float fmodf(float x, float y); -extern __DPCPP_SYCL_EXTERNAL double fmod(double x, double y); -extern __DPCPP_SYCL_EXTERNAL float remainderf(float x, float y); -extern __DPCPP_SYCL_EXTERNAL double remainder(double x, double y); -extern __DPCPP_SYCL_EXTERNAL float remquof(float x, float y, int *q); -extern __DPCPP_SYCL_EXTERNAL double remquo(double x, double y, int *q); -extern __DPCPP_SYCL_EXTERNAL float nextafterf(float x, float y); -extern __DPCPP_SYCL_EXTERNAL double nextafter(double x, double y); -extern __DPCPP_SYCL_EXTERNAL float fdimf(float x, float y); -extern __DPCPP_SYCL_EXTERNAL double fdim(double x, double y); -extern __DPCPP_SYCL_EXTERNAL float fmaf(float x, float y, float z); -extern __DPCPP_SYCL_EXTERNAL double fma(double x, double y, double z); -extern __DPCPP_SYCL_EXTERNAL float sinf(float x); -extern __DPCPP_SYCL_EXTERNAL double sin(double x); -extern __DPCPP_SYCL_EXTERNAL float cosf(float x); -extern __DPCPP_SYCL_EXTERNAL double cos(double x); -extern __DPCPP_SYCL_EXTERNAL float tanf(float x); -extern __DPCPP_SYCL_EXTERNAL double tan(double x); -extern __DPCPP_SYCL_EXTERNAL float asinf(float x); -extern __DPCPP_SYCL_EXTERNAL double asin(double x); -extern __DPCPP_SYCL_EXTERNAL float acosf(float x); -extern __DPCPP_SYCL_EXTERNAL double acos(double x); -extern __DPCPP_SYCL_EXTERNAL float atanf(float x); -extern __DPCPP_SYCL_EXTERNAL double atan(double x); -extern __DPCPP_SYCL_EXTERNAL float powf(float x, float y); -extern __DPCPP_SYCL_EXTERNAL double pow(double x, double y); -extern __DPCPP_SYCL_EXTERNAL float atan2f(float x, float y); -extern __DPCPP_SYCL_EXTERNAL double atan2(double x, double y); - -extern __DPCPP_SYCL_EXTERNAL float sinhf(float x); -extern __DPCPP_SYCL_EXTERNAL double sinh(double x); -extern __DPCPP_SYCL_EXTERNAL float coshf(float x); -extern __DPCPP_SYCL_EXTERNAL double cosh(double x); -extern __DPCPP_SYCL_EXTERNAL float tanhf(float x); -extern __DPCPP_SYCL_EXTERNAL double tanh(double x); -extern __DPCPP_SYCL_EXTERNAL float asinhf(float x); -extern __DPCPP_SYCL_EXTERNAL double asinh(double x); -extern __DPCPP_SYCL_EXTERNAL float acoshf(float x); -extern __DPCPP_SYCL_EXTERNAL double acosh(double x); -extern __DPCPP_SYCL_EXTERNAL float atanhf(float x); -extern __DPCPP_SYCL_EXTERNAL double atanh(double x); -extern __DPCPP_SYCL_EXTERNAL double frexp(double x, int *exp); -extern __DPCPP_SYCL_EXTERNAL double ldexp(double x, int exp); -extern __DPCPP_SYCL_EXTERNAL double hypot(double x, double y); extern __DPCPP_SYCL_EXTERNAL void *memcpy(void *dest, const void *src, size_t n); @@ -604,65 +514,6 @@ extern __DPCPP_SYCL_EXTERNAL void __assert_fail(const char *expr, const char *file, unsigned int line, const char *func); -extern __DPCPP_SYCL_EXTERNAL float frexpf(float x, int *exp); -extern __DPCPP_SYCL_EXTERNAL float ldexpf(float x, int exp); -extern __DPCPP_SYCL_EXTERNAL float hypotf(float x, float y); - -// MS UCRT supports most of the C standard library but is -// an exception. -extern __DPCPP_SYCL_EXTERNAL float cimagf(float __complex__ z); -extern __DPCPP_SYCL_EXTERNAL double cimag(double __complex__ z); -extern __DPCPP_SYCL_EXTERNAL float crealf(float __complex__ z); -extern __DPCPP_SYCL_EXTERNAL double creal(double __complex__ z); -extern __DPCPP_SYCL_EXTERNAL float cargf(float __complex__ z); -extern __DPCPP_SYCL_EXTERNAL double carg(double __complex__ z); -extern __DPCPP_SYCL_EXTERNAL float cabsf(float __complex__ z); -extern __DPCPP_SYCL_EXTERNAL double cabs(double __complex__ z); -extern __DPCPP_SYCL_EXTERNAL float __complex__ cprojf(float __complex__ z); -extern __DPCPP_SYCL_EXTERNAL double __complex__ cproj(double __complex__ z); -extern __DPCPP_SYCL_EXTERNAL float __complex__ cexpf(float __complex__ z); -extern __DPCPP_SYCL_EXTERNAL double __complex__ cexp(double __complex__ z); -extern __DPCPP_SYCL_EXTERNAL float __complex__ clogf(float __complex__ z); -extern __DPCPP_SYCL_EXTERNAL double __complex__ clog(double __complex__ z); -extern __DPCPP_SYCL_EXTERNAL float __complex__ cpowf(float __complex__ z); -extern __DPCPP_SYCL_EXTERNAL double __complex__ cpow(double __complex__ z); -extern __DPCPP_SYCL_EXTERNAL float __complex__ csqrtf(float __complex__ z); -extern __DPCPP_SYCL_EXTERNAL double __complex__ csqrt(double __complex__ z); -extern __DPCPP_SYCL_EXTERNAL float __complex__ csinhf(float __complex__ z); -extern __DPCPP_SYCL_EXTERNAL double __complex__ csinh(double __complex__ z); -extern __DPCPP_SYCL_EXTERNAL float __complex__ ccoshf(float __complex__ z); -extern __DPCPP_SYCL_EXTERNAL double __complex__ ccosh(double __complex__ z); -extern __DPCPP_SYCL_EXTERNAL float __complex__ ctanhf(float __complex__ z); -extern __DPCPP_SYCL_EXTERNAL double __complex__ ctanh(double __complex__ z); -extern __DPCPP_SYCL_EXTERNAL float __complex__ csinf(float __complex__ z); -extern __DPCPP_SYCL_EXTERNAL double __complex__ csin(double __complex__ z); -extern __DPCPP_SYCL_EXTERNAL float __complex__ ccosf(float __complex__ z); -extern __DPCPP_SYCL_EXTERNAL double __complex__ ccos(double __complex__ z); -extern __DPCPP_SYCL_EXTERNAL float __complex__ ctanf(float __complex__ z); -extern __DPCPP_SYCL_EXTERNAL double __complex__ ctan(double __complex__ z); -extern __DPCPP_SYCL_EXTERNAL float __complex__ cacosf(float __complex__ z); -extern __DPCPP_SYCL_EXTERNAL double __complex__ cacos(double __complex__ z); -extern __DPCPP_SYCL_EXTERNAL float __complex__ cacoshf(float __complex__ z); -extern __DPCPP_SYCL_EXTERNAL double __complex__ cacosh(double __complex__ z); -extern __DPCPP_SYCL_EXTERNAL float __complex__ casinf(float __complex__ z); -extern __DPCPP_SYCL_EXTERNAL double __complex__ casin(double __complex__ z); -extern __DPCPP_SYCL_EXTERNAL float __complex__ casinhf(float __complex__ z); -extern __DPCPP_SYCL_EXTERNAL double __complex__ casinh(double __complex__ z); -extern __DPCPP_SYCL_EXTERNAL float __complex__ catanf(float __complex__ z); -extern __DPCPP_SYCL_EXTERNAL double __complex__ catan(double __complex__ z); -extern __DPCPP_SYCL_EXTERNAL float __complex__ catanhf(float __complex__ z); -extern __DPCPP_SYCL_EXTERNAL double __complex__ catanh(double __complex__ z); -extern __DPCPP_SYCL_EXTERNAL float __complex__ cpolarf(float rho, float theta); -extern __DPCPP_SYCL_EXTERNAL double __complex__ cpolar(double rho, - double theta); -extern __DPCPP_SYCL_EXTERNAL float __complex__ __mulsc3(float a, float b, - float c, float d); -extern __DPCPP_SYCL_EXTERNAL double __complex__ __muldc3(double a, double b, - double c, double d); -extern __DPCPP_SYCL_EXTERNAL float __complex__ __divsc3(float a, float b, - float c, float d); -extern __DPCPP_SYCL_EXTERNAL double __complex__ __divdc3(float a, float b, - float c, float d); } #elif defined(_WIN32) extern "C" { @@ -672,21 +523,6 @@ extern "C" { // APIs used by STL, such as _Cosh, are undocumented, even though // they are open-sourced. Recognizing them as builtins is not // straightforward currently. -extern __DPCPP_SYCL_EXTERNAL double _Cosh(double x, double y); -extern __DPCPP_SYCL_EXTERNAL int _dpcomp(double x, double y); -extern __DPCPP_SYCL_EXTERNAL int _dsign(double x); -extern __DPCPP_SYCL_EXTERNAL short _Dtest(double *px); -extern __DPCPP_SYCL_EXTERNAL short _dtest(double *px); -extern __DPCPP_SYCL_EXTERNAL short _Exp(double *px, double y, short eoff); -extern __DPCPP_SYCL_EXTERNAL float _FCosh(float x, float y); -extern __DPCPP_SYCL_EXTERNAL int _fdpcomp(float x, float y); -extern __DPCPP_SYCL_EXTERNAL int _fdsign(float x); -extern __DPCPP_SYCL_EXTERNAL short _FDtest(float *px); -extern __DPCPP_SYCL_EXTERNAL short _fdtest(float *px); -extern __DPCPP_SYCL_EXTERNAL short _FExp(float *px, float y, short eoff); -extern __DPCPP_SYCL_EXTERNAL float _FSinh(float x, float y); -extern __DPCPP_SYCL_EXTERNAL double _Sinh(double x, double y); -extern __DPCPP_SYCL_EXTERNAL float _hypotf(float x, float y); extern __DPCPP_SYCL_EXTERNAL void _wassert(const wchar_t *wexpr, const wchar_t *wfile, unsigned line); } diff --git a/sycl/include/sycl/stl_wrappers/cmath b/sycl/include/sycl/stl_wrappers/cmath new file mode 100644 index 0000000000000..c25eadf6394a1 --- /dev/null +++ b/sycl/include/sycl/stl_wrappers/cmath @@ -0,0 +1,197 @@ +#pragma once + +// Include real STL header - the next one from the include search +// directories. +#if defined(__has_include_next) +// GCC/clang support go through this path. +#include_next +#else +// MSVC doesn't support "#include_next", so we have to be creative. +// Our header is located in "stl_wrappers/complex" so it won't be picked by the +// following include. MSVC's installation, on the other hand, has the layout +// where the following would result in the we want. This is obviously +// hacky, but the best we can do... +#include <../include/cmath> +#endif + +// *** *** + +#include + +#ifdef __SYCL_DEVICE_ONLY__ +extern "C" { +extern __DPCPP_SYCL_EXTERNAL int abs(int x); +extern __DPCPP_SYCL_EXTERNAL long int labs(long int x); +extern __DPCPP_SYCL_EXTERNAL long long int llabs(long long int x); + +extern __DPCPP_SYCL_EXTERNAL div_t div(int x, int y); +extern __DPCPP_SYCL_EXTERNAL ldiv_t ldiv(long int x, long int y); +extern __DPCPP_SYCL_EXTERNAL lldiv_t lldiv(long long int x, long long int y); +extern __DPCPP_SYCL_EXTERNAL float scalbnf(float x, int n); +extern __DPCPP_SYCL_EXTERNAL double scalbn(double x, int n); +extern __DPCPP_SYCL_EXTERNAL float logf(float x); +extern __DPCPP_SYCL_EXTERNAL double log(double x); +extern __DPCPP_SYCL_EXTERNAL float expf(float x); +extern __DPCPP_SYCL_EXTERNAL double exp(double x); +extern __DPCPP_SYCL_EXTERNAL float log10f(float x); +extern __DPCPP_SYCL_EXTERNAL double log10(double x); +extern __DPCPP_SYCL_EXTERNAL float modff(float x, float *intpart); +extern __DPCPP_SYCL_EXTERNAL double modf(double x, double *intpart); +extern __DPCPP_SYCL_EXTERNAL float exp2f(float x); +extern __DPCPP_SYCL_EXTERNAL double exp2(double x); +extern __DPCPP_SYCL_EXTERNAL float expm1f(float x); +extern __DPCPP_SYCL_EXTERNAL double expm1(double x); +extern __DPCPP_SYCL_EXTERNAL int ilogbf(float x); +extern __DPCPP_SYCL_EXTERNAL int ilogb(double x); +extern __DPCPP_SYCL_EXTERNAL float log1pf(float x); +extern __DPCPP_SYCL_EXTERNAL double log1p(double x); +extern __DPCPP_SYCL_EXTERNAL float log2f(float x); +extern __DPCPP_SYCL_EXTERNAL double log2(double x); +extern __DPCPP_SYCL_EXTERNAL float logbf(float x); +extern __DPCPP_SYCL_EXTERNAL double logb(double x); +extern __DPCPP_SYCL_EXTERNAL float sqrtf(float x); +extern __DPCPP_SYCL_EXTERNAL double sqrt(double x); +extern __DPCPP_SYCL_EXTERNAL float cbrtf(float x); +extern __DPCPP_SYCL_EXTERNAL double cbrt(double x); +extern __DPCPP_SYCL_EXTERNAL float erff(float x); +extern __DPCPP_SYCL_EXTERNAL double erf(double x); +extern __DPCPP_SYCL_EXTERNAL float erfcf(float x); +extern __DPCPP_SYCL_EXTERNAL double erfc(double x); +extern __DPCPP_SYCL_EXTERNAL float tgammaf(float x); +extern __DPCPP_SYCL_EXTERNAL double tgamma(double x); +extern __DPCPP_SYCL_EXTERNAL float lgammaf(float x); +extern __DPCPP_SYCL_EXTERNAL double lgamma(double x); +extern __DPCPP_SYCL_EXTERNAL float fmodf(float x, float y); +extern __DPCPP_SYCL_EXTERNAL double fmod(double x, double y); +extern __DPCPP_SYCL_EXTERNAL float remainderf(float x, float y); +extern __DPCPP_SYCL_EXTERNAL double remainder(double x, double y); +extern __DPCPP_SYCL_EXTERNAL float remquof(float x, float y, int *q); +extern __DPCPP_SYCL_EXTERNAL double remquo(double x, double y, int *q); +extern __DPCPP_SYCL_EXTERNAL float nextafterf(float x, float y); +extern __DPCPP_SYCL_EXTERNAL double nextafter(double x, double y); +extern __DPCPP_SYCL_EXTERNAL float fdimf(float x, float y); +extern __DPCPP_SYCL_EXTERNAL double fdim(double x, double y); +extern __DPCPP_SYCL_EXTERNAL float fmaf(float x, float y, float z); +extern __DPCPP_SYCL_EXTERNAL double fma(double x, double y, double z); +extern __DPCPP_SYCL_EXTERNAL float sinf(float x); +extern __DPCPP_SYCL_EXTERNAL double sin(double x); +extern __DPCPP_SYCL_EXTERNAL float cosf(float x); +extern __DPCPP_SYCL_EXTERNAL double cos(double x); +extern __DPCPP_SYCL_EXTERNAL float tanf(float x); +extern __DPCPP_SYCL_EXTERNAL double tan(double x); +extern __DPCPP_SYCL_EXTERNAL float asinf(float x); +extern __DPCPP_SYCL_EXTERNAL double asin(double x); +extern __DPCPP_SYCL_EXTERNAL float acosf(float x); +extern __DPCPP_SYCL_EXTERNAL double acos(double x); +extern __DPCPP_SYCL_EXTERNAL float atanf(float x); +extern __DPCPP_SYCL_EXTERNAL double atan(double x); +extern __DPCPP_SYCL_EXTERNAL float powf(float x, float y); +extern __DPCPP_SYCL_EXTERNAL double pow(double x, double y); +extern __DPCPP_SYCL_EXTERNAL float atan2f(float x, float y); +extern __DPCPP_SYCL_EXTERNAL double atan2(double x, double y); + +extern __DPCPP_SYCL_EXTERNAL float sinhf(float x); +extern __DPCPP_SYCL_EXTERNAL double sinh(double x); +extern __DPCPP_SYCL_EXTERNAL float coshf(float x); +extern __DPCPP_SYCL_EXTERNAL double cosh(double x); +extern __DPCPP_SYCL_EXTERNAL float tanhf(float x); +extern __DPCPP_SYCL_EXTERNAL double tanh(double x); +extern __DPCPP_SYCL_EXTERNAL float asinhf(float x); +extern __DPCPP_SYCL_EXTERNAL double asinh(double x); +extern __DPCPP_SYCL_EXTERNAL float acoshf(float x); +extern __DPCPP_SYCL_EXTERNAL double acosh(double x); +extern __DPCPP_SYCL_EXTERNAL float atanhf(float x); +extern __DPCPP_SYCL_EXTERNAL double atanh(double x); +extern __DPCPP_SYCL_EXTERNAL double frexp(double x, int *exp); +extern __DPCPP_SYCL_EXTERNAL double ldexp(double x, int exp); +extern __DPCPP_SYCL_EXTERNAL double hypot(double x, double y); + +} +#ifdef __GLIBC__ +extern "C" { +extern __DPCPP_SYCL_EXTERNAL float frexpf(float x, int *exp); +extern __DPCPP_SYCL_EXTERNAL float ldexpf(float x, int exp); +extern __DPCPP_SYCL_EXTERNAL float hypotf(float x, float y); + +// MS UCRT supports most of the C standard library but is +// an exception. +extern __DPCPP_SYCL_EXTERNAL float cimagf(float __complex__ z); +extern __DPCPP_SYCL_EXTERNAL double cimag(double __complex__ z); +extern __DPCPP_SYCL_EXTERNAL float crealf(float __complex__ z); +extern __DPCPP_SYCL_EXTERNAL double creal(double __complex__ z); +extern __DPCPP_SYCL_EXTERNAL float cargf(float __complex__ z); +extern __DPCPP_SYCL_EXTERNAL double carg(double __complex__ z); +extern __DPCPP_SYCL_EXTERNAL float cabsf(float __complex__ z); +extern __DPCPP_SYCL_EXTERNAL double cabs(double __complex__ z); +extern __DPCPP_SYCL_EXTERNAL float __complex__ cprojf(float __complex__ z); +extern __DPCPP_SYCL_EXTERNAL double __complex__ cproj(double __complex__ z); +extern __DPCPP_SYCL_EXTERNAL float __complex__ cexpf(float __complex__ z); +extern __DPCPP_SYCL_EXTERNAL double __complex__ cexp(double __complex__ z); +extern __DPCPP_SYCL_EXTERNAL float __complex__ clogf(float __complex__ z); +extern __DPCPP_SYCL_EXTERNAL double __complex__ clog(double __complex__ z); +extern __DPCPP_SYCL_EXTERNAL float __complex__ cpowf(float __complex__ z); +extern __DPCPP_SYCL_EXTERNAL double __complex__ cpow(double __complex__ z); +extern __DPCPP_SYCL_EXTERNAL float __complex__ csqrtf(float __complex__ z); +extern __DPCPP_SYCL_EXTERNAL double __complex__ csqrt(double __complex__ z); +extern __DPCPP_SYCL_EXTERNAL float __complex__ csinhf(float __complex__ z); +extern __DPCPP_SYCL_EXTERNAL double __complex__ csinh(double __complex__ z); +extern __DPCPP_SYCL_EXTERNAL float __complex__ ccoshf(float __complex__ z); +extern __DPCPP_SYCL_EXTERNAL double __complex__ ccosh(double __complex__ z); +extern __DPCPP_SYCL_EXTERNAL float __complex__ ctanhf(float __complex__ z); +extern __DPCPP_SYCL_EXTERNAL double __complex__ ctanh(double __complex__ z); +extern __DPCPP_SYCL_EXTERNAL float __complex__ csinf(float __complex__ z); +extern __DPCPP_SYCL_EXTERNAL double __complex__ csin(double __complex__ z); +extern __DPCPP_SYCL_EXTERNAL float __complex__ ccosf(float __complex__ z); +extern __DPCPP_SYCL_EXTERNAL double __complex__ ccos(double __complex__ z); +extern __DPCPP_SYCL_EXTERNAL float __complex__ ctanf(float __complex__ z); +extern __DPCPP_SYCL_EXTERNAL double __complex__ ctan(double __complex__ z); +extern __DPCPP_SYCL_EXTERNAL float __complex__ cacosf(float __complex__ z); +extern __DPCPP_SYCL_EXTERNAL double __complex__ cacos(double __complex__ z); +extern __DPCPP_SYCL_EXTERNAL float __complex__ cacoshf(float __complex__ z); +extern __DPCPP_SYCL_EXTERNAL double __complex__ cacosh(double __complex__ z); +extern __DPCPP_SYCL_EXTERNAL float __complex__ casinf(float __complex__ z); +extern __DPCPP_SYCL_EXTERNAL double __complex__ casin(double __complex__ z); +extern __DPCPP_SYCL_EXTERNAL float __complex__ casinhf(float __complex__ z); +extern __DPCPP_SYCL_EXTERNAL double __complex__ casinh(double __complex__ z); +extern __DPCPP_SYCL_EXTERNAL float __complex__ catanf(float __complex__ z); +extern __DPCPP_SYCL_EXTERNAL double __complex__ catan(double __complex__ z); +extern __DPCPP_SYCL_EXTERNAL float __complex__ catanhf(float __complex__ z); +extern __DPCPP_SYCL_EXTERNAL double __complex__ catanh(double __complex__ z); +extern __DPCPP_SYCL_EXTERNAL float __complex__ cpolarf(float rho, float theta); +extern __DPCPP_SYCL_EXTERNAL double __complex__ cpolar(double rho, + double theta); +extern __DPCPP_SYCL_EXTERNAL float __complex__ __mulsc3(float a, float b, + float c, float d); +extern __DPCPP_SYCL_EXTERNAL double __complex__ __muldc3(double a, double b, + double c, double d); +extern __DPCPP_SYCL_EXTERNAL float __complex__ __divsc3(float a, float b, + float c, float d); +extern __DPCPP_SYCL_EXTERNAL double __complex__ __divdc3(float a, float b, + float c, float d); +} +#elif defined(_WIN32) +extern "C" { +// TODO: documented C runtime library APIs must be recognized as +// builtins by FE. This includes _dpcomp, _dsign, _dtest, +// _fdpcomp, _fdsign, _fdtest, _hypotf, _wassert. +// APIs used by STL, such as _Cosh, are undocumented, even though +// they are open-sourced. Recognizing them as builtins is not +// straightforward currently. +extern __DPCPP_SYCL_EXTERNAL double _Cosh(double x, double y); +extern __DPCPP_SYCL_EXTERNAL int _dpcomp(double x, double y); +extern __DPCPP_SYCL_EXTERNAL int _dsign(double x); +extern __DPCPP_SYCL_EXTERNAL short _Dtest(double *px); +extern __DPCPP_SYCL_EXTERNAL short _dtest(double *px); +extern __DPCPP_SYCL_EXTERNAL short _Exp(double *px, double y, short eoff); +extern __DPCPP_SYCL_EXTERNAL float _FCosh(float x, float y); +extern __DPCPP_SYCL_EXTERNAL int _fdpcomp(float x, float y); +extern __DPCPP_SYCL_EXTERNAL int _fdsign(float x); +extern __DPCPP_SYCL_EXTERNAL short _FDtest(float *px); +extern __DPCPP_SYCL_EXTERNAL short _fdtest(float *px); +extern __DPCPP_SYCL_EXTERNAL short _FExp(float *px, float y, short eoff); +extern __DPCPP_SYCL_EXTERNAL float _FSinh(float x, float y); +extern __DPCPP_SYCL_EXTERNAL double _Sinh(double x, double y); +extern __DPCPP_SYCL_EXTERNAL float _hypotf(float x, float y); +} +#endif +#endif // __SYCL_DEVICE_ONLY__ diff --git a/sycl/test-e2e/Basic/built-ins/host_math.cpp b/sycl/test-e2e/Basic/built-ins/host_math.cpp index 4b57ce7424549..52ddcb91b21a2 100644 --- a/sycl/test-e2e/Basic/built-ins/host_math.cpp +++ b/sycl/test-e2e/Basic/built-ins/host_math.cpp @@ -1,8 +1,10 @@ // RUN: %{build} -o %t.out // RUN: %{run} %t.out +#include #include #include + #include template T get_ulp_std(T x) { diff --git a/sycl/test-e2e/Basic/built-ins/marray_common.cpp b/sycl/test-e2e/Basic/built-ins/marray_common.cpp index 1a14295219aa5..bac942ee6503d 100644 --- a/sycl/test-e2e/Basic/built-ins/marray_common.cpp +++ b/sycl/test-e2e/Basic/built-ins/marray_common.cpp @@ -3,8 +3,8 @@ #ifdef _WIN32 #define _USE_MATH_DEFINES // To use math constants -#include #endif +#include #include diff --git a/sycl/test-e2e/Basic/built-ins/vec_common.cpp b/sycl/test-e2e/Basic/built-ins/vec_common.cpp index 88360e15265bb..f6f857dbd5104 100644 --- a/sycl/test-e2e/Basic/built-ins/vec_common.cpp +++ b/sycl/test-e2e/Basic/built-ins/vec_common.cpp @@ -2,9 +2,9 @@ // RUN: %{run} %t.out #ifdef _WIN32 -#define _USE_MATH_DEFINES // To use vath constants -#include +#define _USE_MATH_DEFINES // To use math constants #endif +#include #include diff --git a/sycl/test-e2e/DeviceLib/imf_fp16_trivial_test.cpp b/sycl/test-e2e/DeviceLib/imf_fp16_trivial_test.cpp index f80c13636d468..2efbedd0aa59f 100644 --- a/sycl/test-e2e/DeviceLib/imf_fp16_trivial_test.cpp +++ b/sycl/test-e2e/DeviceLib/imf_fp16_trivial_test.cpp @@ -12,6 +12,7 @@ // UNSUPPORTED: ze_debug && windows #include "imf_utils.hpp" +#include #include namespace sycl_imf = sycl::ext::intel::math; diff --git a/sycl/test-e2e/DeviceLib/math_test_marray_vec_common.hpp b/sycl/test-e2e/DeviceLib/math_test_marray_vec_common.hpp index 1c10543f68d41..a6d30d882e791 100644 --- a/sycl/test-e2e/DeviceLib/math_test_marray_vec_common.hpp +++ b/sycl/test-e2e/DeviceLib/math_test_marray_vec_common.hpp @@ -1,5 +1,7 @@ #include +#include + using namespace sycl; template class TypeHelper; diff --git a/sycl/test-e2e/Matrix/joint_matrix_apply_cuda.hpp b/sycl/test-e2e/Matrix/joint_matrix_apply_cuda.hpp index 4303239cefe32..d6aecdd299bef 100644 --- a/sycl/test-e2e/Matrix/joint_matrix_apply_cuda.hpp +++ b/sycl/test-e2e/Matrix/joint_matrix_apply_cuda.hpp @@ -10,6 +10,8 @@ #include +#include + using namespace sycl; using namespace sycl::ext::oneapi::experimental::matrix; using sycl::ext::oneapi::bfloat16; diff --git a/sycl/test-e2e/Reduction/reduction_utils.hpp b/sycl/test-e2e/Reduction/reduction_utils.hpp index 7fac577a1e6ac..e3bb2902d1c19 100644 --- a/sycl/test-e2e/Reduction/reduction_utils.hpp +++ b/sycl/test-e2e/Reduction/reduction_utils.hpp @@ -1,5 +1,7 @@ +#include #include #include + #include using namespace sycl; diff --git a/sycl/test/basic_tests/no_math_in_global_ns.cpp b/sycl/test/basic_tests/no_math_in_global_ns.cpp new file mode 100644 index 0000000000000..18e22dc932675 --- /dev/null +++ b/sycl/test/basic_tests/no_math_in_global_ns.cpp @@ -0,0 +1,19 @@ +// RUN: %clangxx -fsycl -fsyntax-only -Xclang -verify %s -Xclang -verify-ignore-unexpected=note +// expected-no-diagnostics + +// MSVC has the following includes: +// +// -> +// -> +// -> +// XFAIL: windows + +#include + +using namespace sycl; + +int main() { + queue q; + q.single_task([=] { sqrt(1.0); }).wait(); + return 0; +} diff --git a/sycl/test/basic_tests/sycl_maximum_minimum.cpp b/sycl/test/basic_tests/sycl_maximum_minimum.cpp index 630777215b7c8..dd88701ecce99 100644 --- a/sycl/test/basic_tests/sycl_maximum_minimum.cpp +++ b/sycl/test/basic_tests/sycl_maximum_minimum.cpp @@ -4,6 +4,7 @@ #include #include +#include #include int main() { diff --git a/sycl/test/matrix/matrix-bfloat16-test-coord-basicB.cpp b/sycl/test/matrix/matrix-bfloat16-test-coord-basicB.cpp index b141f2176971d..ceb741c04982a 100644 --- a/sycl/test/matrix/matrix-bfloat16-test-coord-basicB.cpp +++ b/sycl/test/matrix/matrix-bfloat16-test-coord-basicB.cpp @@ -1,7 +1,9 @@ // RUN: %clangxx -fsycl -O2 -DSYCL_EXT_ONEAPI_MATRIX_VERSION=4 %s -o %t.out // Kernel B sum by col +#include #include + #include using namespace sycl;