Skip to content

Commit

Permalink
GPU: Should not include std header in GPU device code
Browse files Browse the repository at this point in the history
  • Loading branch information
davidrohr committed Nov 27, 2024
1 parent f76f1a7 commit 5d037e6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
3 changes: 2 additions & 1 deletion Common/Constants/include/CommonConstants/MathConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ namespace constants
{
namespace math
{
constexpr float Almost0 = 1.175494351e-38f;
constexpr float Almost0 = 0x1.0p-126f; // smallest non-denormal float
constexpr float Epsilon = 0x0.000002p0f; // smallest float such that 1 != 1 + Epsilon
constexpr float Almost1 = 1.f - 1.0e-6f;
constexpr float VeryBig = 1.f / Almost0;

Expand Down
15 changes: 5 additions & 10 deletions DataFormats/Reconstruction/src/TrackParametrizationWithError.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,9 @@
#include "ReconstructionDataFormats/TrackParametrizationWithError.h"
#include "ReconstructionDataFormats/Vertex.h"
#include "ReconstructionDataFormats/DCA.h"
#include "CommonConstants/MathConstants.h"
#include <GPUCommonLogger.h>

#ifndef __OPENCL__
#include <cfloat>
#else
#include <float.h>
#endif

#ifndef GPUCA_GPUCODE_DEVICE
#include <iostream>
#endif
Expand Down Expand Up @@ -794,11 +789,11 @@ GPUd() auto TrackParametrizationWithError<value_T>::getPredictedChi2(const Track
// get chi2 wrt other track, which must be defined at the same parameters X,alpha
// Supplied non-initialized covToSet matrix is filled by inverse combined matrix for further use

if (gpu::CAMath::Abs(this->getAlpha() - rhs.getAlpha()) > FLT_EPSILON) {
if (gpu::CAMath::Abs(this->getAlpha() - rhs.getAlpha()) > o2::constants::math::Epsilon) {
LOG(error) << "The reference Alpha of the tracks differ: " << this->getAlpha() << " : " << rhs.getAlpha();
return 2.f * HugeF;
}
if (gpu::CAMath::Abs(this->getX() - rhs.getX()) > FLT_EPSILON) {
if (gpu::CAMath::Abs(this->getX() - rhs.getX()) > o2::constants::math::Epsilon) {
LOG(error) << "The reference X of the tracks differ: " << this->getX() << " : " << rhs.getX();
return 2.f * HugeF;
}
Expand Down Expand Up @@ -827,11 +822,11 @@ GPUd() bool TrackParametrizationWithError<value_T>::update(const TrackParametriz
// update track with other track, the inverted combined cov matrix should be supplied

// consider skipping this check, since it is usually already done upstream
if (gpu::CAMath::Abs(this->getAlpha() - rhs.getAlpha()) > FLT_EPSILON) {
if (gpu::CAMath::Abs(this->getAlpha() - rhs.getAlpha()) > o2::constants::math::Epsilon) {
LOG(error) << "The reference Alpha of the tracks differ: " << this->getAlpha() << " : " << rhs.getAlpha();
return false;
}
if (gpu::CAMath::Abs(this->getX() - rhs.getX()) > FLT_EPSILON) {
if (gpu::CAMath::Abs(this->getX() - rhs.getX()) > o2::constants::math::Epsilon) {
LOG(error) << "The reference X of the tracks differ: " << this->getX() << " : " << rhs.getX();
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion GPU/Common/GPUCommonConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#if !defined(__OPENCL1__)
namespace GPUCA_NAMESPACE::gpu::gpu_common_constants
{
static CONSTEXPR const float kCLight = 0.000299792458f;
static CONSTEXPR const float kCLight = 0.000299792458f; // TODO: Duplicate of MathConstants, fix this when OpenCL1 is removed
}
#endif

Expand Down

0 comments on commit 5d037e6

Please sign in to comment.