Skip to content

Commit

Permalink
Add CommonMath macro for prints
Browse files Browse the repository at this point in the history
  • Loading branch information
mconcas committed Mar 28, 2024
1 parent 37f37f6 commit 192ebdd
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 24 deletions.
31 changes: 21 additions & 10 deletions DataFormats/Reconstruction/src/TrackParametrization.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,13 @@ GPUd() void TrackParametrization<value_T>::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
}

Expand All @@ -604,15 +610,20 @@ GPUd() void TrackParametrization<value_T>::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
}

Expand Down
10 changes: 5 additions & 5 deletions DataFormats/Reconstruction/src/TrackParametrizationWithError.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1244,11 +1244,11 @@ GPUd() void TrackParametrizationWithError<value_T>::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
}

Expand Down
11 changes: 11 additions & 0 deletions GPU/Common/GPUCommonMath.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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<const unsigned int&>(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)); }

Expand Down
18 changes: 9 additions & 9 deletions GPU/GPUTracking/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 192ebdd

Please sign in to comment.