46 #include "utils/logger.h"
134 int mpiResult; NDBG_UNUSED(mpiResult);
138 mpiResult = MPI_Fetch_and_op(&newLock, &oldLock, MPI_LONG, rank,
140 assert(mpiResult == MPI_SUCCESS);
142 mpiResult = MPI_Win_flush_local(rank,
m_window);
143 assert(mpiResult == MPI_SUCCESS);
158 int mpiResult; NDBG_UNUSED(mpiResult);
165 assert(mpiResult == MPI_SUCCESS);
182 int mpiResult; NDBG_UNUSED(mpiResult);
187 long myLock =
lockId(threadId);
189 mpiResult = MPI_Compare_and_swap(&mutexUnlocked, &myLock, &oldLock,
191 assert(mpiResult == MPI_SUCCESS);
193 mpiResult = MPI_Win_flush_local(rank,
m_window);
194 assert(mpiResult == MPI_SUCCESS);
196 if (oldLock != myLock)
197 mpiResult = MPI_Recv(0L, 0, MPI_BYTE, MPI_ANY_SOURCE,
m_tagOffset+threadId,
199 assert(mpiResult == MPI_SUCCESS);
218 #endif // MPI_MUTEX_H
unsigned int totalThreads() const
unsigned int threadId() const
static const long MUTEX_UNLOCKED
void release(int rank, unsigned long offset)
Release the lock for a block.
const numa::NumaComm * m_numa
long lockId(unsigned int threadId) const
Include file for C and C++ API.
long acquire(int rank, unsigned long offset)
Acquire a lock.
void init(MPIComm &comm, MPI_Win window, const numa::NumaComm &numa)
int reserveTags(unsigned int num)
void initMutexMem(long &lock)