forked from llnl/RAJAPerf
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDAXPY_ATOMIC-Kokkos.cpp
More file actions
70 lines (53 loc) · 1.69 KB
/
Copy pathDAXPY_ATOMIC-Kokkos.cpp
File metadata and controls
70 lines (53 loc) · 1.69 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
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