ac/llvm: improve sync scope for global atomics
authorRhys Perry <pendingchaos02@gmail.com>
Wed, 27 Nov 2019 16:49:53 +0000 (16:49 +0000)
committerRhys Perry <pendingchaos02@gmail.com>
Mon, 2 Dec 2019 10:48:27 +0000 (10:48 +0000)
Stronger ordering is implemented in SPIRV->NIR with barriers.

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
src/amd/llvm/ac_nir_to_llvm.c

index ddf9f09fe0cf670185f8ffdd1bd8b64e4aeb27e6..830866bc5cb898995ed4429f731e3ff7fde15fb3 100644 (file)
@@ -3024,6 +3024,9 @@ static LLVMValueRef visit_var_atomic(struct ac_nir_context *ctx,
 
        nir_deref_instr *deref = nir_instr_as_deref(instr->src[0].ssa->parent_instr);
        if (deref->mode == nir_var_mem_global) {
+               /* use "singlethread" sync scope to implement relaxed ordering */
+               sync_scope = LLVM_VERSION_MAJOR >= 9 ? "singlethread-one-as" : "singlethread";
+
                LLVMTypeRef ptr_type = LLVMPointerType(LLVMTypeOf(src), LLVMGetPointerAddressSpace(LLVMTypeOf(ptr)));
                ptr = LLVMBuildBitCast(ctx->ac.builder, ptr, ptr_type , "");
        }