Skip to content

Commit a63596e

Browse files
committed
GPU: keep the constant memory block out of Metal's constant address space
MSL's generic address space does not span constant, so a generic member function cannot be called on an object living there, and the shared code is generic throughout. Metal therefore implies GPUCA_NO_CONSTANT_MEMORY, which redirects GPUconstant() to GPUglobal(). GPUconstantref() has to follow: the Metal block hardcoded constant and so kept handing out constant references whatever the setting; dropping it lets it fall through to the generic fallback.
1 parent 186a4af commit a63596e

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

‎GPU/Common/GPUCommonDef.h‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,10 @@
5858
#define GPUCA_ALIGPUCODE // Part of GPUTracking library but not of interface
5959
#endif
6060

61-
#if (defined(__CUDACC__) && defined(GPUCA_CUDA_NO_CONSTANT_MEMORY)) || (defined(__HIPCC__) && defined(GPUCA_HIP_NO_CONSTANT_MEMORY)) || (defined(__OPENCL__) && defined(GPUCA_OPENCL_NO_CONSTANT_MEMORY))
61+
// __METAL__ unconditionally: the MSL generic address space does not span
62+
// `constant`, so a generic member function cannot be called on an object living
63+
// there, and the shared code is generic throughout.
64+
#if (defined(__CUDACC__) && defined(GPUCA_CUDA_NO_CONSTANT_MEMORY)) || (defined(__HIPCC__) && defined(GPUCA_HIP_NO_CONSTANT_MEMORY)) || (defined(__OPENCL__) && defined(GPUCA_OPENCL_NO_CONSTANT_MEMORY)) || defined(__METAL__)
6265
#define GPUCA_NO_CONSTANT_MEMORY
6366
#elif (defined(__CUDACC__) || defined(__HIPCC__)) && !defined(GPUCA_GPUCODE_HOSTONLY)
6467
#define GPUCA_HAS_GLOBAL_SYMBOL_CONSTANT_MEM

‎GPU/Common/GPUCommonDefAPI.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@
167167
#define GPUglobalref() device
168168
#define GPUsharedref() threadgroup
169169
#define GPUprivateref() thread
170-
#define GPUconstantref() constant
171170
#define GPUconstexprref() GPUconstexpr()
172171
#define GPUdouble() float
173172
#define GPUbarrier() threadgroup_barrier(mem_flags::mem_device | mem_flags::mem_threadgroup)

0 commit comments

Comments
 (0)