Commit 7761fbae authored by Mathieu Faverge's avatar Mathieu Faverge

Merge branch 'runtimes/cleanup' into 'master'

Cleanup the runtime mess

See merge request solverstack/chameleon!76
parents c16e494e a66b21dc
......@@ -107,7 +107,7 @@ void morse_fatal_error(const char *func_name, const char *msg_text)
**/
int morse_rank(MORSE_context_t *morse)
{
return RUNTIME_rank( morse );
return RUNTIME_thread_rank( morse );
}
/*******************************************************************************
......@@ -233,31 +233,36 @@ int MORSE_My_Mpi_Rank(void)
return MORSE_SUCCESS;
#endif
}
/*******************************************************************************
* Display a progress percentage in stderr
**/
void update_progress(int currentValue, int maximumValue) {
div_t res ;
static int progress = -1; /* varie de 0 a 100 au cours du calcul concerne */
div_t res ;
static int progress = -1; /* varie de 0 a 100 au cours du calcul concerne */
if (maximumValue==0)
res.quot=100 ;
else {
if (currentValue<INT_MAX/100)
res=div(currentValue*100, maximumValue) ;
/* Calcule le quotient de la division */
else
res.quot=(int)( (long long) currentValue*100/maximumValue) ;
}
if (maximumValue == 0) {
res.quot = 100;
}
else {
if (currentValue < (INT_MAX / 100) ) {
res = div(currentValue*100, maximumValue);
}
else {
/* Calcule le quotient de la division */
res.quot = (int)( (long long)( currentValue * 100 ) / maximumValue );
}
}
// Print the percentage
if (res.quot > progress)
fprintf(stderr, "%3d%%\b\b\b\b", res.quot) ;
progress=res.quot ;
// Print the percentage
if (res.quot > progress) {
fprintf(stderr, "%3d%%\b\b\b\b", res.quot);
}
progress = res.quot;
if (currentValue>=maximumValue) {
progress=-1 ;
}
if (currentValue >= maximumValue) {
progress = -1;
}
}
// A function to display the progress indicator.
......
......@@ -111,7 +111,7 @@ int MORSE_InitPar(int ncpus, int ncudas, int nthreads_per_worker)
}
# endif
#endif
RUNTIME_init_scheduler( morse, ncpus, ncudas, nthreads_per_worker );
RUNTIME_init( morse, ncpus, ncudas, nthreads_per_worker );
return MORSE_SUCCESS;
}
......@@ -138,7 +138,7 @@ int MORSE_Finalize(void)
# if !defined(CHAMELEON_SIMULATION)
RUNTIME_barrier(morse);
# endif
RUNTIME_finalize_scheduler( morse );
RUNTIME_finalize( morse );
#if defined(CHAMELEON_USE_MPI)
if (!morse->mpi_outer_init)
......@@ -250,14 +250,19 @@ int MORSE_Distributed_stop(void)
*
******************************************************************************
*
* @return
* \retval MORSE_SUCCESS successful exit
* @retval The size of the distributed computation
* @retval -1 if context not initialized
*
*****************************************************************************/
int MORSE_Comm_size( int *size )
int MORSE_Comm_size()
{
RUNTIME_comm_size (size);
return MORSE_SUCCESS;
MORSE_context_t *morse = morse_context_self();
if (morse == NULL) {
morse_error("MORSE_Comm_size()", "MORSE not initialized");
return -1;
}
return RUNTIME_comm_size( morse );
}
/** ***************************************************************************
......@@ -268,14 +273,19 @@ int MORSE_Comm_size( int *size )
*
******************************************************************************
*
* @return
* \retval MORSE_SUCCESS successful exit
* @retval The rank of the distributed computation
* @retval -1 if context not initialized
*
*****************************************************************************/
int MORSE_Comm_rank( int *rank )
int MORSE_Comm_rank()
{
RUNTIME_comm_rank (rank);
return MORSE_SUCCESS;
MORSE_context_t *morse = morse_context_self();
if (morse == NULL) {
morse_error("MORSE_Comm_rank()", "MORSE not initialized");
return -1;
}
return RUNTIME_comm_rank( morse );
}
/** ***************************************************************************
......@@ -293,5 +303,11 @@ int MORSE_Comm_rank( int *rank )
*****************************************************************************/
int MORSE_GetThreadNbr( )
{
return RUNTIME_get_thread_nbr();
MORSE_context_t *morse = morse_context_self();
if (morse == NULL) {
morse_error("MORSE_GetThreadNbr()", "MORSE not initialized");
return -1;
}
return RUNTIME_thread_size( morse );
}
......@@ -110,7 +110,17 @@ MORSE_desc_t morse_desc_init_user(MORSE_enum dtyp, int mb, int nb, int bsiz,
int (*get_blkldd) ( const MORSE_desc_t*, int ),
int (*get_rankof) ( const MORSE_desc_t*, int, int ))
{
MORSE_context_t *morse;
MORSE_desc_t desc;
memset( &desc, 0, sizeof(MORSE_desc_t) );
morse = morse_context_self();
if (morse == NULL) {
morse_error("MORSE_Desc_Create", "MORSE not initialized");
return desc;
}
// If one of the function get_* is NULL, we switch back to the default, like in morse_desc_init()
desc.get_blkaddr = get_blkaddr ? get_blkaddr : morse_getaddr_ccrb;
desc.get_blkldd = get_blkldd ? get_blkldd : morse_getblkldd_ccrb;
......@@ -144,7 +154,7 @@ MORSE_desc_t morse_desc_init_user(MORSE_enum dtyp, int mb, int nb, int bsiz,
desc.register_mat = 1;
desc.ooc = 0;
RUNTIME_comm_rank( &(desc.myrank) );
desc.myrank = RUNTIME_comm_rank( morse );
// Grid size
desc.p = p;
......@@ -185,8 +195,6 @@ MORSE_desc_t morse_desc_init_user(MORSE_enum dtyp, int mb, int nb, int bsiz,
desc.A12 = (size_t)( desc.llm%mb)*(size_t)(desc.lln - desc.lln%nb) + desc.A21;
desc.A22 = (size_t)(desc.llm - desc.llm%mb)*(size_t)( desc.lln%nb) + desc.A12;
RUNTIME_desc_init( &desc );
return desc;
}
......@@ -241,7 +249,8 @@ MORSE_desc_t* morse_desc_submatrix(MORSE_desc_t *descA, int i, int j, int m, int
descB->mt = (m == 0) ? 0 : (descB->i+m-1)/mb - descB->i/mb + 1;
descB->nt = (n == 0) ? 0 : (descB->j+n-1)/nb - descB->j/nb + 1;
RUNTIME_desc_submatrix( descB );
// Increase the number of occurences to avoid multiple free of runtime specific data structures.
descB->occurences++;
return descB;
}
......@@ -301,7 +310,7 @@ int morse_desc_mat_alloc( MORSE_desc_t *desc )
size_t size = (size_t)(desc->llm) * (size_t)(desc->lln)
* (size_t)MORSE_Element_Size(desc->dtyp);
if ((desc->mat = RUNTIME_mat_alloc(size)) == NULL) {
if ((desc->mat = RUNTIME_malloc(size)) == NULL) {
morse_error("morse_desc_mat_alloc", "malloc() failed");
return MORSE_ERR_OUT_OF_RESOURCES;
}
......@@ -327,7 +336,7 @@ int morse_desc_mat_free( MORSE_desc_t *desc )
size_t size = (size_t)(desc->llm) * (size_t)(desc->lln)
* (size_t)MORSE_Element_Size(desc->dtyp);
RUNTIME_mat_free(desc->mat, size);
RUNTIME_free(desc->mat, size);
desc->mat = NULL;
}
return MORSE_SUCCESS;
......@@ -423,7 +432,7 @@ int MORSE_Desc_Create(MORSE_desc_t **descptr, void *mat, MORSE_enum dtyp, int mb
size_t size = (size_t)(desc->llm) * (size_t)(desc->lln)
* (size_t)MORSE_Element_Size(desc->dtyp);
if ((desc->mat = RUNTIME_mat_alloc(size)) == NULL) {
if ((desc->mat = RUNTIME_malloc(size)) == NULL) {
morse_error("MORSE_Desc_Create", "malloc() failed");
return MORSE_ERR_OUT_OF_RESOURCES;
}
......@@ -843,6 +852,6 @@ int MORSE_Desc_Getoncpu(MORSE_desc_t *desc) {
*
*****************************************************************************/
void MORSE_user_tag_size(int user_tag_width, int user_tag_sep) {
RUNTIME_user_tag_size(user_tag_width, user_tag_sep);
RUNTIME_comm_set_tag_sizes( user_tag_width, user_tag_sep );
return;
}
......@@ -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;
......
......@@ -103,7 +103,7 @@ int main(int argc, char *argv[]) {
MORSE_Set(MORSE_INNER_BLOCK_SIZE, iparam[IPARAM_IB] );
#if defined(CHAMELEON_USE_MPI)
MORSE_Comm_size( &NMPIPROC );
NMPIPROC = MORSE_Comm_size();
/* Check P */
if ( (iparam[IPARAM_P] > 1) &&
(NMPIPROC % iparam[IPARAM_P] != 0) ) {
......@@ -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;
......
......@@ -107,7 +107,7 @@ int main(int argc, char *argv[]) {
MORSE_Set(MORSE_INNER_BLOCK_SIZE, iparam[IPARAM_IB] );
#if defined(CHAMELEON_USE_MPI)
MORSE_Comm_size( &NMPIPROC );
NMPIPROC = MORSE_Comm_size();
/* Check P */
if ( (iparam[IPARAM_P] > 1) &&
(NMPIPROC % iparam[IPARAM_P] != 0) ) {
......@@ -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 {
......
......@@ -25,10 +25,6 @@
#ifndef CHAMELEON_CONFIG_H_HAS_BEEN_INCLUDED
#define CHAMELEON_CONFIG_H_HAS_BEEN_INCLUDED
#define MORSE_VERSION_MAJOR @MORSE_VERSION_MAJOR@
#define MORSE_VERSION_MINOR @MORSE_VERSION_MINOR@
#define MORSE_VERSION_MICRO @MORSE_VERSION_MICRO@
#define CHAMELEON_VERSION_MAJOR @CHAMELEON_VERSION_MAJOR@
#define CHAMELEON_VERSION_MINOR @CHAMELEON_VERSION_MINOR@
#define CHAMELEON_VERSION_MICRO @CHAMELEON_VERSION_MICRO@
......
/**
*
* @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>