Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
csegarragonz committed Oct 27, 2021
1 parent 59f969b commit a626d66
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/proto/faabric.proto
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ message MpiHostsToRanksMessage {
}

// ---------------------------------------------
// PROFILING
// TRACING
// ---------------------------------------------

message MpiPerRankMessageCount {
Expand Down Expand Up @@ -162,7 +162,7 @@ message Message {
bytes sgxPolicy = 36;
bytes sgxResult = 37;

// This last struct is used for tracing purposes, it should only be set in
// This last struct is used for tracing purposes, it is only used in
// non-release builds
CallRecords records = 38;
}
Expand Down
2 changes: 1 addition & 1 deletion src/scheduler/Executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
#include <faabric/util/macros.h>
#include <faabric/util/memory.h>
#include <faabric/util/queue.h>
#include <faabric/util/tracing.h>
#include <faabric/util/timing.h>
#include <faabric/util/tracing.h>

#define POOL_SHUTDOWN -1

Expand Down
6 changes: 4 additions & 2 deletions src/scheduler/MpiWorld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -581,8 +581,10 @@ void MpiWorld::send(int sendRank,
}

// In non-release builds, track that we have sent this message
faabric::util::tracing::getCallRecords().addRecord(thisMsgId,
faabric::util::tracing::RecordType::MpiPerRankMessageCount, recvRank);
faabric::util::tracing::getCallRecords().addRecord(
thisMsgId,
faabric::util::tracing::RecordType::MpiPerRankMessageCount,
recvRank);
}

void MpiWorld::recv(int sendRank,
Expand Down
22 changes: 14 additions & 8 deletions src/util/tracing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ void CallRecords::startRecording(const faabric::Message& msg)
{
#ifndef NDEBUG
if (linkedMsg != nullptr && linkedMsg->id() != msg.id()) {
SPDLOG_ERROR("CallRecords already linked to a different message: (linked: {} != provided: {})",
linkedMsg->id(), msg.id());
SPDLOG_ERROR("Error starting recording, records not linked to the right"
" message: (linked: {} != provided: {})",
linkedMsg->id(),
msg.id());
throw std::runtime_error("CallRecords linked to a different message");
} else if (linkedMsg == nullptr) {
linkedMsg = std::make_shared<faabric::Message>(msg);
Expand All @@ -21,8 +23,10 @@ void CallRecords::stopRecording(faabric::Message& msg)
{
#ifndef NDEBUG
if (linkedMsg == nullptr || linkedMsg->id() != msg.id()) {
SPDLOG_ERROR("CallRecords not linked to the right message: (linked: {} != provided: {})",
linkedMsg->id(), msg.id());
SPDLOG_ERROR("Error stopping recording, records not linked to the right"
" message: (linked: {} != provided: {})",
linkedMsg->id(),
msg.id());
throw std::runtime_error("CallRecords linked to a different message");
}

Expand Down Expand Up @@ -72,14 +76,17 @@ void CallRecords::addRecord(int msgId, RecordType recordType, int idToIncrement)
#ifndef NDEBUG
// Check message id
if (linkedMsg == nullptr || linkedMsg->id() != msgId) {
SPDLOG_ERROR("CallRecords not linked to the right message: (linked: {} != provided: {})",
linkedMsg->id(), msgId);
SPDLOG_ERROR("CallRecords not linked to the right message: (linked: {} "
"!= provided: {})",
linkedMsg->id(),
msgId);
throw std::runtime_error("CallRecords linked to a different message");
}

// Add the record to the list of on going records if it is not there
bool mustInit = false;
auto it = std::find(onGoingRecordings.begin(), onGoingRecordings.end(), recordType);
auto it =
std::find(onGoingRecordings.begin(), onGoingRecordings.end(), recordType);
if (it == onGoingRecordings.end()) {
onGoingRecordings.push_back(recordType);
mustInit = true;
Expand Down Expand Up @@ -107,7 +114,6 @@ void CallRecords::addRecord(int msgId, RecordType recordType, int idToIncrement)
#endif
}


CallRecords& getCallRecords()
{
static thread_local CallRecords callRecords;
Expand Down
17 changes: 12 additions & 5 deletions tests/test/util/test_tracing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,17 @@ TEST_CASE_METHOD(MpiTestFixture,
std::vector<int> messageData = { 0, 1, 2 };
auto buffer = new int[messageData.size()];

world.send(
rankA1, rankA2, BYTES(messageData.data()), MPI_INT, messageData.size());
world.recv(
rankA1, rankA2, BYTES(buffer), MPI_INT, messageData.size(), &status);
int numToSend = 10;

for (int i = 0; i < numToSend; i++) {
world.send(rankA1,
rankA2,
BYTES(messageData.data()),
MPI_INT,
messageData.size());
world.recv(
rankA1, rankA2, BYTES(buffer), MPI_INT, messageData.size(), &status);
}

// Stop recording and check we have only recorded one message
faabric::util::tracing::getCallRecords().stopRecording(msg);
Expand All @@ -35,7 +42,7 @@ TEST_CASE_METHOD(MpiTestFixture,
REQUIRE(msg.records().mpimsgcount().ranks_size() == worldSize);
for (int i = 0; i < worldSize; i++) {
if (i == rankA2) {
REQUIRE(msg.records().mpimsgcount().nummessages(i) == 1);
REQUIRE(msg.records().mpimsgcount().nummessages(i) == numToSend);
} else {
REQUIRE(msg.records().mpimsgcount().nummessages(i) == 0);
}
Expand Down

0 comments on commit a626d66

Please sign in to comment.