Skip to content

Commit

Permalink
SuiteSparse_config: Record in header if timer functions are available
Browse files Browse the repository at this point in the history
Record in "SuiteSparse_config.h" if working timer functions are available
in libsuitesparse_config.

Always indirect to `SuiteSparse_time` when dependent libraries use
`SUITESPARSE_TIME`.

Add new preprocessor macro `SUITESPARSE_CONFIG_TIMER` which records the
function that is used by libsuitesparse_config for its timer functions.
Use that new preprocessor macro in the reports of UMFPACK.
  • Loading branch information
mmuetzel committed Jun 5, 2024
1 parent f96ba9c commit fe9cde9
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 13 deletions.
9 changes: 8 additions & 1 deletion SuiteSparse_config/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,14 @@ else ( )
endif ( )
endif ( )

if ( NOT SUITESPARSE_CONFIG_USE_OPENMP AND NOT SUITESPARSE_HAVE_CLOCK_GETTIME )
if ( SUITESPARSE_CONFIG_USE_OPENMP OR SUITESPARSE_HAVE_CLOCK_GETTIME )
set ( SUITESPARSE_TIMER_ENABLED ON )
if ( SUITESPARSE_CONFIG_USE_OPENMP )
set ( SUITESPARSE_CONFIG_TIMER "omp_get_wtime" )
else ( )
set ( SUITESPARSE_CONFIG_TIMER "clock_gettime" )
endif ( )
else ( )
message ( STATUS "No OpenMP and no clock_gettime available. Timing functions won't work." )
endif ( )

Expand Down
8 changes: 3 additions & 5 deletions SuiteSparse_config/Config/SuiteSparse_config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -372,12 +372,10 @@ int SuiteSparse_divcomplex
// but other packages can themselves use OpenMP. In this case,
// those packages should use omp_get_wtime() directly. This can
// be done via the SUITESPARSE_TIME macro, defined below:
#cmakedefine SUITESPARSE_TIMER_ENABLED
#cmakedefine SUITESPARSE_HAVE_CLOCK_GETTIME
#if defined ( _OPENMP )
#define SUITESPARSE_TIMER_ENABLED
#define SUITESPARSE_TIME (omp_get_wtime ( ))
#elif defined ( SUITESPARSE_HAVE_CLOCK_GETTIME )
#define SUITESPARSE_TIMER_ENABLED
#cmakedefine SUITESPARSE_CONFIG_TIMER @SUITESPARSE_CONFIG_TIMER@
#if defined ( SUITESPARSE_TIMER_ENABLED )
#define SUITESPARSE_TIME (SuiteSparse_time ( ))
#else
// No timer is available
Expand Down
8 changes: 3 additions & 5 deletions SuiteSparse_config/SuiteSparse_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -372,12 +372,10 @@ int SuiteSparse_divcomplex
// but other packages can themselves use OpenMP. In this case,
// those packages should use omp_get_wtime() directly. This can
// be done via the SUITESPARSE_TIME macro, defined below:
#define SUITESPARSE_TIMER_ENABLED
#define SUITESPARSE_HAVE_CLOCK_GETTIME
#if defined ( _OPENMP )
#define SUITESPARSE_TIMER_ENABLED
#define SUITESPARSE_TIME (omp_get_wtime ( ))
#elif defined ( SUITESPARSE_HAVE_CLOCK_GETTIME )
#define SUITESPARSE_TIMER_ENABLED
#define SUITESPARSE_CONFIG_TIMER omp_get_wtime
#if defined ( SUITESPARSE_TIMER_ENABLED )
#define SUITESPARSE_TIME (SuiteSparse_time ( ))
#else
// No timer is available
Expand Down
2 changes: 1 addition & 1 deletion UMFPACK/Source/umfpack_report_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ void UMFPACK_report_control

PRINTF ((" CPU timer: ")) ;
#ifdef SUITESPARSE_TIMER_ENABLED
PRINTF (( xstr( SUITESPARSE_TIME ) "\n")) ;
PRINTF (( xstr( SUITESPARSE_CONFIG_TIMER ) "\n")) ;
#else
PRINTF (("no timer used.\n")) ;
#endif
Expand Down
2 changes: 1 addition & 1 deletion UMFPACK/Source/umfpack_report_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ void UMFPACK_report_info

PRINTF ((" CPU timer: ")) ;
#ifdef SUITESPARSE_TIMER_ENABLED
PRINTF (( xstr( SUITESPARSE_TIME ) "\n")) ;
PRINTF (( xstr( SUITESPARSE_CONFIG_TIMER ) "\n")) ;
#else
PRINTF (("no timer used.\n")) ;
#endif
Expand Down

0 comments on commit fe9cde9

Please sign in to comment.