From 06bc5e93a7e82eaf412ba7cc3c0e720610a74dad Mon Sep 17 00:00:00 2001 From: Giulio Eulisse <10544+ktf@users.noreply.github.com> Date: Thu, 24 Sep 2026 10:55:12 +0200 Subject: [PATCH] GPU: three additional Metal adaptations GPUCommonAlgorithm::sortOnDevice takes an auto parameter, which is C++20. It is already skipped for OpenCL, at C++17, and MSL 4.1 reports C++17 as well. GPUTPCTrackParam::TransportToXAlpha declares its material constants static at function scope, which MSL rejects; constexpr without static is accepted, as in SMatrixGPU. Guard SMatrixGPU C++20 code using __cplusplus version macro. --- Common/MathUtils/include/MathUtils/SMatrixGPU.h | 2 +- GPU/Common/GPUCommonAlgorithm.h | 2 +- GPU/GPUTracking/SectorTracker/GPUTPCTrackParam.cxx | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Common/MathUtils/include/MathUtils/SMatrixGPU.h b/Common/MathUtils/include/MathUtils/SMatrixGPU.h index 2e551aac98d24..212a3a2cf910d 100644 --- a/Common/MathUtils/include/MathUtils/SMatrixGPU.h +++ b/Common/MathUtils/include/MathUtils/SMatrixGPU.h @@ -518,7 +518,7 @@ class SMatrixGPU R mRep; }; -#if !defined(__OPENCL__) && !defined(__METAL__) // TODO: current C++ for OpenCL 2021 and MSL 4.1 are both at C++17, so no concepts. But we don't need this trick there anyway, so we can just hide it. +#if __cplusplus >= 202002L // the constraint below is a requires-clause; we do not need the trick where there are no concepts template requires(sizeof(typename X::traits_type::pos_type) != 0) // do not provide a template to fair::Logger, etc... (pos_type is a member type of all std::ostream classes) GPUd() X& operator<<(Y& y, const SMatrixGPU&) diff --git a/GPU/Common/GPUCommonAlgorithm.h b/GPU/Common/GPUCommonAlgorithm.h index be88973561e0a..f2707a96c0a3f 100644 --- a/GPU/Common/GPUCommonAlgorithm.h +++ b/GPU/Common/GPUCommonAlgorithm.h @@ -41,7 +41,7 @@ class GPUCommonAlgorithm GPUd() static void sortInBlock(T* begin, T* end, const S& comp); template GPUd() static void sortDeviceDynamic(T* begin, T* end, const S& comp); -#ifndef __OPENCL__ +#if __cplusplus >= 202002L // sortOnDevice takes an auto parameter template GPUh() static void sortOnDevice(auto* rec, int32_t stream, T* begin, size_t N, const S& comp); #endif diff --git a/GPU/GPUTracking/SectorTracker/GPUTPCTrackParam.cxx b/GPU/GPUTracking/SectorTracker/GPUTPCTrackParam.cxx index 6ce031882caec..774bcfb54b6a5 100644 --- a/GPU/GPUTracking/SectorTracker/GPUTPCTrackParam.cxx +++ b/GPU/GPUTracking/SectorTracker/GPUTPCTrackParam.cxx @@ -304,10 +304,10 @@ GPUd() bool GPUTPCTrackParam::TransportToXWithMaterial(float x, GPUTPCTrackLinea { //* Transport the track parameters to X=x taking into account material budget - static constexpr float kRho = 1.025e-3f; // [g/cm^3] - static constexpr float kRadLen = 28811.7f; //[cm] + constexpr float kRho = 1.025e-3f; // [g/cm^3] + constexpr float kRadLen = 28811.7f; //[cm] - static constexpr float kRadLenInv = 1.f / kRadLen; + constexpr float kRadLenInv = 1.f / kRadLen; float dl; if (!TransportToX(x, t0, Bz, maxSinPhi, &dl)) {