Skip to content

Commit

Permalink
contiguous only keyword for sim
Browse files Browse the repository at this point in the history
  • Loading branch information
palumbom committed Apr 15, 2024
1 parent 66e8f80 commit 941f74b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
16 changes: 9 additions & 7 deletions src/convenience.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,18 @@ Synthesize spectra given parameters in `spec` and `disk` instances.
function synthesize_spectra(spec::SpecParams{T}, disk::DiskParams{T};
seed_rng::Bool=false, verbose::Bool=true,
use_gpu::Bool=false, precision::DataType=Float64,
skip_times::BitVector=falses(disk.Nt)) where T<:AF
skip_times::BitVector=falses(disk.Nt),
contiguous_only::Bool=false) where T<:AF
# call appropriate simulation function on cpu or gpu
if use_gpu
return synth_gpu(spec, disk, seed_rng, verbose, precision, skip_times)
return synth_gpu(spec, disk, seed_rng, verbose, precision, skip_times, contiguous_only)
else
return synth_cpu(spec, disk, seed_rng, verbose, skip_times)
return synth_cpu(spec, disk, seed_rng, verbose, skip_times, contiguous_only)
end
end

function synth_cpu(spec::SpecParams{T}, disk::DiskParams{T}, seed_rng::Bool,
verbose::Bool, skip_times::BitVector) where T<:AF
verbose::Bool, skip_times::BitVector, contiguous_only::Bool) where T<:AF
# parse out dimensions for memory allocation
N = disk.N
Nt = disk.Nt
Expand Down Expand Up @@ -49,7 +50,7 @@ function synth_cpu(spec::SpecParams{T}, disk::DiskParams{T}, seed_rng::Bool,
if verbose
println("\t>>> Template: " * splitdir(file)[end])
end
soldata = SolarData(fname=file)
soldata = SolarData(fname=file, contiguous_only=contiguous_only)

# get conv. blueshift and keys from input data
get_keys_and_cbs!(wsp, soldata)
Expand All @@ -75,7 +76,8 @@ function synth_cpu(spec::SpecParams{T}, disk::DiskParams{T}, seed_rng::Bool,
end

function synth_gpu(spec::SpecParams{T}, disk::DiskParams{T}, seed_rng::Bool,
verbose::Bool, precision::DataType, skip_times::BitVector) where T<:AF
verbose::Bool, precision::DataType, skip_times::BitVector,
contiguous_only::Bool) where T<:AF
# make sure there is actually a GPU to use
@assert CUDA.functional()

Expand Down Expand Up @@ -122,7 +124,7 @@ function synth_gpu(spec::SpecParams{T}, disk::DiskParams{T}, seed_rng::Bool,
if verbose
println("\t>>> Template: " * splitdir(file)[end])
end
soldata_cpu = SolarData(fname=file)
soldata_cpu = SolarData(fname=file, contiguous_only=contiguous_only)
soldata = GPUSolarData(soldata_cpu, precision=precision)

# get conv. blueshift and keys from input data
Expand Down
2 changes: 1 addition & 1 deletion src/gpu/gpu_sim.jl
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,6 @@ function disk_sim_gpu(spec::SpecParams{T1}, disk::DiskParams{T1}, soldata::GPUSo
@cusync flux_cpu .= Array(flux)

# make sure nothing is still running on GPU
CUDA.synchronize()
# CUDA.synchronize()
return nothing
end

0 comments on commit 941f74b

Please sign in to comment.