Skip to content

Commit

Permalink
nits: clang-format passing with llvm 17
Browse files Browse the repository at this point in the history
  • Loading branch information
csegarragonz committed Mar 4, 2024
1 parent 89c98da commit 8d5c4a9
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 32 deletions.
5 changes: 5 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ DerivePointerAlignment: false
BreakBeforeBraces: Custom
BraceWrapping:
AfterClass: true
AfterEnum: true
AfterExternBlock: true
AfterFunction: true
AfterStruct: true
AfterUnion: true
SplitEmptyFunction: false
SplitEmptyRecord: false
---
7 changes: 3 additions & 4 deletions func/omp/complex_reduce.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,9 @@ int main(int argc, char* argv[])
FAASM_REDUCE(reducedA, FAASM_TYPE_INT, FAASM_OP_SUM)
FAASM_REDUCE(reducedB, FAASM_TYPE_DOUBLE, FAASM_OP_SUM)

#pragma omp parallel for num_threads(nThreads) default(none) \
private(privateA,privateB) \
shared(loopSize,sharedA,sharedB,counts) \
reduction(+ : reducedA,reducedB)
#pragma omp parallel for num_threads(nThreads) default(none) private( \
privateA, privateB) shared(loopSize, sharedA, sharedB, counts) \
reduction(+ : reducedA, reducedB)
for (int i = 0; i < loopSize; i++) {
int threadNum = omp_get_thread_num();

Expand Down
4 changes: 2 additions & 2 deletions func/omp/custom_reduce.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ complex_t complex_add(complex_t a, complex_t b)
return c;
}

#pragma omp declare reduction(cmplxAdd:complex_t \
: omp_out = complex_add(omp_out, omp_in)) \
#pragma omp declare reduction(cmplxAdd:complex_t : omp_out = \
complex_add(omp_out, omp_in)) \
initializer(omp_priv = { 0, 0 })

int main()
Expand Down
6 changes: 2 additions & 4 deletions func/omp/default_shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@ int main(int argc, char* argv[])

FAASM_REDUCE(count, FAASM_TYPE_INT, FAASM_OP_SUM)

#pragma omp parallel for num_threads(5) \
default(none) \
shared(nLoops, flagsStack, flagsHeap) \
reduction(+ : count)
#pragma omp parallel for num_threads(5) default(none) \
shared(nLoops, flagsStack, flagsHeap) reduction(+ : count)
for (int i = 0; i < nLoops; i++) {
int threadNum = omp_get_thread_num();
count += (threadNum + 1);
Expand Down
5 changes: 2 additions & 3 deletions func/omp/inspect_reduction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ int inspectAdder(int a, int b)
return a + b;
}

#pragma omp declare reduction(inspectAdd:int \
: omp_out = inspectAdder(omp_out, omp_in)) \
initializer(omp_priv = 0)
#pragma omp declare reduction(inspectAdd \
:int : omp_out = inspectAdder(omp_out, omp_in)) initializer(omp_priv = 0)

