@@ -24,8 +24,6 @@ import LinearAlgebra: (\), AdjointFactorization,
2424
2525using SparseArrays
2626using SparseArrays: getcolptr, AbstractSparseVecOrMat
27- import Libdl
28-
2927export
3028 Dense,
3129 Factor,
@@ -174,86 +172,19 @@ function newcommon(; print = 0) # no printing from CHOLMOD by default
174172end
175173
176174function getcommon (:: Type{Int32} )
177- init_once ()
175+ LibSuiteSparse . init_suitesparse ()
178176 return get! (newcommon, task_local_storage (), :cholmod_common ):: Ref{cholmod_common}
179177end
180178
181179function getcommon (:: Type{Int64} )
182- init_once ()
180+ LibSuiteSparse . init_suitesparse ()
183181 return get! (newcommon_l, task_local_storage (), :cholmod_common_l ):: Ref{cholmod_common}
184182end
185183
186184getcommon () = getcommon (Int)
187185
188186const BUILD_VERSION = VersionNumber (CHOLMOD_MAIN_VERSION, CHOLMOD_SUB_VERSION, CHOLMOD_SUBSUB_VERSION)
189187
190- const init_once = Base. OncePerProcess {Nothing} () do
191- try
192- # ## Check if the linked library is compatible with the Julia code
193- if Libdl. dlsym_e (Libdl. dlopen (" libcholmod" ), :cholmod_version ) != C_NULL
194- current_version_array = Vector {Cint} (undef, 3 )
195- cholmod_version (current_version_array)
196- current_version = VersionNumber (current_version_array... )
197- else # CHOLMOD < 2.1.1 does not include cholmod_version()
198- current_version = v " 0.0.0"
199- end
200-
201-
202- if current_version < CHOLMOD_MIN_VERSION
203- @warn """
204- CHOLMOD version incompatibility
205-
206- Julia was compiled with CHOLMOD version $BUILD_VERSION . It is
207- currently linked with a version older than
208- $(CHOLMOD_MIN_VERSION) . This might cause Julia to
209- terminate when working with sparse matrix factorizations,
210- e.g. solving systems of equations with \\ .
211-
212- It is recommended that you use Julia with a recent version
213- of CHOLMOD, or download the generic binaries
214- from www.julialang.org, which ship with the correct
215- versions of all dependencies.
216- """
217- elseif BUILD_VERSION. major != current_version. major
218- @warn """
219- CHOLMOD version incompatibility
220-
221- Julia was compiled with CHOLMOD version $BUILD_VERSION . It is
222- currently linked with version $current_version .
223- This might cause Julia to terminate when working with
224- sparse matrix factorizations, e.g. solving systems of
225- equations with \\ .
226-
227- It is recommended that you use Julia with the same major
228- version of CHOLMOD as the one used during the build, or
229- download the generic binaries from www.julialang.org,
230- which ship with the correct versions of all dependencies.
231- """
232- end
233-
234- # Register gc tracked allocator if CHOLMOD is new enough
235- if current_version >= v " 4.0.3"
236- ccall ((:SuiteSparse_config_malloc_func_set , libsuitesparseconfig),
237- Cvoid, (Ptr{Cvoid},), cglobal (:jl_malloc , Ptr{Cvoid}))
238- ccall ((:SuiteSparse_config_calloc_func_set , libsuitesparseconfig),
239- Cvoid, (Ptr{Cvoid},), cglobal (:jl_calloc , Ptr{Cvoid}))
240- ccall ((:SuiteSparse_config_realloc_func_set , libsuitesparseconfig),
241- Cvoid, (Ptr{Cvoid},), cglobal (:jl_realloc , Ptr{Cvoid}))
242- ccall ((:SuiteSparse_config_free_func_set , libsuitesparseconfig),
243- Cvoid, (Ptr{Cvoid},), cglobal (:jl_free , Ptr{Cvoid}))
244- elseif current_version >= v " 3.0.0"
245- cnfg = cglobal ((:SuiteSparse_config , libsuitesparseconfig), Ptr{Cvoid})
246- unsafe_store! (cnfg, cglobal (:jl_malloc , Ptr{Cvoid}), 1 )
247- unsafe_store! (cnfg, cglobal (:jl_calloc , Ptr{Cvoid}), 2 )
248- unsafe_store! (cnfg, cglobal (:jl_realloc , Ptr{Cvoid}), 3 )
249- unsafe_store! (cnfg, cglobal (:jl_free , Ptr{Cvoid}), 4 )
250- end
251-
252- catch ex
253- @error " Error during initialization of module CHOLMOD" exception= ex,catch_backtrace ()
254- end
255- end
256-
257188# ###################
258189# Type definitions #
259190# ###################
0 commit comments