Skip to content

Commit 1080e91

Browse files
authored
Manage sparse dependencies using dlopen (#302)
* dlopen for rocSPARSE * dlopen for CHOLMOD * Updated hipsolver_sparse.cpp * Updated tests * Updated documentation * Default BUILD_WITH_SPARSE to ON for static library * Added comment * Add packages to recommends * Rename --embed-sparse option to --sparse * Addressed review comments
1 parent 3de3b56 commit 1080e91

File tree

17 files changed

+761
-72
lines changed

17 files changed

+761
-72
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ Full documentation for hipSOLVER is available at the [hipSOLVER Documentation](h
1111
### Optimized
1212
### Changed
1313
- Binaries in debug builds no longer have a "-d" suffix.
14+
- Changed rocSPARSE and SuiteSparse to be run-time dependencies by default. The `BUILD_WITH_SPARSE` CMake option can still be used
15+
to convert them into build-time dependencies (now off by default).
16+
- The --no-sparse option of the install script now only affects the hipSOLVER clients and their dependency on hipSPARSE. Use the
17+
`BUILD_HIPSPARSE_TESTS` CMake option to enable tests for the hipsolverSp API (on by default).
1418

1519
### Deprecated
1620
### Removed

CMakeLists.txt

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,21 @@ endif()
101101
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${ROCM_PATH}/lib/cmake/hip ${HIP_PATH}/cmake)
102102

103103
# NOTE: workaround until hip cmake modules fixes symlink logic in their config files; remove when fixed
104-
list(APPEND CMAKE_PREFIX_PATH /opt/rocm /opt/rocm/llvm /opt/rocm/hip)
104+
list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH}/lib/cmake/hip /opt/rocm /opt/rocm/llvm /opt/rocm/hip)
105+
106+
option(BUILD_SHARED_LIBS "Build hipSOLVER as a shared library" ON)
107+
if(BUILD_SHARED_LIBS)
108+
set(BUILD_WITH_SPARSE_DEFAULT OFF)
109+
else()
110+
set(BUILD_WITH_SPARSE_DEFAULT ON)
111+
endif()
105112

106113
option(BUILD_ADDRESS_SANITIZER "Build with address sanitizer enabled" OFF)
107114
option(BUILD_CODE_COVERAGE "Build hipSOLVER with code coverage enabled" OFF)
108115
option(BUILD_HIPBLAS_TESTS "Build additional tests to ensure hipBLAS and hipSOLVER are compatible (requires installed hipBLAS)" OFF)
116+
option(BUILD_HIPSPARSE_TESTS "Build additional tests to cover sparse functionality (requires installed hipSPARSE)" ON)
109117
# BUILD_SHARED_LIBS is a cmake built-in; we make it an explicit option such that it shows in cmake-gui
110-
option(BUILD_SHARED_LIBS "Build hipSOLVER as a shared library" ON)
111-
option(BUILD_WITH_SPARSE "Build hipSOLVER with sparse functionality and tests enabled (requires additional dependencies)" "${UNIX}")
118+
option(BUILD_WITH_SPARSE "Build hipSOLVER with sparse functionality available at build time (requires installed dependencies)" "${BUILD_WITH_SPARSE_DEFAULT}")
112119
option(BUILD_VERBOSE "Output additional build information" OFF)
113120
option(USE_CUDA "Look for CUDA and use that as a backend if found" OFF)
114121
option(HIPSOLVER_FIND_PACKAGE_LAPACK_CONFIG "Skip module mode search for LAPACK" ON)
@@ -228,20 +235,24 @@ if(NOT USE_CUDA)
228235
rocm_package_add_rpm_dependencies(STATIC_DEPENDS "rocblas-static-devel >= ${rocblas_minimum}" "rocsolver-static-devel >= ${rocsolver_minimum}")
229236
rocm_package_add_deb_dependencies(STATIC_DEPENDS "rocblas-static-dev >= ${rocblas_minimum}" "rocsolver-static-dev >= ${rocsolver_minimum}")
230237

238+
if(SYSTEM_OS STREQUAL "centos" OR SYSTEM_OS STREQUAL "rhel" OR SYSTEM_OS STREQUAL "mariner")
239+
list(APPEND hipsolver_pkgdeps "suitesparse")
240+
elseif(SYSTEM_OS STREQUAL "ubuntu" AND SYSTEM_OS_VERSION VERSION_GREATER_EQUAL "24.04")
241+
list(APPEND hipsolver_pkgdeps "libcholmod5" "libsuitesparseconfig7")
242+
else()
243+
list(APPEND hipsolver_pkgdeps "libcholmod3" "libsuitesparseconfig5")
244+
endif()
245+
231246
if(BUILD_WITH_SPARSE)
232247
set(rocsparse_minimum 2.3.0)
233248
rocm_package_add_dependencies(SHARED_DEPENDS "rocsparse >= ${rocsparse_minimum}")
234249
rocm_package_add_rpm_dependencies(STATIC_DEPENDS "rocsparse-static-devel >= ${rocsparse_minimum}")
235250
rocm_package_add_deb_dependencies(STATIC_DEPENDS "rocsparse-static-dev >= ${rocsparse_minimum}")
236251

237-
if(SYSTEM_OS STREQUAL "centos" OR SYSTEM_OS STREQUAL "rhel" OR SYSTEM_OS STREQUAL "mariner")
238-
list(APPEND hipsolver_pkgdeps "suitesparse")
239-
elseif(SYSTEM_OS STREQUAL "ubuntu" AND SYSTEM_OS_VERSION VERSION_GREATER_EQUAL "24.04")
240-
list(APPEND hipsolver_pkgdeps "libcholmod5" "libsuitesparseconfig7")
241-
else()
242-
list(APPEND hipsolver_pkgdeps "libcholmod3" "libsuitesparseconfig5")
243-
endif()
244252
rocm_package_add_dependencies(DEPENDS ${hipsolver_pkgdeps})
253+
else()
254+
list(APPEND CPACK_DEBIAN_RUNTIME_PACKAGE_RECOMMENDS "rocsparse" ${hipsolver_pkgdeps})
255+
list(APPEND CPACK_RPM_RUNTIME_PACKAGE_SUGGESTS "rocsparse" ${hipsolver_pkgdeps})
245256
endif()
246257
endif()
247258

clients/benchmarks/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#
2121
# ########################################################################
2222

23-
if(BUILD_WITH_SPARSE)
23+
if(BUILD_HIPSPARSE_TESTS)
2424
if(NOT TARGET hipsparse)
2525
if(CUSTOM_HIPSPARSE)
2626
set(ENV{hipsparse_DIR} ${CUSTOM_HIPSPARSE})
@@ -52,7 +52,7 @@ target_link_libraries(hipsolver-bench PRIVATE
5252
clients-common
5353
roc::hipsolver
5454
)
55-
if(BUILD_WITH_SPARSE)
55+
if(BUILD_HIPSPARSE_TESTS)
5656
set_source_files_properties(client.cpp
5757
PROPERTIES
5858
COMPILE_DEFINITIONS HAVE_HIPSPARSE

clients/gtest/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ if(BUILD_HIPBLAS_TESTS)
3333
endif()
3434
endif()
3535

36-
if(BUILD_WITH_SPARSE)
36+
if(BUILD_HIPSPARSE_TESTS)
3737
if(NOT TARGET hipsparse)
3838
if(CUSTOM_HIPSPARSE)
3939
set(ENV{hipsparse_DIR} ${CUSTOM_HIPSPARSE})
@@ -117,7 +117,7 @@ if(BUILD_HIPBLAS_TESTS)
117117
target_link_libraries(hipsolver-test PRIVATE roc::hipblas)
118118
target_sources(hipsolver-test PRIVATE hipblas_include1_gtest.cpp hipblas_include2_gtest.cpp)
119119
endif()
120-
if(BUILD_WITH_SPARSE)
120+
if(BUILD_HIPSPARSE_TESTS)
121121
target_link_libraries(hipsolver-test PRIVATE roc::hipsparse)
122122
target_sources(hipsolver-test PRIVATE ${hipsolverSp_test_source})
123123
endif()

clients/gtest/csrlsvchol_gtest.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ template <bool HOST>
6666
class CSRLSVCHOL_BASE : public ::TestWithParam<csrlsvchol_tuple>
6767
{
6868
protected:
69+
void SetUp() override
70+
{
71+
if(hipsolverSpCreate(nullptr) == HIPSOLVER_STATUS_NOT_SUPPORTED)
72+
GTEST_SKIP() << "Sparse dependencies could not be loaded";
73+
}
6974
void TearDown() override
7075
{
7176
EXPECT_EQ(hipGetLastError(), hipSuccess);

docs/howto/usage.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,8 @@ user-provided and automatically allocated workspaces.
246246

247247
Using rocSOLVER's in-place functions
248248
--------------------------------------
249-
The solvers `gesv` and `gels` in cuSOLVER are out-of-place in the sense that the solution vectors `X` do not overwrite the input matrix `B`. In rocSOLVER this is not the case; when `hipsolverXXgels` or `hipsolverXXgesv` call rocSOLVER, some data
249+
The solvers `gesv` and `gels` in cuSOLVER are out-of-place in the sense that the solution vectors `X` do not overwrite the input matrix `B`.
250+
In rocSOLVER this is not the case; when `hipsolverXXgels` or `hipsolverXXgesv` call rocSOLVER, some data
250251
movements must be done internally to restore `B` and copy the results back to `X`. These copies could introduce noticeable
251252
overhead depending on the size of the matrices. To avoid this potential problem, users can pass `X = B` to `hipsolverXXgels`
252253
or `hipsolverXXgesv` when using the rocSOLVER backend; in this case, no data movements will be required, and the solution

docs/installation/install.rst

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ Download pre-built packages from :doc:`ROCm's package servers <rocm-install-on-l
1515

1616
* ``sudo apt update && sudo apt install hipsolver``
1717

18-
.. note::
19-
The pre-built packages depend on the third-party library SuiteSparse, which must be installed on the system prior to installing hipSOLVER. SuiteSparse can be installed using the package manager of most distros.
20-
2118

2219
Build & install library using script (Ubuntu only)
2320
===================================================
@@ -28,7 +25,6 @@ so it may prompt you for a password.
2825
* ``./install.sh -id`` --- build library, build dependencies, and install (-d flag only needs to be passed once on a system).
2926
* ``./install.sh -ic`` --- build library, build clients (tests, benchmarks, and samples), and install.
3027
* ``./install.sh --cuda`` --- build library on a CUDA-enabled machine, with cuSOLVER as the backend.
31-
* ``./install.sh --no-sparse`` --- build library without hipsolverSp functionality, with rocSOLVER as the backend.
3228

3329
To see more options, use the help option of the install script.
3430

@@ -64,17 +60,18 @@ The rocSOLVER backend has the following dependencies:
6460

6561
1. `rocSOLVER <https://github.com/ROCmSoftwarePlatform/rocSOLVER>`_
6662
2. `rocBLAS <https://github.com/ROCmSoftwarePlatform/rocBLAS>`_
67-
3. `rocSPARSE <https://github.com/ROCmSoftwarePlatform/rocSPARSE>`_ (optional, required by default)
68-
4. `SuiteSparse <https://github.com/DrTimothyAldenDavis/SuiteSparse>`_ modules CHOLMOD and SuiteSparse_config (optional, required by default)
63+
3. `rocSPARSE <https://github.com/ROCmSoftwarePlatform/rocSPARSE>`_ (optional)
64+
4. `SuiteSparse <https://github.com/DrTimothyAldenDavis/SuiteSparse>`_ modules CHOLMOD and SuiteSparse_config (optional)
6965

7066
rocSOLVER itself depends on rocBLAS and rocSPARSE, therefore all three libraries should be present with a standard rocSOLVER installation. For more information
7167
about building and installing rocSOLVER, refer to the :doc:`rocSOLVER documentation <rocsolver:installation/installlinux>`.
7268

7369
SuiteSparse is a third-party library, and can be installed using the package managers of most distros. Together with rocSPARSE, it is used to provide
74-
functionality for the hipsolverSp API. If only hipsolverDn and/or hipsolverRf are needed, these dependencies can be ignored by setting the ``BUILD_WITH_SPARSE``
75-
option to ``OFF``.
70+
functionality for the hipsolverSp API. By default, both libraries are run-time dependencies and will be dynamically loaded at run-time by dlopen if they are
71+
present on the system. If the ``BUILD_WITH_SPARSE`` option is set to ``ON``, these will instead become build-time dependencies and must be present on the
72+
system in order to build hipSOLVER.
7673

77-
* ``DBUILD_WITH_SPARSE=OFF``
74+
* ``DBUILD_WITH_SPARSE=ON``
7875

7976

8077
Build library + tests + benchmarks + samples manually
@@ -104,11 +101,11 @@ the ``CMAKE_PREFIX_PATH`` definition. The following is a sequence of steps to bu
104101
make -j$(nproc) install
105102
106103
hipBLAS is only required if the ``BUILD_HIPBLAS_TESTS`` option is set to ``ON``, and is used to ensure compatibility between the hipblas enums defined
107-
separately by hipBLAS and hipSOLVER. hipSPARSE is required by default but can be ignored if the ``BUILD_WITH_SPARSE`` option is set to ``OFF``, and is used
104+
separately by hipBLAS and hipSOLVER. hipSPARSE is required by default but can be ignored if the ``BUILD_HIPSPARSE_TESTS`` option is set to ``OFF``, and is used
108105
to create objects required by tests for the hipsolverSp API.
109106

110107
* ``DBUILD_HIPBLAS_TESTS=ON``
111-
* ``DBUILD_WITH_SPARSE=OFF``
108+
* ``DBUILD_HIPSPARSE_TESTS=OFF``
112109

113110
Both libraries can be installed similarly to hipSOLVER. For example, the install scripts for hipBLAS and hipSPARSE can each be invoked to build and
114111
install the respective library via:

docs/reference/refactor-api/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ For ease of porting from existing cuSOLVER applications to hipSOLVER, functions
1616
method signatures that are consistent with the cusolverRf interface. At present, equivalent functions have not been added to hipSOLVER's regular API.
1717

1818
* :ref:`refactor_types`
19-
* :ref:`refactor_helpers`
19+
* :ref:`refactor_helpers`
2020
* :ref:`refactor_refactorfunc`

docs/reference/sparse-api/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ regular API. Note that there are :ref:`some performance limitations <sparse_perf
1818
functionality required for optimal performance has been implemented yet.
1919

2020
* :ref:`sparse_types`
21-
* :ref:`sparse_helpers`
21+
* :ref:`sparse_helpers`
2222
* :ref:`sparse_sparsefunc`
2323

install.sh

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ function display_help()
5454
echo " [--static] Create static library instead of shared library"
5555
echo " [--codecoverage] Build with code coverage profiling enabled, excluding release mode."
5656
echo " [--address-sanitizer] Build with address sanitizer enabled. Uses hipcc to compile"
57-
echo " [--no-sparse] Build with sparse functionality and tests disabled."
57+
echo " [--sparse] Build with sparse functionality enabled at build time."
58+
echo " [--no-sparse] Build with sparse functionality tests disabled."
5859
echo " [--docs] (experimental) Pass this flag to build the documentation from source."
5960
echo " [--cmake-arg] Forward the given argument to CMake when configuring the build"
6061
}
@@ -363,7 +364,8 @@ build_cuda=false
363364
build_hip_clang=true
364365
build_release=true
365366
build_relocatable=false
366-
build_sparse=true
367+
build_sparse=false
368+
build_sparse_tests=true
367369
build_docs=false
368370
cmake_prefix_path=/opt/rocm
369371
cuda_path=/usr/local/cuda
@@ -383,7 +385,7 @@ declare -a cmake_client_options
383385
# check if we have a modern version of getopt that can handle whitespace and long parameters
384386
getopt -T
385387
if [[ $? -eq 4 ]]; then
386-
GETOPT_PARSE=$(getopt --name "${0}" --longoptions help,install,codecoverage,clients,no-solver,dependencies,debug,relwithdebinfo,hip-clang,no-hip-clang,compiler:,cuda,use-cuda,cudapath:,static,cmakepp,relocatable:,rocm-dev:,rocblas:,rocblas-path:,hipblas-path:,rocsolver:,rocsolver-path:,rocsparse:,rocsparse-path:,hipsparse-path:,custom-target:,docs,address-sanitizer,no-sparse,cmake-arg: --options rhicndgkp:v:b:s: -- "$@")
388+
GETOPT_PARSE=$(getopt --name "${0}" --longoptions help,install,codecoverage,clients,no-solver,dependencies,debug,relwithdebinfo,hip-clang,no-hip-clang,compiler:,cuda,use-cuda,cudapath:,static,cmakepp,relocatable:,rocm-dev:,rocblas:,rocblas-path:,hipblas-path:,rocsolver:,rocsolver-path:,rocsparse:,rocsparse-path:,hipsparse-path:,custom-target:,docs,address-sanitizer,sparse,no-sparse,cmake-arg: --options rhicndgkp:v:b:s: -- "$@")
387389
else
388390
echo "Need a new version of getopt"
389391
exit 1
@@ -450,8 +452,11 @@ while true; do
450452
build_address_sanitizer=true
451453
compiler=hipcc
452454
shift ;;
455+
--sparse)
456+
build_sparse=true
457+
shift ;;
453458
--no-sparse)
454-
build_sparse=false
459+
build_sparse_tests=false
455460
shift ;;
456461
-p|--cmakepp)
457462
cmake_prefix_path=${2}
@@ -675,9 +680,12 @@ fi
675680
cmake_common_options+=("-DBUILD_ADDRESS_SANITIZER=ON")
676681
fi
677682

678-
# no sparse
679-
if [[ "${build_sparse}" == false ]]; then
680-
cmake_common_options+=("-DBUILD_WITH_SPARSE=OFF")
683+
# build with sparse
684+
if [[ "${build_sparse}" == true ]]; then
685+
cmake_common_options+=("-DBUILD_WITH_SPARSE=ON")
686+
fi
687+
if [[ "${build_sparse_tests}" == false ]]; then
688+
cmake_common_options+=("-DBUILD_HIPSPARSE_TESTS=OFF")
681689
fi
682690

683691
# Build library

library/src/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ prepend_path(".." hipsolver_headers_public relative_hipsolver_headers_public)
4242

4343
if(NOT USE_CUDA)
4444
set(hipsolver_source
45+
"${CMAKE_CURRENT_SOURCE_DIR}/amd_detail/dlopen/cholmod.cpp"
46+
"${CMAKE_CURRENT_SOURCE_DIR}/amd_detail/dlopen/rocsparse.cpp"
4547
"${CMAKE_CURRENT_SOURCE_DIR}/amd_detail/hipsolver_conversions.cpp"
4648
"${CMAKE_CURRENT_SOURCE_DIR}/amd_detail/hipsolver.cpp"
4749
"${CMAKE_CURRENT_SOURCE_DIR}/amd_detail/hipsolver_dense.cpp"
@@ -100,6 +102,10 @@ endif()
100102

101103
set(static_depends)
102104

105+
if(NOT BUILD_WITH_SPARSE)
106+
target_link_libraries(hipsolver PRIVATE $<$<PLATFORM_ID:Linux>:${CMAKE_DL_LIBS}>)
107+
endif()
108+
103109
# Build hipsolver from source on AMD platform
104110
if(NOT USE_CUDA)
105111
# Find rocBLAS
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
/* ************************************************************************
2+
* Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy
5+
* of this software and associated documentation files (the "Software"), to deal
6+
* in the Software without restriction, including without limitation the rights
7+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell cop-
8+
* ies of the Software, and to permit persons to whom the Software is furnished
9+
* to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in all
12+
* copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IM-
15+
* PLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
16+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
17+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
18+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNE-
19+
* CTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20+
*
21+
*
22+
* ************************************************************************ */
23+
24+
#include "cholmod.hpp"
25+
#include "load_function.hpp"
26+
27+
HIPSOLVER_BEGIN_NAMESPACE
28+
29+
fp_cholmod_start g_cholmod_start;
30+
fp_cholmod_finish g_cholmod_finish;
31+
fp_cholmod_allocate_sparse g_cholmod_allocate_sparse;
32+
fp_cholmod_free_sparse g_cholmod_free_sparse;
33+
fp_cholmod_allocate_dense g_cholmod_allocate_dense;
34+
fp_cholmod_free_dense g_cholmod_free_dense;
35+
fp_cholmod_free_factor g_cholmod_free_factor;
36+
fp_cholmod_drop g_cholmod_drop;
37+
fp_cholmod_analyze g_cholmod_analyze;
38+
fp_cholmod_analyze_ordering g_cholmod_analyze_ordering;
39+
fp_cholmod_factorize g_cholmod_factorize;
40+
fp_cholmod_solve g_cholmod_solve;
41+
42+
static bool load_cholmod()
43+
{
44+
#ifdef _WIN32
45+
// Library users will need to call SetErrorMode(SEM_FAILCRITICALERRORS) if
46+
// they wish to avoid an error message box when this library is not found.
47+
// The call is not done by hipSOLVER directly, as it is not thread-safe and
48+
// will affect the global state of the program.
49+
void* handle = LoadLibraryW(L"cholmod.dll");
50+
#else
51+
void* handle = dlopen("libcholmod.so.5", RTLD_NOW | RTLD_LOCAL);
52+
char* err = dlerror(); // clear errors
53+
54+
if(!handle)
55+
{
56+
handle = dlopen("libcholmod.so.4", RTLD_NOW | RTLD_LOCAL);
57+
err = dlerror(); // clear errors
58+
}
59+
60+
if(!handle)
61+
{
62+
handle = dlopen("libcholmod.so.3", RTLD_NOW | RTLD_LOCAL);
63+
err = dlerror(); // clear errors
64+
}
65+
66+
if(!handle)
67+
{
68+
handle = dlopen("libcholmod.so", RTLD_NOW | RTLD_LOCAL);
69+
err = dlerror(); // clear errors
70+
}
71+
#ifndef NDEBUG
72+
if(!handle)
73+
std::cerr << "hipsolver: error loading libcholmod.so: " << err << std::endl;
74+
#endif
75+
#endif /* _WIN32 */
76+
if(!handle)
77+
return false;
78+
79+
if(!load_function(handle, "cholmod_start", g_cholmod_start))
80+
return false;
81+
if(!load_function(handle, "cholmod_finish", g_cholmod_finish))
82+
return false;
83+
84+
if(!load_function(handle, "cholmod_allocate_sparse", g_cholmod_allocate_sparse))
85+
return false;
86+
if(!load_function(handle, "cholmod_free_sparse", g_cholmod_free_sparse))
87+
return false;
88+
if(!load_function(handle, "cholmod_allocate_dense", g_cholmod_allocate_dense))
89+
return false;
90+
if(!load_function(handle, "cholmod_free_dense", g_cholmod_free_dense))
91+
return false;
92+
if(!load_function(handle, "cholmod_free_factor", g_cholmod_free_factor))
93+
return false;
94+
95+
if(!load_function(handle, "cholmod_drop", g_cholmod_drop))
96+
return false;
97+
if(!load_function(handle, "cholmod_analyze", g_cholmod_analyze))
98+
return false;
99+
if(!load_function(handle, "cholmod_analyze_ordering", g_cholmod_analyze_ordering))
100+
return false;
101+
if(!load_function(handle, "cholmod_factorize", g_cholmod_factorize))
102+
return false;
103+
if(!load_function(handle, "cholmod_solve", g_cholmod_solve))
104+
return false;
105+
106+
return true;
107+
}
108+
109+
bool try_load_cholmod()
110+
{
111+
// Function-scope static initialization has been thread-safe since C++11.
112+
// There is an implicit mutex guarding the initialization.
113+
static bool result = load_cholmod();
114+
return result;
115+
}
116+
117+
HIPSOLVER_END_NAMESPACE

0 commit comments

Comments
 (0)