Skip to content

Commit

Permalink
Upgrade to clang-format-16
Browse files Browse the repository at this point in the history
  • Loading branch information
Tools authored and bernhardmgruber committed Sep 8, 2023
1 parent 3fc6626 commit 2b8e52a
Show file tree
Hide file tree
Showing 139 changed files with 702 additions and 393 deletions.
66 changes: 57 additions & 9 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@ DisableFormat: false

AccessModifierOffset: -4
AlignAfterOpenBracket: AlwaysBreak
AlignArrayOfStructures: None
AlignConsecutiveAssignments: false
AlignConsecutiveBitFields: false
AlignConsecutiveDeclarations: false
AlignConsecutiveMacros: false
AlignEscapedNewlines: Right
AlignOperands: Align
AlignTrailingComments: false
AlignTrailingComments:
Kind: Never
AllowAllArgumentsOnNextLine: false
AllowAllConstructorInitializersOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
Expand All @@ -29,78 +30,109 @@ AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: false
BinPackParameters: false
BitFieldColonSpacing: Both
BreakAfterAttributes: Never
BreakBeforeBinaryOperators: All
BreakBeforeBraces: Allman
BreakBeforeConceptDeclarations: true
BreakBeforeConceptDeclarations: Always
BreakBeforeInlineASMColon: OnlyMultiline
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeComma
BreakInheritanceList: BeforeComma
BreakStringLiterals: true
ColumnLimit: 119
CommentPragmas: '^ COMMENT pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DeriveLineEnding: true
DerivePointerAlignment: false
EmptyLineAfterAccessModifier: Never
EmptyLineBeforeAccessModifier: Always
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
IncludeBlocks: Regroup
IncludeIsMainRegex: '(Test)?$'
IncludeIsMainSourceRegex: ''
IndentAccessModifiers: false
IndentCaseBlocks: true
IndentCaseLabels: false
IndentExternBlock: AfterExternBlock
IndentGotoLabels: true
IndentPPDirectives: AfterHash
IndentRequires: true
IndentRequiresClause: false
IndentWidth: 4
IndentWrappedFunctionNames: false
InsertBraces: false
InsertNewlineAtEOF: true
IntegerLiteralSeparator:
Binary: 4
Decimal: 3
DecimalMinDigits: 7
Hex: 4
KeepEmptyLinesAtTheStartOfBlocks: false
LambdaBodyIndentation: Signature
LineEnding: DeriveLF
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 2
NamespaceIndentation: All
PackConstructorInitializers: CurrentLine
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakOpenParenthesis: 0 # default made explicit here
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyIndentedWhitespace: 0 # default made explicit here
PenaltyReturnTypeOnItsOwnLine: 1000
PointerAlignment: Left
QualifierAlignment: Right
PPIndentWidth: -1 # follow IndentWidth
QualifierAlignment: Custom
QualifierOrder: ['friend', 'static', 'inline', 'constexpr', 'type', 'const', 'volatile', 'restrict']
ReferenceAlignment: Pointer # follow PointerAlignment
ReflowComments: true
RemoveBracesLLVM: false
RemoveSemicolon: false
RequiresClausePosition: WithPreceding
RequiresExpressionIndentation: OuterScope
ShortNamespaceLines: 0
SortIncludes: true
SortUsingDeclarations: true
SortUsingDeclarations: Lexicographic
SeparateDefinitionBlocks: Always
SpaceAfterCStyleCast: true
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: false
SpaceAroundPointerQualifiers: Default # follow PointerAlignment
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: Never
SpaceBeforeRangeBasedForLoopColon: true
SpaceBeforeSquareBrackets: false
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInConditionalStatement: false
SpacesInContainerLiterals: false
SpacesInCStyleCastParentheses: false
SpacesInLineCommentPrefix:
Minimum: 1
Maximum: -1
SpacesInParentheses: false
SpacesInSquareBrackets: false
SpaceBeforeSquareBrackets: false
TabWidth: 4
UseCRLF: false
UseTab: Never

# Project specific options
#AttributeMacros: []
#ForEachMacros: []
#IfMacros: []
IncludeCategories:
# Local headers (in "") above all else
- Regex: '"([A-Za-z0-9.\/-_])+"'
Expand All @@ -118,5 +150,21 @@ IncludeCategories:
# below alpaka's includes
- Regex: '<([A-Za-z0-9.\/-_])+>'
Priority: 4
# Macros: []
# NamespaceMacros: []
StatementAttributeLikeMacros:
- 'ALPAKA_DEVICE_VOLATILE'
- 'ALPAKA_FN_ACC'
- 'ALPAKA_FN_EXTERN'
- 'ALPAKA_FN_HOST'
- 'ALPAKA_FN_HOST_ACC'
- 'ALPAKA_FN_INLINE'
- 'ALPAKA_STATIC_ACC_MEM_CONSTANT'
- 'ALPAKA_STATIC_ACC_MEM_GLOBAL'
- 'ALPAKA_UNROLL'
- 'ALPAKA_VECTORIZE_HINT'
#StatementMacros: []
#TypenameMacros: []
#WhitespaceSensitiveMacros: []

