Commit 50e573f5 authored by carlushuang's avatar carlushuang
Browse files

fix format

parent f74b77bc
...@@ -3,10 +3,9 @@ ...@@ -3,10 +3,9 @@
#include <stdint.h> #include <stdint.h>
namespace ck { namespace ck {
struct workgroup_barrier { struct workgroup_barrier
__device__ workgroup_barrier(uint32_t * ptr) : {
base_ptr(ptr) __device__ workgroup_barrier(uint32_t* ptr) : base_ptr(ptr) {}
{}
__device__ uint32_t ld(uint32_t offset) __device__ uint32_t ld(uint32_t offset)
{ {
...@@ -29,48 +28,46 @@ struct workgroup_barrier { ...@@ -29,48 +28,46 @@ struct workgroup_barrier {
__device__ void wait_eq(uint32_t offset, uint32_t value) __device__ void wait_eq(uint32_t offset, uint32_t value)
{ {
if(threadIdx.x == 0){ if(threadIdx.x == 0)
while(ld(offset) != value){} {
while(ld(offset) != value) {}
} }
__syncthreads(); __syncthreads();
} }
__device__ void wait_lt(uint32_t offset, uint32_t value) __device__ void wait_lt(uint32_t offset, uint32_t value)
{ {
if(threadIdx.x == 0){ if(threadIdx.x == 0)
while(ld(offset) < value){} {
while(ld(offset) < value) {}
} }
__syncthreads(); __syncthreads();
} }
__device__ void wait_set(uint32_t offset, uint32_t compare, uint32_t value) __device__ void wait_set(uint32_t offset, uint32_t compare, uint32_t value)
{ {
if(threadIdx.x == 0){ if(threadIdx.x == 0)
while(atomicCAS(base_ptr + offset, compare, value) != compare){} {
while(atomicCAS(base_ptr + offset, compare, value) != compare) {}
} }
__syncthreads(); __syncthreads();
} }
// enter critical zoon, assume buffer is zero when launch kernel // enter critical zoon, assume buffer is zero when launch kernel
__device__ void aquire(uint32_t offset) __device__ void aquire(uint32_t offset) { wait_set(offset, 0, 1); }
{
wait_set(offset, 0, 1);
}
// exit critical zoon, assume buffer is zero when launch kernel // exit critical zoon, assume buffer is zero when launch kernel
__device__ void release(uint32_t offset) __device__ void release(uint32_t offset) { wait_set(offset, 1, 0); }
{
wait_set(offset, 1, 0);
}
__device__ void inc(uint32_t offset) __device__ void inc(uint32_t offset)
{ {
__syncthreads(); __syncthreads();
if(threadIdx.x == 0){ if(threadIdx.x == 0)
{
atomicAdd(base_ptr + offset, 1); atomicAdd(base_ptr + offset, 1);
} }
} }
uint32_t * base_ptr; uint32_t* base_ptr;
}; };
} } // namespace ck
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment