Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/noise_interfaces/noise_process_interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,11 @@ must throw an informative error instead of silently reusing an invalid increment
# slot L₂ was popped from.
cutLength = L₁ - dtM
if cutLength > W.rswm.discard_length
if W.Z == nothing
if isinplace(W)
@.. L₂ -= W.dWtilde
W.Z !== nothing && @.. L₃ -= W.dZtilde
ResettableStacks.copyat_or_push!(W.S₁, (cutLength, L₂, L₃))
elseif W.Z == nothing
ResettableStacks.copyat_or_push!(
W.S₁, (cutLength, L₂ - W.dWtilde, nothing)
)
Expand Down
23 changes: 23 additions & 0 deletions test/RSwM_correctness_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -173,4 +173,27 @@
end
end
end

@testset "RSwM3 in-place S₂ bridge reject_step! does not allocate" begin
W = WienerProcess!(
0.0, zeros(4), zeros(4);
rswm = RSWM(adaptivealg = :RSwM3), rng = Xoshiro(7)
)
calculate_step!(W, 0.2, nothing, nothing)
for _ in 1:50
reject_step!(W, 0.5 * W.dt, nothing, nothing)
accept_step!(W, 0.2, nothing, nothing)
end
# Measure through a local function so @allocated sees a compiled call site.
# A bare `@allocated reject_step!(...)` after `using` inside `@testset` /
# `@safetestset` leaves a 32 B/call world-age artifact on Julia 1.10.
measure_reject(W) = @allocated reject_step!(W, 0.5 * W.dt, nothing, nothing)
total = 0
for _ in 1:100
@test !isempty(W.S₂)
total += measure_reject(W)
accept_step!(W, 0.2, nothing, nothing)
end
@test total == 0
end
end
Loading