Add plotting code
This commit is contained in:
@@ -12,6 +12,14 @@ int main(int argc, char *argv[]) // ping pong
|
|||||||
int size, rank, partner, i, count, r, repetitions;
|
int size, rank, partner, i, count, r, repetitions;
|
||||||
double time, bandwidth;
|
double time, bandwidth;
|
||||||
|
|
||||||
|
FILE *fp;
|
||||||
|
fp = fopen("data.dat", "w");
|
||||||
|
if (!fp) {
|
||||||
|
printf("file could not be opened\n");
|
||||||
|
getchar();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
MPI_Init(&argc, &argv);
|
MPI_Init(&argc, &argv);
|
||||||
MPI_Comm_size(MPI_COMM_WORLD, &size);
|
MPI_Comm_size(MPI_COMM_WORLD, &size);
|
||||||
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
|
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
|
||||||
@@ -47,8 +55,10 @@ int main(int argc, char *argv[]) // ping pong
|
|||||||
time = 1e6 * time; // micro-seconds
|
time = 1e6 * time; // micro-seconds
|
||||||
bandwidth = count * sizeof(double) / time; // MByte/s
|
bandwidth = count * sizeof(double) / time; // MByte/s
|
||||||
|
|
||||||
if (rank == 0)
|
if (rank == 0) {
|
||||||
|
fprintf(fp, "%12zd %12d %12.2f %12.2f\n", count * sizeof(double), repetitions, time, bandwidth);
|
||||||
printf("%12zd %12d %12.2f %12.2f\n", count * sizeof(double), repetitions, time, bandwidth);
|
printf("%12zd %12d %12.2f %12.2f\n", count * sizeof(double), repetitions, time, bandwidth);
|
||||||
|
}
|
||||||
count = count * 2;
|
count = count * 2;
|
||||||
repetitions = repetitions / 2;
|
repetitions = repetitions / 2;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user