Skip to content
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
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ add_subdirectory(apps-kokkos)
add_subdirectory(lcals)
add_subdirectory(lcals-kokkos)
add_subdirectory(polybench)
add_subdirectory(polybench-kokkos)
add_subdirectory(stream)
add_subdirectory(stream-kokkos)
add_subdirectory(algorithm)
Expand All @@ -31,6 +32,7 @@ set(RAJA_PERFSUITE_LIBS
lcals
lcals-kokkos
polybench
polybench-kokkos
stream
stream-kokkos
algorithm
Expand Down
6 changes: 0 additions & 6 deletions src/basic-kokkos/NESTED_INIT-Kokkos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,6 @@ void NESTED_INIT::runKokkosVariant(VariantID vid) {
// See the basic NESTED_INIT.hpp file for defnition of NESTED_INIT

auto array_kokkos_view = getViewFromPointer(array, nk, nj, ni);
//
// Used in Kokkos variant (below). Do not remove.
//
auto nestedinit_lam = [=](Index_type i, Index_type j, Index_type k) {
NESTED_INIT_BODY;
};

switch (vid) {

Expand Down
9 changes: 0 additions & 9 deletions src/lcals-kokkos/INT_PREDICT-Kokkos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,6 @@ void INT_PREDICT::runKokkosVariant(VariantID vid) {
// Loop counter increment uses macro to quiet C++20 compiler warning
for (RepIndex_type irep = 0; irep < run_reps; RP_REPCOUNTINC(irep)) {

// Declare variables in INT_PREDICT.hpp
Real_type dm22 = m_dm22;
Real_type dm23 = m_dm23;
Real_type dm24 = m_dm24;
Real_type dm25 = m_dm25;
Real_type dm26 = m_dm26;
Real_type dm27 = m_dm27;
Real_type dm28 = m_dm28;

Kokkos::parallel_for(
"INT_PREDICT_Kokkos Kokkos_Lambda",
Kokkos::RangePolicy<Kokkos::DefaultExecutionSpace>(ibegin, iend),
Expand Down
18 changes: 18 additions & 0 deletions src/polybench-kokkos/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
###############################################################################
# Copyright (c) Lawrence Livermore National Security, LLC and other
# RAJA Project Developers. See top-level LICENSE and COPYRIGHT
# files for dates and other details. No copyright assignment is required
# to contribute to RAJA Performance Suite.
#
# SPDX-License-Identifier: (BSD-3-Clause)
###############################################################################

blt_add_library(
NAME polybench-kokkos
SOURCES
POLYBENCH_HEAT_3D-Kokkos.cpp
POLYBENCH_JACOBI_1D-Kokkos.cpp
POLYBENCH_JACOBI_2D-Kokkos.cpp
INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}/../polybench
DEPENDS_ON common ${RAJA_PERFSUITE_DEPENDS}
)
92 changes: 92 additions & 0 deletions src/polybench-kokkos/POLYBENCH_HEAT_3D-Kokkos.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// Copyright (c) Lawrence Livermore National Security, LLC and other
// RAJA Project Developers. See top-level LICENSE and COPYRIGHT
// files for dates and other details. No copyright assignment is required
// to contribute to RAJA Performance Suite.
//
// SPDX-License-Identifier: (BSD-3-Clause)
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//

#include "POLYBENCH_HEAT_3D.hpp"

#if defined(RUN_KOKKOS)

#include "common/KokkosViewUtils.hpp"

#include <iostream>

namespace rajaperf {
namespace polybench {

void POLYBENCH_HEAT_3D::runKokkosVariant(VariantID vid) {
const Index_type run_reps = getRunReps();

POLYBENCH_HEAT_3D_DATA_SETUP;

auto A_view = getViewFromPointer(A, N, N, N);
auto B_view = getViewFromPointer(B, N, N, N);

switch (vid) {
case Kokkos_Lambda: {

Kokkos::fence();
startTimer();

// Loop counter increment uses macro to quiet C++20 compiler warning
for (RepIndex_type irep = 0; irep < run_reps; RP_REPCOUNTINC(irep)) {

Kokkos::parallel_for(
"POLYBENCH_HEAT_3D Kokkos_Lambda--BODY1",
Kokkos::MDRangePolicy<Kokkos::Rank<3>,
Kokkos::IndexType<Index_type>>(
{1, 1, 1}, {N - 1, N - 1, N - 1}),
KOKKOS_LAMBDA(Index_type i, Index_type j, Index_type k) {
B_view(i, j, k) =
0.125 * (A_view(i + 1, j, k) - 2.0 * A_view(i, j, k) +
A_view(i - 1, j, k)) +
0.125 * (A_view(i, j + 1, k) - 2.0 * A_view(i, j, k) +
A_view(i, j - 1, k)) +
0.125 * (A_view(i, j, k + 1) - 2.0 * A_view(i, j, k) +
A_view(i, j, k - 1)) +
A_view(i, j, k);
});

Kokkos::parallel_for(
"POLYBENCH_HEAT_3D Kokkos_Lambda--BODY2",
Kokkos::MDRangePolicy<Kokkos::Rank<3>,
Kokkos::IndexType<Index_type>>(
{1, 1, 1}, {N - 1, N - 1, N - 1}),
KOKKOS_LAMBDA(Index_type i, Index_type j, Index_type k) {
A_view(i, j, k) =
0.125 * (B_view(i + 1, j, k) - 2.0 * B_view(i, j, k) +
B_view(i - 1, j, k)) +
0.125 * (B_view(i, j + 1, k) - 2.0 * B_view(i, j, k) +
B_view(i, j - 1, k)) +
0.125 * (B_view(i, j, k + 1) - 2.0 * B_view(i, j, k) +
B_view(i, j, k - 1)) +
B_view(i, j, k);
});

}

Kokkos::fence();
stopTimer();

moveDataToHostFromKokkosView(A, A_view, N, N, N);
moveDataToHostFromKokkosView(B, B_view, N, N, N);

break;
}

default: {
std::cout << "\n POLYBENCH_HEAT_3D : Unknown variant id = " << vid
<< std::endl;
}
}
}

RAJAPERF_DEFAULT_TUNING_DEFINE_BOILERPLATE(POLYBENCH_HEAT_3D, Kokkos, Kokkos_Lambda)

} // end namespace polybench
} // end namespace rajaperf
#endif // RUN_KOKKOS
76 changes: 76 additions & 0 deletions src/polybench-kokkos/POLYBENCH_JACOBI_1D-Kokkos.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// Copyright (c) Lawrence Livermore National Security, LLC and other
// RAJA Project Developers. See top-level LICENSE and COPYRIGHT
// files for dates and other details. No copyright assignment is required
// to contribute to RAJA Performance Suite.
//
// SPDX-License-Identifier: (BSD-3-Clause)
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//

#include "POLYBENCH_JACOBI_1D.hpp"

#if defined(RUN_KOKKOS)

#include "common/KokkosViewUtils.hpp"

#include <iostream>

namespace rajaperf {
namespace polybench {

void POLYBENCH_JACOBI_1D::runKokkosVariant(VariantID vid) {
const Index_type run_reps = getRunReps();

POLYBENCH_JACOBI_1D_DATA_SETUP;

auto A_view = getViewFromPointer(A, N);
auto B_view = getViewFromPointer(B, N);

switch (vid) {
case Kokkos_Lambda: {

Kokkos::fence();
startTimer();

// Loop counter increment uses macro to quiet C++20 compiler warning
for (RepIndex_type irep = 0; irep < run_reps; RP_REPCOUNTINC(irep)) {

Kokkos::parallel_for(
"JACOBI_1D_Kokkos Kokkos_Lambda--BODY1",
Kokkos::RangePolicy<Kokkos::DefaultExecutionSpace,
Kokkos::IndexType<Index_type>>(1, N - 1),
KOKKOS_LAMBDA(Index_type i) {
B_view(i) = 0.33333 * (A_view(i - 1) + A_view(i) + A_view(i + 1));
});

Kokkos::parallel_for(
"JACOBI_1D_Kokkos Kokkos_Lambda--BODY2",
Kokkos::RangePolicy<Kokkos::DefaultExecutionSpace,
Kokkos::IndexType<Index_type>>(1, N - 1),
KOKKOS_LAMBDA(Index_type i) {
A_view(i) = 0.33333 * (B_view(i - 1) + B_view(i) + B_view(i + 1));
});

}

Kokkos::fence();
stopTimer();

moveDataToHostFromKokkosView(A, A_view, N);
moveDataToHostFromKokkosView(B, B_view, N);

break;
}

default: {
std::cout << "\n POLYBENCH_JACOBI_1D : Unknown variant id = " << vid
<< std::endl;
}
}
}

RAJAPERF_DEFAULT_TUNING_DEFINE_BOILERPLATE(POLYBENCH_JACOBI_1D, Kokkos, Kokkos_Lambda)

} // end namespace polybench
} // end namespace rajaperf
#endif // RUN_KOKKOS
82 changes: 82 additions & 0 deletions src/polybench-kokkos/POLYBENCH_JACOBI_2D-Kokkos.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// Copyright (c) Lawrence Livermore National Security, LLC and other
// RAJA Project Developers. See top-level LICENSE and COPYRIGHT
// files for dates and other details. No copyright assignment is required
// to contribute to RAJA Performance Suite.
//
// SPDX-License-Identifier: (BSD-3-Clause)
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//

#include "POLYBENCH_JACOBI_2D.hpp"

#if defined(RUN_KOKKOS)

#include "common/KokkosViewUtils.hpp"

#include <iostream>

namespace rajaperf {
namespace polybench {

void POLYBENCH_JACOBI_2D::runKokkosVariant(VariantID vid) {
const Index_type run_reps = getRunReps();

POLYBENCH_JACOBI_2D_DATA_SETUP;

auto A_view = getViewFromPointer(A, N, N);
auto B_view = getViewFromPointer(B, N, N);

switch (vid) {
case Kokkos_Lambda: {

Kokkos::fence();
startTimer();

// Loop counter increment uses macro to quiet C++20 compiler warning
for (RepIndex_type irep = 0; irep < run_reps; RP_REPCOUNTINC(irep)) {

Kokkos::parallel_for(
"JACOBI_2D_Kokkos Kokkos_Lambda--BODY1",
Kokkos::MDRangePolicy<Kokkos::Rank<2>,
Kokkos::IndexType<Index_type>>(
{1, 1}, {N - 1, N - 1}),
KOKKOS_LAMBDA(Index_type i, Index_type j) {
B_view(i, j) =
0.2 * (A_view(i, j) + A_view(i, j - 1) + A_view(i, j + 1) +
A_view(i + 1, j) + A_view(i - 1, j));
});

Kokkos::parallel_for(
"JACOBI_2D_Kokkos Kokkos_Lambda--BODY2",
Kokkos::MDRangePolicy<Kokkos::Rank<2>,
Kokkos::IndexType<Index_type>>(
{1, 1}, {N - 1, N - 1}),
KOKKOS_LAMBDA(Index_type i, Index_type j) {
A_view(i, j) =
0.2 * (B_view(i, j) + B_view(i, j - 1) + B_view(i, j + 1) +
B_view(i + 1, j) + B_view(i - 1, j));
});

}

Kokkos::fence();
stopTimer();

moveDataToHostFromKokkosView(A, A_view, N, N);
moveDataToHostFromKokkosView(B, B_view, N, N);

break;
}

default: {
std::cout << "\n POLYBENCH_JACOBI_2D : Unknown variant id = " << vid
<< std::endl;
}
}
}

RAJAPERF_DEFAULT_TUNING_DEFINE_BOILERPLATE(POLYBENCH_JACOBI_2D, Kokkos, Kokkos_Lambda)

} // end namespace polybench
} // end namespace rajaperf
#endif // RUN_KOKKOS
2 changes: 2 additions & 0 deletions src/polybench/POLYBENCH_HEAT_3D.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,15 @@ class POLYBENCH_HEAT_3D : public KernelBase
void defineSeqVariantTunings();
void defineOpenMPVariantTunings();
void defineOpenMPTargetVariantTunings();
void defineKokkosVariantTunings();
void defineCudaVariantTunings();
void defineHipVariantTunings();
void defineSyclVariantTunings();

void runSeqVariant(VariantID vid);
void runOpenMPVariant(VariantID vid);
void runOpenMPTargetVariant(VariantID vid);
void runKokkosVariant(VariantID vid);

template < size_t block_size >
void runCudaVariantImpl(VariantID vid);
Expand Down
2 changes: 2 additions & 0 deletions src/polybench/POLYBENCH_JACOBI_1D.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,15 @@ class POLYBENCH_JACOBI_1D : public KernelBase
void defineSeqVariantTunings();
void defineOpenMPVariantTunings();
void defineOpenMPTargetVariantTunings();
void defineKokkosVariantTunings();
void defineCudaVariantTunings();
void defineHipVariantTunings();
void defineSyclVariantTunings();

void runSeqVariant(VariantID vid);
void runOpenMPVariant(VariantID vid);
void runOpenMPTargetVariant(VariantID vid);
void runKokkosVariant(VariantID vid);

template < size_t block_size >
void runCudaVariantImpl(VariantID vid);
Expand Down
2 changes: 2 additions & 0 deletions src/polybench/POLYBENCH_JACOBI_2D.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,15 @@ class POLYBENCH_JACOBI_2D : public KernelBase
void defineSeqVariantTunings();
void defineOpenMPVariantTunings();
void defineOpenMPTargetVariantTunings();
void defineKokkosVariantTunings();
void defineCudaVariantTunings();
void defineHipVariantTunings();
void defineSyclVariantTunings();

void runSeqVariant(VariantID vid);
void runOpenMPVariant(VariantID vid);
void runOpenMPTargetVariant(VariantID vid);
void runKokkosVariant(VariantID vid);

template < size_t block_size >
void runCudaVariantImpl(VariantID vid);
Expand Down
1 change: 1 addition & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ set(RAJA_PERFSUITE_TEST_EXECUTABLE_DEPENDS
lcals
lcals-kokkos
polybench
polybench-kokkos
stream
stream-kokkos
algorithm
Expand Down
Loading