...
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ jobs:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: DoozyX/clang-format-lint-action@v0.14
- uses: DoozyX/clang-format-lint-action@v0.16.2
with:
clangFormatVersion: 14
clangFormatVersion: 16
exclude: './thirdParty'
inplace: True
- run: |
Expand Down
1 change: 0 additions & 1 deletion example/babelstream/src/Stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ class Stream
virtual void read_arrays(std::vector<T>& a, std::vector<T>& b, std::vector<T>& c) = 0;
};


// Implementation specific device functions
void listDevices(void);
std::string getDeviceName(int const);
Expand Down
5 changes: 1 addition & 4 deletions example/babelstream/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
#endif

// Default size of 2^25
int ARRAY_SIZE = 33554432;
int ARRAY_SIZE = 33'554'432;
unsigned int num_times = 100;
unsigned int deviceIndex = 0;
bool use_float = false;
Expand Down Expand Up @@ -101,7 +101,6 @@ int main(int argc, char* argv[])
run<double>();
}


// Run the 5 main kernels
template<typename T>
std::vector<std::vector<double>> run_all(Stream<T>* stream, T& sum)
Expand Down Expand Up @@ -194,7 +193,6 @@ std::vector<std::vector<double>> run_nstream(Stream<T>* stream)
return timings;
}


// Generic run routine
// Runs the kernel(s) and prints output.
template<typename T>
Expand Down Expand Up @@ -426,7 +424,6 @@ void run()
delete stream;
}


template<typename T>
void check_solution(unsigned int const ntimes, std::vector<T>& a, std::vector<T>& b, std::vector<T>& c, T& sum)
{
Expand Down
1 change: 0 additions & 1 deletion example/bufferCopy/src/bufferCopy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ struct PrintBufferKernel
}
};


//! Tests if the value of the buffer on index i is equal to i.
struct TestBufferKernel
{
Expand Down
1 change: 0 additions & 1 deletion example/complex/src/complex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include <cstdint>
#include <iostream>


//! Complex numbers demonstration kernel
struct ComplexKernel
{
Expand Down
3 changes: 0 additions & 3 deletions example/heatEquation/src/heatEquation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include <iostream>
#include <utility>


//! alpaka version of explicit finite-difference 1d heat equation solver
//!
//! Solving equation u_t(x, t) = u_xx(x, t) using a simple explicit scheme with
Expand Down Expand Up @@ -45,7 +44,6 @@ struct HeatEquationKernel
}
};


//! Exact solution to the test problem
//! u_t(x, t) = u_xx(x, t), x in [0, 1], t in [0, T]
//! u(0, t) = u(1, t) = 0
Expand All @@ -59,7 +57,6 @@ auto exactSolution(double const x, double const t) -> double
return std::exp(-pi * pi * t) * std::sin(pi * x);
}


//! Each kernel computes the next step for one point.
//! Therefore the number of threads should be equal to numNodesX.
//! Every time step the kernel will be executed numNodesX-times
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ struct Kernel
}
};


auto main() -> int
{
// Defines and setup.
Expand Down
8 changes: 4 additions & 4 deletions example/randomCells2D/src/randomCells2D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
#include <iostream>
#include <tuple>

unsigned constexpr NUM_CALCULATIONS = 256;
unsigned constexpr NUM_X = 127;
unsigned constexpr NUM_Y = 211;
constexpr unsigned NUM_CALCULATIONS = 256;
constexpr unsigned NUM_X = 127;
constexpr unsigned NUM_Y = 211;

/// Selected PRNG engine for single-value operation
template<typename TAcc>
Expand Down Expand Up @@ -121,7 +121,7 @@ struct RunTimestepKernelVector
using DistributionResult =
typename RandomEngineVector<TAcc>::template ResultContainer<float>; // Container type which will store
// the distribution results
unsigned constexpr resultVectorSize = std::tuple_size_v<DistributionResult>; // Size of the result vector
constexpr unsigned resultVectorSize = std::tuple_size_v<DistributionResult>; // Size of the result vector
alpaka::rand::UniformReal<DistributionResult> dist; // Vector-aware distribution function


Expand Down
12 changes: 6 additions & 6 deletions example/randomStrategies/src/randomStrategies.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@
#include <iostream>

// This example generates NUM_ROLLS of random events for each of NUM_POINTS points.
unsigned constexpr NUM_POINTS = 2000; ///< Number of "points". Each will be processed by a single thread.
unsigned constexpr NUM_ROLLS = 2000; ///< Amount of random number "dice rolls" performed for each "point".
constexpr unsigned NUM_POINTS = 2000; ///< Number of "points". Each will be processed by a single thread.
constexpr unsigned NUM_ROLLS = 2000; ///< Amount of random number "dice rolls" performed for each "point".

/// Selected PRNG engine
// Comment the current "using" line, and uncomment a different one to change the PRNG engine
template<typename TAcc>
using RandomEngine = alpaka::rand::Philox4x32x10<TAcc>;

// using RandomEngine = alpaka::rand::engine::cpu::MersenneTwister;
// using RandomEngine = alpaka::rand::engine::cpu::TinyMersenneTwister;
// using RandomEngine = alpaka::rand::engine::uniform_cuda_hip::Xor;
Expand Down Expand Up @@ -159,7 +160,6 @@ struct InitRandomKernel<Strategy::offset>
}
};