int main()
{
Expand Down
6 changes: 3 additions & 3 deletions func/omp/mem_stress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ int main(int argc, char** argv)
FAASM_REDUCE(totalLoops, FAASM_TYPE_INT, FAASM_OP_SUM)

#pragma omp parallel for num_threads(nThreads) default(none) \
shared(ptrs, counts) reduction(+:totalLoops)
shared(ptrs, counts) reduction(+ : totalLoops)
for (int i = 0; i < ITERATIONS; i++) {
totalLoops++;

Expand All @@ -49,7 +49,7 @@ int main(int argc, char** argv)
FAASM_REDUCE(totalLoops, FAASM_TYPE_INT, FAASM_OP_SUM)

#pragma omp parallel for num_threads(nThreads) default(none) \
shared(ptrs, counts) reduction(+:totalLoops)
shared(ptrs, counts) reduction(+ : totalLoops)
for (int i = 0; i < ITERATIONS; i++) {
totalLoops++;
::free(ptrs[i]);
Expand All @@ -61,7 +61,7 @@ int main(int argc, char** argv)
FAASM_REDUCE(totalLoops, FAASM_TYPE_INT, FAASM_OP_SUM)

#pragma omp parallel for num_threads(nThreads) default(none) \
shared(ptrs, counts) reduction(+:totalLoops)
shared(ptrs, counts) reduction(+ : totalLoops)
for (int i = 0; i < ITERATIONS; i++) {
totalLoops++;
size_t mallocSize = (i % 6) * 1024;
Expand Down
5 changes: 2 additions & 3 deletions func/omp/pi_faasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ int main(int argc, char** argv)
int nTotal = nWorkers * CHUNK_SIZE;

FAASM_REDUCE(result, FAASM_TYPE_LONG, FAASM_OP_SUM)
#pragma omp parallel num_threads(nWorkers) default(none) \
shared(nTotal) \
reduction(+ : result)
#pragma omp parallel num_threads(nWorkers) default(none) shared(nTotal) \
reduction(+ : result)
{
// Different seed per thread
std::uniform_real_distribution<double> unif(0, 1);
Expand Down
5 changes: 2 additions & 3 deletions func/omp/pi_native.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ int main(int argc, char** argv)

printf("Estimating Pi with %i workers\n", nWorkers);

#pragma omp parallel num_threads(nWorkers) default(none) \
shared(nTotal) \
reduction(+ : result)
#pragma omp parallel num_threads(nWorkers) default(none) shared(nTotal) \
reduction(+ : result)
{
// Different seed per thread
std::uniform_real_distribution<double> unif(0, 1);
Expand Down
3 changes: 2 additions & 1 deletion func/omp/reduction_integral.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ double doBetterReduction()

FAASM_REDUCE(sum, FAASM_TYPE_DOUBLE, FAASM_OP_SUM)

#pragma omp parallel for private(x) default(none) shared(nSteps, step) reduction(+:sum)
#pragma omp parallel for private(x) default(none) shared(nSteps, step) \
reduction(+ : sum)
for (i = 0; i < nSteps; ++i) {
x = (i + 0.5) * step;
sum += 4.0 / (1.0 + x * x);
Expand Down
5 changes: 2 additions & 3 deletions func/omp/repeated_reduce.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ bool doReduce()
FAASM_REDUCE(reducedA, FAASM_TYPE_INT, FAASM_OP_SUM)
FAASM_REDUCE(reducedB, FAASM_TYPE_INT, FAASM_OP_SUM)

#pragma omp parallel for num_threads(nThreads) default(none) \
shared(counts,loopSize,success) \
reduction(+ : reducedA,reducedB)
#pragma omp parallel for num_threads(nThreads) default(none) \
shared(counts, loopSize, success) reduction(+ : reducedA, reducedB)
for (int i = 0; i < loopSize; i++) {
int threadNum = omp_get_thread_num();
counts[threadNum]++;
Expand Down
3 changes: 2 additions & 1 deletion func/omp/simple_reduce.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ int main(int argc, char* argv[])

FAASM_REDUCE(count, FAASM_TYPE_INT, FAASM_OP_SUM)

#pragma omp parallel for num_threads(5) default(none) shared(loopSize) reduction(+ : count)
#pragma omp parallel for num_threads(5) default(none) shared(loopSize) \
reduction(+ : count)
for (int i = 0; i < loopSize; i++) {
count += (omp_get_thread_num() + 1);
}
Expand Down
7 changes: 3 additions & 4 deletions func/omp/single_thread_reduce.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,9 @@ int main(int argc, char* argv[])
FAASM_REDUCE(reducedA, FAASM_TYPE_INT, FAASM_OP_SUM)
FAASM_REDUCE(reducedB, FAASM_TYPE_DOUBLE, FAASM_OP_SUM)

#pragma omp parallel for num_threads(1) default(none) \
private(privateA,privateB) \
reduction(+ : reducedA,reducedB) \
shared(loopSize, sharedA)
#pragma omp parallel for num_threads(1) default(none) private(privateA, \
privateB) \
reduction(+ : reducedA, reducedB) shared(loopSize, sharedA)
for (int i = 0; i < loopSize; i++) {
int threadNum = omp_get_thread_num();

Expand Down
5 changes: 4 additions & 1 deletion tests/test_input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ TEST_CASE("Test string input", "[input]")

std::string expected;
std::string defaultVal = "default";
SECTION("No input") { expected = defaultVal; }
SECTION("No input")
{
expected = defaultVal;
}

SECTION("Input")
{
Expand Down

0 comments on commit 8d5c4a9

Please sign in to comment.