diff --git a/AMD/Doc/AMD_UserGuide.pdf b/AMD/Doc/AMD_UserGuide.pdf index e1c12a9e0..7a0d676fe 100644 Binary files a/AMD/Doc/AMD_UserGuide.pdf and b/AMD/Doc/AMD_UserGuide.pdf differ diff --git a/CAMD/Doc/CAMD_UserGuide.pdf b/CAMD/Doc/CAMD_UserGuide.pdf index 00891f92f..879dfea77 100644 Binary files a/CAMD/Doc/CAMD_UserGuide.pdf and b/CAMD/Doc/CAMD_UserGuide.pdf differ diff --git a/CHOLMOD/CMakeLists.txt b/CHOLMOD/CMakeLists.txt index b7bbe8c7a..985ce51e0 100644 --- a/CHOLMOD/CMakeLists.txt +++ b/CHOLMOD/CMakeLists.txt @@ -380,6 +380,11 @@ if ( OPENMP_FOUND ) set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS} " ) set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_C_FLAGS} " ) include_directories ( ${OpenMP_C_INCLUDE_DIRS} ) +else ( ) + # to fix METIS: use threadprivate variables for GKRAND instead globals, + # so multiple user threads can call cholmod_analyze in parallel on + # different matrices, and avoid global locking of the system rand. + include ( SuiteSparse__thread ) endif ( ) # libm: diff --git a/CHOLMOD/Doc/CHOLMOD_UserGuide.pdf b/CHOLMOD/Doc/CHOLMOD_UserGuide.pdf index 696cefcad..011d3cd6d 100644 Binary files a/CHOLMOD/Doc/CHOLMOD_UserGuide.pdf and b/CHOLMOD/Doc/CHOLMOD_UserGuide.pdf differ diff --git a/CHOLMOD/Doc/CHOLMOD_UserGuide.tex b/CHOLMOD/Doc/CHOLMOD_UserGuide.tex index ba3fb078c..184396fb6 100644 --- a/CHOLMOD/Doc/CHOLMOD_UserGuide.tex +++ b/CHOLMOD/Doc/CHOLMOD_UserGuide.tex @@ -48,7 +48,7 @@ \end{abstract} %------------------------------------------------------------------------------- -CHOLMOD Copyright\copyright 2005-2022 by Timothy A. Davis, All Rights Reserved. +CHOLMOD Copyright\copyright 2005-2023 by Timothy A. Davis, All Rights Reserved. Portions are also copyrighted by William W. Hager (the {\tt Modify} Module), and the University of Florida (the {\tt Partition} and {\tt Core} Modules). All Rights Reserved. diff --git a/CHOLMOD/Doc/ChangeLog b/CHOLMOD/Doc/ChangeLog index 684d6a83b..00a931d25 100644 --- a/CHOLMOD/Doc/ChangeLog +++ b/CHOLMOD/Doc/ChangeLog @@ -6,6 +6,8 @@ FIXME DATE, 2023: version 4.2.0 cholmod_metis_wrapper.c, Tcov/memory.c. * support for SPQR: minor changes to support SPQR v4.2.0 with 32-bit integers; no change to user-visible API. + * METIS now using GKRAND: with threadprivate state variables, to + avoid global system lock when using CHOLMON on many user threads June 16, 2023: version 4.0.4 diff --git a/CHOLMOD/Partition/cholmod_metis_wrapper.h b/CHOLMOD/Partition/cholmod_metis_wrapper.h index cdc56a521..0a3ac9315 100644 --- a/CHOLMOD/Partition/cholmod_metis_wrapper.h +++ b/CHOLMOD/Partition/cholmod_metis_wrapper.h @@ -2,7 +2,7 @@ // CHOLMOD/Partition/cholmod_metis_wrapper.h: METIS renaming for CHOLMOD //------------------------------------------------------------------------------ -// CHOLMOD/Partition Module. Copyright (C) 2005-2022, University of Florida. +// CHOLMOD/Partition Module. Copyright (C) 2005-2023, University of Florida. // All Rights Reserved. Author: Timothy A. Davis. // SPDX-License-Identifier: LGPL-2.1+ @@ -11,6 +11,11 @@ #ifndef CHOLMOD_METIS_WRAP_H #define CHOLMOD_METIS_WRAP_H +// always use GKRAND instead of the system rand in METIS +#ifndef USE_GKRAND +#define USE_GKRAND +#endif + #if defined ( __GNUC__ ) && !defined ( __clang__ ) // disable memcpy warnings: #pragma GCC diagnostic ignored "-Wstringop-overflow=" diff --git a/CHOLMOD/SuiteSparse_metis/GKlib/random.c b/CHOLMOD/SuiteSparse_metis/GKlib/random.c index d18e7188b..b6462a060 100644 --- a/CHOLMOD/SuiteSparse_metis/GKlib/random.c +++ b/CHOLMOD/SuiteSparse_metis/GKlib/random.c @@ -60,11 +60,41 @@ GK_MKRANDOM(gk_z, size_t, ssize_t) #define UM 0xFFFFFFFF80000000ULL /* Most significant 33 bits */ #define LM 0x7FFFFFFFULL /* Least significant 31 bits */ +// added by Tim Davis for CHOLMOD: mt and mti state variables threadprivate +#if defined ( _OPENMP ) + // OpenMP threadprivate is preferred + static uint64_t mt[NN]; + static int mti=NN+1; + #pragma omp threadprivate (mt,mti) + +#elif defined ( HAVE_KEYWORD__THREAD ) + + // gcc and many other compilers support the __thread keyword + __thread static uint64_t mt[NN]; + __thread static int mti=NN+1; + +#elif defined ( HAVE_KEYWORD__DECLSPEC_THREAD ) + + // Windows: __declspec (thread) + __declspec ( thread ) static uint64_t mt[NN]; + __declspec ( thread ) static int mti=NN+1; + +#elif defined ( HAVE_KEYWORD__THREAD_LOCAL ) + + // ANSI C11 threads + #include + _Thread_local static uint64_t mt[NN]; + _Thread_local static int mti=NN+1; + +#else +// original METIS uses global state: this is not thread-safe: /* The array for the state vector */ static uint64_t mt[NN]; /* mti==NN+1 means mt[NN] is not initialized */ static int mti=NN+1; +#endif + #endif /* USE_GKRAND */ /* initializes mt[NN] with a seed */ diff --git a/GraphBLAS/Doc/GraphBLAS_UserGuide.pdf b/GraphBLAS/Doc/GraphBLAS_UserGuide.pdf index 04caf9fd0..e1baf0e98 100644 Binary files a/GraphBLAS/Doc/GraphBLAS_UserGuide.pdf and b/GraphBLAS/Doc/GraphBLAS_UserGuide.pdf differ diff --git a/KLU/Doc/KLU_UserGuide.pdf b/KLU/Doc/KLU_UserGuide.pdf index 8f0997036..f02be7269 100644 Binary files a/KLU/Doc/KLU_UserGuide.pdf and b/KLU/Doc/KLU_UserGuide.pdf differ diff --git a/LDL/Doc/ldl_userguide.pdf b/LDL/Doc/ldl_userguide.pdf index d92239280..bb1a65095 100644 Binary files a/LDL/Doc/ldl_userguide.pdf and b/LDL/Doc/ldl_userguide.pdf differ diff --git a/Makefile b/Makefile index 40a9d5db5..630cbe52f 100644 --- a/Makefile +++ b/Makefile @@ -183,7 +183,7 @@ demos: # Create the PDF documentation docs: ( cd GraphBLAS && $(MAKE) docs ) - ( cd Mongoose && $(MAKE) docs ) + # ( cd Mongoose && $(MAKE) docs ) ( cd AMD && $(MAKE) docs ) ( cd CAMD && $(MAKE) docs ) ( cd KLU && $(MAKE) docs ) diff --git a/SPEX/Doc/SPEX_UserGuide.pdf b/SPEX/Doc/SPEX_UserGuide.pdf index 3ed9cae9c..93216ed6e 100644 Binary files a/SPEX/Doc/SPEX_UserGuide.pdf and b/SPEX/Doc/SPEX_UserGuide.pdf differ diff --git a/SuiteSparse_config/SuiteSparse__thread.cmake b/SuiteSparse_config/SuiteSparse__thread.cmake new file mode 100644 index 000000000..75c5cb61d --- /dev/null +++ b/SuiteSparse_config/SuiteSparse__thread.cmake @@ -0,0 +1,72 @@ +#------------------------------------------------------------------------------- +# GraphBLAS/cmake_modules/SuiteSparse__thread.cmake +#------------------------------------------------------------------------------- + +# Copyright (c) 2017-2023, Timothy A. Davis. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 + +#------------------------------------------------------------------------------- + +# determine if the __thread keyword is available, which is an extension by +# gcc but supported by many compilers, to indicate thread-local-storage. + +include ( CheckCSourceRuns ) + +set ( thread_src +" #include + __thread int x = 1 ; + int main (void) + { + x = 0 ; + return (x) ; + } +" ) + +set ( declspec_thread_src +" #include + __declspec ( thread ) int x = 1 ; + int main (void) + { + x = 0 ; + return (x) ; + } +" ) + +set ( thread_local_src +" #include + #include + _Thread_local int x = 1 ; + int main (void) + { + x = 0 ; + return (x) ; + } +" ) + +check_c_source_runs ( "${declspec_thread_src}" HAVE_KEYWORD__DECLSPEC_THREAD ) + +check_c_source_runs ( "${thread_src}" HAVE_KEYWORD__THREAD ) + +check_c_source_runs ( "${thread_local_src}" HAVE_KEYWORD__THREAD_LOCAL ) + +if ( HAVE_KEYWORD__DECLSPEC_THREAD ) + add_compile_definitions ( HAVE_KEYWORD__DECLSPEC_THREAD ) + message ( STATUS "__declspec(thread) keyword: available" ) +else ( ) + message ( STATUS "__declspec(thread) keyword: not available" ) +endif ( ) + +if ( HAVE_KEYWORD__THREAD ) + add_compile_definitions ( HAVE_KEYWORD__THREAD ) + message ( STATUS "__thread keyword: available" ) +else ( ) + message ( STATUS "__thread keyword: not available" ) +endif ( ) + +if ( HAVE_KEYWORD__THREAD_LOCAL ) + add_compile_definitions ( HAVE_KEYWORD__THREAD_LOCAL ) + message ( STATUS "_Thread_local keyword: available" ) +else ( ) + message ( STATUS "_Thread_local_thread keyword: not available" ) +endif ( ) + diff --git a/UMFPACK/Doc/UMFPACK_QuickStart.pdf b/UMFPACK/Doc/UMFPACK_QuickStart.pdf index f50c094f4..6a7c97778 100644 Binary files a/UMFPACK/Doc/UMFPACK_QuickStart.pdf and b/UMFPACK/Doc/UMFPACK_QuickStart.pdf differ diff --git a/UMFPACK/Doc/UMFPACK_UserGuide.pdf b/UMFPACK/Doc/UMFPACK_UserGuide.pdf index 85f47ff68..a851a7210 100644 Binary files a/UMFPACK/Doc/UMFPACK_UserGuide.pdf and b/UMFPACK/Doc/UMFPACK_UserGuide.pdf differ