Skip to content

Commit 5241492

Browse files
authored
Merge pull request #591 from krasznaa/SYCLAbsFixes-main-20240515
oneAPI 2024.1.0 Support, main branch (2024.05.15.)
2 parents a337215 + 4efb749 commit 5241492

File tree

11 files changed

+74
-30
lines changed

11 files changed

+74
-30
lines changed

core/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ include( traccc-compiler-options-cpp )
1111
traccc_add_library( traccc_core core TYPE SHARED
1212
# Common definitions.
1313
"include/traccc/definitions/track_parametrization.hpp"
14+
"include/traccc/definitions/math.hpp"
1415
"include/traccc/definitions/primitives.hpp"
1516
"include/traccc/definitions/common.hpp"
1617
"include/traccc/definitions/qualifiers.hpp"
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/** TRACCC library, part of the ACTS project (R&D line)
2+
*
3+
* (c) 2024 CERN for the benefit of the ACTS project
4+
*
5+
* Mozilla Public License Version 2.0
6+
*/
7+
8+
#pragma once
9+
10+
// SYCL include(s).
11+
#if defined(CL_SYCL_LANGUAGE_VERSION) || defined(SYCL_LANGUAGE_VERSION)
12+
#include <CL/sycl.hpp>
13+
#endif
14+
15+
// System include(s).
16+
#include <cmath>
17+
18+
namespace traccc {
19+
20+
/// Namespace to pick up math functions from
21+
#if defined(CL_SYCL_LANGUAGE_VERSION) || defined(SYCL_LANGUAGE_VERSION)
22+
namespace math = cl::sycl;
23+
#else
24+
namespace math = std;
25+
#endif // SYCL
26+
27+
} // namespace traccc

core/include/traccc/edm/cell.hpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
// traccc include(s).
1111
#include "traccc/definitions/common.hpp"
12+
#include "traccc/definitions/math.hpp"
1213
#include "traccc/definitions/primitives.hpp"
1314
#include "traccc/edm/container.hpp"
1415
#include "traccc/geometry/pixel_data.hpp"
@@ -88,8 +89,8 @@ inline bool operator==(const cell& lhs, const cell& rhs) {
8889

8990
return ((lhs.module_link == rhs.module_link) &&
9091
(lhs.channel0 == rhs.channel0) && (lhs.channel1 == rhs.channel1) &&
91-
(std::abs(lhs.activation - rhs.activation) < float_epsilon) &&
92-
(std::abs(lhs.time - rhs.time) < float_epsilon));
92+
(math::fabs(lhs.activation - rhs.activation) < float_epsilon) &&
93+
(math::fabs(lhs.time - rhs.time) < float_epsilon));
9394
}
9495

9596
} // namespace traccc

core/include/traccc/edm/measurement.hpp

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
/** TRACCC library, part of the ACTS project (R&D line)
22
*
3-
* (c) 2022 CERN for the benefit of the ACTS project
3+
* (c) 2022-2024 CERN for the benefit of the ACTS project
44
*
55
* Mozilla Public License Version 2.0
66
*/
77

88
#pragma once
99

