From f195f0cda34908ddcabe47ac9f43ae607d37b3ab Mon Sep 17 00:00:00 2001 From: Erik Faulhaber <44124897+efaulhaber@users.noreply.github.com> Date: Mon, 13 Oct 2025 12:24:00 +0200 Subject: [PATCH 1/3] Make interpolation with different smoothing length work on the GPU --- src/general/interpolation.jl | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/general/interpolation.jl b/src/general/interpolation.jl index bf26f80906..538d37407f 100644 --- a/src/general/interpolation.jl +++ b/src/general/interpolation.jl @@ -394,7 +394,9 @@ function interpolate_line(start, end_, n_points, semi, ref_system, v_ode, u_ode; # Convert to coordinate matrix points_coords_ = collect(reinterpret(reshape, eltype(start_svector), points_coords)) - return interpolate_points(points_coords_, semi, ref_system, v_ode, u_ode; + points_coords__ = Adapt.adapt(semi.parallelization_backend, points_coords_) + + return interpolate_points(points_coords__, semi, ref_system, v_ode, u_ode; smoothing_length=smoothing_length, cut_off_bnd=cut_off_bnd, clip_negative_pressure) end @@ -496,9 +498,15 @@ function process_neighborhood_searches(semi, u_ode, ref_system, smoothing_length old_nhs = get_neighborhood_search(ref_system, system, semi) nhs = PointNeighbors.copy_neighborhood_search(old_nhs, search_radius, nparticles(system)) - PointNeighbors.initialize!(nhs, point_coords, system_coords) - return nhs + # In case of GPU backends, we need to move the internal data structures + # of the neighborhood search to the GPU as well. + # On the CPU, this is a no-op. + nhs_ = Adapt.adapt(semi.parallelization_backend, nhs) + + PointNeighbors.initialize!(nhs_, point_coords, system_coords) + + return nhs_ end return neighborhood_searches From fa55170d5fe9c1647ef4380997b6312c33d84010 Mon Sep 17 00:00:00 2001 From: Sven Berger Date: Fri, 21 Nov 2025 18:30:10 +0100 Subject: [PATCH 2/3] add test --- dev/PointNeighbors | 1 + test/examples/gpu.jl | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 160000 dev/PointNeighbors diff --git a/dev/PointNeighbors b/dev/PointNeighbors new file mode 160000 index 0000000000..4d57002bf2 --- /dev/null +++ b/dev/PointNeighbors @@ -0,0 +1 @@ +Subproject commit 4d57002bf2cfd68ebc7357c59d0101f6af1722d9 diff --git a/test/examples/gpu.jl b/test/examples/gpu.jl index 49fb7bc49f..a63cb200f6 100644 --- a/test/examples/gpu.jl +++ b/test/examples/gpu.jl @@ -520,6 +520,32 @@ end 913.2089]) end + @testset verbose=true "Line with different smoothing_length" begin + # Interpolation parameters + n_interpolation_points = 10 + start_point = Float32[0.5, 0.0] + end_point = Float32[0.5, 0.5] + + result = interpolate_line(start_point, end_point, n_interpolation_points, + semi_new, semi_new.systems[1], sol; + cut_off_bnd=false, smoothing_length=0.2f0) + + @test isapprox(Array(result.computed_density), + Float32[500.96387, 859.06744, 989.0479, 1001.3735, + 1001.30927, 1001.0831, 1000.7325, 1000.3575, + 999.8011, 975.98553]) + + @test isapprox(Array(result.density), + Float32[1002.1891, 1002.0748, 1001.8913, 1001.67126, + 1001.4529, 1001.2382, 1001.0298, 1000.81964, + 1000.594, 1000.3878]) + + @test isapprox(Array(result.pressure), + Float32[5154.1177, 4885.1, 4452.6533, 3934.9075, 3420.5737, + 2915.0933, 2424.0908, 1929.7888, 1398.8309, + 913.2089]) + end + @testset verbose=true "Plane" begin interpolation_start = Float32[0.0, 0.0] interpolation_end = Float32[1.0, 1.0] From 206019094b95045ceb73377805e129356362b59c Mon Sep 17 00:00:00 2001 From: Sven Berger Date: Fri, 21 Nov 2025 18:59:32 +0100 Subject: [PATCH 3/3] remove PN --- dev/PointNeighbors | 1 - 1 file changed, 1 deletion(-) delete mode 160000 dev/PointNeighbors diff --git a/dev/PointNeighbors b/dev/PointNeighbors deleted file mode 160000 index 4d57002bf2..0000000000 --- a/dev/PointNeighbors +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 4d57002bf2cfd68ebc7357c59d0101f6af1722d9