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