From 192ebdd719bb47d17073196b149434f0e9007690 Mon Sep 17 00:00:00 2001 From: Matteo Concas Date: Wed, 20 Mar 2024 17:43:09 +0100 Subject: [PATCH] Add CommonMath macro for prints --- .../src/TrackParametrization.cxx | 31 +++++++++++++------ .../src/TrackParametrizationWithError.cxx | 10 +++--- GPU/Common/GPUCommonMath.h | 11 +++++++ GPU/GPUTracking/CMakeLists.txt | 18 +++++------ 4 files changed, 46 insertions(+), 24 deletions(-) diff --git a/DataFormats/Reconstruction/src/TrackParametrization.cxx b/DataFormats/Reconstruction/src/TrackParametrization.cxx index 4b2b0de01e323..738548c1ce5eb 100644 --- a/DataFormats/Reconstruction/src/TrackParametrization.cxx +++ b/DataFormats/Reconstruction/src/TrackParametrization.cxx @@ -591,7 +591,13 @@ GPUd() void TrackParametrization::printParam() const printf("%s\n", asString().c_str()); #else printf("X:%+.4e Alp:%+.3e Par: %+.4e %+.4e %+.4e %+.4e %+.4e |Q|:%d %s", - getX(), getAlpha(), getY(), getZ(), getSnp(), getTgl(), getQ2Pt(), getAbsCharge(), getPID().getName()); + getX(), getAlpha(), getY(), getZ(), getSnp(), getTgl(), getQ2Pt(), getAbsCharge(), +#ifndef __OPENCL__ + getPID().getName() +#else + "" +#endif + ); #endif } @@ -604,15 +610,20 @@ GPUd() void TrackParametrization::printParamHexadecimal() printf("%s\n", asStringHexadecimal().c_str()); #else printf("X:%x Alp:%x Par: %x %x %x %x %x |Q|:%x %s", - __float_as_uint(getX()), - __float_as_uint(getAlpha()), - __float_as_uint(getY()), - __float_as_uint(getZ()), - __float_as_uint(getSnp()), - __float_as_uint(getTgl()), - __float_as_uint(getQ2Pt()), - __float_as_uint(getAbsCharge()), - getPID().getName()); + gpu::CAMath::Float2UIntReint(getX()), + gpu::CAMath::Float2UIntReint(getAlpha()), + gpu::CAMath::Float2UIntReint(getY()), + gpu::CAMath::Float2UIntReint(getZ()), + gpu::CAMath::Float2UIntReint(getSnp()), + gpu::CAMath::Float2UIntReint(getTgl()), + gpu::CAMath::Float2UIntReint(getQ2Pt()), + gpu::CAMath::Float2UIntReint(getAbsCharge()), +#ifndef __OPENCL__ + getPID().getName() +#else + "" +#endif + ); #endif } diff --git a/DataFormats/Reconstruction/src/TrackParametrizationWithError.cxx b/DataFormats/Reconstruction/src/TrackParametrizationWithError.cxx index fbcdf96437c3d..f1ba9a6798842 100644 --- a/DataFormats/Reconstruction/src/TrackParametrizationWithError.cxx +++ b/DataFormats/Reconstruction/src/TrackParametrizationWithError.cxx @@ -1244,11 +1244,11 @@ GPUd() void TrackParametrizationWithError::printHexadecimal() "<> %7s [%x %x %x %x]\n" "<> %7s [%x %x %x %x %x]\n", "<> CovMat:", - __float_as_uint(mC[kSigY2]), "", - __float_as_uint(mC[kSigZY]), __float_as_uint(mC[kSigZ2]), "", - __float_as_uint(mC[kSigSnpY]), __float_as_uint(mC[kSigSnpZ]), __float_as_uint(mC[kSigSnp2]), "", - __float_as_uint(mC[kSigTglY]), __float_as_uint(mC[kSigTglZ]), __float_as_uint(mC[kSigTglSnp]), __float_as_uint(mC[kSigTgl2]), "", - __float_as_uint(mC[kSigQ2PtY]), __float_as_uint(mC[kSigQ2PtZ]), __float_as_uint(mC[kSigQ2PtSnp]), __float_as_uint(mC[kSigQ2PtTgl]), __float_as_uint(mC[kSigQ2Pt2])); + gpu::CAMath::Float2UIntReint(mC[kSigY2]), "", + gpu::CAMath::Float2UIntReint(mC[kSigZY]), gpu::CAMath::Float2UIntReint(mC[kSigZ2]), "", + gpu::CAMath::Float2UIntReint(mC[kSigSnpY]), gpu::CAMath::Float2UIntReint(mC[kSigSnpZ]), gpu::CAMath::Float2UIntReint(mC[kSigSnp2]), "", + gpu::CAMath::Float2UIntReint(mC[kSigTglY]), gpu::CAMath::Float2UIntReint(mC[kSigTglZ]), gpu::CAMath::Float2UIntReint(mC[kSigTglSnp]), gpu::CAMath::Float2UIntReint(mC[kSigTgl2]), "", + gpu::CAMath::Float2UIntReint(mC[kSigQ2PtY]), gpu::CAMath::Float2UIntReint(mC[kSigQ2PtZ]), gpu::CAMath::Float2UIntReint(mC[kSigQ2PtSnp]), gpu::CAMath::Float2UIntReint(mC[kSigQ2PtTgl]), gpu::CAMath::Float2UIntReint(mC[kSigQ2Pt2])); #endif } diff --git a/GPU/Common/GPUCommonMath.h b/GPU/Common/GPUCommonMath.h index 1e45d89de61ea..fbf67c1369b19 100644 --- a/GPU/Common/GPUCommonMath.h +++ b/GPU/Common/GPUCommonMath.h @@ -75,6 +75,7 @@ class GPUCommonMath GPUd() static CONSTEXPR float Pi() { return 3.1415927f; } GPUd() static float Round(float x); GPUd() static float Floor(float x); + GPUd() static unsigned int Float2UIntReint(const float& x); GPUd() static unsigned int Float2UIntRn(float x); GPUd() static int Float2IntRn(float x); GPUd() static float Modf(float x, float y); @@ -207,6 +208,16 @@ GPUdi() float2 GPUCommonMath::MakeFloat2(float x, float y) } GPUdi() float GPUCommonMath::Modf(float x, float y) { return CHOICE(fmodf(x, y), fmodf(x, y), fmod(x, y)); } + +GPUdi() unsigned int GPUCommonMath::Float2UIntReint(const float& x) +{ +#if !defined(GPUCA_GPUCODE) || defined(__OPENCL__) || defined(__OPENCL_HOST__) + return reinterpret_cast(x); +#else + return __float_as_uint(x); +#endif +} + GPUdi() unsigned int GPUCommonMath::Float2UIntRn(float x) { return (unsigned int)(int)(x + 0.5f); } GPUdi() float GPUCommonMath::Floor(float x) { return CHOICE(floorf(x), floorf(x), floor(x)); } diff --git a/GPU/GPUTracking/CMakeLists.txt b/GPU/GPUTracking/CMakeLists.txt index 220681176828c..81832fe00e25d 100644 --- a/GPU/GPUTracking/CMakeLists.txt +++ b/GPU/GPUTracking/CMakeLists.txt @@ -527,15 +527,15 @@ if(CUDA_ENABLED OR OPENCL1_ENABLED OR OPENCL2_ENABLED OR HIP_ENABLED) if(CUDA_ENABLED) add_subdirectory(Base/cuda) endif() - # if(OPENCL1_ENABLED OR OPENCL2_ENABLED) - # add_subdirectory(Base/opencl-common) - # endif() - # if(OPENCL1_ENABLED) - # add_subdirectory(Base/opencl) - # endif() - # if(OPENCL2_ENABLED) - # add_subdirectory(Base/opencl2) - # endif() + if(OPENCL1_ENABLED OR OPENCL2_ENABLED) + add_subdirectory(Base/opencl-common) + endif() + if(OPENCL1_ENABLED) + add_subdirectory(Base/opencl) + endif() + if(OPENCL2_ENABLED) + add_subdirectory(Base/opencl2) + endif() if(HIP_ENABLED) add_subdirectory(Base/hip) endif()