Skip to content

Commit

Permalink
Use C++11 atomic flag for locking instead of MPI_Win_lock() since the…
Browse files Browse the repository at this point in the history
… latter does not work on Cori/KNL/Intel.
  • Loading branch information
pnorbert committed Jul 16, 2021
1 parent 8dba298 commit e35f5ea
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
22 changes: 5 additions & 17 deletions source/adios2/toolkit/aggregator/mpi/MPIShmChain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,7 @@ namespace aggregator

MPIShmChain::MPIShmChain() : MPIAggregator() {}

MPIShmChain::~MPIShmChain()
{
Close();
/*if (m_IsActive)
{
m_NodeComm.Free("free per-node comm in ~MPIShmChain()");
m_OnePerNodeComm.Free("free chain of nodes in ~MPIShmChain()");
m_AllAggregatorsComm.Free(
"free comm of all aggregators in ~MPIShmChain()");
m_AggregatorChainComm.Free(
"free chains of aggregators in ~MPIShmChain()");
}*/
}
MPIShmChain::~MPIShmChain() { Close(); }

void MPIShmChain::Close()
{
Expand Down Expand Up @@ -286,7 +274,7 @@ MPIShmChain::ShmDataBuffer *MPIShmChain::LockProducerBuffer()
std::this_thread::sleep_for(std::chrono::duration<double>(0.00001));
}

m_Comm.Win_Lock(helper::Comm::LockType::Exclusive, 0, 0, m_Win);
m_Shm->lockSegment.lock();
if (m_Shm->producerBuffer == LastBufferUsed::A)

{
Expand All @@ -302,7 +290,7 @@ MPIShmChain::ShmDataBuffer *MPIShmChain::LockProducerBuffer()
// point to shm data buffer (in local process memory)
sdb->buf = m_Shm->bufA;
}
m_Comm.Win_Unlock(0, m_Win);
m_Shm->lockSegment.unlock();

// We determined we want a specific buffer
// Now we need to get a lock on it in case consumer is using it
Expand Down Expand Up @@ -343,7 +331,7 @@ MPIShmChain::ShmDataBuffer *MPIShmChain::LockConsumerBuffer()
// At this point we know buffer A has content or going to have content
// when we successfully lock it

m_Comm.Win_Lock(helper::Comm::LockType::Exclusive, 0, 0, m_Win);
m_Shm->lockSegment.lock();
if (m_Shm->consumerBuffer == LastBufferUsed::A)

{
Expand All @@ -359,7 +347,7 @@ MPIShmChain::ShmDataBuffer *MPIShmChain::LockConsumerBuffer()
// point to shm data buffer (in local process memory)
sdb->buf = m_Shm->bufA;
}
m_Comm.Win_Unlock(0, m_Win);
m_Shm->lockSegment.unlock();

// We determined we want a specific buffer
// Now we need to get a lock on it in case producer is using it
Expand Down
1 change: 1 addition & 0 deletions source/adios2/toolkit/aggregator/mpi/MPIShmChain.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ class MPIShmChain : public MPIAggregator
// user facing structs
ShmDataBuffer sdbA;
ShmDataBuffer sdbB;
aggregator::Spinlock lockSegment;
// locks for individual buffers (sdb and buf)
aggregator::Spinlock lockA;
aggregator::Spinlock lockB;
Expand Down

0 comments on commit e35f5ea

Please sign in to comment.