hello,
I am running experiments to measure execution times of
several MPI_Send()one from several nodes at once to one
receiving node.
The performance timing gives strange jumps sporadically
from 1000 microsecs up to 200,000 microsecs in the range
of 8k to 65536 message sizes, then is fine, a straight
line.
I am wondering if this is due to 'unsafe' programming,
that is I do not take system buffering into account when
sending a number of messages together to one node?
Most of the time the timing is predictable but for 10-20%
it jumps very high, I am increasing my message sizes at
one byte at a time, all messages sent are the same size.
My code is:
#include "mpi.h"
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <math.h>
#include <unistd.h>
#include <math.h>
#include <string.h>
#include <time.h>
main(int argc, char *argv[])
{
int myid, numprocs, i, ibytes;
MPI_Status reqstat;
char *s_buf, *r_buf;
FILE *file;
double *buffer;
int nodes=atoi(argv[2]);
int size=atoi(argv[3]);
//int size=1;
double t_start = 0.0, t_end = 0.0;
double latency = 0.0;
int ierr;
MPI_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &numprocs);
MPI_Comm_rank(MPI_COMM_WORLD, &myid);
file = fopen(argv[1], "a");
if (file == NULL) {
fprintf(stderr, "LogP: cannot open '%s' for writing\n",
argv[1]);
return MPI_ERR_INTERN;
}
//for(size = 14001; size < 20000; size=size++)
//for(size = 20001; size < 30000; size=size++)
//for(size = 30001; size < 40000; size=size++)
//for(size = 40001; size < 50000; size=size++)
//for(size = 50001; size < 60000; size=size++)
//for(size = 60001; size < 70000; size=size++)
//for(size = 1024; size < 101376; size=size+10)
//for(size = 1024; size < 1051648; size=size+1024)
// {
// touch the data
if (myid>0){
s_buf = (char *)malloc(sizeof(char)*size);
for (i = 0; i < size; i++)
s_buf[i] = 'a';
}
if (myid==0){
r_buf = (char *)malloc(sizeof(char)*nodes*size);
for (i = 0; i < size*nodes; i++)
r_buf[i] = 'b';
}
MPI_Barrier(MPI_COMM_WORLD);
t_start = MPI_Wtime();
if ((myid >0) && (myid <= nodes)) {
MPI_Send(s_buf, size, MPI_CHAR, 0, 1, MPI_COMM_WORLD);
}
if (myid ==0) {
for (i = 1; i <= nodes; i++) {
ierr= MPI_Recv(r_buf+(i-1)*size, size, MPI_CHAR,
MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD,
&reqstat);
}
t_end = MPI_Wtime();
if(ierr!=0){ fprintf(file, "error receiving\n");}
else {free(r_buf);}
if (myid !=0) {
free(s_buf);
}
if (myid ==0) {
latency = (t_end - t_start) * 1.0e6 ;
fprintf(file, "%0.2f\n", latency);
// printf( "%d ", size);
// printf( "%0.2f\n", latency);
}
}
// } //size loop
fclose(file);
MPI_Finalize();
}
--------------------------------------------
thanks,
Maureen
|