Skip to content

Commit e216523

Browse files
bmmogensenBjorn
andauthored
Support Julia built with USE_GPL_LIBS=0 (#18)
* Add fixes to enable build when USE_GPL_LIBS = 0 Co-authored-by: Bjorn <bmm@hafniumlabs.com>
1 parent 385c7a4 commit e216523

File tree

2 files changed

+51
-15
lines changed

2 files changed

+51
-15
lines changed

src/factorizations.jl

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,26 +122,33 @@ macro makefrommatrix(fact)
122122
end
123123
end
124124

125-
126-
127125
include("jacobi.jl")
128126
include("ilu0.jl")
129127
include("parallel_jacobi.jl")
130128
include("parallel_ilu0.jl")
131-
include("umfpack_lu.jl")
132-
include("cholmod_cholesky.jl")
133129

134130
@eval begin
135-
136-
@makefrommatrix LUFactorization
137-
@makefrommatrix CholeskyFactorization
131+
138132
@makefrommatrix ILU0Preconditioner
139133
@makefrommatrix JacobiPreconditioner
140134
@makefrommatrix ParallelJacobiPreconditioner
141135
@makefrommatrix ParallelILU0Preconditioner
142136

143137
end
144138

139+
if Base.USE_GPL_LIBS
140+
#requires SuiteSparse which is not available in non-GPL builds
141+
include("umfpack_lu.jl")
142+
include("cholmod_cholesky.jl")
143+
144+
@eval begin
145+
146+
@makefrommatrix LUFactorization
147+
@makefrommatrix CholeskyFactorization
148+
149+
end
150+
end
151+
145152

146153

147154

test/runtests.jl

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -157,16 +157,20 @@ function test_addition(;m=10,n=10,d=0.1) where {Tv,Ti}
157157
csc2==2*csc
158158
end
159159

160-
161160
function test_operations(n)
162161
A=ExtendableSparseMatrix(n,n)
163162
sprand_sdd!(A)
164163
b=rand(n)
164+
if Base.USE_GPL_LIBS begin
165+
#requires SuiteSparse which is not available on non-GPL builds
165166
x=A\b
166167
Ax=A*x
167168
b Ax
168169
end
169-
170+
else
171+
true
172+
end
173+
end
170174

171175
@testset "Operations" begin
172176
for irun=1:10
@@ -175,7 +179,7 @@ end
175179
d=0.3*rand()
176180
@test test_addition(m=m,n=n,d=d)
177181
end
178-
182+
179183
@test test_operations(10)
180184
@test test_operations(100)
181185
@test test_operations(1000)
@@ -261,6 +265,8 @@ function test_precon2(precon,k,l,m;maxiter=10000)
261265
end
262266

263267

268+
if Base.USE_GPL_LIBS begin
269+
#requires SuiteSparse which is not available on non-GPL builds
264270
@testset "preconditioners" begin
265271
@test all(isapprox.(test_precon(ILU0Preconditioner,20,20,20), (true, 1.3535160424212675e-5), rtol=1.0e-5))
266272
@test all(isapprox.(test_precon(JacobiPreconditioner,20,20,20), (true, 2.0406032775945658e-5), rtol=1.0e-5))
@@ -269,15 +275,15 @@ end
269275
@test all(isapprox.(test_precon(AMGPreconditioner,20,20,20), (true, 6.863753664354144e-7), rtol=1.0e-2))
270276
end
271277

272-
273278
@testset "preconditioners 2" begin
274279
@test all(isapprox.(test_precon2(ILU0Preconditioner(),20,20,20), (true, 1.3535160424212675e-5), rtol=1.0e-5))
275280
@test all(isapprox.(test_precon2(JacobiPreconditioner(),20,20,20), (true, 2.0406032775945658e-5), rtol=1.0e-5))
276281
@test all(isapprox.(test_precon2(ParallelJacobiPreconditioner(),20,20,20), (true, 2.0406032775945658e-5), rtol=1.0e-5))
277282
@test all(isapprox.(test_precon2(ILUTPreconditioner(),20,20,20), (true, 1.2719511868322086e-5), rtol=1.0e-5))
278283
@test all(isapprox.(test_precon2(AMGPreconditioner(),20,20,20), (true, 6.863753664354144e-7), rtol=1.0e-2))
279284
end
280-
285+
end
286+
end
281287

282288

283289
##############################################
@@ -288,7 +294,12 @@ function test_symmetric(n,uplo)
288294
flush!(A)
289295
SA=Symmetric(A,uplo)
290296
Scsc=Symmetric(A.cscmatrix,uplo)
297+
if Base.USE_GPL_LIBS
298+
#requires SuiteSparse which is not available on non-GPL builds
291299
SA\b Scsc\b
300+
else
301+
true
302+
end
292303
end
293304

294305

@@ -313,7 +324,12 @@ function test_hermitian(n,uplo)
313324
b=rand(n)
314325
HA=Hermitian(A,uplo)
315326
Hcsc=Hermitian(A.cscmatrix,uplo)
327+
if Base.USE_GPL_LIBS
328+
#requires SuiteSparse which is not available on non-GPL builds
316329
HA\b Hcsc\b
330+
else
331+
true
332+
end
317333
end
318334

319335
@testset "hermitian" begin
@@ -361,7 +377,8 @@ function test_lu2(k,l,m;lufac=ExtendableSparse.LUFactorization())
361377
all(x1ext.< x2ext)
362378
end
363379

364-
380+
if Base.USE_GPL_LIBS
381+
#requires SuiteSparse which is not available on non-GPL builds
365382
@testset "ExtendableSparse.LUFactorization" begin
366383
@test test_lu1(10,10,10)
367384
@test test_lu1(25,40,1)
@@ -371,7 +388,10 @@ end
371388
@test test_lu2(25,40,1)
372389
@test test_lu2(1000,1,1)
373390
end
391+
end
374392

393+
if Base.USE_GPL_LIBS
394+
#requires SuiteSparse which is not available on non-GPL builds
375395
@testset "Cholesky" begin
376396
@test test_lu1(10,10,10,lufac=CholeskyFactorization())
377397
@test test_lu1(25,40,1,lufac=CholeskyFactorization())
@@ -381,7 +401,11 @@ end
381401
@test test_lu2(25,40,1,lufac=CholeskyFactorization())
382402
@test test_lu2(1000,1,1,lufac=CholeskyFactorization())
383403
end
404+
end
384405

406+
407+
if Base.USE_GPL_LIBS
408+
#requires SuiteSparse which is not available on non-GPL builds
385409
@testset "mkl-pardiso" begin
386410
if !Sys.isapple()
387411
@test test_lu1(10,10,10,lufac=MKLPardisoLU())
@@ -396,8 +420,10 @@ end
396420
# @test test_lu2(25,40,1,lufac=MKLPardisoLU(mtype=2))
397421
# @test test_lu2(1000,1,1,lufac=MKLPardisoLU(mtype=2))
398422
end
423+
end
399424

400-
425+
if Base.USE_GPL_LIBS
426+
#requires SuiteSparse which is not available on non-GPL builds
401427
if Pardiso.PARDISO_LOADED[]
402428
@testset "pardiso" begin
403429
@test test_lu1(10,10,10,lufac=PardisoLU())
@@ -414,7 +440,7 @@ if Pardiso.PARDISO_LOADED[]
414440

415441
end
416442
end
417-
443+
end
418444

419445

420446
##############################################
@@ -462,6 +488,9 @@ function test_linearsolve(n)
462488

463489
end
464490

491+
if Base.USE_GPL_LIBS
492+
#requires SuiteSparse which is not available on non-GPL builds
465493
@testset "LinearSolve" begin
466494
test_linearsolve(20)
467495
end
496+
end

0 commit comments

Comments
 (0)