-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cuda): Add transposer kernels for reordering field data.
- Loading branch information
Showing
3 changed files
with
48 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
module m_cuda_kernels_trans | ||
use cudafor | ||
|
||
use m_common, only: dp | ||
use m_cuda_common, only: SZ | ||
|
||
contains | ||
|
||
attributes(global) subroutine trans_x2y_k(u_y, u_x) | ||
implicit none | ||
|
||
real(dp), device, intent(out), dimension(:, :, :) :: u_y | ||
real(dp), device, intent(in), dimension(:, :, :) :: u_x | ||
|
||
real(dp), shared :: tile(SZ, SZ) | ||
integer :: i, j, b_i, b_j, b_k, nz | ||
|
||
i = threadIdx%x; j = threadIdx%y | ||
b_i = blockIdx%x; b_j = blockIdx%y; b_k = blockIdx%z | ||
nz = gridDim%z*blockDim%z | ||
|
||
! copy into shared | ||
tile(i, j) = u_x(i, j+(b_i-1)*SZ, b_j+(b_k-1)*nz) | ||
|
||
call syncthreads() | ||
|
||
! copy into output array from shared | ||
u_y(i, j+(b_k-1)*SZ, b_j+(b_i-1)*nz) = tile(j, i) | ||
|
||
end subroutine trans_x2y_k | ||
|
||
end module m_cuda_kernels_trans |