From 7cc5a208b4d18bb7ff863b25e46b3451d4e6b574 Mon Sep 17 00:00:00 2001 From: Giulio Eulisse <10544+ktf@users.noreply.github.com> Date: Fri, 25 Sep 2026 12:30:27 +0200 Subject: [PATCH] GPU: extend two existing OpenCL device workarounds to Metal Both of these already exist for OpenCL, for reasons that apply unchanged to Metal. The processing settings block in GPUSettingsList.h is skipped for OpenCL because it declares std::string and std::vector members, which GPUSettings.h explicitly does not include for device code. Metal needs the same exclusion. These configs are host-side only: GPUParam carries GPUSettingsRec and GPUSettingsParam, and the processing settings appear only as pointer arguments to host methods, so nothing transferred changes shape. GPUCommonBitSet already carries an extra constructor for OpenCL's __constant. Metal needs the opposite: MSL will not use a user-declared copy constructor to build an object in the constant address space, which is where GPUconstexpr() arrays of bitset live, and leaving the copy constructor implicit makes them constructible again. That one line accounted for 84 of the remaining diagnostics, across DetID and GlobalTrackID. Metal translation unit: 136 errors to 27. --- GPU/GPUTracking/Definitions/GPUSettingsList.h | 4 ++-- GPU/Utils/GPUCommonBitSet.h | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/GPU/GPUTracking/Definitions/GPUSettingsList.h b/GPU/GPUTracking/Definitions/GPUSettingsList.h index 4e3e0cd32d752..81949f0b8ed2a 100644 --- a/GPU/GPUTracking/Definitions/GPUSettingsList.h +++ b/GPU/GPUTracking/Definitions/GPUSettingsList.h @@ -221,7 +221,7 @@ AddSubConfig(GPUSettingsRecDynamic, dyn) AddHelp("help", 'h') EndConfig() -#ifndef __OPENCL__ +#if !defined(__OPENCL__) && !defined(__METAL__) // these use std::string / std::vector, which device code does not have // Parameters that might affect the RTC code (if these change, the cache cannot be used) BeginSubConfig(GPUSettingsProcessingRTC, rtc, configStandalone.proc, "RTC", 0, "Processing settings", proc_rtc) AddOption(cacheOutput, bool, false, "", 0, "Cache RTC compilation results") @@ -428,7 +428,7 @@ AddSubConfig(GPUSettingsProcessingNNclusterizer, nn) AddSubConfig(GPUSettingsProcessingScaling, scaling) AddHelp("help", 'h') EndConfig() -#endif // __OPENCL__ +#endif // !__OPENCL__ && !__METAL__ #ifndef GPUCA_GPUCODE_DEVICE // Light settings concerning the event display (can be changed without rebuilding vertices) diff --git a/GPU/Utils/GPUCommonBitSet.h b/GPU/Utils/GPUCommonBitSet.h index 302334e01e29d..e35587ab60c7b 100644 --- a/GPU/Utils/GPUCommonBitSet.h +++ b/GPU/Utils/GPUCommonBitSet.h @@ -37,7 +37,12 @@ class bitset public: GPUdDefault() constexpr bitset() = default; +#ifndef __METAL__ + // MSL will not use a user-declared copy constructor to build an object in the + // constant address space, where GPUconstexpr() arrays of bitset live. Leaving + // it implicit is what makes those arrays constructible. GPUdDefault() constexpr bitset(const bitset&) = default; +#endif #ifdef __OPENCL__ GPUdDefault() constexpr bitset(const __constant bitset&) = default; #endif // __OPENCL__