Skip to content

Commit 5d037e6

Browse files
committed
GPU: Should not include std header in GPU device code
1 parent f76f1a7 commit 5d037e6

File tree

3 files changed

+8
-12
lines changed

3 files changed

+8
-12
lines changed

Common/Constants/include/CommonConstants/MathConstants.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ namespace constants
2222
{
2323
namespace math
2424
{
25-
constexpr float Almost0 = 1.175494351e-38f;
25+
constexpr float Almost0 = 0x1.0p-126f; // smallest non-denormal float
26+
constexpr float Epsilon = 0x0.000002p0f; // smallest float such that 1 != 1 + Epsilon
2627
constexpr float Almost1 = 1.f - 1.0e-6f;
2728
constexpr float VeryBig = 1.f / Almost0;
2829

DataFormats/Reconstruction/src/TrackParametrizationWithError.cxx

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,9 @@
1212
#include "ReconstructionDataFormats/TrackParametrizationWithError.h"
1313
#include "ReconstructionDataFormats/Vertex.h"
1414
#include "ReconstructionDataFormats/DCA.h"
15+
#include "CommonConstants/MathConstants.h"
1516
#include <GPUCommonLogger.h>
1617

17-
#ifndef __OPENCL__
18-
#include <cfloat>
19-
#else
20-
#include <float.h>
21-
#endif
22-
2318
#ifndef GPUCA_GPUCODE_DEVICE
2419
#include <iostream>
2520
#endif
@@ -794,11 +789,11 @@ GPUd() auto TrackParametrizationWithError<value_T>::getPredictedChi2(const Track
794789
// get chi2 wrt other track, which must be defined at the same parameters X,alpha
795790
// Supplied non-initialized covToSet matrix is filled by inverse combined matrix for further use
796791

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

829824
// consider skipping this check, since it is usually already done upstream
830-
if (gpu::CAMath::Abs(this->getAlpha() - rhs.getAlpha()) > FLT_EPSILON) {
825+
if (gpu::CAMath::Abs(this->getAlpha() - rhs.getAlpha()) > o2::constants::math::Epsilon) {
831826
LOG(error) << "The reference Alpha of the tracks differ: " << this->getAlpha() << " : " << rhs.getAlpha();
832827
return false;
833828
}
834-
if (gpu::CAMath::Abs(this->getX() - rhs.getX()) > FLT_EPSILON) {
829+
if (gpu::CAMath::Abs(this->getX() - rhs.getX()) > o2::constants::math::Epsilon) {
835830
LOG(error) << "The reference X of the tracks differ: " << this->getX() << " : " << rhs.getX();
836831
return false;
837832
}

GPU/Common/GPUCommonConstants.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#if !defined(__OPENCL1__)
2121
namespace GPUCA_NAMESPACE::gpu::gpu_common_constants
2222
{
23-
static CONSTEXPR const float kCLight = 0.000299792458f;
23+
static CONSTEXPR const float kCLight = 0.000299792458f; // TODO: Duplicate of MathConstants, fix this when OpenCL1 is removed
2424
}
2525
#endif
2626

0 commit comments

Comments
 (0)