-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #164 from JuliaGeodynamics/adm/MKC
Improve and fix marker chain on GPUs
- Loading branch information
Showing
12 changed files
with
172 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,42 @@ | ||
function init_markerchain(backend, nxcell, min_xcell, max_xcell, xv, initial_elevation) | ||
@parallel_indices (i) function fill_coords_index!( | ||
px, py, index, x, initial_elevation, dx_chain, nxcell, max_xcell | ||
) | ||
# lower-left corner of the cell | ||
x0 = x[i] | ||
# fill index array | ||
for ip in 1:nxcell | ||
@index px[ip, i] = x0 + dx_chain * ip | ||
@index py[ip, i] = initial_elevation | ||
@index index[ip, i] = true | ||
end | ||
return nothing | ||
end | ||
|
||
function init_markerchain(::Type{JustPIC.CPUBackend}, nxcell, min_xcell, max_xcell, xv, initial_elevation) | ||
nx = length(xv) - 1 | ||
dx = xv[2] - xv[1] | ||
dx_chain = dx / (nxcell + 1) | ||
px, py = ntuple(_ -> @fill(NaN, (nx,), celldims = (max_xcell,)), Val(2)) | ||
index = @fill(false, (nx,), celldims = (max_xcell,), eltype = Bool) | ||
|
||
@parallel (1:nx) fill_coords_index!( | ||
@parallel (1:nx) fill_markerchain_coords_index!( | ||
px, py, index, xv, initial_elevation, dx_chain, nxcell, max_xcell | ||
) | ||
|
||
return MarkerChain(backend, (px, py), index, xv, min_xcell, max_xcell) | ||
return MarkerChain(JustPIC.CPUBackend, (px, py), index, xv, min_xcell, max_xcell) | ||
end | ||
|
||
@parallel_indices (i) function fill_markerchain_coords_index!( | ||
px, py, index, x, initial_elevation, dx_chain, nxcell, max_xcell | ||
) | ||
# lower-left corner of the cell | ||
x0 = x[i] | ||
# fill index array | ||
for ip in 1:nxcell | ||
@index px[ip, i] = x0 + dx_chain * ip | ||
@index py[ip, i] = initial_elevation | ||
@index index[ip, i] = true | ||
end | ||
return nothing | ||
end | ||
|
||
@parallel_indices (i) function fill_markerchain_coords_index!( | ||
px, py, index, x, initial_elevation::AbstractArray{T, 1}, dx_chain, nxcell, max_xcell | ||
) where {T} | ||
# lower-left corner of the cell | ||
x0 = x[i] | ||
initial_elevation0 = initial_elevation[i] | ||
# fill index array | ||
for ip in 1:nxcell | ||
@index px[ip, i] = x0 + dx_chain * ip | ||
@index py[ip, i] = initial_elevation0 | ||
@index index[ip, i] = true | ||
end | ||
return nothing | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.