Skip to content

Commit da3986b

Browse files
committed
GPU: hand the kernel pointers to Thread() as generic pointers
A kernel's buffers are device memory and the address arrives as an integer, but the Thread() entry points take their pointer arguments unannotated, which is the generic address space. Forwarding a device pointer made the call deduce a device pointer for Args..., which matched no explicit specialisation, so the kernels linked against a Thread() that is declared and never defined. The cast goes through device first rather than straight from the integer, so the generic pointer is formed by the normal conversion.
1 parent c1c86e4 commit da3986b

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎GPU/GPUTracking/Definitions/GPUDef.h‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@
3434
// As for OpenCL, pointers travel as a 64-bit address: a pointer to a derived
3535
// class is not a valid kernel argument type in MSL either.
3636
#define GPUPtr1(idx, a, b) constant uint64_t& b [[buffer(idx)]]
37-
#define GPUPtr2(a, b) ((device a) b)
37+
// through device and then to generic: the kernel's own buffers are device
38+
// memory, but the Thread() entry points take the pointer unannotated
39+
#define GPUPtr2(a, b) ((a)((device a)(b)))
3840
#define GPUArg1(idx, a, b) constant a& b [[buffer(idx)]]
3941
#else
4042
#define GPUPtr1(idx, a, b) a b

0 commit comments

Comments
 (0)