Skip to content

Commit

Permalink
Improve test data printing
Browse files Browse the repository at this point in the history
  • Loading branch information
cscjlan committed Aug 29, 2024
1 parent ff4b446 commit a582090
Show file tree
Hide file tree
Showing 81 changed files with 100,207 additions and 9,159 deletions.
86 changes: 47 additions & 39 deletions src/grid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,7 @@ template <typename T, int32_t stencil> class FsGrid {
ss << "MPI_UNDEFINED";
}
ss << newliner;
ss << "comm size: " << rank;
ss << "comm size: " << size;

MPI_Group group = MPI_GROUP_NULL;
FSGRID_MPI_CHECK(MPI_Comm_group(comm, &group), "Failed to get group from comm ", comm);
Expand All @@ -878,38 +878,42 @@ template <typename T, int32_t stencil> class FsGrid {
}
ss << newliner;
ss << "group size: " << size;
FSGRID_MPI_CHECK(MPI_Group_free(&group), "Failed to free group");
}

MPI_Group remotegroup = MPI_GROUP_NULL;
FSGRID_MPI_CHECK(MPI_Comm_remote_group(comm, &remotegroup), "Failed to get remotegroup from comm ", comm);
if (remotegroup != MPI_GROUP_NULL) {
int rank = 0;
FSGRID_MPI_CHECK(MPI_Group_rank(remotegroup, &rank), "Failed to get rank from remotegroup ",
remotegroup);
int size = 0;
FSGRID_MPI_CHECK(MPI_Group_size(remotegroup, &size), "Failed to get size from remotegroup ",
remotegroup);

ss << newliner;
ss << "remotegroup rank: ";
if (rank != MPI_UNDEFINED) {
ss << rank;
} else {
ss << "MPI_UNDEFINED";
}
ss << newliner;
ss << "remotegroup size: " << size;
}

int remotesize = 0;
FSGRID_MPI_CHECK(MPI_Comm_remote_size(comm, &remotesize), "Failed to get remotesize from comm ", comm);
ss << newliner;
ss << "remotesize: " << remotesize;

int isInterComm = 0;
FSGRID_MPI_CHECK(MPI_Comm_test_inter(comm, &isInterComm), "Failed to get intecomm flag from comm ", comm);
ss << newliner;
ss << "is intercomm: " << isInterComm;
if (isInterComm) {
MPI_Group remotegroup = MPI_GROUP_NULL;
FSGRID_MPI_CHECK(MPI_Comm_remote_group(comm, &remotegroup), "Failed to get remotegroup from comm ",
comm);
if (remotegroup != MPI_GROUP_NULL) {
int rank = 0;
FSGRID_MPI_CHECK(MPI_Group_rank(remotegroup, &rank), "Failed to get rank from remotegroup ",
remotegroup);
int size = 0;
FSGRID_MPI_CHECK(MPI_Group_size(remotegroup, &size), "Failed to get size from remotegroup ",
remotegroup);

ss << newliner;
ss << "remotegroup rank: ";
if (rank != MPI_UNDEFINED) {
ss << rank;
} else {
ss << "MPI_UNDEFINED";
}
ss << newliner;
ss << "remotegroup size: " << size;
FSGRID_MPI_CHECK(MPI_Group_free(&remotegroup), "Failed to free remotegroup");
}

int remotesize = 0;
FSGRID_MPI_CHECK(MPI_Comm_remote_size(comm, &remotesize), "Failed to get remotesize from comm ", comm);
ss << newliner;
ss << "remotesize: " << remotesize;
}
}
};

Expand Down Expand Up @@ -945,12 +949,12 @@ template <typename T, int32_t stencil> class FsGrid {
pushContainerValues(localStart);
ss << "\n\t]";
ss << "\n\tneigbourSendType: [";
for (const auto& v : getMPITypes(true)) {
for (const auto& v : getMPITypes(neighbourSendType)) {
ss << "\n\t\t" << v.display("\n\t\t");
}
ss << "\n\t]";
ss << "\n\tneighbourReceiveType: [";
for (const auto& v : getMPITypes(false)) {
for (const auto& v : getMPITypes(neighbourReceiveType)) {
ss << "\n\t\t" << v.display("\n\t\t");
}
ss << "\n\t]";
Expand All @@ -973,7 +977,7 @@ template <typename T, int32_t stencil> class FsGrid {
int combiner = -1;
std::vector<int> integers;
std::vector<MPI_Aint> addresses;
std::vector<MPI_Datatype> dataTypes;
std::vector<MPITypeMetaData> metaDatas;

std::string display(std::string newliner) const {
std::stringstream ss;
Expand Down Expand Up @@ -1019,29 +1023,29 @@ template <typename T, int32_t stencil> class FsGrid {
};

ss << "{";
ss << newliner << "\tcombiner :" << combiner;
ss << newliner << "\tcombiner: " << combiner;
ss << newliner << "\tintegers: [" << newliner << "\t\t";
pushContainerValues(integers, false, 9);
ss << newliner << "\t]";
ss << newliner << "\taddresses: [" << newliner << "\t\t";
pushContainerValues(addresses, true, 9);
ss << newliner << "\t]";
ss << newliner << "\tdata types: [" << newliner << "\t\t";
pushContainerValues(dataTypes, true, 9);
for (const auto& mt : metaDatas) {
ss << mt.display(newliner + "\t\t");
}
ss << newliner << "\t]";
ss << newliner << "}";

return ss.str();
}
};

std::array<MPITypeMetaData, 27> getMPITypes(bool send) const {
const auto typeVec = send ? neighbourSendType : neighbourReceiveType;
std::array<MPITypeMetaData, 27> metadatas;
template <typename U> std::vector<MPITypeMetaData> getMPITypes(const U& typeVec) const {
std::vector<MPITypeMetaData> metadatas(typeVec.size());
for (size_t i = 0; i < typeVec.size(); i++) {
const auto mpiType = typeVec[i];

if (mpiType == MPI_DATATYPE_NULL) {
if (mpiType == MPI_DATATYPE_NULL || mpiType == MPI_BYTE) {
continue;
}

Expand All @@ -1054,11 +1058,15 @@ template <typename T, int32_t stencil> class FsGrid {

metadatas[i].integers.resize(numIntegers);
metadatas[i].addresses.resize(numAddresses);
metadatas[i].dataTypes.resize(numDataTypes);
std::vector<MPI_Datatype> dataTypes(numDataTypes);
FSGRID_MPI_CHECK(MPI_Type_get_contents(mpiType, numIntegers, numAddresses, numDataTypes,
metadatas[i].integers.data(), metadatas[i].addresses.data(),
metadatas[i].dataTypes.data()),
dataTypes.data()),
"Failed to get type contents for type ", mpiType);

if (numDataTypes != 0) {
metadatas[i].metaDatas = getMPITypes(dataTypes);
}
}

return metadatas;
Expand Down
Loading

0 comments on commit a582090

Please sign in to comment.