Example #1
0
double MPID_Wtick( void )
{
    MPIU_THREADSAFE_INIT_DECL(initTick);
    static double tickval = -1.0;
    double timediff;  /* Keep compiler happy about timediff set before use*/
    MPID_Time_t t1, t2;
    int    cnt;
    int    icnt;

    if (initTick) {
	MPIU_THREADSAFE_INIT_BLOCK_BEGIN(initTick);
	tickval = 1.0e6;
	for (icnt=0; icnt<10; icnt++) {
	    cnt = 1000;
	    MPID_Wtime( &t1 );
	    /* Make it abundently clear to the compiler that this block is
	       executed at least once. */
	    do {
		MPID_Wtime( &t2 );
		MPID_Wtime_diff( &t1, &t2, &timediff );
		if (timediff > 0) break;
	    }
	    while (cnt--);
	    if (cnt && timediff > 0.0 && timediff < tickval) {
		MPID_Wtime_diff( &t1, &t2, &tickval );
	    }
	}
	MPIU_THREADSAFE_INIT_CLEAR(initTick);
	MPIU_THREADSAFE_INIT_BLOCK_END(initTick);
    }
    return tickval;
}
Example #2
0
int MPID_Wtime_init( void )
{
    MPID_Time_t t1, t2;
    DWORD s1, s2;
    double d;
    int i;

    MPID_Wtime(&t1);
    MPID_Wtime(&t1);

    /* time an interval using both timers */
    s1 = GetTickCount();
    MPID_Wtime(&t1);
    /*Sleep(250);*/ /* Sleep causes power saving cpu's to stop which stops the counter */
    while (GetTickCount() - s1 < 200)
    {
	for (i=2; i<1000; i++)
	    d = (double)i / (double)(i-1);
    }
    s2 = GetTickCount();
    MPID_Wtime(&t2);

    /* calculate the frequency of the assembly cycle counter */
    MPID_Seconds_per_tick = ((double)(s2 - s1) / 1000.0) / (double)((__int64)(t2 - t1));
    /*
    printf("t2-t1 %10d\nsystime diff %d\nfrequency %g\n CPU MHz %g\n", 
	(int)(t2-t1), (int)(s2 - s1), MPID_Seconds_per_tick, MPID_Seconds_per_tick * 1.0e6);
    */
    return 0;
}
Example #3
0
FORT_DLL_SPEC double FORT_CALL mpi_wtime_ ( void ) {
    double d; MPID_Time_t t;

    MPID_Wtime( &t );
    MPID_Wtime_todouble( &t, &d );
    return d;
}
Example #4
0
static double RLOG_timestamp(void)
{
    double d;
    MPID_Time_t t;
    MPID_Wtime(&t);
    MPID_Wtime_todouble(&t, &d);
    return d;
}
Example #5
0
int MPID_Wtime_init(void)
{
    unsigned long long t1, t2;
    struct timeval tv1, tv2;
    double td1, td2;

    gettimeofday(&tv1, NULL);
    MPID_Wtime(&t1);
    usleep(250000);
    gettimeofday(&tv2, NULL);
    MPID_Wtime(&t2);

    td1 = tv1.tv_sec + tv1.tv_usec / 1000000.0;
    td2 = tv2.tv_sec + tv2.tv_usec / 1000000.0;

    MPID_Seconds_per_tick = (td2 - td1) / (double)(t2 - t1);
    return 0;
}
Example #6
0
/*@
  MPI_Wtime - Returns an elapsed time on the calling processor

  Return value:
  Time in seconds since an arbitrary time in the past.

  Notes:
  This is intended to be a high-resolution, elapsed (or wall) clock.
  See 'MPI_WTICK' to determine the resolution of 'MPI_WTIME'.
  If the attribute 'MPI_WTIME_IS_GLOBAL' is defined and true, then the
  value is synchronized across all processes in 'MPI_COMM_WORLD'.  

  Notes for Fortran:
  This is a function, declared as 'DOUBLE PRECISION MPI_WTIME()' in Fortran.

.see also: MPI_Wtick, MPI_Comm_get_attr, MPI_Attr_get
@*/
double MPI_Wtime( void )
{
    double d;
    MPID_Time_t t;
    MPID_MPI_STATE_DECL(MPID_STATE_MPI_WTIME);

    MPIR_ERRTEST_INITIALIZED_ORDIE();

    MPID_MPI_FUNC_ENTER(MPID_STATE_MPI_WTIME);
    MPID_Wtime( &t );
    MPID_Wtime_todouble( &t, &d );
    MPID_MPI_FUNC_EXIT(MPID_STATE_MPI_WTIME);

    return d;
}