@@ -48,7 +48,7 @@ GPUhdi() T to02Pi(T phi)
4848template <typename T>
4949GPUhdi () void bringTo02Pi (T& phi)
5050{
51- phi = to02Pi<T> (phi);
51+ phi = to02Pi (phi);
5252}
5353
5454template <typename T>
@@ -68,7 +68,7 @@ inline T to02PiGen(T phi)
6868template <typename T>
6969inline void bringTo02PiGen (T& phi)
7070{
71- phi = to02PiGen<T> (phi);
71+ phi = to02PiGen (phi);
7272}
7373
7474template <typename T>
@@ -87,7 +87,7 @@ GPUhdi() T toPMPi(T phi)
8787template <typename T>
8888GPUhdi () void bringToPMPi (T& phi)
8989{
90- phi = toPMPi<T> (phi);
90+ phi = toPMPi (phi);
9191}
9292
9393template <typename T>
@@ -107,10 +107,10 @@ inline T toPMPiGen(T phi)
107107template <typename T>
108108inline void bringToPMPiGen (T& phi)
109109{
110- phi = toPMPiGen<T> (phi);
110+ phi = toPMPiGen (phi);
111111}
112112
113- #ifdef __OPENCL__ // TODO: get rid of that stupid workaround for OpenCL template address spaces
113+ #if defined( __OPENCL__) || defined(__METAL__) // TODO: get rid of that stupid workaround for OpenCL template address spaces
114114template <typename T, typename S, typename U>
115115GPUhdi () void sincos(T ang, S& s, U& c)
116116{
@@ -275,12 +275,11 @@ GPUhdi() constexpr T fastATan2(T y, T x)
275275 // Average inaccuracy: 0.00048
276276 // Max inaccuracy: 0.00084
277277 // Speed: 6.2 times faster than atan2f()
278- constexpr T Pi = 3.1415926535897932384626433832795 ;
279-
280278 auto atan = [](T a) -> T {
281279 // returns the arctan for the angular range [-Pi/4, Pi/4]
282280 // the polynomial coefficients are taken from:
283281 // https://stackoverflow.com/questions/42537957/fast-accurate-atan-arctan-approximation-algorithm
282+ constexpr T Pi = 3.1415926535897932384626433832795 ;
284283 constexpr T A = 0.0776509570923569 ;
285284 constexpr T B = -0.287434475393028 ;
286285 constexpr T C = ((Pi / 4 ) - A - B);
@@ -290,6 +289,7 @@ GPUhdi() constexpr T fastATan2(T y, T x)
290289
291290 auto atan2P = [atan](T yy, T xx) -> T {
292291 // fast atan2(yy,xx) for the angular range [0,+Pi]
292+ constexpr T Pi = 3.1415926535897932384626433832795 ;
293293 constexpr T Pi025 = 1 * Pi / 4 ;
294294 constexpr T Pi075 = 3 * Pi / 4 ;
295295 const T x1 = xx + yy; // point p1 (x1,y1) = (xx,yy) - Pi/4
@@ -299,7 +299,7 @@ GPUhdi() constexpr T fastATan2(T y, T x)
299299 if (xx < 0 ) { // p1 is in the range [Pi/4, 3*Pi/4]
300300 phi0 = Pi075;
301301 tan = y1 > T (0 ) ? -x1 / y1 : T (0 ); // yy is always >=0, hence y1>=0
302- } else { // p1 is in the range [-Pi/4, Pi/4]
302+ } else { // p1 is in the range [-Pi/4, Pi/4]
303303 phi0 = Pi025;
304304 tan = x1 > T (0 ) ? y1 / x1 : T (0 );
305305 }
@@ -376,41 +376,41 @@ GPUdi() double pi()
376376 return o2::constants::math::PI ;
377377}
378378
379- #ifndef GPUCA_GPUCODE_DEVICE
379+ #if !defined( GPUCA_GPUCODE_DEVICE) || defined(__CUDACC__) || defined(__HIPCC__) // Double specialisations, not for OpenCL and Metal
380380template <>
381381GPUdi () double tan(double x)
382382{
383- return std::tan (x);
383+ return o2::gpu::GPUCommonMath::Tand (x);
384384};
385385template <>
386386GPUdi () double sin(double x)
387387{
388- return std::sin (x);
388+ return o2::gpu::GPUCommonMath::Sind (x);
389389};
390390template <>
391391GPUdi () double atan2(double y, double x)
392392{
393- return std::atan2 (y, x);
393+ return o2::gpu::GPUCommonMath::ATan2d (y, x);
394394};
395395template <>
396396GPUdi () double atan(double x)
397397{
398- return std::atan (x);
398+ return o2::gpu::GPUCommonMath::ATand (x);
399399};
400400template <>
401401GPUdi () double asin(double x)
402402{
403- return std::asin (x);
403+ return o2::gpu::GPUCommonMath::ASind (x);
404404};
405405template <>
406406GPUdi () double acos(double x)
407407{
408- return std::acos (x);
408+ return o2::gpu::GPUCommonMath::ACosd (x);
409409};
410410template <>
411411GPUdi () double cos(double x)
412412{
413- return std::cos (x);
413+ return o2::gpu::GPUCommonMath::Cosd (x);
414414};
415415#endif
416416
0 commit comments