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