Skip to content

Commit

Permalink
Move offset check to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon Etter committed Apr 15, 2021
1 parent cebee5a commit 4612f87
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 27 deletions.
27 changes: 0 additions & 27 deletions stdlib/SuiteSparse/src/cholmod.jl
Original file line number Diff line number Diff line change
Expand Up @@ -269,33 +269,6 @@ function __init__()
"""
end

### Check that the Common and Method Julia structs are consistent with their C counterparts
method_offsets = Vector{Csize_t}(undef,15)
ccall((:jl_cholmod_method_offsets, :libsuitesparse_wrapper),
Nothing, (Ptr{Csize_t},), method_offsets)
common_offsets = Vector{Csize_t}(undef,107)
ccall((:jl_cholmod_common_offsets, :libsuitesparse_wrapper),
Nothing, (Ptr{Csize_t},), common_offsets)
common_size = ccall((:jl_cholmod_common_size, :libsuitesparse_wrapper), Csize_t, ())
if !( all(method_offsets .== fieldoffset.(Method,1:length(method_offsets))) &&
all(common_offsets .== fieldoffset.(Common,1:length(common_offsets))) &&
common_size == sizeof(Common) )
@error """
CHOLMOD binary incompatibility
Julia was compiled with a CHOLMOD version whose binary
representation of the cholmod_common_struct is
incompatible with the one currently linked. This might
cause Julia to terminate when working with sparse matrix
factorizations, e.g. solving systems of equations with \\.
This problem can be fixed by modifying the Julia
representation of cholmod_common in cholmod.jl, or by
downloading the generic binaries from www.julialang.org,
which ship with the correct versions of all dependencies.
"""
end

### Initiate CHOLMOD
### common controls the type of factorization and keeps pointers
### to temporary memory. We need to manage a copy for each thread.
Expand Down
15 changes: 15 additions & 0 deletions stdlib/SuiteSparse/test/cholmod.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,21 @@ using SparseArrays: getcolptr
# CHOLMOD tests
Random.seed!(123)

@testset "Check that the Common and Method Julia structs are consistent with their C counterparts" begin
common_size = ccall((:jl_cholmod_common_size, :libsuitesparse_wrapper), Csize_t, ())
@test common_size == sizeof(CHOLMOD.Common)

method_offsets = Vector{Csize_t}(undef,15)
ccall((:jl_cholmod_method_offsets, :libsuitesparse_wrapper),
Nothing, (Ptr{Csize_t},), method_offsets)
@test method_offsets == fieldoffset.(CHOLMOD.Method,1:length(method_offsets))

common_offsets = Vector{Csize_t}(undef,107)
ccall((:jl_cholmod_common_offsets, :libsuitesparse_wrapper),
Nothing, (Ptr{Csize_t},), common_offsets)
@test common_offsets == fieldoffset.(CHOLMOD.Common,1:length(common_offsets))
end

@testset "based on deps/SuiteSparse-4.0.2/CHOLMOD/Demo/" begin

# chm_rdsp(joinpath(Sys.BINDIR, "../../deps/SuiteSparse-4.0.2/CHOLMOD/Demo/Matrix/bcsstk01.tri"))
Expand Down

0 comments on commit 4612f87

Please sign in to comment.