initial commit

This commit is contained in:
Carl Pearson
2020-09-03 16:39:23 -06:00
commit f7e51a4b7d
7 changed files with 539 additions and 0 deletions

38
bin/pingpong.cpp Normal file
View File

@@ -0,0 +1,38 @@
#include "bench/bench.hpp"
#include <mpi.h>
#include <iostream>
void pingpong(bench::State &state) {
const int rank = bench::world_rank();
const int size = bench::world_size();
const size_t sz = 1;
char *sbuf = new char[sz];
char *rbuf = new char[sz];
for (auto _ : state) {
if (0 == rank) {
MPI_Send(sbuf, sz, MPI_BYTE, 1, 0, MPI_COMM_WORLD);
MPI_Recv(rbuf, sz, MPI_BYTE, 1, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
} else if (1 == rank) {
MPI_Recv(rbuf, sz, MPI_BYTE, 0, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
MPI_Send(sbuf, sz, MPI_BYTE, 0, 0, MPI_COMM_WORLD);
}
}
state.set_bytes_processed(sz);
delete[] sbuf;
delete[] rbuf;
}
int main(int argc, char **argv) {
bench::init(argc, argv);
bench::register_bench("pingpong", pingpong)->timing_root_rank()->no_iter_barrier();
bench::run_benchmarks();
bench::finalize();
}