@@ -21,13 +21,26 @@ using Base.SparseMatrix: AbstractSparseMatrix, SparseMatrixCSC, increment, indty
21
21
22
22
include (" cholmod_h.jl" )
23
23
24
+ # ## These offsets are defined in SuiteSparse_wrapper.c
25
+ const common_size = ccall ((:jl_cholmod_common_size ,:libsuitesparse_wrapper ),Int,())
26
+
27
+ const cholmod_com_offsets = Array (Csize_t, 19 )
28
+ ccall ((:jl_cholmod_common_offsets , :libsuitesparse_wrapper ),
29
+ Void, (Ptr{Csize_t},), cholmod_com_offsets)
30
+
31
+ const common_supernodal = (1 : 4 ) + cholmod_com_offsets[4 ]
32
+ const common_final_ll = (1 : 4 ) + cholmod_com_offsets[7 ]
33
+ const common_print = (1 : 4 ) + cholmod_com_offsets[13 ]
34
+ const common_itype = (1 : 4 ) + cholmod_com_offsets[18 ]
35
+ const common_dtype = (1 : 4 ) + cholmod_com_offsets[19 ]
36
+
24
37
# # macro to generate the name of the C function according to the integer type
25
38
macro cholmod_name (nm,typ) string (" cholmod_" , eval (typ) == SuiteSparse_long ? " l_" : " " , nm) end
26
39
27
40
for Ti in IndexTypes
28
41
@eval begin
29
42
function common (:: Type{$Ti} )
30
- a = fill (0xff , cholmod_com_sz )
43
+ a = fill (0xff , common_size )
31
44
@isok ccall ((@cholmod_name " start" $ Ti
32
45
, :libcholmod ), Cint, (Ptr{UInt8},), a)
33
46
set_print_level (a, 0 ) # no printing from CHOLMOD by default
@@ -36,15 +49,66 @@ for Ti in IndexTypes
36
49
end
37
50
end
38
51
39
- # ## These offsets are defined in SuiteSparse_wrapper.c
40
- const cholmod_com_offsets = Array (Csize_t, 19 )
41
- ccall ((:jl_cholmod_common_offsets , :libsuitesparse_wrapper ),
42
- Void, (Ptr{Csize_t},), cholmod_com_offsets)
43
- const common_supernodal = (1 : 4 ) + cholmod_com_offsets[4 ]
44
- const common_final_ll = (1 : 4 ) + cholmod_com_offsets[7 ]
45
- const common_print = (1 : 4 ) + cholmod_com_offsets[13 ]
46
- const common_itype = (1 : 4 ) + cholmod_com_offsets[18 ]
47
- const common_dtype = (1 : 4 ) + cholmod_com_offsets[19 ]
52
+ const version_array = Array (Cint, 3 )
53
+ if dlsym (dlopen (" libcholmod" ), :cholmod_version ) != C_NULL
54
+ ccall ((:cholmod_version , :libcholmod ), Cint, (Ptr{Cint},), version_array)
55
+ else
56
+ ccall ((:jl_cholmod_version , :libsuitesparse_wrapper ), Cint, (Ptr{Cint},), version_array)
57
+ end
58
+ const version = VersionNumber (version_array... )
59
+
60
+ function __init__ ()
61
+ if dlsym (dlopen (" libcholmod" ), :cholmod_version ) == C_NULL
62
+ warn ("""
63
+
64
+ CHOLMOD version incompatibility
65
+
66
+ Julia was compiled with CHOLMOD version $version , but is currently linked with a
67
+ version older than 2.1.0. This might cause Julia to terminate when working with
68
+ sparse matrices for operations involving factorization of a matrix, e.g. solving
69
+ systems of equations with \\ .
70
+
71
+ It is recommended that you either upgrade the package that provides CHOLMOD or
72
+ download the OS X or generic Linux binary from www.julialang.org, which is
73
+ shipped with the correct versions of all dependencies.
74
+ """ )
75
+ else
76
+ tmp = Array (Cint, 3 )
77
+ ccall ((:cholmod_version , :libcholmod ), Cint, (Ptr{Cint},), version_array)
78
+ ccall ((:jl_cholmod_version , :libsuitesparse_wrapper ), Cint, (Ptr{Cint},), tmp)
79
+ if tmp != version_array
80
+ warn ("""
81
+
82
+ CHOLMOD version incompatibility
83
+
84
+ Julia was compiled with CHOLMOD version $version , but is currently linked
85
+ with version $(VersionNumber (tmp... )) . This might cause Julia to terminate when working
86
+ with sparse matrices for operations involving factorization of a matrix,
87
+ e.g. solving systems of equations with \\ .
88
+
89
+ It is recommended that you either upgrade the package that provides CHOLMOD
90
+ or download the OS X or generic Linux binary from www.julialang.org, which
91
+ is shipped with the correct versions of all dependencies.
92
+ """ )
93
+ end
94
+ end
95
+
96
+ intsize = Int (ccall ((:jl_cholmod_sizeof_long ,:libsuitesparse_wrapper ),Csize_t,()))
97
+ if intsize != 4 length (IndexTypes)
98
+ warn ("""
99
+
100
+ CHOLMOD integer size incompatibility
101
+
102
+ Julia was compiled with a version of CHOLMOD that supported $(32 length (IndexTypes)) bit integers,
103
+ but is currently linked with version that supports $(8 intsize) integers. This might
104
+ cause Julia to terminate when working with sparse matrices for operations
105
+ involving factorization of a matrix, e.g. solving systems of equations with \\ .
106
+
107
+ This problem can be fixed by downloading the OS X or generic Linux binary from
108
+ www.julialang.org, which are shipped with the correct versions of all dependencies.
109
+ """ )
110
+ end
111
+ end
48
112
49
113
function set_print_level (cm:: Array{UInt8} , lev:: Integer )
50
114
cm[common_print] = reinterpret (UInt8, [Int32 (lev)])
0 commit comments