-
Notifications
You must be signed in to change notification settings - Fork 0
/
send_buffer.cpp
48 lines (41 loc) · 1.03 KB
/
send_buffer.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include "prettyprint.hpp"
#include <iostream>
#include <mpi.h>
#include "logging.hpp"
/// Tests the amount of data that can be send, without a matching receive.
void Send()
{
double sizeofint = sizeof(int) / 1024.0;
INFO << "sizeof(int) = " << sizeof(int);
int i = 0;
while (true) {
INFO << "Iteration " << i << ", data send = " << i * sizeofint << " KB";
MPI_Send(&i, 1, MPI_INT, 1, 0, MPI_COMM_WORLD);
++i;
}
}
/// Tests the amount of data that can be send, without a matching receive.
void Isend()
{
double sizeofint = sizeof(int) / 1024.0;
INFO << "sizeof(int) = " << sizeof(int);
int i = 0;
while (true) {
INFO << "Iteration " << i << ", data send = " << i * sizeofint << " KB";
MPI_Request req;
MPI_Isend(&i, 1, MPI_INT, 1, 0, MPI_COMM_WORLD, &req);
MPI_Wait(&req, MPI_STATUS_IGNORE);
++i;
}
}
int main(int argc, char **argv)
{
MPI_Init(&argc, &argv);
logging::init(true);
int rank;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if (rank == 0) {
Send();
}
MPI_Finalize();
}