17 LSLAB_DEVICE
void lock() {
18 if(threadIdx.x % 32 == 0) {
20 while(!l.compare_exchange_strong(expect,-1, cuda::std::memory_order_acquire)) {
27 LSLAB_DEVICE
void unlock() {
28 if(threadIdx.x % 32 == 0) {
29 l.store(0, cuda::std::memory_order_release);
33 LSLAB_DEVICE
void shared_lock() {
34 if(threadIdx.x % 32 == 0) {
36 int pred = l.load(cuda::std::memory_order_relaxed);
37 if(pred != -1 && l.compare_exchange_strong(pred, pred + 1, cuda::std::memory_order_acquire)) {
45 LSLAB_DEVICE
int status() {
49 LSLAB_DEVICE
void shared_unlock() {
50 if(threadIdx.x % 32 == 0) {
51 l.fetch_add(-1, cuda::std::memory_order_release);
56 alignas(32)
char _[32];
57 cuda::std::atomic<int> l;
77 if(mtx) mtx->unlock();
83 if(mtx) mtx->unlock();
102 if(mtx) mtx->shared_unlock();
112 if(mtx) mtx->shared_unlock();
Definition: warp_mutex.h:13
Definition: warp_mutex.h:119
Definition: warp_mutex.h:90
Definition: warp_mutex.h:62