Skip to content

Commit f5f9c70

Browse files
authored
Add release in device free when necessary (llvm#531)
1 parent 8e059a9 commit f5f9c70

File tree

1 file changed

+6
-0
lines changed
  • amd/device-libs/ockl/src

1 file changed

+6
-0
lines changed

amd/device-libs/ockl/src/dm.cl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,8 @@ typedef struct heap_s {
180180
#define AFO(P, V, O) __opencl_atomic_fetch_or (P, V, O, memory_scope_device)
181181
#define ACE(P, E, V, O) __opencl_atomic_compare_exchange_strong(P, E, V, O, O, memory_scope_device)
182182

183+
#define NEED_RELEASE __oclc_ISA_version >= 9400 && __oclc_ISA_version < 10000
184+
183185
// get the heap pointer
184186
static __global heap_t *
185187
get_heap_ptr(void) {
@@ -377,6 +379,10 @@ __ockl_dm_dealloc(ulong addr)
377379
return;
378380
}
379381

382+
if (NEED_RELEASE) {
383+
__builtin_amdgcn_fence(__ATOMIC_RELEASE, "agent", "global");
384+
}
385+
380386
// Find a slab block
381387
ulong saddr = addr & ~(ulong)0x1fffffUL;
382388
__global slab_t *sptr = (__global slab_t *)saddr;

0 commit comments

Comments
 (0)