Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segmentation fault with SCOTCH #121

Open
amontoison opened this issue Jan 26, 2025 · 1 comment
Open

Segmentation fault with SCOTCH #121

amontoison opened this issue Jan 26, 2025 · 1 comment
Labels

Comments

@amontoison
Copy link
Member

amontoison commented Jan 26, 2025

@abuttari
I recompiled qr_mumps with Yggdrasil for @MaxenceGollier and I linked qr_mumps with SCOTCH v7.0.6 this time.
It was a pain to cross-compile SCOTCH a few years ago so I never tested it.
However I have a segmentation fault when I use it now:

[8314] signal 11 (1): Erreur de segmentation
in expression starting at /home/alexis/Bureau/git/QRMumps.jl/test/test_qrm.jl:313
free at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
_SCOTCHgraphFree at /home/alexis/.julia/artifacts/dee4cf51795976ee3232b834fec63ffeefe4a5a4/lib/libscotch.so.7.0 (unknown line)
sqrm_do_scotch_ at /home/alexis/.julia/artifacts/99a61771b57631d9779ad332148d30e4eee81f4b/lib/libsqrm.so (unknown line)
sqrm_do_ordering_ at /home/alexis/.julia/artifacts/99a61771b57631d9779ad332148d30e4eee81f4b/lib/libsqrm.so (unknown line)
sqrm_analysis_core_ at /home/alexis/.julia/artifacts/99a61771b57631d9779ad332148d30e4eee81f4b/lib/libsqrm.so (unknown line)
sqrm_analyse_async_.part.0 at /home/alexis/.julia/artifacts/99a61771b57631d9779ad332148d30e4eee81f4b/lib/libsqrm.so (unknown line)
sqrm_analyse_ at /home/alexis/.julia/artifacts/99a61771b57631d9779ad332148d30e4eee81f4b/lib/libsqrm.so (unknown line)
sqrm_analyse_c at /home/alexis/.julia/artifacts/99a61771b57631d9779ad332148d30e4eee81f4b/lib/libsqrm.so (unknown line)
sqrm_analyse_c at /home/alexis/Bureau/git/QRMumps.jl/src/wrapper/libqrmumps.jl:19

I added some unit tests in #120 if you want to reproduce the error.

@amontoison amontoison added the bug label Jan 26, 2025
@amontoison
Copy link
Member Author

amontoison commented Jan 26, 2025

I also have these small examples:

using QRMumps, LinearAlgebra, SparseArrays, Printf

irn = [1, 1, 1, 2, 3, 3, 4, 4, 5, 5, 6, 7, 7]
jcn = [1, 3, 5, 2, 3, 5, 1, 4, 4, 5, 2, 1, 3]
val = [1.0, 2.0, 3.0, 1.0, 1.0, 2.0, 4.0, 1.0, 5.0, 1.0, 3.0, 6.0, 1.0]

A = sparse(irn, jcn, val, 7, 5)
b = [22.0, 5.0, 13.0, 8.0, 25.0, 5.0, 9.0]
x_star = [1.0, 2.0, 3.0, 4.0, 5.0]

qrm_init()

spmat = qrm_spmat_init(A)
spfct = qrm_spfct_init(spmat)

# Compute a column permutation with SCOTCH
qrm_set(spfct, "qrm_ordering", 5)

qrm_analyse!(spmat, spfct)
qrm_factorize!(spmat, spfct)
z = qrm_apply(spfct, b, transp='t')
x = qrm_solve(spfct, z)

error_norm = norm(x - x_star)
r = A * x - b
optimality_residual_norm = norm(A' * r)

@printf("Error norm ‖x* - x‖ = %10.5e\n", error_norm)
@printf("Optimality residual norm ‖Aᵀr‖ = %10.5e\n", optimality_residual_norm)
using QRMumps, LinearAlgebra, SparseArrays, Printf

irn = [1, 1, 1, 2, 3, 3, 4, 4, 5, 5, 6, 7, 7]
jcn = [1, 3, 5, 2, 3, 5, 1, 4, 4, 5, 2, 1, 3]
val = [1.0+im, 2.0-im, 3.0+im, 1.0-im, 1.0+im, 2.0-im, 4.0+im, 1.0-im, 5.0+im, 1.0-im, 3.0+im, 6.0-im, 1.0+im]

A = sparse(irn, jcn, val, 7, 5)
b = [1.0+im, 2.0+im, 3.0+im, 4.0+im, 5.0+im, 6.0+im, 7.0+im]
z = copy(b)
x = zeros(ComplexF64, 5)

qrm_init()

spmat = qrm_spmat_init(A)
spfct = qrm_spfct_init(spmat)

# Compute a column permutation with SCOTCH
qrm_set(spfct, "qrm_ordering", 5)

qrm_analyse!(spmat, spfct)
qrm_factorize!(spmat, spfct)
qrm_apply!(spfct, z, transp='c')
qrm_solve!(spfct, z, x)

r = A * x - b
optimality_residual_norm = norm(A' * r)

@printf("Optimality residual norm ‖Aᵀr‖ = %10.5e\n", optimality_residual_norm)
using QRMumps, LinearAlgebra, SparseArrays, Printf

irn = [1, 2, 1, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5]
jcn = [1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5]
val = [4.0, 1.0, 1.0, 4.0, 1.0, 1.0, 4.0, 1.0, 1.0, 4.0, 1.0, 1.0, 4.0]

A = sparse(irn, jcn, val, 5, 5)
A_U = triu(A)
b = [5.0, 6.0, 6.0, 6.0, 5.0]
x_star = [1.0, 1.0, 1.0, 1.0, 1.0]

qrm_init()

spmat = qrm_spmat_init(A_U, sym=true)
spfct = qrm_spfct_init(spmat)

# Compute a column permutation with SCOTCH
qrm_set(spfct, "qrm_ordering", 5)

qrm_analyse!(spmat, spfct)
qrm_factorize!(spmat, spfct)
z = qrm_solve(spfct, b, transp='t')
x = qrm_solve(spfct, z)

error_norm = norm(x - x_star)
residual_norm = norm(A * x - b)

@printf("Error norm ‖x* - x‖ = %10.5e\n", error_norm)
@printf("Residual norm ‖Ax - b‖ = %10.5e\n", residual_norm)
using QRMumps, LinearAlgebra, SparseArrays, Printf

irn = [1, 1, 1, 2, 2, 3]
jcn = [1, 2, 3, 2, 3, 3]
val = [7.0, im, -5im, 8.0, 5.0, 10.0]

A = Hermitian(sparse(irn, jcn, val, 3, 3), :U)
b = [11.0-6im, 32.0+12im, 35.0+20im]
x_star = [1.0+im, 2.0+im, 3.0+im]
x = copy(b)

qrm_init()

spmat = qrm_spmat_init(A)
spfct = qrm_spfct_init(spmat)

# Compute a column permutation with SCOTCH
qrm_set(spfct, "qrm_ordering", 5)

qrm_analyse!(spmat, spfct)
qrm_factorize!(spmat, spfct)

qrm_solve!(spfct, x, x, transp='c')
qrm_solve!(spfct, x, x)

error_norm = norm(x - x_star)
residual_norm = norm(A * x - b)

@printf("Error norm ‖x* - x‖ = %10.5e\n", error_norm)
@printf("Residual norm ‖Ax - b‖ = %10.5e\n", residual_norm)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant