Commit a66b21dc authored by Mathieu Faverge's avatar Mathieu Faverge

Factorize timer

parent 32181183
......@@ -47,9 +47,7 @@
#include <sys/resource.h>
#endif
/* Common functions for all steps of the tutorial */
static void get_thread_count(int *thrdnbr) {
#if defined WIN32 || defined WIN64
sscanf( getenv( "NUMBER_OF_PROCESSORS" ), "%d", thrdnbr );
......@@ -65,7 +63,6 @@ static int startswith(const char *s, const char *prefix) {
return 1;
}
/* define complexity of algorithms - see Lawn 41 page 120 */
#define FMULS_POTRF(__n) ((double)(__n) * (((1. / 6.) * (double)(__n) + 0.5) * (double)(__n) + (1. / 3.)))
#define FADDS_POTRF(__n) ((double)(__n) * (((1. / 6.) * (double)(__n) ) * (double)(__n) - (1. / 6.)))
......@@ -73,68 +70,6 @@ static int startswith(const char *s, const char *prefix) {
#define FADDS_TRSM(__m, __n) (0.5 * (double)(__n) * (double)(__m) * ((double)(__m)-1.))
/* define some tools to time the program */
#if defined( _WIN32 ) || defined( _WIN64 )
#include <windows.h>
#include <time.h>
#include <sys/timeb.h>
#if defined(_MSC_VER) || defined(_MSC_EXTENSIONS)
#define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64
#else
#define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL
#endif
struct timezone
{
int tz_minuteswest; /* minutes W of Greenwich */
int tz_dsttime; /* type of dst correction */
};
int gettimeofday(struct timeval* tv, struct timezone* tz)
{
FILETIME ft;
unsigned __int64 tmpres = 0;
static int tzflag;
if (NULL != tv)
{
GetSystemTimeAsFileTime(&ft);
tmpres |= ft.dwHighDateTime;
tmpres <<= 32;
tmpres |= ft.dwLowDateTime;
/*converting file time to unix epoch*/
tmpres /= 10; /*convert into microseconds*/
tmpres -= DELTA_EPOCH_IN_MICROSECS;
tv->tv_sec = (long)(tmpres / 1000000UL);
tv->tv_usec = (long)(tmpres % 1000000UL);
}
if (NULL != tz)
{
if (!tzflag)
{
_tzset();
tzflag++;
}
tz->tz_minuteswest = _timezone / 60;
tz->tz_dsttime = _daylight;
}
return 0;
}
#else /* Non-Windows */
#include <sys/time.h>
#endif
/*
* struct timeval {time_t tv_sec; suseconds_t tv_usec;};
*/
double cWtime(void)
{
struct timeval tp;
gettimeofday( &tp, NULL );
return tp.tv_sec + 1e-6 * tp.tv_usec;
}
#include <chameleon/chameleon_timer.h>
#endif /* LAPACK_TO_MORSE_H */
......@@ -98,7 +98,7 @@ int main(int argc, char *argv[]) {
/* solve the system AX = B using the Cholesky factorization */
/************************************************************/
cpu_time = -cWtime();
cpu_time = -CHAMELEON_timer();
/* Cholesky factorization:
* A is replaced by its factorization L or L^T depending on uplo */
......@@ -124,7 +124,7 @@ int main(int argc, char *argv[]) {
CblasNonUnit,
N, NRHS, 1.0, A, N, X, N);
cpu_time += cWtime();
cpu_time += CHAMELEON_timer();
/* print informations to user */
gflops = flops / cpu_time;
......
......@@ -120,7 +120,7 @@ int main(int argc, char *argv[]) {
/* solve the system AX = B using the Cholesky factorization */
/************************************************************/
cpu_time = -cWtime();
cpu_time = -CHAMELEON_timer();
/* Cholesky factorization:
* A is replaced by its factorization L or L^T depending on uplo */
......@@ -132,7 +132,7 @@ int main(int argc, char *argv[]) {
*/
MORSE_dpotrs(UPLO, N, NRHS, A, N, X, N);
cpu_time += cWtime();
cpu_time += CHAMELEON_timer();
/* print informations to user */
gflops = flops / cpu_time;
......
......@@ -164,7 +164,7 @@ int main(int argc, char *argv[]) {
/* solve the system AX = B using the Cholesky factorization */
/************************************************************/
cpu_time = -cWtime();
cpu_time = -CHAMELEON_timer();
/* Cholesky factorization:
* A is replaced by its factorization L or L^T depending on uplo */
......@@ -176,7 +176,7 @@ int main(int argc, char *argv[]) {
*/
MORSE_dpotrs_Tile( UPLO, descA, descX );
cpu_time += cWtime();
cpu_time += CHAMELEON_timer();
/* print informations to user */
gflops = flops / cpu_time;
......
......@@ -147,7 +147,7 @@ int main(int argc, char *argv[]) {
/* solve the system AX = B using the Cholesky factorization */
/************************************************************/
cpu_time = -cWtime();
cpu_time = -CHAMELEON_timer();
/* Cholesky factorization:
* A is replaced by its factorization L or L^T depending on uplo */
......@@ -159,7 +159,7 @@ int main(int argc, char *argv[]) {
*/
MORSE_dpotrs_Tile( UPLO, descA, descX );
cpu_time += cWtime();
cpu_time += CHAMELEON_timer();
/* print informations to user */
gflops = flops / cpu_time;
......
......@@ -127,7 +127,7 @@ int main(int argc, char *argv[]) {
/* solve the system AX = B using the Cholesky factorization */
/************************************************************/
cpu_time = -cWtime();
cpu_time = -CHAMELEON_timer();
MORSE_Sequence_Create(&sequence);
......@@ -157,7 +157,7 @@ int main(int argc, char *argv[]) {
}
MORSE_Sequence_Destroy(sequence);
cpu_time += cWtime();
cpu_time += CHAMELEON_timer();
/* print informations to user */
gflops = flops / cpu_time;
......
......@@ -131,7 +131,7 @@ int main(int argc, char *argv[]) {
/* solve the system AX = B using the Cholesky factorization */
/************************************************************/
cpu_time = -cWtime();
cpu_time = -CHAMELEON_timer();
MORSE_Sequence_Create(&sequence);
......@@ -161,7 +161,7 @@ int main(int argc, char *argv[]) {
}
MORSE_Sequence_Destroy(sequence);
cpu_time += cWtime();
cpu_time += CHAMELEON_timer();
/* print informations to user */
gflops = flops / cpu_time;
......
......@@ -153,7 +153,7 @@ int main(int argc, char *argv[]) {
/* solve the system AX = B using the Cholesky factorization */
/************************************************************/
cpu_time = -cWtime();
cpu_time = -CHAMELEON_timer();
MORSE_Sequence_Create(&sequence);
......@@ -183,7 +183,7 @@ int main(int argc, char *argv[]) {
}
MORSE_Sequence_Destroy(sequence);
cpu_time += cWtime();
cpu_time += CHAMELEON_timer();
/* print informations to user */
gflops = flops / cpu_time;
......
......@@ -161,7 +161,7 @@ int main(int argc, char *argv[]) {
/* solve the system AX = B using the Cholesky factorization */
/************************************************************/
cpu_time = -cWtime();
cpu_time = -CHAMELEON_timer();
MORSE_Sequence_Create(&sequence);
......@@ -191,7 +191,7 @@ int main(int argc, char *argv[]) {
}
MORSE_Sequence_Destroy(sequence);
cpu_time += cWtime();
cpu_time += CHAMELEON_timer();
/* print informations to user */
gflops = flops / cpu_time;
......
......@@ -37,69 +37,6 @@ static int startswith(const char *s, const char *prefix) {
#define FMULS_TRSM(__m, __n) (0.5 * (double)(__n) * (double)(__m) * ((double)(__m)+1.))
#define FADDS_TRSM(__m, __n) (0.5 * (double)(__n) * (double)(__m) * ((double)(__m)-1.))
/* define some tools to time the program */
#if defined( _WIN32 ) || defined( _WIN64 )
#include <windows.h>
#include <time.h>
#include <sys/timeb.h>
#if defined(_MSC_VER) || defined(_MSC_EXTENSIONS)
#define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64
#else
#define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL
#endif
struct timezone
{
int tz_minuteswest; /* minutes W of Greenwich */
int tz_dsttime; /* type of dst correction */
};
int gettimeofday(struct timeval* tv, struct timezone* tz)
{
FILETIME ft;
unsigned __int64 tmpres = 0;
static int tzflag;
if (NULL != tv)
{
GetSystemTimeAsFileTime(&ft);
tmpres |= ft.dwHighDateTime;
tmpres <<= 32;
tmpres |= ft.dwLowDateTime;
/*converting file time to unix epoch*/
tmpres /= 10; /*convert into microseconds*/
tmpres -= DELTA_EPOCH_IN_MICROSECS;
tv->tv_sec = (long)(tmpres / 1000000UL);
tv->tv_usec = (long)(tmpres % 1000000UL);
}
if (NULL != tz)
{
if (!tzflag)
{
_tzset();
tzflag++;
}
tz->tz_minuteswest = _timezone / 60;
tz->tz_dsttime = _daylight;
}
return 0;
}
#else /* Non-Windows */
#include <sys/time.h>
#endif
/*
* struct timeval {time_t tv_sec; suseconds_t tv_usec;};
*/
double cWtime(void)
{
struct timeval tp;
gettimeofday( &tp, NULL );
return tp.tv_sec + 1e-6 * tp.tv_usec;
}
#include <coreblas/lapacke.h>
#include <morse.h>
......@@ -288,7 +225,7 @@ int main(int argc, char *argv[]) {
/* solve the system AX = B using the Cholesky factorization */
/************************************************************/
cpu_time = -cWtime();
cpu_time = -CHAMELEON_timer();
/* Cholesky facorization:
* A is replaced by its factorization L or L^T depending on uplo */
......@@ -300,7 +237,7 @@ int main(int argc, char *argv[]) {
*/
MORSE_dpotrs(UPLO, N, NRHS, A, N, X, N);
cpu_time += cWtime();
cpu_time += CHAMELEON_timer();
/* print informations to user */
gflops = flops / cpu_time;
......
......@@ -132,7 +132,7 @@ int main(int argc, char *argv[]) {
/* solve the system AX = B using the Cholesky factorization */
/************************************************************/
cpu_time = -cWtime();
cpu_time = -CHAMELEON_timer();
/* Cholesky factorization:
* A is replaced by its factorization L or L^T depending on uplo */
......@@ -144,7 +144,7 @@ int main(int argc, char *argv[]) {
*/
MORSE_dpotrs_Tile( UPLO, descA, descX );
cpu_time += cWtime();
cpu_time += CHAMELEON_timer();
/* print informations to user */
gflops = flops / cpu_time;
......
......@@ -77,68 +77,7 @@ static int startswith(const char *s, const char *prefix) {
#define FADDS_TRSM(__m, __n) (0.5 * (double)(__n) * (double)(__m) * ((double)(__m)-1.))
/* define some tools to time the program */
#if defined( _WIN32 ) || defined( _WIN64 )
#include <windows.h>
#include <time.h>
#include <sys/timeb.h>
#if defined(_MSC_VER) || defined(_MSC_EXTENSIONS)
#define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64
#else
#define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL
#endif
struct timezone
{
int tz_minuteswest; /* minutes W of Greenwich */
int tz_dsttime; /* type of dst correction */
};
int gettimeofday(struct timeval* tv, struct timezone* tz)
{
FILETIME ft;
unsigned __int64 tmpres = 0;
static int tzflag;
if (NULL != tv)
{
GetSystemTimeAsFileTime(&ft);
tmpres |= ft.dwHighDateTime;
tmpres <<= 32;
tmpres |= ft.dwLowDateTime;
/*converting file time to unix epoch*/
tmpres /= 10; /*convert into microseconds*/
tmpres -= DELTA_EPOCH_IN_MICROSECS;
tv->tv_sec = (long)(tmpres / 1000000UL);
tv->tv_usec = (long)(tmpres % 1000000UL);
}
if (NULL != tz)
{
if (!tzflag)
{
_tzset();
tzflag++;
}
tz->tz_minuteswest = _timezone / 60;
tz->tz_dsttime = _daylight;
}
return 0;
}
#else /* Non-Windows */
#include <sys/time.h>
#endif
/*
* struct timeval {time_t tv_sec; suseconds_t tv_usec;};
*/
double cWtime(void)
{
struct timeval tp;
gettimeofday( &tp, NULL );
return tp.tv_sec + 1e-6 * tp.tv_usec;
}
#include <chameleon/chameleon_timer.h>
/* Integer parameters */
enum iparam_ooc {
......
/**
*
* @copyright 2009-2014 The University of Tennessee and The University of
* Tennessee Research Foundation. All rights reserved.
* @copyright 2012-2017 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
* Univ. Bordeaux. All rights reserved.
*
* @file chameleon_timer.h
*
* Provide a simple timer for examples and runtimes which do not provide their
* own timer.
*
**/
#ifndef _chameleon_timer_h_
#define _chameleon_timer_h_
#if defined( _WIN32 ) || defined( _WIN64 )
#include <windows.h>
#include <time.h>
#include <sys/timeb.h>
#if defined(_MSC_VER) || defined(_MSC_EXTENSIONS)
#define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64
#else
#define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL
#endif
struct timezone
{
int tz_minuteswest; /* minutes W of Greenwich */
int tz_dsttime; /* type of dst correction */
};
static inline int
gettimeofday(struct timeval* tv, struct timezone* tz)
{
FILETIME ft;
unsigned __int64 tmpres = 0;
static int tzflag;
if (NULL != tv)
{
GetSystemTimeAsFileTime(&ft);
tmpres |= ft.dwHighDateTime;
tmpres <<= 32;
tmpres |= ft.dwLowDateTime;
/*converting file time to unix epoch*/
tmpres /= 10; /*convert into microseconds*/
tmpres -= DELTA_EPOCH_IN_MICROSECS;
tv->tv_sec = (long)(tmpres / 1000000UL);
tv->tv_usec = (long)(tmpres % 1000000UL);
}
if (NULL != tz)
{
if (!tzflag)
{
_tzset();
tzflag++;
}
tz->tz_minuteswest = _timezone / 60;
tz->tz_dsttime = _daylight;
}
return 0;
}
#else /* Non-Windows */
#include <sys/time.h>
#endif
/**
* @brief Return a simple timestamp in s.
*
* @return The timestamp in s without any barriers.
*/
static inline double
CHAMELEON_timer(void)
{
struct timeval tp;
gettimeofday( &tp, NULL );
return tp.tv_sec + 1e-6 * tp.tv_usec;
}
#endif /* _chameleon_timer_h_ */
......@@ -8,74 +8,10 @@
*
**/
#include "chameleon_parsec.h"
#if defined( _WIN32 ) || defined( _WIN64 )
#include <windows.h>
#include <time.h>
#include <sys/timeb.h>
#if defined(_MSC_VER) || defined(_MSC_EXTENSIONS)
#define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64
#else
#define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL
#endif
struct timezone
{
int tz_minuteswest; /* minutes W of Greenwich */
int tz_dsttime; /* type of dst correction */
};
int gettimeofday(struct timeval* tv, struct timezone* tz)
{
FILETIME ft;
unsigned __int64 tmpres = 0;
static int tzflag;
if (NULL != tv)
{
GetSystemTimeAsFileTime(&ft);
tmpres |= ft.dwHighDateTime;
tmpres <<= 32;
tmpres |= ft.dwLowDateTime;
/*converting file time to unix epoch*/
tmpres /= 10; /*convert into microseconds*/
tmpres -= DELTA_EPOCH_IN_MICROSECS;
tv->tv_sec = (long)(tmpres / 1000000UL);
tv->tv_usec = (long)(tmpres % 1000000UL);
}
if (NULL != tz)
{
if (!tzflag)
{
_tzset();
tzflag++;
}
tz->tz_minuteswest = _timezone / 60;
tz->tz_dsttime = _daylight;
}
return 0;
}
#else /* Non-Windows */
#include <sys/time.h>
#endif
double cWtime(void);
/*
* struct timeval {time_t tv_sec; suseconds_t tv_usec;};
*/
double cWtime(void)
{
struct timeval tp;
gettimeofday( &tp, NULL );
return tp.tv_sec + 1e-6 * tp.tv_usec;
}
#include "chameleon_timer.h"
double RUNTIME_get_time(){
return cWtime();
return CHAMELEON_timer();
}
void RUNTIME_start_profiling()
......
......@@ -47,9 +47,9 @@ void CORE_ztile_zero_quark(Quark *quark)
}
void MORSE_TASK_ztile_zero(const MORSE_option_t *options,
int X1, int X2, int Y1, int Y2,
const MORSE_desc_t *A, int Am, int An, int lda)
void MORSE_TASK_ztile_zero( const MORSE_option_t *options,
int X1, int X2, int Y1, int Y2,
const MORSE_desc_t *A, int Am, int An, int lda )
{
quark_option_t *opt = (quark_option_t*)(options->schedopt);
QUARK_Insert_Task(opt->quark, CORE_ztile_zero_quark, (Quark_Task_Flags*)opt,
......
......@@ -18,74 +18,10 @@
*
**/
#include "chameleon_quark.h"
#if defined( _WIN32 ) || defined( _WIN64 )
#include <windows.h>
#include <time.h>
#include <sys/timeb.h>
#if defined(_MSC_VER) || defined(_MSC_EXTENSIONS)
#define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64
#else
#define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL
#endif
struct timezone
{
int tz_minuteswest; /* minutes W of Greenwich */
int tz_dsttime; /* type of dst correction */
};
int gettimeofday(struct timeval* tv, struct timezone* tz)
{
FILETIME ft;
unsigned __int64 tmpres = 0;
static int tzflag;
if (NULL != tv)
{
GetSystemTimeAsFileTime(&ft);
tmpres |= ft.dwHighDateTime;
tmpres <<= 32;
tmpres |= ft.dwLowDateTime;
/*converting file time to unix epoch*/
tmpres /= 10; /*convert into microseconds*/
tmpres -= DELTA_EPOCH_IN_MICROSECS;
tv->tv_sec = (long)(tmpres / 1000000UL);
tv->tv_usec = (long)(tmpres % 1000000UL);
}
if (NULL != tz)
{
if (!tzflag)
{
_tzset();
tzflag++;
}
tz->tz_minuteswest = _timezone / 60;
tz->tz_dsttime = _daylight;
}
return 0;
}
#else /* Non-Windows */
#include <sys/time.h>
#endif
double cWtime(void);
/*
* struct timeval {time_t tv_sec; suseconds_t tv_usec;};
*/
double cWtime(void)
{
struct timeval tp;
gettimeofday( &tp, NULL );
return tp.tv_sec + 1e-6 * tp.tv_usec;
}
#include "chameleon/chameleon_timer.h"
double RUNTIME_get_time(){
return cWtime();
return CHAMELEON_timer();
}
void RUNTIME_start_profiling()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment