initial commit
This commit is contained in:
27
bin/allreduce.cpp
Normal file
27
bin/allreduce.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
#include "bench/bench.hpp"
|
||||
|
||||
#include <mpi.h>
|
||||
|
||||
void allreduce(bench::State &state) {
|
||||
|
||||
|
||||
const int rank = bench::world_rank();
|
||||
const int size = bench::world_size();
|
||||
|
||||
const size_t sz = 1000;
|
||||
|
||||
char *data = new char[sz];
|
||||
for (auto _ : state) {
|
||||
MPI_Allreduce(MPI_IN_PLACE, data, sz, MPI_BYTE, MPI_SUM, MPI_COMM_WORLD);
|
||||
}
|
||||
|
||||
state.set_bytes_processed(sz * size);
|
||||
delete[] data;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
bench::init(argc, argv);
|
||||
bench::register_bench("allreduce", allreduce)->timing_max_rank();
|
||||
bench::run_benchmarks();
|
||||
bench::finalize();
|
||||
}
|
||||
16
bin/empty.cpp
Normal file
16
bin/empty.cpp
Normal file
@@ -0,0 +1,16 @@
|
||||
#include "bench/bench.hpp"
|
||||
|
||||
#include <mpi.h>
|
||||
|
||||
void empty(bench::State &state) {
|
||||
for (auto _ : state) {
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
bench::init(argc, argv);
|
||||
bench::register_bench("empty", empty)->timing_root_rank()->no_iter_barrier();
|
||||
bench::run_benchmarks();
|
||||
bench::finalize();
|
||||
}
|
||||
38
bin/pingpong.cpp
Normal file
38
bin/pingpong.cpp
Normal 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();
|
||||
}
|
||||
Reference in New Issue
Block a user