-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #248 from LLNL/pr-from-fork/206
Pr for Basic Kokkos
- Loading branch information
Showing
44 changed files
with
1,050 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
############################################################################### | ||
# Copyright (c) 2017-20, Lawrence Livermore National Security, LLC | ||
# and RAJA Performance Suite project contributors. | ||
# See the RAJAPerf/COPYRIGHT file for details. | ||
# | ||
# SPDX-License-Identifier: (BSD-3-Clause) | ||
############################################################################### | ||
|
||
#include_directories(SYSTEM ${CMAKE_CURRENT_SOURCE_DIR}/../basic) | ||
|
||
blt_add_library( | ||
NAME basic-kokkos | ||
SOURCES | ||
PI_ATOMIC-Kokkos.cpp | ||
DAXPY-Kokkos.cpp | ||
IF_QUAD-Kokkos.cpp | ||
INIT3-Kokkos.cpp | ||
INIT_VIEW1D-Kokkos.cpp | ||
INIT_VIEW1D_OFFSET-Kokkos.cpp | ||
MULADDSUB-Kokkos.cpp | ||
NESTED_INIT-Kokkos.cpp | ||
REDUCE3_INT-Kokkos.cpp | ||
TRAP_INT-Kokkos.cpp | ||
DAXPY_ATOMIC-Kokkos.cpp | ||
INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}/../basic | ||
DEPENDS_ON common ${RAJA_PERFSUITE_DEPENDS} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// | ||
// Copyright (c) 2017-20, Lawrence Livermore National Security, LLC | ||
// and RAJA Performance Suite project contributors. | ||
// See the RAJAPerf/COPYRIGHT file for details. | ||
// | ||
// SPDX-License-Identifier: (BSD-3-Clause) | ||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// | ||
|
||
#include "DAXPY.hpp" | ||
#if defined(RUN_KOKKOS) | ||
#include "common/KokkosViewUtils.hpp" | ||
#include <iostream> | ||
|
||
namespace rajaperf { | ||
namespace basic { | ||
|
||
struct DaxpyFunctor { | ||
Real_ptr x; | ||
Real_ptr y; | ||
Real_type a; | ||
DaxpyFunctor(Real_ptr m_x, Real_ptr m_y, Real_type m_a) | ||
: x(m_x), y(m_y), a(m_a) {} | ||
void operator()(Index_type i) const { DAXPY_BODY; } | ||
}; | ||
|
||
void DAXPY::runKokkosVariant(VariantID vid, size_t RAJAPERF_UNUSED_ARG(tune_idx)) { | ||
const Index_type run_reps = getRunReps(); | ||
const Index_type ibegin = 0; | ||
const Index_type iend = getActualProblemSize(); | ||
|
||
DAXPY_DATA_SETUP; | ||
|
||
auto x_view = getViewFromPointer(x, iend); | ||
auto y_view = getViewFromPointer(y, iend); | ||
|
||
switch (vid) { | ||
|
||
case Kokkos_Lambda: { | ||
|
||
Kokkos::fence(); | ||
startTimer(); | ||
|
||
for (RepIndex_type irep = 0; irep < run_reps; ++irep) { | ||
Kokkos::parallel_for( | ||
"DAXPY-Kokkos Kokkos_Lambda", | ||
Kokkos::RangePolicy<Kokkos::DefaultExecutionSpace>(ibegin, iend), | ||
KOKKOS_LAMBDA(Index_type i) { y_view[i] += a * x_view[i]; }); | ||
} | ||
|
||
Kokkos::fence(); | ||
stopTimer(); | ||
|
||
break; | ||
} | ||
default: { | ||
std::cout << "\n DAXPY : Unknown variant id = " << vid << std::endl; | ||
} | ||
} | ||
|
||
// Move data (i.e., pointer, KokkosView-wrapped ponter) back to the host from | ||
// the device | ||
|
||
moveDataToHostFromKokkosView(x, x_view, iend); | ||
moveDataToHostFromKokkosView(y, y_view, iend); | ||
} | ||
|
||
} // end namespace basic | ||
} // end namespace rajaperf | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// | ||
// Copyright (c) 2017-21, Lawrence Livermore National Security, LLC | ||
// and RAJA Performance Suite project contributors. | ||
// See the RAJAPerf/LICENSE file for details. | ||
// | ||
// SPDX-License-Identifier: (BSD-3-Clause) | ||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// | ||
|
||
#include "DAXPY_ATOMIC.hpp" | ||
#if defined(RUN_KOKKOS) | ||
#include "common/KokkosViewUtils.hpp" | ||
#include <iostream> | ||
|
||
// Delete me | ||
// For de-bugging: | ||
#include "RAJA/RAJA.hpp" | ||
|
||
namespace rajaperf { | ||
namespace basic { | ||
|
||
void DAXPY_ATOMIC::runKokkosVariant(VariantID vid, size_t RAJAPERF_UNUSED_ARG(tune_idx)) | ||
{ | ||
|
||
const Index_type run_reps = getRunReps(); | ||
const Index_type ibegin = 0; | ||
const Index_type iend = getActualProblemSize(); | ||
|
||
DAXPY_ATOMIC_DATA_SETUP; | ||
// | ||
// Kokkos Views to wrap pointers declared in DAXPY_ATOMIC.hpp | ||
// | ||
|
||
auto x_view = getViewFromPointer(x, iend); | ||
auto y_view = getViewFromPointer(y, iend); | ||
|
||
switch (vid) { | ||
|
||
case Kokkos_Lambda: { | ||
|
||
Kokkos::fence(); | ||
startTimer(); | ||
|
||
for (RepIndex_type irep = 0; irep < run_reps; ++irep) { | ||
|
||
Kokkos::parallel_for( | ||
"DAXPY_ATOMIC_Kokkos Kokkos_Lambda", | ||
Kokkos::RangePolicy<Kokkos::DefaultExecutionSpace>(ibegin, iend), | ||
KOKKOS_LAMBDA(Index_type i) { | ||
Kokkos::atomic_add(&y_view[i], a * x_view[i]); | ||
}); | ||
} | ||
|
||
Kokkos::fence(); | ||
stopTimer(); | ||
|
||
break; | ||
} | ||
|
||
default: { | ||
getCout() << "\n DAXPY_ATOMIC : Unknown variant id = " << vid << std::endl; | ||
} | ||
} | ||
|
||
moveDataToHostFromKokkosView(x, x_view, iend); | ||
moveDataToHostFromKokkosView(y, y_view, iend); | ||
} | ||
|
||
} // end namespace basic | ||
} // end namespace rajaperf | ||
#endif |
Oops, something went wrong.