You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
KernelAbstractions.@kernelfunctionload_boundary_region_kernel(::Clamp, result, arr, region_code::NTuple{N,Int}, neigh_dist, boundary_dims::NTuple{N,Bool}) where N
184
+
raw_idx = KernelAbstractions.@index(Global)
185
+
186
+
# Convert linear index to Cartesian index
187
+
idx =CartesianIndices(result)[raw_idx]
188
+
189
+
# Compute source index for each dimension
190
+
src_idx =CartesianIndex(ntuple(N) do i
191
+
nd =get_neigh_dist(neigh_dist, i)
192
+
if boundary_dims[i] && region_code[i] ==-1
193
+
# Low boundary - clamp to first element
194
+
firstindex(arr, i)
195
+
elseif boundary_dims[i] && region_code[i] ==+1
196
+
# High boundary - clamp to last element
197
+
lastindex(arr, i)
198
+
elseif region_code[i] ==-1
199
+
# Not at boundary but loading from low side of neighbor
200
+
lastindex(arr, i) - nd + idx[i]
201
+
elseif region_code[i] ==+1
202
+
# Not at boundary but loading from high side of neighbor
203
+
firstindex(arr, i) + idx[i] -1
204
+
else
205
+
# Full extent
206
+
idx[i]
207
+
end
208
+
end)
209
+
result[idx] = arr[src_idx]
210
+
end
183
211
functionload_boundary_region(::Clamp, arr, region_code::NTuple{N,Int}, neigh_dist, boundary_dims::NTuple{N,Bool}) where N
184
212
# Compute the size of this halo region
185
213
region_size =ntuple(N) do i
@@ -188,29 +216,7 @@ function load_boundary_region(::Clamp, arr, region_code::NTuple{N,Int}, neigh_di
188
216
189
217
result =similar(arr, region_size)
190
218
191
-
for idx inCartesianIndices(result)
192
-
# Compute source index for each dimension
193
-
src_idx =CartesianIndex(ntuple(N) do i
194
-
nd =get_neigh_dist(neigh_dist, i)
195
-
if boundary_dims[i] && region_code[i] ==-1
196
-
# Low boundary - clamp to first element
197
-
firstindex(arr, i)
198
-
elseif boundary_dims[i] && region_code[i] ==+1
199
-
# High boundary - clamp to last element
200
-
lastindex(arr, i)
201
-
elseif region_code[i] ==-1
202
-
# Not at boundary but loading from low side of neighbor
203
-
lastindex(arr, i) - nd + idx[i]
204
-
elseif region_code[i] ==+1
205
-
# Not at boundary but loading from high side of neighbor
0 commit comments