-
Notifications
You must be signed in to change notification settings - Fork 247
Open
Description
For Khronos folks, this is partially discussed in internal issue 152.
The "Memory Semantics" that are generated for the OpenCL C 2.0 atomic functions are debatably incorrect. Consider this OpenCL C kernel, which performs an atomic store to an atomic variable in the global address space, performing a release operation:
kernel void test(global atomic_int* gptr, local atomic_int* lptr) {
atomic_store_explicit(gptr, 2, memory_order_release);
}The SPIR-V atomic instruction that is generated for this kernel is something like:
OpAtomicStore %13 %uint_1 %uint_4 %uint_2
Here are the operands for this instruction:
%13is the pointer operand, from previous instructions.%uint_1is the Scope for Memory, and represents Device scope. This makes sense, since the default memory scope ismemory_scope_device: "The functions that do not have memory_scope argument have the same semantics as the corresponding functions with the memory_scope argument set to memory_scope_device."%uint_4is the Memory Semantics. This represents the Release memory order, which is good, but strangely there are no affected memory spaces.%uint_2is the value that is stored, and is fine.
Should the SPIR-V LLVM Translator include affected memory spaces in the generated atomic instruction? If so, how should it determine which memory spaces are affected? If not, what should it mean to have an atomic memory order, but no affected memory spaces?
Metadata
Metadata
Assignees
Labels
No labels