Skip to content

Commit

Permalink
remove blas thread that always segfault
Browse files Browse the repository at this point in the history
  • Loading branch information
mloubout committed Mar 19, 2024
1 parent 7caaf90 commit 5796b01
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 47 deletions.
3 changes: 1 addition & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,14 @@ ZygoteJUDIExt = "Zygote"

[extras]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
ArgParse = "c7e460c6-2fb9-53a9-8c5b-16f535851c63"
Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c"
JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
TimerOutputs = "a759f4b9-e2f1-59dc-863e-4aeb61b1ea8f"

[targets]
test = ["Aqua", "ArgParse", "JLD2", "Printf", "Test", "TimerOutputs", "Flux"]
test = ["Aqua", "JLD2", "Printf", "Test", "TimerOutputs", "Flux"]

[weakdeps]
Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c"
Expand Down
2 changes: 0 additions & 2 deletions src/JUDI.jl
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,6 @@ function __init__()
end
end

# BLAS num threads for dense LA such as sinc interpolation
BLAS.set_num_threads(Threads.nthreads())
end

end
2 changes: 1 addition & 1 deletion src/pysource/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ def _cfl_coeff(self):
c_fd = sum(np.abs(coeffs[-1][-1])) / 2
return .9 * np.sqrt(self.dim) / self.dim / c_fd
a1 = 4 # 2nd order in time
so = max(self._space_order, 4)
so = max(self._space_order // 2, 4)
coeffs = fd_w(2, range(-so, so), 0)[-1][-1]
return .9 * np.sqrt(a1/float(self.grid.dim * sum(np.abs(coeffs))))

Expand Down
14 changes: 5 additions & 9 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# Updated July 2020

using JUDI
using ArgParse, Test, Printf, Aqua
using Test, Printf, Aqua
using SegyIO, LinearAlgebra, Distributed, JOLI
using TimerOutputs: TimerOutputs, @timeit

Expand All @@ -25,13 +25,10 @@ const GROUP = get(ENV, "GROUP", "JUDI")
# JUDI seismic utils
include("seismic_utils.jl")

parsed_args = parse_commandline()
const nlayer = parsed_args["nlayer"]
const tti = parsed_args["tti"] || contains(GROUP, "TTI")
const fs = parsed_args["fs"] || contains(GROUP, "FS")
const nw = (GROUP == "BASICS" || GROUP == "ISO_OP") ? 2 : 0
const viscoacoustic = parsed_args["viscoacoustic"] || contains(GROUP, "VISCO")

const nlayer = 2
const tti = contains(GROUP, "TTI")
const fs = contains(GROUP, "FS")
const viscoacoustic = true #contains(GROUP, "VISCO")

# Utility macro to run block of code with a single omp threa
macro single_threaded(expr)
Expand Down Expand Up @@ -72,7 +69,6 @@ issues = ["test_issues.jl"]

# custom
if endswith(GROUP, ".jl")
# VERSION >= v"1.7" && push!(Base.ARGS, "-p 2")
timeit_include(GROUP)
end

Expand Down
26 changes: 0 additions & 26 deletions test/seismic_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -99,32 +99,6 @@ function setup_geom(model; nsrc=1, tn=1500f0, dt=nothing)
end


### Process command line args
function parse_commandline()
s = ArgParseSettings()
@add_arg_table! s begin
"--tti"
help = "TTI, default False"
action = :store_true
"--viscoacoustic"
help = "Viscoacoustic, default False"
action = :store_true
"--fs"
help = "Free surface, default False"
action = :store_true
"--nlayer", "-n"
help = "Number of layers"
arg_type = Int
default = 2
"--parallel", "-p"
help = "Number of workers"
arg_type = Int
default = 1
end
return parse_args(s)
end


# Example structures
example_model(; n=(120,100), d=(10f0, 10f0), o=(0f0, 0f0), m=randn(Float32, n)) = Model(n, d, o, m)

Expand Down
Binary file modified test/shot_record_250.0_0.0_20.0.segy
Binary file not shown.
Binary file modified test/shot_record_750.0_0.0_20.0.segy
Binary file not shown.
8 changes: 4 additions & 4 deletions test/test_adjoint.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Date: May 2020
#

using Distributed
nw = 2

# # Set parallel if specified
if nw > 1 && nworkers() < nw
Expand Down Expand Up @@ -60,9 +60,9 @@ test_adjoint(adj::Bool, last::Bool) = (adj || last) ? (@test adj) : (@test_skip
# Modeling operators
@testset "Adjoint test with $(nlayer) layers and tti $(tti) and viscoacoustic $(viscoacoustic) and freesurface $(fs)" begin
@timeit TIMEROUTPUT "Adjoint" begin
opt = Options(sum_padding=true, dt_comp=dt, free_surface=parsed_args["fs"], f0=f0)
opt = Options(sum_padding=true, dt_comp=dt, free_surface=fs, f0=f0)
F = judiModeling(model0, srcGeometry, recGeometry; options=opt)

@show q.nsrc
# Nonlinear modeling
y = F*q

Expand All @@ -84,7 +84,7 @@ end
# Extended source modeling
@testset "Extended source adjoint test with $(nlayer) layers and tti $(tti) and viscoacoustic $(viscoacoustic) and freesurface $(fs)" begin
@timeit TIMEROUTPUT "Extended source adjoint" begin
opt = Options(sum_padding=true, dt_comp=dt, free_surface=parsed_args["fs"], f0=f0)
opt = Options(sum_padding=true, dt_comp=dt, free_surface=fs, f0=f0)
F = judiModeling(model0, srcGeometry, recGeometry; options=opt)
Pr = judiProjection(recGeometry)
Fw = judiModeling(model0; options=opt)
Expand Down
2 changes: 1 addition & 1 deletion test/test_linearity.jl
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ end


####################### Extended source operators ##########################################
if parsed_args["tti"]
if tti
ftol = 5f-4
end

Expand Down
5 changes: 3 additions & 2 deletions test/test_modeling.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
# Mathias Louboutin, [email protected]
# Updated July 2020

nw = 2

# Set parallel if specified
if nw > 1 && nworkers() < nw
addprocs(nw-nworkers() + 1; exeflags=["--code-coverage=user", "--inline=no", "--check-bounds=yes"])
end

@everywhere using JOLI
@everywhere using JUDI, LinearAlgebra, Test, Distributed
@everywhere using JOLI, JUDI, LinearAlgebra, Test, Distributed

### Model
model, model0, dm = setup_model(tti, viscoacoustic, nlayer; n=(101, 101), d=(10., 10.))
Expand Down

0 comments on commit 5796b01

Please sign in to comment.