Skip to content

Commit bf6a591

Browse files
committed
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.
1 parent 900b5e4 commit bf6a591

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

‎GPU/GPUTracking/Definitions/GPUSettingsList.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ AddSubConfig(GPUSettingsRecDynamic, dyn)
221221
AddHelp("help", 'h')
222222
EndConfig()
223223

224-
#ifndef __OPENCL__
224+
#if !defined(__OPENCL__) && !defined(__METAL__) // these use std::string / std::vector, which device code does not have
225225
// Parameters that might affect the RTC code (if these change, the cache cannot be used)
226226
BeginSubConfig(GPUSettingsProcessingRTC, rtc, configStandalone.proc, "RTC", 0, "Processing settings", proc_rtc)
227227
AddOption(cacheOutput, bool, false, "", 0, "Cache RTC compilation results")
@@ -428,7 +428,7 @@ AddSubConfig(GPUSettingsProcessingNNclusterizer, nn)
428428
AddSubConfig(GPUSettingsProcessingScaling, scaling)
429429
AddHelp("help", 'h')
430430
EndConfig()
431-
#endif // __OPENCL__
431+
#endif // !__OPENCL__ && !__METAL__
432432

433433
#ifndef GPUCA_GPUCODE_DEVICE
434434
// Light settings concerning the event display (can be changed without rebuilding vertices)

‎GPU/Utils/GPUCommonBitSet.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,12 @@ class bitset
3737

3838
public:
3939
GPUdDefault() constexpr bitset() = default;
40+
#ifndef __METAL__
41+
// MSL will not use a user-declared copy constructor to build an object in the
42+
// constant address space, where GPUconstexpr() arrays of bitset live. Leaving
43+
// it implicit is what makes those arrays constructible.
4044
GPUdDefault() constexpr bitset(const bitset&) = default;
45+
#endif
4146
#ifdef __OPENCL__
4247
GPUdDefault() constexpr bitset(const __constant bitset&) = default;
4348
#endif // __OPENCL__

0 commit comments

Comments
 (0)