/// Fill the result buffer with random "dice rolls"
struct FillKernel
{
Expand Down Expand Up @@ -217,7 +217,7 @@ struct Writer;
template<>
struct Writer<Strategy::seed>
{
void static save(float const* buffer, Box const& box)
static void save(float const* buffer, Box const& box)
{
saveDataAndShowAverage("out_seed.csv", buffer, box);
}
Expand All @@ -226,7 +226,7 @@ struct Writer<Strategy::seed>
template<>
struct Writer<Strategy::subsequence>
{
void static save(float const* buffer, Box const& box)
static void save(float const* buffer, Box const& box)
{
saveDataAndShowAverage("out_subsequence.csv", buffer, box);
}
Expand All @@ -235,7 +235,7 @@ struct Writer<Strategy::subsequence>
template<>
struct Writer<Strategy::offset>
{
void static save(float const* buffer, Box const& box)
static void save(float const* buffer, Box const& box)
{
saveDataAndShowAverage("out_offset.csv", buffer, box);
}
Expand Down
18 changes: 13 additions & 5 deletions example/reduce/src/iterator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class Iterator
//! Returns the current element.
//!
//! Returns a reference to the current index.
ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE auto operator*() -> const T&
ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE auto operator*() -> T const&
{
return mData[mIndex];
}
Expand All @@ -123,8 +123,12 @@ class IteratorCpu : public Iterator<T, TBuf>
//! \param linearizedIndex The linearized index.
//! \param gridSize The grid size.
//! \param n The problem size.
ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE
IteratorCpu(TAcc const& acc, TBuf const* data, uint32_t linearizedIndex, uint32_t gridSize, uint64_t n)
ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE IteratorCpu(
TAcc const& acc,
TBuf const* data,
uint32_t linearizedIndex,
uint32_t gridSize,
uint64_t n)
: Iterator<T, TBuf>(
data,
static_cast<uint32_t>((n * linearizedIndex) / alpaka::math::min(acc, static_cast<uint64_t>(gridSize), n)),
Expand Down Expand Up @@ -244,8 +248,12 @@ class IteratorGpu : public Iterator<T, TBuf>
//! \param linearizedIndex The linearized index.
//! \param gridSize The grid size.
//! \param n The problem size.
ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE
IteratorGpu(TAcc const&, TBuf const* data, uint32_t linearizedIndex, uint32_t gridSize, uint64_t n)
ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE IteratorGpu(
TAcc const&,
TBuf const* data,
uint32_t linearizedIndex,
uint32_t gridSize,
uint64_t n)
: Iterator<T, TBuf>(data, linearizedIndex, n)
, mGridSize(gridSize)
{
Expand Down
2 changes: 1 addition & 1 deletion example/reduce/src/kernel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ struct cheapArray
//! \param index The index of the element to be accessed.
//!
//! Returns the requested element per constant reference.
ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE auto operator[](uint64_t index) const -> const T&
ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE auto operator[](uint64_t index) const -> T const&
{
return data[index];
}
Expand Down
2 changes: 2 additions & 0 deletions include/alpaka/acc/AccCpuOmp2Blocks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ namespace alpaka
{
using type = AccCpuOmp2Blocks<TDim, TIdx>;
};

//! The CPU OpenMP 2.0 block accelerator device properties get trait specialization.
template<typename TDim, typename TIdx>
struct GetAccDevProps<AccCpuOmp2Blocks<TDim, TIdx>>
Expand All @@ -153,6 +154,7 @@ namespace alpaka
static_cast<size_t>(AccCpuOmp2Blocks<TDim, TIdx>::staticAllocBytes())};
}
};

//! The CPU OpenMP 2.0 block accelerator name trait specialization.
template<typename TDim, typename TIdx>
struct GetAccName<AccCpuOmp2Blocks<TDim, TIdx>>
Expand Down
Loading

0 comments on commit 2b8e52a

Please sign in to comment.