Skip to content

Commit

Permalink
synchronize immediately after kernels finish
Browse files Browse the repository at this point in the history
  • Loading branch information
rkierulf committed Jan 24, 2025
1 parent 7eb2902 commit fa9abfb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions KomaMRICore/src/simulation/SimMethods/Bloch/gpu/BlochGPU.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ function run_spin_precession!(
Val(!(p.motion isa NoMotion)), Val(length(M.xy)), Val(groupsize), Val(next_least_power_of_two(groupsize)), Val(groupsize - next_least_power_of_two(groupsize)),
ndrange=(cld(length(M.xy), groupsize) * groupsize)
)
KA.synchronize(backend)

AK.reduce(+, view(pre.sig_output,:,1:length(sig)); init=zero(Complex{T}), dims=1, temp=view(pre.sig_output_final,:,1:length(sig)))
sig .= transpose(view(pre.sig_output_final,:,1:length(sig)))
Expand Down Expand Up @@ -70,6 +71,7 @@ function run_spin_excitation!(
Val(!(p.motion isa NoMotion)),
ndrange=size(M.xy,1)
)
KA.synchronize(backend)

#Reset Spin-State (Magnetization). Only for FlowPath
outflow_spin_reset!(M, seq.t', p.motion; replace_by=p.ρ) # TODO: reset state inside kernel
Expand Down
4 changes: 3 additions & 1 deletion KomaMRICore/src/simulation/SimulatorCore.jl
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ function run_sim_time_iter!(
end
samples += Nadc
#Update progress
KA.synchronize(backend)
next!(
progress_bar;
showvalues=[
Expand All @@ -218,6 +217,9 @@ function run_sim_time_iter!(
)
update_blink_window_progress!(w, block, Nblocks)
end
# Ensure simulation is actually finished before reporting the final time
KA.synchronize(backend)

return nothing
end

Expand Down

0 comments on commit fa9abfb

Please sign in to comment.