-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathATOMIC.cpp
More file actions
129 lines (94 loc) · 3.14 KB
/
Copy pathATOMIC.cpp
File metadata and controls
129 lines (94 loc) · 3.14 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// 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 "ATOMIC.hpp"
#include "RAJA/RAJA.hpp"
#include "common/DataUtils.hpp"
namespace rajaperf
{
namespace algorithm
{
ATOMIC::ATOMIC(const RunParams& params)
: KernelBase(rajaperf::Algorithm_ATOMIC, params)
{
setDefaultProblemSize(1000000);
setDefaultReps(50);
setSize(params.getTargetSize(getDefaultProblemSize()),
params.getReps(getDefaultReps()));
setChecksumConsistency(ChecksumConsistency::Inconsistent); // atomics
setChecksumTolerance(ChecksumTolerance::normal);
setComplexity(Complexity::N);
setMaxPerfectLoopDimensions(1);
setProblemDimensionality(1);
setUsesFeature(Forall);
setUsesFeature(Atomic);
addVariantTunings();
}
void ATOMIC::setSize(Index_type target_size, Index_type target_reps)
{
setActualProblemSize( target_size );
setRunReps( target_reps );
setItsPerRep( getActualProblemSize() );
setKernelsPerRep(1);
setBytesAllocatedPerRep( 1*sizeof(Real_type) * getActualProblemSize() ); // atomic (assumes replication == problem size)
setBytesReadPerRep( 0 );
setBytesWrittenPerRep( 0 );
setBytesModifyWrittenPerRep( 0 );
setBytesAtomicModifyWrittenPerRep( 1*sizeof(Real_type) * getActualProblemSize() ); // atomic (assumes replication == problem size)
setFLOPsPerRep(getActualProblemSize());
}
ATOMIC::~ATOMIC()
{
}
void ATOMIC::setUp(VariantID vid, size_t RAJAPERF_UNUSED_ARG(tune_idx))
{
m_init = 0;
m_final = -static_cast<int>(vid);
}
void ATOMIC::updateChecksum(VariantID RAJAPERF_UNUSED_ARG(vid), size_t RAJAPERF_UNUSED_ARG(tune_idx))
{
addToChecksum(m_final);
}
void ATOMIC::tearDown(VariantID RAJAPERF_UNUSED_ARG(vid), size_t RAJAPERF_UNUSED_ARG(tune_idx))
{
}
// Only define setCountedAttributes functions past this point
// BEWARE: data types (Index_type, Real_ptr, etc) become wrappers past this point
#include "common/CountingMacros.hpp"
void ATOMIC::setCountedAttributes()
{
const size_t replication = getActualProblemSize();
VariantID vid = VariantID::Base_Seq;
size_t tune_idx = 0;
RAJAPERF_COUNTERS_INITIALIZE();
RAJAPERF_COUNTERS_CODE_WRAPPER(
setUp(vid, tune_idx);
);
{
RAJAPERF_COUNTERS_CODE_WRAPPER(
const Index_type ibegin = 0;
const Index_type iend = getActualProblemSize();
ATOMIC_DATA_SETUP(replication);
);
RAJAPERF_COUNTERS_REP_SCOPE()
{
RAJAPERF_COUNTERS_PAR_LOOP(for (Index_type i = ibegin; i < iend; ++i )) {
RAJAPERF_COUNTERS_LOOP_BODY(ATOMIC_BODY(RAJAPERF_ATOMIC_ADD_COUNTING, i, ATOMIC_VALUE));
}
}
RAJAPERF_COUNTERS_CODE_WRAPPER(
ATOMIC_DATA_TEARDOWN(replication);
);
}
RAJAPERF_COUNTERS_CODE_WRAPPER(
tearDown(vid, tune_idx);
);
RAJAPERF_COUNTERS_FINALIZE();
}
} // end namespace algorithm
} // end namespace rajaperf