1010
// Project include(s).
11+
#include "traccc/definitions/math.hpp"
1112
#include "traccc/definitions/primitives.hpp"
1213
#include "traccc/definitions/qualifiers.hpp"
1314
#include "traccc/definitions/track_parametrization.hpp"
@@ -62,7 +63,7 @@ TRACCC_HOST_DEVICE inline bool operator<(const measurement& lhs,
6263

6364
if (lhs.surface_link != rhs.surface_link) {
6465
return lhs.surface_link < rhs.surface_link;
65-
} else if (std::abs(lhs.local[0] - rhs.local[0]) > float_epsilon) {
66+
} else if (math::fabs(lhs.local[0] - rhs.local[0]) > float_epsilon) {
6667
return (lhs.local[0] < rhs.local[0]);
6768
} else {
6869
return (lhs.local[1] < rhs.local[1]);
@@ -74,10 +75,10 @@ TRACCC_HOST_DEVICE
7475
inline bool operator==(const measurement& lhs, const measurement& rhs) {
7576

7677
return ((lhs.surface_link == rhs.surface_link) &&
77-
(std::abs(lhs.local[0] - rhs.local[0]) < float_epsilon) &&
78-
(std::abs(lhs.local[1] - rhs.local[1]) < float_epsilon) &&
79-
(std::abs(lhs.variance[0] - rhs.variance[0]) < float_epsilon) &&
80-
(std::abs(lhs.variance[1] - rhs.variance[1]) < float_epsilon));
78+
(math::fabs(lhs.local[0] - rhs.local[0]) < float_epsilon) &&
79+
(math::fabs(lhs.local[1] - rhs.local[1]) < float_epsilon) &&
80+
(math::fabs(lhs.variance[0] - rhs.variance[0]) < float_epsilon) &&
81+
(math::fabs(lhs.variance[1] - rhs.variance[1]) < float_epsilon));
8182
}
8283

8384
/// Comparator based on detray barcode value

core/include/traccc/edm/spacepoint.hpp

+6-5
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
// Project include(s).
1111
#include "traccc/definitions/common.hpp"
12+
#include "traccc/definitions/math.hpp"
1213
#include "traccc/definitions/primitives.hpp"
1314
#include "traccc/definitions/qualifiers.hpp"
1415
#include "traccc/edm/container.hpp"
@@ -47,9 +48,9 @@ struct spacepoint {
4748
TRACCC_HOST_DEVICE
4849
inline bool operator<(const spacepoint& lhs, const spacepoint& rhs) {
4950

50-
if (std::abs(lhs.x() - rhs.x()) > float_epsilon) {
51+
if (math::fabs(lhs.x() - rhs.x()) > float_epsilon) {
5152
return (lhs.x() < rhs.x());
52-
} else if (std::abs(lhs.y() - rhs.y()) > float_epsilon) {
53+
} else if (math::fabs(lhs.y() - rhs.y()) > float_epsilon) {
5354
return (lhs.y() < rhs.y());
5455
} else {
5556
return (lhs.z() < rhs.z());
@@ -60,9 +61,9 @@ inline bool operator<(const spacepoint& lhs, const spacepoint& rhs) {
6061
TRACCC_HOST_DEVICE
6162
inline bool operator==(const spacepoint& lhs, const spacepoint& rhs) {
6263

63-
return ((std::abs(lhs.x() - rhs.x()) < float_epsilon) &&
64-
(std::abs(lhs.y() - rhs.y()) < float_epsilon) &&
65-
(std::abs(lhs.z() - rhs.z()) < float_epsilon) &&
64+
return ((math::fabs(lhs.x() - rhs.x()) < float_epsilon) &&
65+
(math::fabs(lhs.y() - rhs.y()) < float_epsilon) &&
66+
(math::fabs(lhs.z() - rhs.z()) < float_epsilon) &&
6667
(lhs.meas == rhs.meas));
6768
}
6869

core/include/traccc/seeding/doublet_finding_helper.hpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
/** TRACCC library, part of the ACTS project (R&D line)
22
*
3-
* (c) 2021-2022 CERN for the benefit of the ACTS project
3+
* (c) 2021-2024 CERN for the benefit of the ACTS project
44
*
55
* Mozilla Public License Version 2.0
66
*/
77

88
#pragma once
99

10+
// Local include(s).
11+
#include "traccc/definitions/math.hpp"
1012
#include "traccc/edm/internal_spacepoint.hpp"
1113
#include "traccc/seeding/detail/doublet.hpp"
1214
#include "traccc/seeding/detail/lin_circle.hpp"
@@ -63,7 +65,7 @@ doublet_finding_helper::isCompatible(const internal_spacepoint<spacepoint>& sp1,
6365
// actually zOrigin * deltaR to avoid division by 0 statements
6466
scalar zOrigin = sp1.z() * deltaR - sp1.radius() * cotTheta;
6567
if (deltaR > config.deltaRMax || deltaR < config.deltaRMin ||
66-
std::fabs(cotTheta) > config.cotThetaMax * deltaR ||
68+
math::fabs(cotTheta) > config.cotThetaMax * deltaR ||
6769
zOrigin < config.collisionRegionMin * deltaR ||
6870
zOrigin > config.collisionRegionMax * deltaR) {
6971
return false;
@@ -76,7 +78,7 @@ doublet_finding_helper::isCompatible(const internal_spacepoint<spacepoint>& sp1,
7678
// actually zOrigin * deltaR to avoid division by 0 statements
7779
scalar zOrigin = sp1.z() * deltaR - sp1.radius() * cotTheta;
7880
if (deltaR > config.deltaRMax || deltaR < config.deltaRMin ||
79-
std::fabs(cotTheta) > config.cotThetaMax * deltaR ||
81+
math::fabs(cotTheta) > config.cotThetaMax * deltaR ||
8082
zOrigin < config.collisionRegionMin * deltaR ||
8183
zOrigin > config.collisionRegionMax * deltaR) {
8284
return false;

core/include/traccc/seeding/spacepoint_binning_helper.hpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#pragma once
99

1010
// Project include(s).
11+
#include "traccc/definitions/math.hpp"
1112
#include "traccc/edm/internal_spacepoint.hpp"
1213
#include "traccc/edm/spacepoint.hpp"
1314
#include "traccc/seeding/detail/seeding_config.hpp"
@@ -57,8 +58,8 @@ inline std::pair<detray::axis2::circular<>, detray::axis2::regular<>> get_axes(
5758
// evaluating the azimutal deflection including the maximum impact
5859
// parameter
5960
scalar deltaAngleWithMaxD0 =
60-
std::abs(std::asin(grid_config.impactMax / (rMin)) -
61-
std::asin(grid_config.impactMax / grid_config.rMax));
61+
math::fabs(std::asin(grid_config.impactMax / (rMin)) -
62+
std::asin(grid_config.impactMax / grid_config.rMax));
6263

6364
// evaluating delta Phi based on the inner and outer angle, and the
6465
// azimutal deflection including the maximum impact parameter Divide by

core/include/traccc/seeding/track_params_estimation_helper.hpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
/** TRACCC library, part of the ACTS project (R&D line)
22
*
3-
* (c) 2021-2022 CERN for the benefit of the ACTS project
3+
* (c) 2021-2024 CERN for the benefit of the ACTS project
44
*
55
* Mozilla Public License Version 2.0
66
*/
77

88
#pragma once
99

1010
// Library include(s).
11+
#include "traccc/definitions/math.hpp"
1112
#include "traccc/edm/seed.hpp"
1213
#include "traccc/edm/spacepoint.hpp"
1314
#include "traccc/edm/track_parameters.hpp"
@@ -117,8 +118,9 @@ inline TRACCC_HOST_DEVICE bound_vector seed_to_bound_vector(
117118

118119
// The estimated momentum, and its projection along the magnetic
119120
// field diretion
120-
scalar pInGeV = std::abs(1.0f / getter::element(params, e_bound_qoverp, 0));
121-
scalar pzInGeV = 1.0f / std::abs(qOverPt) * invTanTheta;
121+
scalar pInGeV =
122+
math::fabs(1.0f / getter::element(params, e_bound_qoverp, 0));
123+
scalar pzInGeV = 1.0f / math::fabs(qOverPt) * invTanTheta;
122124
scalar massInGeV = mass / unit<scalar>::GeV;
123125

124126
// The estimated velocity, and its projection along the magnetic

core/include/traccc/seeding/triplet_finding_helper.hpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
/** TRACCC library, part of the ACTS project (R&D line)
22
*
3-
* (c) 2021-2022 CERN for the benefit of the ACTS project
3+
* (c) 2021-2024 CERN for the benefit of the ACTS project
44
*
55
* Mozilla Public License Version 2.0
66
*/
77

88
#pragma once
99

10+
// Local include(s).
11+
#include "traccc/definitions/math.hpp"
1012
#include "traccc/edm/internal_spacepoint.hpp"
1113
#include "traccc/seeding/detail/doublet.hpp"
1214
#include "traccc/seeding/detail/lin_circle.hpp"
@@ -58,7 +60,7 @@ bool TRACCC_HOST_DEVICE triplet_finding_helper::isCompatible(
5860
// if the error is larger than the difference in theta, no need to
5961
// compare with scattering
6062
if (deltaCotTheta2 - error2 > 0) {
61-
deltaCotTheta = std::abs(deltaCotTheta);
63+
deltaCotTheta = math::fabs(deltaCotTheta);
6264
// if deltaTheta larger than the scattering for the lower pT cut, skip
6365
error = std::sqrt(error2);
6466
dCotThetaMinusError2 = deltaCotTheta2 + error2 -
@@ -119,7 +121,7 @@ bool TRACCC_HOST_DEVICE triplet_finding_helper::isCompatible(
119121
// A and B allow calculation of impact params in U/V plane with linear
120122
// function
121123
// (in contrast to having to solve a quadratic function in x/y plane)
122-
impact_parameter = std::abs((A - B * spM.radius()) * spM.radius());
124+
impact_parameter = math::fabs((A - B * spM.radius()) * spM.radius());
123125

124126
if (impact_parameter > config.impactMax) {
125127
return false;

device/common/include/traccc/finding/device/impl/apply_interaction.ipp

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77

88
#pragma once
99

10+
// Project include(s).
11+
#include "traccc/definitions/math.hpp"
12+
1013
// Detray include(s).
1114
#include "detray/geometry/surface.hpp"
1215

@@ -43,7 +46,7 @@ TRACCC_DEVICE inline void apply_interaction(
4346
interactor_type{}.update(
4447
bound_param, interactor_state,
4548
static_cast<int>(detray::navigation::direction::e_forward), sf,
46-
std::abs(
49+
math::fabs(
4750
sf.cos_angle(ctx, bound_param.dir(), bound_param.bound_local())));
4851
}
4952

device/common/include/traccc/seeding/device/impl/update_triplet_weights.ipp

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
/** TRACCC library, part of the ACTS project (R&D line)
22
*
3-
* (c) 2021-2023 CERN for the benefit of the ACTS project
3+
* (c) 2021-2024 CERN for the benefit of the ACTS project
44
*
55
* Mozilla Public License Version 2.0
66
*/
77

8+
#pragma once
9+
10+
// Project include(s).
11+
#include "traccc/definitions/math.hpp"
12+
813
// System include(s).
914
#include <cassert>
1015

11-
#pragma once
12-
1316
namespace traccc::device {
1417

1518
TRACCC_HOST_DEVICE
@@ -82,7 +85,7 @@ inline void update_triplet_weights(
8285
// compared top SP should have at least deltaRMin distance
8386
const scalar otherTop_r = other_spT.radius();
8487
const scalar deltaR = currentTop_r - otherTop_r;
85-
if (std::abs(deltaR) < filter_config.deltaRMin) {
88+
if (math::fabs(deltaR) < filter_config.deltaRMin) {
8689
continue;
8790
}
8891

@@ -106,7 +109,7 @@ inline void update_triplet_weights(
106109
// compatible seed (20mm instead of 5mm) add new compatible seed
107110
// only if distance larger than rmin to all other compatible
108111
// seeds
109-
if (std::abs(previousDiameter - otherTop_r) <
112+
if (math::fabs(previousDiameter - otherTop_r) <
110113
filter_config.deltaRMin) {
111114
newCompSeed = false;
112115
break;

0 commit comments

Comments
 (0)