Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AMD-related Code Changes #1363

Merged
merged 5 commits into from
Oct 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
252 changes: 109 additions & 143 deletions include/gridtools/boundary_conditions/apply_gpu.hpp

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "../../common/cuda_util.hpp"
#include "../../common/defs.hpp"
#include "../../common/hypercube_iterator.hpp"
#include "../../common/integral_constant.hpp"
#include "../../common/layout_map_metafunctions.hpp"
#include "../../common/make_array.hpp"
#include "../../common/tuple_util.hpp"
Expand All @@ -24,6 +25,9 @@

namespace gridtools {
namespace impl {
// compile-time block size due to HIP-Clang bug https://github.com/ROCm-Developer-Tools/HIP/issues/1283
using block_size_1d_t = integral_constant<int_t, 8>;

template <typename DataType>
__global__ void transform_cuda_loop_kernel(DataType *dst,
DataType *src,
Expand All @@ -32,13 +36,13 @@ namespace gridtools {
gridtools::array<gridtools::uint_t, GT_TRANSFORM_MAX_DIM> src_strides,
gridtools::array<size_t, GT_TRANSFORM_MAX_DIM - 3> outer_dims) {

int i = blockIdx.x * blockDim.x + threadIdx.x;
int i = blockIdx.x * block_size_1d_t::value + threadIdx.x;
fthaler marked this conversation as resolved.
Show resolved Hide resolved
if (i >= dims[0])
return;
int j = blockIdx.y * blockDim.y + threadIdx.y;
int j = blockIdx.y * block_size_1d_t::value + threadIdx.y;
if (j >= dims[1])
return;
int k = blockIdx.z * blockDim.z + threadIdx.z;
int k = blockIdx.z * block_size_1d_t::value + threadIdx.z;
if (k >= dims[2])
return;

Expand Down Expand Up @@ -67,16 +71,15 @@ namespace gridtools {
const std::vector<uint_t> &dims,
const std::vector<uint_t> &dst_strides,
const std::vector<uint_t> &src_strides) {
int block_size_1d = 8;

auto a_dims = impl::vector_to_dims_array<GT_TRANSFORM_MAX_DIM>(dims);
gridtools::array<size_t, GT_TRANSFORM_MAX_DIM - 3> outer_dims;
std::copy(a_dims.begin() + 3, a_dims.end(), outer_dims.begin());

dim3 grid_size((a_dims[0] + block_size_1d - 1) / block_size_1d,
(a_dims[1] + block_size_1d - 1) / block_size_1d,
(a_dims[2] + block_size_1d - 1) / block_size_1d);
dim3 block_size(block_size_1d, block_size_1d, block_size_1d);
dim3 grid_size((a_dims[0] + block_size_1d_t::value - 1) / block_size_1d_t::value,
(a_dims[1] + block_size_1d_t::value - 1) / block_size_1d_t::value,
(a_dims[2] + block_size_1d_t::value - 1) / block_size_1d_t::value);
dim3 block_size(block_size_1d_t::value, block_size_1d_t::value, block_size_1d_t::value);

transform_cuda_loop_kernel<<<grid_size, block_size>>>(dst,
src,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"datetime": "2019-09-27T13:21:05.866185+0000",
"datetime": "2019-10-04T11:43:23.453322+0000",
"domain": [
128,
128,
Expand All @@ -9,131 +9,131 @@
"backend": "cuda",
"clustername": "daint",
"compiler": "/opt/nvidia/cudatoolkit9.2/9.2.148_3.19-6.0.7.1_2.1__g3d9acc8/bin/nvcc 9.2.148 (/opt/cray/pe/craype/2.5.15/bin/CC 6.2.0)",
"datetime": "2019-09-27T13:07:16.000000+0000",
"datetime": "2019-10-04T10:48:55.000000+0000",
"grid": "structured",
"hostname": "daint102",
"hostname": "daint103",
"name": "gridtools",
"precision": "double",
"version": "28825da5472abbe21262c1e9129fd5b6c2048f47"
"version": "201c1c2f2593747cd3415771d3c35946e40e7055"
},
"times": [
{
"measurements": [
0.000433504,
0.000432544,
0.000432,
0.000430784,
0.000430848,
0.000430848,
0.000430464,
0.000430784,
0.000434144,
0.000430272
0.000430528,
0.000431552,
0.0004336,
0.000431072,
0.000431264,
0.000430432,
0.000431712,
0.00043344,
0.000432032,
0.000432032
],
"stencil": "copy"
},
{
"measurements": [
0.00125597,
0.00125155,
0.00126035,
0.00125395,
0.00125923,
0.00125386,
0.00126048,
0.00125405,
0.00125814,
0.00125542
0.00125914,
0.0012567,
0.00125594,
0.00125827,
0.00125648,
0.0012577,
0.00125856,
0.00125898,
0.00126195,
0.00125888
],
"stencil": "horizontal diffusion"
},
{
"measurements": [
0.000982208,
0.000979008,
0.000981312,
0.000982816,
0.000982688,
0.00097936,
0.000981184,
0.000980736,
0.00098,
0.00098272
0.000982528,
0.000983296,
0.000981824,
0.000981248,
0.000981632,
0.000984928,
0.000982944,
0.000981792,
0.000981824,
0.000981696
],
"stencil": "horizontal diffusion fused"
},
{
"measurements": [
0.00243578,
0.00243782,
0.00244026,
0.00244189,
0.0024305,
0.00244522,
0.00244659,
0.00243091,
0.0024401,
0.0024392,
0.00243846,
0.0024321
0.00243872,
0.00243949,
0.00243859,
0.0024393,
0.00244128,
0.00244131,
0.00243984
],
"stencil": "simple horizontal diffusion"
},
{
"measurements": [
0.00239014,
0.00238928,
0.00236496,
0.00236294,
0.00236957,
0.00237619,
0.00237904,
0.00238253,
0.00238272,
0.00237405
0.00237965,
0.00238557,
0.00236499,
0.00236755,
0.00237571,
0.00236826,
0.00237562,
0.00237699,
0.00236566,
0.00237792
],
"stencil": "vertical advection"
},
{
"measurements": [
0.00552717,
0.00553178,
0.00553981,
0.00553309,
0.00553046,
0.00553018,
0.00553389,
0.00553254,
0.00553488,
0.00553142
0.00553043,
0.00553568,
0.00553043,
0.00553594,
0.00553533,
0.00552864,
0.00553149,
0.00553261,
0.00552995,
0.00553114
],
"stencil": "advection pd bott"
},
{
"measurements": [
0.000645248,
0.000650144,
0.00065088,
0.000648064,
0.000649952,
0.000646432,
0.000650592,
0.000647872,
0.000643872,
0.00064672,
0.000649472,
0.000647104
0.000646848,
0.000649504,
0.000649568,
0.000649408,
0.000647616,
0.000650016,
0.000648928
],
"stencil": "layout transformation"
},
{
"measurements": [
0.000405024,
0.00040352,
0.000403072,
0.00040128,
0.000400192,
0.000406784,
0.000403424,
0.00040304,
0.000407936,
0.000401696
0.000386912,
0.000388736,
0.000384768,
0.000388928,
0.000388096,
0.000389248,
0.000385984,
0.00038512,
0.000386208,
0.000385312
],
"stencil": "boundary conditions"
}
Expand Down
Loading