clspv icon indicating copy to clipboard operation
clspv copied to clipboard

clspv should use LLVM atomic instructions

Open alan-baker opened this issue 6 years ago • 3 comments

clspv currently replaces OpenCL atomic builtins with SPIR-V builtins. Instead we should use llvm atomic instructions throughout the flow and translate them in SPIRVProducerPass. Currently some of the builtins are handled this way. Increment, decrement and compare exchange need updated.

Other issues with atomics in clspv: 1.2 opencl atomics should be relaxed and map to Monotonic ordering in LLVM.

All OpenCL atomic builtins claim the pointer is volatile. So at least through the clspv flow atomic instructions should get marked as volatile.

alan-baker avatar Jun 25 '19 17:06 alan-baker

Hi, I am trying to add OpLine information also for atomic instructions in OpenCL, since LLVM atomic ones are not used. Could you please give me some hints for it?

CapZTr avatar Sep 17 '24 09:09 CapZTr

Take a look at lib/ReplaceOpenCLBuiltins.cpp. That pass replaces the OpenCL atomic functions with the spirv.op calls (e.g. replaceAtomics). For debugging, probably what needs to change is for InsertSPIRVOp to copy debug metadata from the original call to the replacement.

alan-baker avatar Sep 17 '24 13:09 alan-baker

Hey, thanks for replying. Already fixed it and created a PR:-)

CapZTr avatar Sep 17 '24 14:09 CapZTr