Skip to content

Commit 088caf1

Browse files
authored
Release 11.5.0.0.172
Signed-off-by: Scott Breyer <[email protected]>
1 parent ae65353 commit 088caf1

File tree

10 files changed

+303
-173
lines changed

10 files changed

+303
-173
lines changed

MpiApps/apps/latency/latency.c

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22
#include <stdio.h>
33
#include <stdlib.h>
44
#include <math.h>
5+
#include <limits.h>
56

67

78
#define MYBUFSIZE 4*1024*1025
9+
#define WARMING_LOOPS 10
10+
#define MAX_LOOPS (INT_MAX - WARMING_LOOPS)
811
char s_buf[MYBUFSIZE];
912
char r_buf[MYBUFSIZE];
1013

11-
int skip = 10;
12-
1314
int main(int argc,char *argv[])
1415
{
1516
int myid, numprocs, i;
@@ -28,15 +29,20 @@ int main(int argc,char *argv[])
2829
MPI_Finalize();
2930
return 0;
3031
}
31-
size=atoi(argv[2]);
3232

3333
loop = atoi(argv[1]);
34+
if ((loop < 0) || (loop > MAX_LOOPS)) {
35+
fprintf(stderr, "Maximum loops count is %d, minimum is 0\n", MAX_LOOPS);
36+
MPI_Finalize();
37+
return 0;
38+
}
3439

35-
if(size > MYBUFSIZE){
36-
fprintf(stderr, "Maximum message size is %d\n",MYBUFSIZE);
37-
MPI_Finalize();
38-
return 0;
39-
}
40+
size=atoi(argv[2]);
41+
if ((size < 0) || (size > MYBUFSIZE)) {
42+
fprintf(stderr, "Maximum message size is %d, minimum is 0\n", MYBUFSIZE);
43+
MPI_Finalize();
44+
return 0;
45+
}
4046

4147
/* touch the data */
4248
for ( i=0; i<size; i++ ){
@@ -48,15 +54,15 @@ int main(int argc,char *argv[])
4854

4955
if (myid == 0)
5056
{
51-
for ( i=0; i< loop+skip; i++ ) {
52-
if ( i == skip ) t_start=MPI_Wtime();
57+
for ( i=0; i < loop + WARMING_LOOPS; i++ ) {
58+
if ( i == WARMING_LOOPS ) t_start=MPI_Wtime();
5359
MPI_Send(s_buf, size, MPI_CHAR, 1, i, MPI_COMM_WORLD);
5460
MPI_Recv(r_buf, size, MPI_CHAR, 1, i + 1000, MPI_COMM_WORLD, &stat);
5561
}
5662
t_end=MPI_Wtime();
5763

5864
}else{
59-
for ( i=0; i< loop+skip; i++ ) {
65+
for ( i=0; i < loop + WARMING_LOOPS; i++ ) {
6066
MPI_Recv(r_buf, size, MPI_CHAR, 0, i, MPI_COMM_WORLD, &stat);
6167
MPI_Send(s_buf, size, MPI_CHAR, 0, i + 1000, MPI_COMM_WORLD);
6268
}

0 commit comments

Comments
 (0)