|
63 | 63 | const version = VersionNumber(version_array...)
|
64 | 64 |
|
65 | 65 | function __init__()
|
66 |
| - ### Check if the linked library is compatible with the Julia code |
67 |
| - if Libdl.dlsym(Libdl.dlopen("libcholmod"), :cholmod_version) == C_NULL |
68 |
| - hasversion = false |
69 |
| - warn(""" |
70 |
| -
|
71 |
| - CHOLMOD version incompatibility |
72 |
| -
|
73 |
| - Julia was compiled with CHOLMOD version $version. It is |
74 |
| - currently linked with a version older than 2.1.0. This |
75 |
| - might cause Julia to terminate when working with sparse |
76 |
| - matrix factorizations, e.g. solving systems of equations |
77 |
| - with \\. |
78 |
| -
|
79 |
| - It is recommended that you use Julia with a recent version |
80 |
| - of CHOLMOD, or download the OS X or generic Linux binaries |
81 |
| - from www.julialang.org, which ship with the correct |
82 |
| - versions of all dependencies. |
83 |
| - """) |
84 |
| - else |
85 |
| - hasversion = true |
86 |
| - tmp = Array(Cint, 3) |
87 |
| - ccall((:cholmod_version, :libcholmod), Cint, (Ptr{Cint},), version_array) |
88 |
| - ccall((:jl_cholmod_version, :libsuitesparse_wrapper), Cint, (Ptr{Cint},), tmp) |
89 |
| - if tmp != version_array |
| 66 | + try |
| 67 | + ### Check if the linked library is compatible with the Julia code |
| 68 | + if Libdl.dlsym(Libdl.dlopen("libcholmod"), :cholmod_version) == C_NULL |
| 69 | + hasversion = false |
90 | 70 | warn("""
|
91 | 71 |
|
92 |
| - CHOLMOD version incompatibility |
| 72 | + CHOLMOD version incompatibility |
93 | 73 |
|
94 |
| - Julia was compiled with CHOLMOD version $version. It |
95 |
| - is currently linked with a version older than |
96 |
| - $(VersionNumber(tmp...)). This might cause Julia to |
97 |
| - terminate when working with sparse matrix |
98 |
| - factorizations, e.g. solving systems of equations |
99 |
| - with \\. |
| 74 | + Julia was compiled with CHOLMOD version $version. It is |
| 75 | + currently linked with a version older than 2.1.0. This |
| 76 | + might cause Julia to terminate when working with sparse |
| 77 | + matrix factorizations, e.g. solving systems of equations |
| 78 | + with \\. |
100 | 79 |
|
101 |
| - It is recommended that you use Julia with a recent |
102 |
| - version of CHOLMOD, or download the OS X or generic |
103 |
| - Linux binary from www.julialang.org, which ship with |
104 |
| - the correct versions of all dependencies. |
| 80 | + It is recommended that you use Julia with a recent version |
| 81 | + of CHOLMOD, or download the OS X or generic Linux binaries |
| 82 | + from www.julialang.org, which ship with the correct |
| 83 | + versions of all dependencies. |
105 | 84 | """)
|
| 85 | + else |
| 86 | + hasversion = true |
| 87 | + tmp = Array(Cint, 3) |
| 88 | + ccall((:cholmod_version, :libcholmod), Cint, (Ptr{Cint},), version_array) |
| 89 | + ccall((:jl_cholmod_version, :libsuitesparse_wrapper), Cint, (Ptr{Cint},), tmp) |
| 90 | + if tmp != version_array |
| 91 | + warn(""" |
| 92 | +
|
| 93 | + CHOLMOD version incompatibility |
| 94 | +
|
| 95 | + Julia was compiled with CHOLMOD version $version. It |
| 96 | + is currently linked with a version older than |
| 97 | + $(VersionNumber(tmp...)). This might cause Julia to |
| 98 | + terminate when working with sparse matrix |
| 99 | + factorizations, e.g. solving systems of equations |
| 100 | + with \\. |
| 101 | +
|
| 102 | + It is recommended that you use Julia with a recent |
| 103 | + version of CHOLMOD, or download the OS X or generic |
| 104 | + Linux binary from www.julialang.org, which ship with |
| 105 | + the correct versions of all dependencies. |
| 106 | + """) |
| 107 | + end |
106 | 108 | end
|
107 |
| - end |
108 | 109 |
|
109 |
| - intsize = Int(ccall((:jl_cholmod_sizeof_long,:libsuitesparse_wrapper),Csize_t,())) |
110 |
| - if intsize != 4length(IndexTypes) |
111 |
| - warn(""" |
| 110 | + intsize = Int(ccall((:jl_cholmod_sizeof_long,:libsuitesparse_wrapper),Csize_t,())) |
| 111 | + if intsize != 4length(IndexTypes) |
| 112 | + warn(""" |
112 | 113 |
|
113 |
| - CHOLMOD integer size incompatibility |
| 114 | + CHOLMOD integer size incompatibility |
114 | 115 |
|
115 |
| - Julia was compiled with a version of CHOLMOD that |
116 |
| - supported $(32length(IndexTypes)) bit integers. It is |
117 |
| - currently linked with version that supports $(8intsize) |
118 |
| - integers. This might cause Julia to terminate when |
119 |
| - working with sparse matrix factorizations, e.g. solving |
120 |
| - systems of equations with \\. |
| 116 | + Julia was compiled with a version of CHOLMOD that |
| 117 | + supported $(32length(IndexTypes)) bit integers. It is |
| 118 | + currently linked with version that supports $(8intsize) |
| 119 | + integers. This might cause Julia to terminate when |
| 120 | + working with sparse matrix factorizations, e.g. solving |
| 121 | + systems of equations with \\. |
121 | 122 |
|
122 |
| - This problem can be fixed by modifying the Julia build |
123 |
| - configuration or by downloading the OS X or generic |
124 |
| - Linux binary from www.julialang.org, which include |
125 |
| - the correct versions of all dependencies. |
126 |
| - """) |
127 |
| - end |
| 123 | + This problem can be fixed by modifying the Julia build |
| 124 | + configuration or by downloading the OS X or generic |
| 125 | + Linux binary from www.julialang.org, which include |
| 126 | + the correct versions of all dependencies. |
| 127 | + """) |
| 128 | + end |
128 | 129 |
|
129 |
| - ### Initiate CHOLMOD |
130 |
| - ### The common struct. Controls the type of factorization and keeps pointers |
131 |
| - ### to temporary memory. |
132 |
| - global const commonStruct = fill(0xff, common_size) |
133 |
| - |
134 |
| - global const common_supernodal = convert(Ptr{Cint}, pointer(commonStruct, cholmod_com_offsets[4] + 1)) |
135 |
| - global const common_final_ll = convert(Ptr{Cint}, pointer(commonStruct, cholmod_com_offsets[7] + 1)) |
136 |
| - global const common_print = convert(Ptr{Cint}, pointer(commonStruct, cholmod_com_offsets[13] + 1)) |
137 |
| - global const common_itype = convert(Ptr{Cint}, pointer(commonStruct, cholmod_com_offsets[18] + 1)) |
138 |
| - global const common_dtype = convert(Ptr{Cint}, pointer(commonStruct, cholmod_com_offsets[19] + 1)) |
139 |
| - global const common_nmethods = convert(Ptr{Cint}, pointer(commonStruct, cholmod_com_offsets[15] + 1)) |
140 |
| - global const common_postorder = convert(Ptr{Cint}, pointer(commonStruct, cholmod_com_offsets[17] + 1)) |
141 |
| - |
142 |
| - start(commonStruct) # initializes CHOLMOD |
143 |
| - set_print_level(commonStruct, 0) # no printing from CHOLMOD by default |
144 |
| - |
145 |
| - # Register gc tracked allocator if CHOLMOD is new enough |
146 |
| - if hasversion && version >= v"3.0.0" |
147 |
| - cnfg = cglobal((:SuiteSparse_config, :libsuitesparseconfig), Ptr{Void}) |
148 |
| - unsafe_store!(cnfg, cglobal(:jl_malloc, Ptr{Void}), 1) |
149 |
| - unsafe_store!(cnfg, cglobal(:jl_calloc, Ptr{Void}), 2) |
150 |
| - unsafe_store!(cnfg, cglobal(:jl_realloc, Ptr{Void}), 3) |
151 |
| - unsafe_store!(cnfg, cglobal(:jl_free, Ptr{Void}), 4) |
152 |
| - end |
| 130 | + ### Initiate CHOLMOD |
| 131 | + ### The common struct. Controls the type of factorization and keeps pointers |
| 132 | + ### to temporary memory. |
| 133 | + global const commonStruct = fill(0xff, common_size) |
| 134 | + |
| 135 | + global const common_supernodal = |
| 136 | + convert(Ptr{Cint}, pointer(commonStruct, cholmod_com_offsets[4] + 1)) |
| 137 | + global const common_final_ll = |
| 138 | + convert(Ptr{Cint}, pointer(commonStruct, cholmod_com_offsets[7] + 1)) |
| 139 | + global const common_print = |
| 140 | + convert(Ptr{Cint}, pointer(commonStruct, cholmod_com_offsets[13] + 1)) |
| 141 | + global const common_itype = |
| 142 | + convert(Ptr{Cint}, pointer(commonStruct, cholmod_com_offsets[18] + 1)) |
| 143 | + global const common_dtype = |
| 144 | + convert(Ptr{Cint}, pointer(commonStruct, cholmod_com_offsets[19] + 1)) |
| 145 | + global const common_nmethods = |
| 146 | + convert(Ptr{Cint}, pointer(commonStruct, cholmod_com_offsets[15] + 1)) |
| 147 | + global const common_postorder = |
| 148 | + convert(Ptr{Cint}, pointer(commonStruct, cholmod_com_offsets[17] + 1)) |
| 149 | + |
| 150 | + start(commonStruct) # initializes CHOLMOD |
| 151 | + set_print_level(commonStruct, 0) # no printing from CHOLMOD by default |
| 152 | + |
| 153 | + # Register gc tracked allocator if CHOLMOD is new enough |
| 154 | + if hasversion && version >= v"3.0.0" |
| 155 | + cnfg = cglobal((:SuiteSparse_config, :libsuitesparseconfig), Ptr{Void}) |
| 156 | + unsafe_store!(cnfg, cglobal(:jl_malloc, Ptr{Void}), 1) |
| 157 | + unsafe_store!(cnfg, cglobal(:jl_calloc, Ptr{Void}), 2) |
| 158 | + unsafe_store!(cnfg, cglobal(:jl_realloc, Ptr{Void}), 3) |
| 159 | + unsafe_store!(cnfg, cglobal(:jl_free, Ptr{Void}), 4) |
| 160 | + end |
153 | 161 |
|
| 162 | + catch ex |
| 163 | + Base.showerror_nostdio(ex, |
| 164 | + "WARNING: Error during initialization of module CHOLMOD") |
| 165 | + end |
154 | 166 | end
|
155 | 167 |
|
156 | 168 | function set_print_level(cm::Array{UInt8}, lev::Integer)
|
|
0 commit comments