Commit 33e626d7 authored by Mathieu Faverge's avatar Mathieu Faverge

Fix issue 16

parent ab62aa98
......@@ -283,3 +283,21 @@ int MORSE_Comm_rank( int *rank )
RUNTIME_comm_rank (rank);
return MORSE_SUCCESS;
}
/** ***************************************************************************
*
* @ingroup Control
*
* MORSE_GetThreadNbr - Return the number of CPU workers initialized by the
* runtime
*
******************************************************************************
*
* @return
* \retval The number of CPU workers started
*
*****************************************************************************/
int MORSE_GetThreadNbr( )
{
return RUNTIME_get_thread_nbr();
}
......@@ -61,23 +61,24 @@ extern "C" {
#endif
/* Auxiliary */
int MORSE_Version (int *ver_major, int *ver_minor, int *ver_micro);
int MORSE_My_Mpi_Rank (void);
int MORSE_Init (int nworkers, int ncudas);
int MORSE_InitPar (int nworkers, int ncudas, int nthreads_per_worker);
int MORSE_Finalize (void);
int MORSE_Pause (void);
int MORSE_Resume (void);
int MORSE_Version (int *ver_major, int *ver_minor, int *ver_micro);
int MORSE_My_Mpi_Rank (void);
int MORSE_Init (int nworkers, int ncudas);
int MORSE_InitPar (int nworkers, int ncudas, int nthreads_per_worker);
int MORSE_Finalize (void);
int MORSE_Pause (void);
int MORSE_Resume (void);
int MORSE_Distributed_start (void);
int MORSE_Distributed_stop (void);
int MORSE_Comm_size ( int *size );
int MORSE_Comm_rank ( int *rank );
int MORSE_Lapack_to_Tile (void *Af77, int LDA, MORSE_desc_t *A);
int MORSE_Tile_to_Lapack (MORSE_desc_t *A, void *Af77, int LDA);
int MORSE_Distributed_start(void);
int MORSE_Distributed_stop (void);
int MORSE_Distributed_size (int*size);
int MORSE_Distributed_rank (int*rank);
int MORSE_Comm_size (int *size);
int MORSE_Comm_rank (int *rank);
int MORSE_Lapack_to_Tile (void *Af77, int LDA, MORSE_desc_t *A);
int MORSE_Tile_to_Lapack (MORSE_desc_t *A, void *Af77, int LDA);
int MORSE_Distributed_start (void);
int MORSE_Distributed_stop (void);
int MORSE_Distributed_size (int *size);
int MORSE_Distributed_rank (int *rank);
int MORSE_GetThreadNbr (void);
/* Descriptor */
int MORSE_Element_Size(int type);
......
......@@ -56,6 +56,7 @@ void RUNTIME_pause (MORSE_context_t*);
void RUNTIME_resume (MORSE_context_t*);
void RUNTIME_comm_rank (int*);
void RUNTIME_comm_size (int*);
int RUNTIME_get_thread_nbr (void);
/*******************************************************************************
* RUNTIME Descriptor
......
......@@ -111,3 +111,11 @@ void RUNTIME_comm_size( int *size )
#endif
return;
}
/*******************************************************************************
* This returns the number of workers
**/
int RUNTIME_get_thread_nbr()
{
return vpmap_get_nb_total_threads();
}
......@@ -104,3 +104,15 @@ void RUNTIME_comm_size( int *size )
*size = 1;
return;
}
/*******************************************************************************
* This returns the number of workers
**/
int RUNTIME_get_thread_nbr()
{
/*
* TODO: should add a function to Quark to get the number of thread from the
* data structure and not from the system function
*/
return quark_get_numthreads();
}
......@@ -229,3 +229,11 @@ void RUNTIME_comm_size( int *size )
#endif
return;
}
/*******************************************************************************
* This returns the number of workers
**/
int RUNTIME_get_thread_nbr()
{
return starpu_worker_get_count_by_type( STARPU_CPU );
}
......@@ -440,15 +440,6 @@ print_header(char *prog_name, int * iparam) {
return;
}
static void
get_thread_count(int *thrdnbr) {
#if defined WIN32 || defined WIN64
sscanf( getenv( "NUMBER_OF_PROCESSORS" ), "%d", thrdnbr );
#else
*thrdnbr = sysconf(_SC_NPROCESSORS_ONLN);
#endif
}
int
main(int argc, char *argv[]) {
int i, m, mx, nx;
......@@ -632,11 +623,6 @@ main(int argc, char *argv[]) {
}
#endif
if ( iparam[IPARAM_THRDNBR] == -1 ) {
get_thread_count( &(iparam[IPARAM_THRDNBR]) );
iparam[IPARAM_THRDNBR] -= iparam[IPARAM_NCUDAS];
}
m = iparam[IPARAM_M];
mx = iparam[IPARAM_MX];
nx = iparam[IPARAM_NX];
......@@ -645,6 +631,9 @@ main(int argc, char *argv[]) {
MORSE_Init( iparam[IPARAM_THRDNBR],
iparam[IPARAM_NCUDAS] );
/* Get thenumber of thread set by the runtime */
iparam[IPARAM_THRDNBR] = MORSE_GetThreadNbr();
/* Stops profiling here to avoid profiling uninteresting routines.
It will be reactivated in the time_*.c routines with the macro START_TIMING() */
RUNTIME_stop_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