Commit 55de6c80 authored by Ben Hazelwood's avatar Ben Hazelwood
Browse files

Tidy up PerfSimulator

parent 772a01a6
...@@ -16,49 +16,23 @@ const int NUM_COMPUTATIONS = 5e7; ...@@ -16,49 +16,23 @@ const int NUM_COMPUTATIONS = 5e7;
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
MPI_Init(&argc, &argv); MPI_Init(&argc, &argv);
// if (argc != 3)
// {
// std::cout << "Usage: mpirun Latency <NUM TRIALS> <NUM COMPUTATIONS>\n";
// MPI_Abort(MPI_COMM_WORLD, 1);
// }
int rank;
int size;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
const int source = 0;
const int dest = size - 1;
char m = '0';
for (int t = 0; t < NUM_TRIALS; t++) for (int t = 0; t < NUM_TRIALS; t++)
{ {
MPI_Barrier(MPI_COMM_WORLD); MPI_Barrier(MPI_COMM_WORLD);
#ifdef COMPARE_PROGRESS #ifdef COMPARE_PROGRESS
MPI_Sendrecv(MPI_IN_PLACE, 0, MPI_BYTE, MPI_PROC_NULL, 0, MPI_IN_PLACE, 0, MPI_BYTE, MPI_PROC_NULL, 0, MPI_COMM_SELF, MPI_STATUS_IGNORE); MPI_Sendrecv(MPI_IN_PLACE, 0, MPI_BYTE, MPI_PROC_NULL, -1, MPI_IN_PLACE, 0, MPI_BYTE, MPI_PROC_NULL, 0, MPI_COMM_SELF, MPI_STATUS_IGNORE);
#endif #endif
for (int i = 0; i < NUM_COMPUTATIONS; i++) { for (int i = 0; i < NUM_COMPUTATIONS; i++) {
sin(1.0/3.0); sin(1.0/3.0); // Arbitrary computation (the compiler shouldn't optimise it out...)
} }
#ifdef COMPARE_PROGRESS #ifdef COMPARE_PROGRESS
MPI_Sendrecv(MPI_IN_PLACE, 0, MPI_BYTE, MPI_PROC_NULL, 1, MPI_IN_PLACE, 0, MPI_BYTE, MPI_PROC_NULL, 0, MPI_COMM_SELF, MPI_STATUS_IGNORE); MPI_Sendrecv(MPI_IN_PLACE, 0, MPI_BYTE, MPI_PROC_NULL, 1, MPI_IN_PLACE, 0, MPI_BYTE, MPI_PROC_NULL, 0, MPI_COMM_SELF, MPI_STATUS_IGNORE);
#endif #endif
MPI_Barrier(MPI_COMM_WORLD); MPI_Barrier(MPI_COMM_WORLD);
// if (rank == source)
// {
// MPI_Recv(&m, 1, MPI_CHAR, source, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
// }
// else
// {
// MPI_Send(&m, 1, MPI_CHAR, dest, 0, MPI_COMM_WORLD);
// }
} }
MPI_Finalize(); MPI_Finalize();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment