forked from llnl/RAJAPerf
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDAXPY-Kokkos.cpp
More file actions
69 lines (54 loc) · 1.79 KB
/
Copy pathDAXPY-Kokkos.cpp
File metadata and controls
69 lines (54 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
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