Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UMFPACK: Display timer function used by SuiteSparse_config in report #823

Merged
merged 3 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
16 changes: 10 additions & 6 deletions SuiteSparse_config/Config/SuiteSparse_config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -372,13 +372,17 @@ 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
#define SUITESPARSE_TIME (SuiteSparse_time ( ))
#cmakedefine SUITESPARSE_CONFIG_TIMER @SUITESPARSE_CONFIG_TIMER@
#if defined ( SUITESPARSE_TIMER_ENABLED )
#if defined ( _OPENMP )
// Avoid indirection through the library if the compilation unit
// including this header happens to use OpenMP.
#define SUITESPARSE_TIME (omp_get_wtime ( ))
#else
#define SUITESPARSE_TIME (SuiteSparse_time ( ))
#endif
#else
// No timer is available
#define SUITESPARSE_TIME (0)
Expand Down
16 changes: 10 additions & 6 deletions SuiteSparse_config/SuiteSparse_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -372,13 +372,17 @@ 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_TIME (SuiteSparse_time ( ))
#define SUITESPARSE_CONFIG_TIMER omp_get_wtime
#if defined ( SUITESPARSE_TIMER_ENABLED )
#if defined ( _OPENMP )
// Avoid indirection through the library if the compilation unit
// including this header happens to use OpenMP.
#define SUITESPARSE_TIME (omp_get_wtime ( ))
#else
#define SUITESPARSE_TIME (SuiteSparse_time ( ))
#endif
#else
// No timer is available
#define SUITESPARSE_TIME (0)
Expand Down
9 changes: 4 additions & 5 deletions UMFPACK/Source/umfpack_report_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@

#include "umf_internal.h"

#define xstr(s) str(s)
#define str(s) #s

void UMFPACK_report_control
(
const double Control [UMFPACK_CONTROL]
Expand Down Expand Up @@ -381,11 +384,7 @@ void UMFPACK_report_control

PRINTF ((" CPU timer: ")) ;
#ifdef SUITESPARSE_TIMER_ENABLED
#ifdef _OPENMP
PRINTF (("omp_get_wtime ( )\n")) ;
#else
PRINTF (("SuiteSparse_time ( )\n")) ;
#endif
PRINTF (( xstr( SUITESPARSE_CONFIG_TIMER ) "\n")) ;
#else
PRINTF (("no timer used.\n")) ;
#endif
Expand Down
9 changes: 4 additions & 5 deletions UMFPACK/Source/umfpack_report_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
} \
}

#define xstr(s) str(s)
#define str(s) #s

/* RATIO macro uses a double relop, but ignore NaN case: */
#define RATIO(a,b,c) (((b) == 0) ? (c) : (((double) a)/((double) b)))

Expand Down Expand Up @@ -160,11 +163,7 @@ void UMFPACK_report_info

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