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

Cleanup get shmem view #20

Merged
merged 2 commits into from
Jul 18, 2018
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
12 changes: 0 additions & 12 deletions include/KokkosInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,6 @@ inline DeviceTeamPolicy get_device_team_policy(const size_t sz, const size_t byt
return policy.set_scratch_size(0, Kokkos::PerTeam(bytes_per_team), Kokkos::PerThread(bytes_per_thread));
}

inline
SharedMemView<int*> get_int_shmem_view_1D(const TeamHandleType& team, size_t len)
{
return Kokkos::subview(SharedMemView<int**>(team.team_shmem(), team.team_size(), len), team.team_rank(), Kokkos::ALL());
}

inline
SharedMemView<stk::mesh::Entity*> get_entity_shmem_view_1D(const TeamHandleType& team, size_t len)
{
return Kokkos::subview(SharedMemView<stk::mesh::Entity**>(team.team_shmem(), team.team_size(), len), team.team_rank(), Kokkos::ALL());
}

template<typename T>
SharedMemView<T*> get_shmem_view_1D(const TeamHandleType& team, size_t len)
{
Expand Down
8 changes: 4 additions & 4 deletions include/SharedMemData.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ struct SharedMemData {
rhs = get_shmem_view_1D<double>(team, rhsSize);
lhs = get_shmem_view_2D<double>(team, rhsSize, rhsSize);

scratchIds = get_int_shmem_view_1D(team, rhsSize);
sortPermutation = get_int_shmem_view_1D(team, rhsSize);
scratchIds = get_shmem_view_1D<int>(team, rhsSize);
sortPermutation = get_shmem_view_1D<int>(team, rhsSize);
}

const stk::mesh::Entity* elemNodes[simdLen];
Expand Down Expand Up @@ -72,8 +72,8 @@ struct SharedMemData_FaceElem {
rhs = get_shmem_view_1D<double>(team, rhsSize);
lhs = get_shmem_view_2D<double>(team, rhsSize, rhsSize);

scratchIds = get_int_shmem_view_1D(team, rhsSize);
sortPermutation = get_int_shmem_view_1D(team, rhsSize);
scratchIds = get_shmem_view_1D<int>(team, rhsSize);
sortPermutation = get_shmem_view_1D<int>(team, rhsSize);
}

const stk::mesh::Entity* connectedNodes[simdLen];
Expand Down
1 change: 1 addition & 0 deletions unit_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ add_sources(GlobalUnitSourceList
UnitTestPecletFunction.C
UnitTestQuadElementPromotion.C
UnitTestRealm.C
UnitTestShmemAlignment.C
UnitTestSideIsInElement.C
UnitTestSideNodeOrdinals.C
UnitTestSidePCoords.C
Expand Down
35 changes: 35 additions & 0 deletions unit_tests/UnitTestShmemAlignment.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include <gtest/gtest.h>

#include <KokkosInterface.h>

TEST(Shmem, align)
{
unsigned N = 1;
unsigned numScalars = 3;

unsigned bytes_per_team = 0;
unsigned bytes_per_thread = 2048;

auto team_exec = sierra::nalu::get_device_team_policy(N, bytes_per_team, bytes_per_thread);
unsigned numCorrectlyAlignedViews = 0;
Kokkos::parallel_reduce(team_exec, KOKKOS_LAMBDA(const sierra::nalu::TeamHandleType& team, unsigned& localResult)
{
sierra::nalu::SharedMemView<double*> view1 = sierra::nalu::get_shmem_view_1D<double>(team, numScalars);
if (alignof(view1.data()) == 8) {
++localResult;
}

sierra::nalu::SharedMemView<double*> view2 = sierra::nalu::get_shmem_view_1D<double>(team, numScalars);
if (alignof(view1.data()) == 8) {
++localResult;
}

sierra::nalu::SharedMemView<double*> view3 = sierra::nalu::get_shmem_view_1D<double>(team, numScalars);
if (alignof(view1.data()) == 8) {
++localResult;
}
}, numCorrectlyAlignedViews);

EXPECT_EQ(3u, numCorrectlyAlignedViews);
}