Skip to content

Commit

Permalink
Add read or write MPI-IO options separately.
Browse files Browse the repository at this point in the history
  • Loading branch information
ykempf committed Mar 20, 2023
1 parent 01cc20e commit c7f42b4
Showing 1 changed file with 32 additions and 10 deletions.
42 changes: 32 additions & 10 deletions timed_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ void readNint(vlsv::ParallelReader &vlsv, int chunkSize, int chunkCount, uint64_
int main(int argc,char* argv[]) {
bool success = true;

if (argc < 6 || (argc >= 6 && argc % 2 != 0))
if (argc < 6)
{
std::cout << "usage : srun timed_test buffer_size min_rank_chunk_size max_rank_chunk_size min_rank_chunk_count max_rank_chunk_count [mpiio_hint mpiio_value]" << std::endl;
std::cout << "usage : srun timed_test buffer_size min_rank_chunk_size max_rank_chunk_size min_rank_chunk_count max_rank_chunk_count [WR mpiio_hint mpiio_value] [RD mpiio_hint mpiio_value]" << std::endl;
}

// Init MPI:
Expand All @@ -72,14 +72,36 @@ int main(int argc,char* argv[]) {
int minChunkCount = std::atoi(argv[4]);
int maxChunkCount = std::atoi(argv[5]);

MPI_Info MPIinfo;
MPI_Info MPIinfo_wr, MPIinfo_rd;
if (argc == 6) {
MPIinfo = MPI_INFO_NULL;
MPIinfo_wr = MPIinfo_rd = MPI_INFO_NULL;
} else {
MPI_Info_create(&MPIinfo);
for (int i=6; i<argc; i+=2)
{
MPI_Info_set(MPIinfo, argv[i], argv[i+1]);
int i=6, wr_count=0, rd_count=0;
MPI_Info_create(&MPIinfo_wr);
MPI_Info_create(&MPIinfo_rd);
MPI_Info * MPIinfo_ptr;
while(true) {
if(i >= argc) {
break;
}
if(argv[i] == std::string("WR")) {
MPIinfo_ptr = &MPIinfo_wr;
i++;
wr_count++;
}
if(argv[i] == std::string("RD")) {
MPIinfo_ptr = &MPIinfo_rd;
i++;
rd_count++;
}
MPI_Info_set(*MPIinfo_ptr, argv[i], argv[i+1]);
i += 2;
}
if(wr_count == 0) {
MPIinfo_wr = MPI_INFO_NULL;
}
if(rd_count == 0) {
MPIinfo_rd = MPI_INFO_NULL;
}
}
if(myRank == 0) {
Expand Down Expand Up @@ -108,7 +130,7 @@ int main(int argc,char* argv[]) {

vlsv::Writer vlsvWriter;
vlsvWriter.setBuffer(bufferSize);
if (vlsvWriter.open("file.out",MPI_COMM_WORLD,0, MPIinfo) == false) {
if (vlsvWriter.open("file.out",MPI_COMM_WORLD,0, MPIinfo_wr) == false) {
success = false;
MPI_Finalize();
return 1;
Expand Down Expand Up @@ -153,7 +175,7 @@ int main(int argc,char* argv[]) {
intData.resize(chunkSizes[myRank]*chunkCounts[myRank]);

vlsv::ParallelReader vlsvReader;
if (vlsvReader.open("file.out",MPI_COMM_WORLD,0, MPIinfo) == false) {
if (vlsvReader.open("file.out",MPI_COMM_WORLD,0, MPIinfo_rd) == false) {
success = false;
MPI_Finalize();
return 1;
Expand Down

0 comments on commit c7f42b4

Please sign in to comment.