Skip to content

Commit

Permalink
Add -T --multithreaded-mpi option to adios2_iotest and use MPI_THREAD…
Browse files Browse the repository at this point in the history
…_SINGLE by default so that SSC works fine with MPI builds that do not support multi-threading. SST/MPI requires to use this new option to work with the test.
  • Loading branch information
pnorbert committed Feb 14, 2023
1 parent 8796325 commit 5181f56
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 9 deletions.
22 changes: 16 additions & 6 deletions source/utils/adios_iotest/adios_iotest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,27 @@

int main(int argc, char *argv[])
{
Settings settings;

/* Check input arguments. Quit if something is wrong. */
if (settings.processArguments(argc, argv))
{
return 1;
}

int provided;
int threadSupportLevel = MPI_THREAD_MULTIPLE;
int threadSupportLevel = MPI_THREAD_SINGLE;
if (settings.multithreadedMPI)
{
threadSupportLevel = MPI_THREAD_MULTIPLE;
}
MPI_Init_thread(&argc, &argv, threadSupportLevel, &provided);

Settings settings;
settings.initDecomp(MPI_COMM_WORLD);

/* Check input arguments. Quit if something is wrong. */
if (settings.processArguments(argc, argv, MPI_COMM_WORLD) ||
settings.extraArgumentChecks())
// MPI-dependent argument checks
if (settings.extraArgumentChecks())
{
MPI_Finalize();
return 1;
}

Expand Down
23 changes: 21 additions & 2 deletions source/utils/adios_iotest/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@ struct option options[] = {{"help", no_argument, NULL, 'h'},
{"weak-scaling", no_argument, NULL, 'w'},
{"timer", no_argument, NULL, 't'},
{"fixed", no_argument, NULL, 'F'},
{"multithreaded-mpi", no_argument, NULL, 'T'},
#ifdef ADIOS2_HAVE_HDF5_PARALLEL
{"hdf5", no_argument, NULL, 'H'},
#endif
{NULL, 0, NULL, 0}};

static const char *optstring = "-hvswtFHa:c:d:D:x:p:";
static const char *optstring = "-hvswtTFHa:c:d:D:x:p:";

size_t Settings::ndigits(size_t n) const
{
Expand Down Expand Up @@ -74,6 +75,7 @@ void Settings::displayHelp()
<< " -v increase verbosity\n"
<< " -h display this help\n"
<< " -F turn on fixed I/O pattern explicitly\n"
<< " -T turn on multi-threaded MPI (needed by SST/MPI)\n"
<< " -p specify the path of the output explicitly\n"
<< " -t print and dump the timing measured by the I/O "
"timer\n\n";
Expand Down Expand Up @@ -206,6 +208,9 @@ int Settings::processArgs(int argc, char *argv[])
case 'F':
fixedPattern = true;
break;
case 'T':
multithreadedMPI = true;
break;
case 'h':
if (!myRank)
{
Expand Down Expand Up @@ -318,13 +323,27 @@ int Settings::processArgs(int argc, char *argv[])
return 0;
}

int Settings::processArguments(int argc, char *argv[], MPI_Comm worldComm)
int Settings::processArguments(int argc, char *argv[])
{
int retval = 0;
try
{
retval = processArgs(argc, argv);
}
catch (std::exception &e) // command-line argument errors
{
std::cout << "ERROR : " << e.what() << std::endl;
displayHelp();
retval = 1;
}
return retval;
}

int Settings::initDecomp(MPI_Comm worldComm)
{
int retval = 0;
try
{
int wrank;
MPI_Comm_rank(worldComm, &wrank);
MPI_Comm_split(worldComm, static_cast<int>(appId), wrank, &appComm);
Expand Down
4 changes: 3 additions & 1 deletion source/utils/adios_iotest/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class Settings
bool ioTimer = false; // used to measure io time
bool fixedPattern = false; // should Lock definitions?
bool isRatioDecomp = false;
bool multithreadedMPI = false; // turn on MT-enabled MPI
IOLib iolib = IOLib::ADIOS;
// process decomposition
std::vector<size_t> processDecomp = {1, 1, 1, 1, 1, 1, 1, 1,
Expand All @@ -56,7 +57,8 @@ class Settings

Settings() = default;
~Settings() = default;
int processArguments(int argc, char *argv[], MPI_Comm worldComm);
int processArguments(int argc, char *argv[]);
int initDecomp(MPI_Comm worldComm);
int extraArgumentChecks();
size_t stringToNumber(const std::string &varName, const char *arg) const;
int parseCSDecomp(const char *arg);
Expand Down

0 comments on commit 5181f56

Please sign in to comment.