Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions src/polybench-kokkos/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
blt_add_library(
NAME polybench-kokkos
SOURCES
POLYBENCH_GEMM-Kokkos.cpp
POLYBENCH_HEAT_3D-Kokkos.cpp
POLYBENCH_JACOBI_1D-Kokkos.cpp
POLYBENCH_JACOBI_2D-Kokkos.cpp
Expand Down
74 changes: 74 additions & 0 deletions src/polybench-kokkos/POLYBENCH_GEMM-Kokkos.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// 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_GEMM.hpp"

#if defined(RUN_KOKKOS)

#include "common/KokkosViewUtils.hpp"

#include <iostream>

namespace rajaperf {
namespace polybench {

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

POLYBENCH_GEMM_DATA_SETUP;

auto A_view = getViewFromPointer(A, ni, nk);
auto B_view = getViewFromPointer(B, nk, nj);
auto C_view = getViewFromPointer(C, ni, nj);

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_GEMM Kokkos_Lambda",
Kokkos::MDRangePolicy<Kokkos::Rank<2>,
Kokkos::IndexType<Index_type>>({0, 0},
{ni, nj}),
KOKKOS_LAMBDA(Index_type i, Index_type j) {
Real_type dot = 0.0;
C_view(i, j) *= beta;
for (Index_type k = 0; k < nk; ++k) {
dot += alpha * A_view(i, k) * B_view(k, j);
}
C_view(i, j) = dot;
});
}

Kokkos::fence();
stopTimer();

moveDataToHostFromKokkosView(A, A_view, ni, nk);
moveDataToHostFromKokkosView(B, B_view, nk, nj);
moveDataToHostFromKokkosView(C, C_view, ni, nj);
Comment thread
MrBurmark marked this conversation as resolved.
Outdated

break;
}

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

RAJAPERF_DEFAULT_TUNING_DEFINE_BOILERPLATE(POLYBENCH_GEMM, Kokkos,
Kokkos_Lambda)

} // end namespace polybench
} // end namespace rajaperf
#endif // RUN_KOKKOS
2 changes: 2 additions & 0 deletions src/polybench/POLYBENCH_GEMM.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,15 @@ class POLYBENCH_GEMM : 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