Skip to content

Commit

Permalink
Fix parallel state equation for macOS ARM (#308)
Browse files Browse the repository at this point in the history
  • Loading branch information
efaulhaber authored Dec 6, 2023
1 parent 2852e00 commit b4267a8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/neighborhood_search/grid_nhs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ function update!(neighborhood_search::GridNeighborhoodSearch, coords_fun)
end

# Use this function barrier and unpack inside to avoid passing closures to Polyester.jl
# with @batch (@threaded).
# Otherwise, @threaded does not work here with Julia ARM on macOS.
# with `@batch` (`@threaded`).
# Otherwise, `@threaded` does not work here with Julia ARM on macOS.
# See https://github.com/JuliaSIMD/Polyester.jl/issues/88.
@inline function mark_changed_cell!(neighborhood_search, cell, coords_fun)
(; hashtable, cell_buffer, cell_buffer_indices) = neighborhood_search
Expand Down
4 changes: 2 additions & 2 deletions src/neighborhood_search/neighborhood_search.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ end
end

# Use this function barrier and unpack inside to avoid passing closures to Polyester.jl
# with @batch (@threaded).
# Otherwise, @threaded does not work here with Julia ARM on macOS.
# with `@batch` (`@threaded`).
# Otherwise, `@threaded` does not work here with Julia ARM on macOS.
# See https://github.com/JuliaSIMD/Polyester.jl/issues/88.
@inline function for_particle_neighbor_inner(f, system_coords, neighbor_system_coords,
neighborhood_search, particle)
Expand Down
13 changes: 9 additions & 4 deletions src/schemes/fluid/weakly_compressible_sph/system.jl
Original file line number Diff line number Diff line change
Expand Up @@ -243,13 +243,18 @@ function reinit_density!(system, v, u, v_ode, u_ode, semi)
end

function compute_pressure!(system, v)
(; state_equation, pressure) = system

@trixi_timeit timer() "state equation" @threaded for particle in eachparticle(system)
pressure[particle] = state_equation(particle_density(v, system, particle))
@threaded for particle in eachparticle(system)
apply_state_equation!(system, particle_density(v, system, particle), particle)
end
end

# Use this function to avoid passing closures to Polyester.jl with `@batch` (`@threaded`).
# Otherwise, `@threaded` does not work here with Julia ARM on macOS.
# See https://github.com/JuliaSIMD/Polyester.jl/issues/88.
@inline function apply_state_equation!(system, density, particle)
system.pressure[particle] = system.state_equation(density)
end

function write_v0!(v0, system::WeaklyCompressibleSPHSystem)
(; initial_condition, density_calculator) = system

Expand Down

0 comments on commit b4267a8

Please sign in to comment.