Add plotting code

This commit is contained in:
daviddoji 2021-04-13 20:44:16 +02:00
parent 533d805d98
commit cc2614d7d2

View File

@ -11,7 +11,15 @@ int main(int argc, char *argv[]) // ping pong
{
int size, rank, partner, i, count, r, repetitions;
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_Comm_size(MPI_COMM_WORLD, &size);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
@ -47,8 +55,10 @@ int main(int argc, char *argv[]) // ping pong
time = 1e6 * time; // micro-seconds
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);
}
count = count * 2;
repetitions = repetitions / 2;
}