Skip to content
This repository has been archived by the owner on May 14, 2024. It is now read-only.

Commit

Permalink
Split feature into separate function
Browse files Browse the repository at this point in the history
Change-Id: Ie72e145b6f1c35b93519e8b46072376fcaa88d79
(cherry picked from commit 0e58ba2)
  • Loading branch information
b-sumner authored and searlmc1 committed May 29, 2020
1 parent ae1a85a commit c2d1eef
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions ockl/src/gaaf.cl
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,28 @@

extern void __llvm_amdgcn_global_atomic_fadd_p1f32_f32(__global float *, float) __asm("llvm.amdgcn.global.atomic.fadd.p1f32.f32");

__attribute__((target("atomic-fadd-insts"))) static void
global_atomic_fadd(__global float *p, float v)
{
__llvm_amdgcn_global_atomic_fadd_p1f32_f32(p, v);
}

static void
generic_atomic_fadd(float *p, float v)
{
atomic_uint *t = (atomic_uint *)p;
uint e = AL(t, memory_order_relaxed, memory_scope_device);
while (!AC(t, &e, AS_UINT(v + AS_FLOAT(e)), memory_order_relaxed, memory_order_relaxed, memory_scope_device))
;
}

void
__ockl_atomic_add_noret_f32(float *p, float v)
{
if (__oclc_ISA_version == 9008 && !__ockl_is_local_addr(p) && !__ockl_is_private_addr(p)) {
__llvm_amdgcn_global_atomic_fadd_p1f32_f32((__global float *)p, v);
global_atomic_fadd((__global float *)p, v);
} else {
atomic_uint *t = (atomic_uint *)p;
uint e = AL(t, memory_order_relaxed, memory_scope_device);
while (!AC(t, &e, AS_UINT(v + AS_FLOAT(e)), memory_order_relaxed, memory_order_relaxed, memory_scope_device))
;
generic_atomic_fadd(p, v);
}
}

0 comments on commit c2d1eef

Please sign in to comment.