Skip to content

Commit

Permalink
applied clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
gberg617 committed Jan 17, 2025
1 parent c04745a commit 8275b6d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 21 deletions.
15 changes: 8 additions & 7 deletions src/axom/lumberjack/MPIUtility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ const char* mpiNonBlockingReceiveMessages(MPI_Comm comm, int tag)
int mpiFlag = 0;
MPI_Iprobe(MPI_ANY_SOURCE, tag, comm, &mpiFlag, &mpiStatus);

if (mpiFlag == 1) {
if(mpiFlag == 1)
{
MPI_Get_count(&mpiStatus, MPI_CHAR, &messageSize);

// Setup where to receive the char array
Expand All @@ -69,12 +70,12 @@ const char* mpiNonBlockingReceiveMessages(MPI_Comm comm, int tag)

// Receive packed Message
MPI_Recv(charArray,
messageSize,
MPI_CHAR,
mpiStatus.MPI_SOURCE,
mpiTag,
comm,
&mpiStatus);
messageSize,
MPI_CHAR,
mpiStatus.MPI_SOURCE,
mpiTag,
comm,
&mpiStatus);
}

return charArray;
Expand Down
16 changes: 9 additions & 7 deletions src/axom/lumberjack/NonCollectiveRootCommunicator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,18 @@ void NonCollectiveRootCommunicator::finalize() { }

int NonCollectiveRootCommunicator::rank() { return m_mpiCommRank; }

void NonCollectiveRootCommunicator::ranksLimit(int value) { m_ranksLimit = value; }
void NonCollectiveRootCommunicator::ranksLimit(int value)
{
m_ranksLimit = value;
}

int NonCollectiveRootCommunicator::ranksLimit() { return m_ranksLimit; }

int NonCollectiveRootCommunicator::numPushesToFlush() { return 1; }

void NonCollectiveRootCommunicator::push(const char* packedMessagesToBeSent,
std::vector<const char*>& receivedPackedMessages)
void NonCollectiveRootCommunicator::push(
const char* packedMessagesToBeSent,
std::vector<const char*>& receivedPackedMessages)
{
if(m_mpiCommRank == 0)
{
Expand All @@ -54,23 +58,21 @@ void NonCollectiveRootCommunicator::push(const char* packedMessagesToBeSent,

if(isPackedMessagesEmpty(currPackedMessages))
{
if (currPackedMessages == nullptr )
if(currPackedMessages == nullptr)
{
receive_messages = false;
}
else
{
delete [] currPackedMessages;
delete[] currPackedMessages;
}

}
else
{
receivedPackedMessages.push_back(currPackedMessages);
}

currPackedMessages = nullptr;

}
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ TEST(lumberjack_NonCollectiveRootCommunicator, noncollective_communication)

int commSize = -1;
MPI_Comm_size(MPI_COMM_WORLD, &commSize);

const int ranksLimit = 5;
axom::lumberjack::NonCollectiveRootCommunicator c;

Expand All @@ -24,7 +24,7 @@ TEST(lumberjack_NonCollectiveRootCommunicator, noncollective_communication)
std::vector<const char*> receivedPackedMessages;

// send message only from even ranks
if ((c.rank() % 2) == 0)
if((c.rank() % 2) == 0)
{
c.push(message.c_str(), receivedPackedMessages);
}
Expand All @@ -35,11 +35,12 @@ TEST(lumberjack_NonCollectiveRootCommunicator, noncollective_communication)
}
else
{
const int numMessagesToReceive = ((commSize % 2) == 0) ? ((commSize / 2) - 1) : (commSize / 2);
const int numMessagesToReceive =
((commSize % 2) == 0) ? ((commSize / 2) - 1) : (commSize / 2);
EXPECT_EQ((int)receivedPackedMessages.size(), numMessagesToReceive);
for(int i = 1; i <= numMessagesToReceive; ++i)
{
std::string currMessage = std::to_string(i*2);
std::string currMessage = std::to_string(i * 2);
bool found = false;
for(auto& rm : receivedPackedMessages)
{
Expand Down Expand Up @@ -69,7 +70,6 @@ TEST(lumberjack_NonCollectiveRootCommunicator, noncollective_communication)
}

receivedPackedMessages.clear();

}

TEST(lumberjack_NonCollectiveRootCommunicator, multiple_communicators)
Expand All @@ -78,7 +78,7 @@ TEST(lumberjack_NonCollectiveRootCommunicator, multiple_communicators)

int commSize = -1;
MPI_Comm_size(MPI_COMM_WORLD, &commSize);

const int ranksLimit = 5;
axom::lumberjack::NonCollectiveRootCommunicator c1;
axom::lumberjack::NonCollectiveRootCommunicator c2;
Expand All @@ -95,5 +95,4 @@ TEST(lumberjack_NonCollectiveRootCommunicator, multiple_communicators)
c2.finalize();

MPI_Barrier(MPI_COMM_WORLD);

}

0 comments on commit 8275b6d

Please sign in to comment.