| 1 |
#include "gtest/gtest.h" |
| 2 |
#include "stk_util/parallel/ParallelComm.hpp" |
| 3 |
#include "stk_unit_test_utils/timer.hpp" |
| 4 |
#include <vector> |
| 5 |
|
| 6 |
|
| 7 |
TEST(ParallelDataExchangePerf, parallel_data_exchange_t_dense) |
| 8 |
{ |
| 9 |
MPI_Comm comm = MPI_COMM_WORLD; |
| 10 |
int commSize = stk::parallel_machine_size(comm); |
| 11 |
int dataSize = 1024 * 1024; |
| 12 |
const unsigned NUM_RUNS = 5; |
| 13 |
const int NUM_ITERS = 100; |
| 14 |
|
| 15 |
std::vector<std::vector<int>> sendData(commSize); |
| 16 |
std::vector<std::vector<int>> recvData(commSize); |
| 17 |
|
| 18 |
for (int i=0; i < commSize; ++i) |
| 19 |
{ |
| 20 |
sendData[i].resize(dataSize); |
| 21 |
recvData[i].resize(dataSize); |
| 22 |
for (int j=0; j < dataSize; ++j) |
| 23 |
sendData[i][j] = j; |
| 24 |
} |
| 25 |
|
| 26 |
stk::unit_test_util::BatchTimer batchTimer(comm); |
| 27 |
batchTimer.initialize_batch_timer(); |
| 28 |
for (unsigned j = 0; j < NUM_RUNS; j++) { |
| 29 |
batchTimer.start_batch_timer(); |
| 30 |
|
| 31 |
for (int i = 0; i < NUM_ITERS; ++i) |
| 32 |
{ |
| 33 |
stk::parallel_data_exchange_t(sendData, recvData, comm); |
| 34 |
} |
| 35 |
batchTimer.stop_batch_timer(); |
| 36 |
} |
| 37 |
batchTimer.print_batch_timing(NUM_ITERS); |
| 38 |
|
| 39 |
// Intel MPI |
| 40 |
// np=1: [0.078, 0.110] |
| 41 |
// np=2: [0.70, 0.95] |
| 42 |
// np=4: [1.84, 2.17] |
| 43 |
// np=8: [4.64, 4.87] |
| 44 |
|
| 45 |
// OpenMPI |
| 46 |
// np=1: [0.09, 0.167] |
| 47 |
// np=2: [0.71, 0.85] |
| 48 |
// np=4: [1.85, 2.09] |
| 49 |
// np=8: [4.25, 4.46] |
| 50 |
} |