Skip to content

Commit 696caf4

Browse files
committed
Refactor RAJA using the make style target
1 parent 70186a9 commit 696caf4

File tree

719 files changed

+70916
-60452
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

719 files changed

+70916
-60452
lines changed

.clang-format

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ BasedOnStyle : LLVM
22
# Indent formatting
33
IndentWidth : 2
44
UseTab: Never
5-
BreakBeforeBraces : Linux
65
KeepEmptyLinesAtTheStartOfBlocks : true
76
MaxEmptyLinesToKeep : 2
87
AccessModifierOffset : -2
8+
# This must be off so that include order in RAJA is preserved
9+
SortIncludes: false
910

1011
# Control curly brace placement
12+
BreakBeforeBraces : Custom
1113
BraceWrapping:
1214
AfterCaseLabel: true
1315
AfterClass: true
@@ -30,22 +32,17 @@ BraceWrapping:
3032
# Pointer alignment
3133
DerivePointerAlignment: false
3234
PointerAlignment: Left
33-
SortIncludes: false
3435
AllowShortIfStatementsOnASingleLine : true
35-
ConstructorInitializerAllOnOneLineOrOnePerLine : true
3636
AllowShortFunctionsOnASingleLine : true
3737
AllowShortLoopsOnASingleLine : false
38-
BinPackParameters : true
3938
AllowAllParametersOfDeclarationOnNextLine : false
4039
AlignTrailingComments : true
40+
BinPackArguments : false
41+
BinPackParameters : false
42+
ConstructorInitializerAllOnOneLineOrOnePerLine : true
4143
ColumnLimit : 80
42-
PenaltyBreakBeforeFirstCallParameter : 100
43-
PenaltyReturnTypeOnItsOwnLine : 65000
44-
PenaltyBreakString : 10
4544

46-
BreakBeforeBinaryOperators : None
4745
AlignAfterOpenBracket: true
48-
BinPackArguments : false
4946
AlignOperands : true
5047
AlwaysBreakTemplateDeclarations : true
51-
48+
BreakBeforeBinaryOperators : None

examples/dynamic-forall.cpp

Lines changed: 54 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,26 @@
2828
void checkResult(int* res, int len);
2929
void printResult(int* res, int len);
3030

31-
using policy_list = camp::list<RAJA::seq_exec
32-
,RAJA::simd_exec
31+
using policy_list = camp::list<RAJA::seq_exec,
32+
RAJA::simd_exec
3333
#if defined(RAJA_ENABLE_OPENMP)
34-
,RAJA::omp_parallel_for_exec
34+
,
35+
RAJA::omp_parallel_for_exec
3536
#endif
3637
#if defined(RAJA_ENABLE_CUDA)
37-
,RAJA::cuda_exec<256>
38-
,RAJA::cuda_exec<512>
38+
,
39+
RAJA::cuda_exec<256>,
40+
RAJA::cuda_exec<512>
3941
#endif
4042
>;
4143

42-
int main(int argc, char *argv[])
44+
int main(int argc, char* argv[])
4345
{
4446

45-
if(argc != 2) {
46-
RAJA_ABORT_OR_THROW("Usage ./dynamic-forall N, where N is the index of the policy to run");
47+
if (argc != 2)
48+
{
49+
RAJA_ABORT_OR_THROW("Usage ./dynamic-forall N, where N is the index of the "
50+
"policy to run");
4751
}
4852

4953
//
@@ -55,58 +59,61 @@ int main(int argc, char *argv[])
5559
const int pol = std::stoi(argv[1]);
5660

5761
std::cout << "\n\nRAJA vector addition example...\n";
58-
std::cout << "Using policy # "<<pol<<std::endl;
62+
std::cout << "Using policy # " << pol << std::endl;
5963

60-
//
61-
// Define vector length
62-
//
64+
//
65+
// Define vector length
66+
//
6367
const int N = 1000000;
6468

65-
//
66-
// Allocate and initialize vector data
67-
//
68-
int *a = memoryManager::allocate<int>(N);
69-
int *b = memoryManager::allocate<int>(N);
70-
int *c = memoryManager::allocate<int>(N);
69+
//
70+
// Allocate and initialize vector data
71+
//
72+
int* a = memoryManager::allocate<int>(N);
73+
int* b = memoryManager::allocate<int>(N);
74+
int* c = memoryManager::allocate<int>(N);
7175

72-
for (int i = 0; i < N; ++i) {
76+
for (int i = 0; i < N; ++i)
77+
{
7378
a[i] = -i;
7479
b[i] = i;
7580
}
7681

7782

78-
//----------------------------------------------------------------------------//
83+
//----------------------------------------------------------------------------//
7984

8085
std::cout << "\n Running C-style vector addition...\n";
8186

8287
// _cstyle_vector_add_start
83-
for (int i = 0; i < N; ++i) {
88+
for (int i = 0; i < N; ++i)
89+
{
8490
c[i] = a[i] + b[i];
8591
}
8692
// _cstyle_vector_add_end
8793

8894
checkResult(c, N);
89-
//printResult(c, N);
95+
// printResult(c, N);
9096

9197

92-
//----------------------------------------------------------------------------//
93-
// Example of dynamic policy selection for forall
94-
//----------------------------------------------------------------------------//
98+
//----------------------------------------------------------------------------//
99+
// Example of dynamic policy selection for forall
100+
//----------------------------------------------------------------------------//
95101

96-
//policy is chosen from the list
97-
RAJA::expt::dynamic_forall<policy_list>(pol, RAJA::RangeSegment(0, N), [=] RAJA_HOST_DEVICE (int i) {
98-
c[i] = a[i] + b[i];
99-
});
102+
// policy is chosen from the list
103+
RAJA::expt::dynamic_forall<policy_list>(
104+
pol, RAJA::RangeSegment(0, N), [=] RAJA_HOST_DEVICE(int i) {
105+
c[i] = a[i] + b[i];
106+
});
100107
// _rajaseq_vector_add_end
101108

102109
checkResult(c, N);
103-
//printResult(c, N);
110+
// printResult(c, N);
104111

105112

106-
//----------------------------------------------------------------------------//
107-
//
108-
// Clean up.
109-
//
113+
//----------------------------------------------------------------------------//
114+
//
115+
// Clean up.
116+
//
110117
memoryManager::deallocate(a);
111118
memoryManager::deallocate(b);
112119
memoryManager::deallocate(c);
@@ -122,12 +129,19 @@ int main(int argc, char *argv[])
122129
void checkResult(int* res, int len)
123130
{
124131
bool correct = true;
125-
for (int i = 0; i < len; i++) {
126-
if ( res[i] != 0 ) { correct = false; }
132+
for (int i = 0; i < len; i++)
133+
{
134+
if (res[i] != 0)
135+
{
136+
correct = false;
137+
}
127138
}
128-
if ( correct ) {
139+
if (correct)
140+
{
129141
std::cout << "\n\t result -- PASS\n";
130-
} else {
142+
}
143+
else
144+
{
131145
std::cout << "\n\t result -- FAIL\n";
132146
}
133147
}
@@ -138,7 +152,8 @@ void checkResult(int* res, int len)
138152
void printResult(int* res, int len)
139153
{
140154
std::cout << std::endl;
141-
for (int i = 0; i < len; i++) {
155+
for (int i = 0; i < len; i++)
156+
{
142157
std::cout << "result[" << i << "] = " << res[i] << std::endl;
143158
}
144159
std::cout << std::endl;

0 commit comments

Comments
 (0)