Skip to content

Commit

Permalink
[alpaka] Avoid narrowing conversions in elements_with_stride_1d/2d
Browse files Browse the repository at this point in the history
  • Loading branch information
fwyzard committed Oct 19, 2021
1 parent 9c905e8 commit 37df2db
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
16 changes: 8 additions & 8 deletions src/alpaka/AlpakaCore/alpakaWorkDivHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ namespace cms::alpakatools::ALPAKA_ACCELERATOR_NAMESPACE {
return *this;
}
#endif
// the iterator has reached or ovrflowed the end of the extent, clamp it to the extent
// the iterator has reached or overflown the end of the extent, clamp it to the extent
index_ = extent_;
return *this;
}
Expand Down Expand Up @@ -425,7 +425,7 @@ namespace cms::alpakatools::ALPAKA_ACCELERATOR_NAMESPACE {
thread_ = {blockDimension[0u] * blockIndex[0u] + threadIndex[0u],
blockDimension[1u] * blockIndex[1u] + threadIndex[1u],
blockDimension[2u] * blockIndex[2u] + threadIndex[2u]};
stride_ = {blockDimension[0u] * gridDimension[0u], 1, 1};
stride_ = {blockDimension[0u] * gridDimension[0u], Idx{1}, Idx{1}};
extent_ = stride_;

blockDim_ = blockDimension;
Expand All @@ -442,7 +442,7 @@ namespace cms::alpakatools::ALPAKA_ACCELERATOR_NAMESPACE {
blockDimension[1u] * blockIndex[1u] + threadIndex[1u],
blockDimension[2u] * blockIndex[2u] + threadIndex[2u]};
thread_ = thread_ + elementIdxShift;
stride_ = {blockDimension[0u] * gridDimension[0u], 1, 1};
stride_ = {blockDimension[0u] * gridDimension[0u], Idx{1}, Idx{1}};

blockDim_ = blockDimension;
}
Expand Down Expand Up @@ -480,7 +480,7 @@ namespace cms::alpakatools::ALPAKA_ACCELERATOR_NAMESPACE {
}
#endif

// the iterator has reached or ovrflowed the end of the extent, clamp it
// the iterator has reached or overflown the end of the extent, clamp it
// to the extent
index_ = extent_;
return *this;
Expand Down Expand Up @@ -538,7 +538,7 @@ namespace cms::alpakatools::ALPAKA_ACCELERATOR_NAMESPACE {
thread_ = {blockDimension[0u] * blockIndex[0u] + threadIndex[0u],
blockDimension[1u] * blockIndex[1u] + threadIndex[1u],
blockDimension[2u] * blockIndex[2u] + threadIndex[2u]};
stride_ = {blockDimension[0u] * gridDimension[0u], blockDimension[1u] * gridDimension[1u], 1};
stride_ = {blockDimension[0u] * gridDimension[0u], blockDimension[1u] * gridDimension[1u], Idx{1}};
extent_ = stride_;

blockDim_ = blockDimension;
Expand All @@ -555,7 +555,7 @@ namespace cms::alpakatools::ALPAKA_ACCELERATOR_NAMESPACE {
blockDimension[1u] * blockIndex[1u] + threadIndex[1u],
blockDimension[2u] * blockIndex[2u] + threadIndex[2u]};
thread_ = thread_ + elementIdxShift;
stride_ = {blockDimension[0u] * gridDimension[0u], blockDimension[1u] * gridDimension[1u], 1};
stride_ = {blockDimension[0u] * gridDimension[0u], blockDimension[1u] * gridDimension[1u], Idx{1}};

blockDim_ = blockDimension;
}
Expand Down Expand Up @@ -600,7 +600,7 @@ namespace cms::alpakatools::ALPAKA_ACCELERATOR_NAMESPACE {
}
#endif

// the iterator has reached or ovrflowed the end of the extent, clamp it
// the iterator has reached or overflown the end of the extent, clamp it
// to the extent
index_ = extent_;
return *this;
Expand Down Expand Up @@ -733,7 +733,7 @@ namespace cms::alpakatools::ALPAKA_ACCELERATOR_NAMESPACE {
}
#endif

// the iterator has reached or ovrflowed the end of the extent, clamp it
// the iterator has reached or overflown the end of the extent, clamp it
// to the extent
index_ = extent_;
return *this;
Expand Down
8 changes: 4 additions & 4 deletions src/alpaka/test/alpaka/elements_stride.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ struct explicit_loop_1d {
auto blockDimension(alpaka::getWorkDiv<alpaka::Block, alpaka::Elems>(acc));
auto gridDimension(alpaka::getWorkDiv<alpaka::Grid, alpaka::Elems>(acc));

Vec3D thread({blockDimension[0u] * blockIdxInGrid[0u] + threadIdxLocal[0u], 0, 0});
Vec3D stride({blockDimension[0u] * gridDimension[0u], 1, 1});
Vec3D thread({blockDimension[0u] * blockIdxInGrid[0u] + threadIdxLocal[0u], Idx{0}, Idx{0}});
Vec3D stride({blockDimension[0u] * gridDimension[0u], Idx{1}, Idx{1}});
Vec3D index(thread);

for (T i = index[0u]; i < elements[0u]; i += stride[0u]) {
Expand Down Expand Up @@ -77,8 +77,8 @@ struct explicit_loop_2d {

Vec3D thread({blockDimension[0u] * blockIdxInGrid[0u] + threadIdxLocal[0u],
blockDimension[1u] * blockIdxInGrid[1u] + threadIdxLocal[1u],
0});
Vec3D stride({blockDimension[0u] * gridDimension[0u], blockDimension[1u] * gridDimension[1u], 1});
Idx{0}});
Vec3D stride({blockDimension[0u] * gridDimension[0u], blockDimension[1u] * gridDimension[1u], Idx{1}});
Vec3D index(thread);

for (T i = index[1u]; i < elements[1u]; i += stride[1u]) {
Expand Down

0 comments on commit 37df2db

Please sign in to comment.