Blame test/util/timer/timers.c
|
Packit |
0848f5 |
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
|
|
Packit |
0848f5 |
/*
|
|
Packit |
0848f5 |
* (C) 2004 by Argonne National Laboratory.
|
|
Packit |
0848f5 |
* See COPYRIGHT in top-level directory.
|
|
Packit |
0848f5 |
*/
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
#include <stdio.h>
|
|
Packit |
0848f5 |
#include <stdlib.h>
|
|
Packit |
0848f5 |
#include "mpi.h"
|
|
Packit |
0848f5 |
#include "test.h"
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
int main( int argc, char **argv )
|
|
Packit |
0848f5 |
{
|
|
Packit |
0848f5 |
int err = 0;
|
|
Packit |
0848f5 |
double t1, t2;
|
|
Packit |
0848f5 |
double tick;
|
|
Packit |
0848f5 |
int i;
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
MPI_Init( &argc, &argv );
|
|
Packit |
0848f5 |
t1 = MPI_Wtime();
|
|
Packit |
0848f5 |
t2 = MPI_Wtime();
|
|
Packit |
0848f5 |
if (t2 - t1 > 0.1 || t2 - t1 < 0.0) {
|
|
Packit |
0848f5 |
err++;
|
|
Packit |
0848f5 |
fprintf( stderr,
|
|
Packit |
0848f5 |
"Two successive calls to MPI_Wtime gave strange results: (%f) (%f)\n",
|
|
Packit |
0848f5 |
t1, t2 );
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
/* Try several times to get a 1 second sleep */
|
|
Packit |
0848f5 |
for (i = 0; i<10; i++) {
|
|
Packit |
0848f5 |
t1 = MPI_Wtime();
|
|
Packit |
0848f5 |
sleep(1);
|
|
Packit |
0848f5 |
t2 = MPI_Wtime();
|
|
Packit |
0848f5 |
if (t2 - t1 >= (1.0 - 0.01) && t2 - t1 <= 5.0) break;
|
|
Packit |
0848f5 |
if (t2 - t1 > 5.0) i = 9;
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
if (i == 10) {
|
|
Packit |
0848f5 |
fprintf( stderr,
|
|
Packit |
0848f5 |
"Timer around sleep(1) did not give 1 second; gave %f\n",
|
|
Packit |
0848f5 |
t2 - t1 );
|
|
Packit |
0848f5 |
fprintf( stderr, "If the sigchk check shows that SIGALRM is in use, \n\
|
|
Packit |
0848f5 |
this indicates only that user programs must NOT use any system call or\n\
|
|
Packit |
0848f5 |
library that uses SIGALRM. SIGALRM is not used by MPICH but may be used\n\
|
|
Packit |
0848f5 |
by the software the MPICH uses to implement communication to other \n\
|
|
Packit |
0848f5 |
processes\n" );
|
|
Packit |
0848f5 |
err++;
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
tick = MPI_Wtick();
|
|
Packit |
0848f5 |
if (tick > 1.0 || tick < 0.0) {
|
|
Packit |
0848f5 |
err++;
|
|
Packit |
0848f5 |
fprintf( stderr, "MPI_Wtick gave a strange result: (%f)\n", tick );
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
Test_Waitforall( );
|
|
Packit |
0848f5 |
MPI_Finalize( );
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
return err;
|
|
Packit |
0848f5 |
}
|