Skip to content

Commit ca0feb5

Browse files
committed
added warm up phase to benchmarks
1 parent 1a5aacc commit ca0feb5

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

benchmark/allreduce_benchmark.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ static void run_mpi_benchmark(options_t* options) {
3232
char* send_buf = malloc(options->msg_size);
3333
char* recv_buf = malloc(options->msg_size);
3434

35+
// warm up
36+
MPI_Allreduce(send_buf, recv_buf, options->msg_size,
37+
MPI_BYTE, MPI_BXOR, MPI_COMM_WORLD);
38+
39+
// benchmark
3540
MPI_Barrier(MPI_COMM_WORLD);
3641
t_start = MPI_Wtime();
3742

@@ -102,6 +107,10 @@ static void run_mona_benchmark(options_t* options) {
102107
char* send_buf = malloc(options->msg_size);
103108
char* recv_buf = malloc(options->msg_size);
104109

110+
// warm up
111+
mona_comm_allreduce(comm, send_buf, recv_buf, 1, options->msg_size,
112+
bxor, NULL, 0);
113+
// benchmark
105114
MPI_Barrier(MPI_COMM_WORLD);
106115
t_start = MPI_Wtime();
107116

benchmark/send_recv_benchmark.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,16 @@ static void run_mpi_benchmark(options_t* options) {
3030

3131
char* buf = malloc(options->msg_size);
3232

33+
// warm up
34+
if(rank % 2 == 0) {
35+
MPI_Send(buf, options->msg_size, MPI_BYTE, (rank+1)%2, 0, MPI_COMM_WORLD);
36+
MPI_Recv(buf, options->msg_size, MPI_BYTE, (rank+1)%2, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
37+
} else {
38+
MPI_Recv(buf, options->msg_size, MPI_BYTE, (rank+1)%2, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
39+
MPI_Send(buf, options->msg_size, MPI_BYTE, (rank+1)%2, 0, MPI_COMM_WORLD);
40+
}
41+
42+
// benchmark
3343
MPI_Barrier(MPI_COMM_WORLD);
3444
t_start = MPI_Wtime();
3545

@@ -76,13 +86,23 @@ static void run_mona_benchmark(options_t* options) {
7686
char other_addr_str[128];
7787
MPI_Sendrecv(addr_str, 128, MPI_BYTE, (rank+1)%2, 0,
7888
other_addr_str, 128, MPI_BYTE, (rank+1)%2, 0,
79-
MPI_COMM_WORLD, MPI_STATUS_IGNORE);
89+
MPI_COMM_WORLD, MPI_STATUS_IGNORE);
8090

8191
ret = mona_addr_lookup(mona, other_addr_str, &addr);
8292
ASSERT_MESSAGE(ret == NA_SUCCESS, "Could not lookup address");
8393

8494
char* buf = malloc(options->msg_size);
8595

96+
// warm up
97+
if(rank % 2 == 0) {
98+
mona_send(mona, buf, options->msg_size, addr, 0, 0);
99+
mona_recv(mona, buf, options->msg_size, addr, 0, NULL, NULL, NULL);
100+
} else {
101+
mona_recv(mona, buf, options->msg_size, addr, 0, NULL, NULL, NULL);
102+
mona_send(mona, buf, options->msg_size, addr, 0, 0);
103+
}
104+
105+
// benchmark
86106
MPI_Barrier(MPI_COMM_WORLD);
87107
t_start = MPI_Wtime();
88108

0 commit comments

Comments
 (0)