Skip to content

Commit

Permalink
relaxed memory order
Browse files Browse the repository at this point in the history
  • Loading branch information
isVoid committed Dec 18, 2024
1 parent 7710372 commit 7ff3a04
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions numba_cuda/numba/cuda/runtime/nrt.cu
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ extern "C" __device__ void* NRT_Allocate(size_t size)
{
void* ptr = NULL;
ptr = malloc(size);
if (TheMSys && TheMSys->stats.enabled) { TheMSys->stats.alloc++; }
if (TheMSys && TheMSys->stats.enabled) {
TheMSys->stats.alloc.fetch_add(1, cuda::memory_order_relaxed) }
return ptr;
}

Expand All @@ -48,7 +49,8 @@ extern "C" __device__ void NRT_MemInfo_init(NRT_MemInfo* mi,
mi->dtor_info = dtor_info;
mi->data = data;
mi->size = size;
if (TheMSys && TheMSys->stats.enabled) { TheMSys->stats.mi_alloc++; }
if (TheMSys && TheMSys->stats.enabled) {
TheMSys->stats.mi_alloc.fetch_add(1, cuda::memory_order_relaxed); }
}

extern "C"
Expand All @@ -63,7 +65,8 @@ __device__ NRT_MemInfo* NRT_MemInfo_new(
extern "C" __device__ void NRT_Free(void* ptr)
{
free(ptr);
if (TheMSys && TheMSys->stats.enabled) { TheMSys->stats.free++; }
if (TheMSys && TheMSys->stats.enabled) {
TheMSys->stats.free.fetch_add(1, cuda::memory_order_relaxed); }
}

extern "C" __device__ void NRT_dealloc(NRT_MemInfo* mi)
Expand All @@ -74,7 +77,8 @@ extern "C" __device__ void NRT_dealloc(NRT_MemInfo* mi)
extern "C" __device__ void NRT_MemInfo_destroy(NRT_MemInfo* mi)
{
NRT_dealloc(mi);
if (TheMSys && TheMSys->stats.enabled) { TheMSys->stats.mi_free++; }
if (TheMSys && TheMSys->stats.enabled) {
TheMSys->stats.mi_free.fetch_add(1, cuda::memory_order_relaxed); }
}

extern "C" __device__ void NRT_MemInfo_call_dtor(NRT_MemInfo* mi)
Expand Down Expand Up @@ -153,7 +157,7 @@ extern "C" __device__ void* NRT_Allocate_External(size_t size) {

if (TheMSys && TheMSys->stats.enabled)
{
TheMSys->stats.alloc++;
TheMSys->stats.alloc.fetch_add(1, cuda::memory_order_relaxed);
}
return ptr;
}
Expand Down

0 comments on commit 7ff3a04

Please sign in to comment.