Skip to content

Commit e6c4c15

Browse files
authored
[LIBCLC] Fix mangling in atomic functions (#7057)
Hard coding the substitution for `AtomicFAddEXT` meant that for the case without AS specified, it was pushing the `MemorySemanticFlag` inside `Scope` namespace creating: ```cpp __spirv_AtomicFAddEXT(double*, __spv::Scope::Flag, __spv::Scope::MemorySemanticsMask::Flag, double) ``` For the `Increment`, the number of chars for the mangled name `_Z24` was correct, but the typo in the op name was resulting in the pointer being lost, resulting in the first argument being just a value: ```cpp __spirv_AtomicIncrementP(unsigned long AS1, __spv::Scope::Flag, __spv::Scope::MemorySemanticsMask::Flag) ```
1 parent 20b1bea commit e6c4c15

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

libclc/ptx-nvidiacl/libspirv/atomic/atomic_add.cl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ __CLC_NVVM_ATOMIC(float, f, float, f, add, _Z21__spirv_AtomicFAddEXT)
2020

2121
#define __CLC_NVVM_ATOMIC_ADD_DOUBLE_IMPL(ADDR_SPACE, ADDR_SPACE_MANGLED, \
2222
ADDR_SPACE_NV, SUBSTITUTION1, \
23-
SUBSTITUTION2) \
23+
SUBSTITUTION2, SUBSTITUTION3) \
2424
long \
2525
_Z18__spirv_AtomicLoadP##ADDR_SPACE_MANGLED##KlN5__spv5Scope4FlagENS1_19MemorySemanticsMask4FlagE( \
2626
volatile ADDR_SPACE const long *, enum Scope, \
@@ -30,7 +30,7 @@ __CLC_NVVM_ATOMIC(float, f, float, f, add, _Z21__spirv_AtomicFAddEXT)
3030
volatile ADDR_SPACE long *, enum Scope, enum MemorySemanticsMask, \
3131
enum MemorySemanticsMask, long, long); \
3232
__attribute__((always_inline)) _CLC_DECL double \
33-
_Z21__spirv_AtomicFAddEXT##P##ADDR_SPACE_MANGLED##d##N5__spv5Scope4FlagENS1_19MemorySemanticsMask4FlagE##d( \
33+
_Z21__spirv_AtomicFAddEXT##P##ADDR_SPACE_MANGLED##d##N5__spv5Scope4FlagENS##SUBSTITUTION3##_19MemorySemanticsMask4FlagE##d( \
3434
volatile ADDR_SPACE double *pointer, enum Scope scope, \
3535
enum MemorySemanticsMask semantics, double value) { \
3636
/* Semantics mask may include memory order, storage class and other info \
@@ -105,9 +105,9 @@ Memory order is stored in the lowest 5 bits */
105105
} \
106106
}
107107

108-
__CLC_NVVM_ATOMIC_ADD_DOUBLE_IMPL(, , _gen_, 0, 4)
109-
__CLC_NVVM_ATOMIC_ADD_DOUBLE_IMPL(__global, U3AS1, _global_, 1, 5)
110-
__CLC_NVVM_ATOMIC_ADD_DOUBLE_IMPL(__local, U3AS3, _shared_, 1, 5)
108+
__CLC_NVVM_ATOMIC_ADD_DOUBLE_IMPL(, , _gen_, 0, 4, 0)
109+
__CLC_NVVM_ATOMIC_ADD_DOUBLE_IMPL(__global, U3AS1, _global_, 1, 5, 1)
110+
__CLC_NVVM_ATOMIC_ADD_DOUBLE_IMPL(__local, U3AS3, _shared_, 1, 5, 1)
111111

112112
#endif
113113

libclc/ptx-nvidiacl/libspirv/atomic/atomic_inc.cl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
#include <spirv/spirv.h>
1111
#include <spirv/spirv_types.h>
1212

13-
__CLC_NVVM_ATOMIC_INCDEC(unsigned int, j, Increment, 1)
14-
__CLC_NVVM_ATOMIC_INCDEC(unsigned long, m, Increment, 1)
13+
__CLC_NVVM_ATOMIC_INCDEC(unsigned int, j, IIncrement, 1)
14+
__CLC_NVVM_ATOMIC_INCDEC(unsigned long, m, IIncrement, 1)
1515

1616
#undef __CLC_NVVM_ATOMIC_TYPES
1717
#undef __CLC_NVVM_ATOMIC

0 commit comments

Comments
 (0)