18 {
19
20
23 util::io::print(fmt::format(
"Initialized MPI. MPI size = {}, MPI rank = {}\n", mpiSize, mpiRank));
25
26
28
29
31
32 if (input.cmdOptionExists("-h") or !input.cmdOptionExists("-o")) {
33
36 << ") -o <test-option; 0 - taskflow, 1 - parallel on in-built mesh, 2 - user-defined mesh>"
37 " -i <vector-size> -n <grid-size>"
38 " -m <horizon-integer-factor>"
39 " -nThreads <number of threads to be used in taskflow>" << std::endl;
40 std::cout << "To test taskflow, run\n";
41 std::cout << argv[0] << " -o 0 -i 10000"
42 " -nThreads <number of threads to be used in taskflow>\n";
43 std::cout << "To test parallel using in-built mesh, run\n";
44 std::cout << argv[0] << " -o 1 -m 4 -n 50\n";
45 std::cout << "To test parallel on user-provided mesh (filename = filepath/meshfile.vtu)" << std::endl;
46 std::cout << argv[0] << " -o 2 -m 4 -f filepath/meshfile.vtu" << std::endl;
47 exit(EXIT_FAILURE);
48 }
49
50
51 size_t testOption(-1);
52
53 if (input.cmdOptionExists("-o")) testOption = std::stoi(input.getCmdOption("-o"));
54
55
56 if (testOption == 0) {
58
59 size_t nTaskflow;
60 if (input.cmdOptionExists("-i")) nTaskflow = std::stoi(input.getCmdOption("-i"));
61 else {
62 nTaskflow = 100000;
63 util::io::print(fmt::format(
"Running test with default vector-size = {}\n", nTaskflow));
64 }
65
66 unsigned int nThreads;
67 if (input.cmdOptionExists("-nThreads")) nThreads = std::stoi(input.getCmdOption("-nThreads"));
68 else {
69 nThreads = std::thread::hardware_concurrency();
70 util::io::print(fmt::format(
"Running test with default number of threads = {}\n", nThreads));
71 }
72
75
76 std::vector<size_t> N_test = {size_t(nTaskflow/100), size_t(nTaskflow/10), nTaskflow, 10*nTaskflow, 100*nTaskflow};
77 int seed = 0;
78 size_t test_count = 0;
79 for (auto n : N_test) {
81 "Test parameters: N = {}\n\n",
82 test_count++, n));
85 }
86 } else if (testOption == 1 or testOption == 2) {
87
89
90 if (mpiSize < 2) {
91 std::cout << "\nNo tests for mpiSize = 1. Skipping this test.\n\n";
92 } else {
93
94 size_t nGrid(0), mHorizon;
95 std::string meshFilename("");
96
97 if (input.cmdOptionExists("-n"))
98 nGrid = size_t(std::stoi(input.getCmdOption("-n")));
99 else {
100
101 if (testOption == 1) {
102 nGrid = 50;
103 util::io::print(fmt::format(
"Running test with default grid size = {}\n", nGrid));
104 }
105 }
106
107 if (input.cmdOptionExists("-m"))
108 mHorizon = size_t(std::stoi(input.getCmdOption("-m")));
109 else {
110 mHorizon = 4;
111 util::io::print(fmt::format(
"Running test with default integer factor for horizon = {}\n", mHorizon));
112 }
113
114
115 if (input.cmdOptionExists("-f")) meshFilename = input.getCmdOption("-f");
116
117
118 if ((nGrid > 0 and testOption == 2) or
119 (!meshFilename.empty() and testOption == 1)) {
120 std::cerr
121 << "Please specify either using uniform mesh (in-built) or user-defined mesh "
122 "to perform the MPI test. "
123 "That is, either specify '-o 1 -n <grid-size>' "
124 "or '-o 2 -f <mesh-filename>'.\n";
125 exit(1);
126 }
127
128
130 }
131 } else {
133 }
134
135 MPI_Finalize();
136 return EXIT_SUCCESS;
137}
size_t const MINOR_VERSION
size_t const UPDATE_VERSION
size_t const MAJOR_VERSION
std::string testTaskflow(size_t N, int seed)
Perform test on taskflow.
void testMPI(size_t nGrid=10, size_t mHorizon=3, size_t testOption=0, std::string meshFilename="")
Perform parallelization test using MPI on mesh partition based on metis.
std::string printStr(const T &msg, int nt=print_default_tab)
Returns formatted string for output.
void print(const T &msg, int nt=print_default_tab, int printMpiRank=print_default_mpi_rank)
Prints formatted information.
void initLogger(int debug_level=logger_default_debug_lvl, std::string filename="")
Initializes the logger.
unsigned int getNThreads()
Get number of threads to be used by taskflow.
void initNThreads(unsigned int nThreads=std::thread::hardware_concurrency())
Initializes MpiStatus struct.
const MpiStatus * getMpiStatus()
Returns pointer to MpiStatus struct.
void initMpi(int argc=0, char *argv[]=nullptr)
Initializes MPI and also creates MpiStatus struct.
int mpiSize()
Get size (number) of processors.
int mpiRank()
get rank (id) of this processor