Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update clang-format and black version #1163

Merged
merged 3 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 64 additions & 22 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
---
# For clang-format version 15!
# For clang-format version 18!

Language: Cpp

AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignArrayOfStructures: None
Expand All @@ -11,53 +10,67 @@ AlignConsecutiveAssignments:
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
AlignFunctionPointers: false
PadOperators: false
AlignConsecutiveBitFields:
Enabled: true
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
AlignFunctionPointers: false
PadOperators: false
AlignConsecutiveDeclarations:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
AlignFunctionPointers: false
PadOperators: false
AlignConsecutiveMacros:
Enabled: true
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
AlignFunctionPointers: false
PadOperators: true
AlignConsecutiveShortCaseStatements:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCaseColons: false
AlignEscapedNewlines: Left
AlignOperands: Align
AlignTrailingComments: true
AlignTrailingComments:
Kind: Always
OverEmptyLines: 0
AllowAllArgumentsOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortEnumsOnASingleLine: true
AllowBreakBeforeNoexceptSpecifier: Never
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortCompoundRequirementOnASingleLine: true
AllowShortEnumsOnASingleLine: true
AllowShortFunctionsOnASingleLine: Empty
AllowShortLambdasOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: true
BinPackParameters: true
BitFieldColonSpacing: After
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: Never
AfterEnum: false
AfterExternBlock: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: true
BeforeElse: true
BeforeLambdaBody: false
Expand All @@ -66,26 +79,26 @@ BraceWrapping:
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: false
BreakAdjacentStringLiterals: true
BreakAfterAttributes: Never
BreakBeforeBinaryOperators: None
BreakBeforeConceptDeclarations: Allowed
BreakBeforeBraces: Custom
BreakInheritanceList: BeforeColon
BreakBeforeInlineASMColon: OnlyMultiline
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: BeforeColon
BreakStringLiterals: false
ColumnLimit: 105
CommentPragmas: '^ IWYU pragma:'
QualifierAlignment: Left
CompactNamespaces: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DeriveLineEnding: false
DerivePointerAlignment: false
DisableFormat: false
EmptyLineAfterAccessModifier: Never
EmptyLineBeforeAccessModifier: Always
PackConstructorInitializers: BinPack
FixNamespaceComments: false
ForEachMacros:
- foreach
Expand Down Expand Up @@ -126,44 +139,64 @@ IncludeCategories:
IncludeIsMainRegex: '_disabled$'
IncludeIsMainSourceRegex: ''
IndentAccessModifiers: false
IndentCaseLabels: true
IndentCaseBlocks: false
IndentCaseLabels: true
IndentExternBlock: AfterExternBlock
IndentGotoLabels: true
IndentPPDirectives: None
IndentExternBlock: AfterExternBlock
IndentRequiresClause: true
IndentWidth: 2
IndentWrappedFunctionNames: false
InsertBraces: false
InsertNewlineAtEOF: true
IntegerLiteralSeparator:
Binary: -1
BinaryMinDigits: 0
Decimal: -1
DecimalMinDigits: 0
Hex: -1
HexMinDigits: 0
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: false
KeepEmptyLinesAtEOF: false
LambdaBodyIndentation: Signature
LineEnding: LF
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
PackConstructorInitializers: BinPack
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 2500
PenaltyBreakComment: 1500
PenaltyBreakFirstLessLess: 500
PenaltyBreakOpenParenthesis: 50
PenaltyBreakScopeResolution: 500
PenaltyBreakString: 10000
PenaltyBreakTemplateDeclaration: 500
PenaltyExcessCharacter: 100
PenaltyReturnTypeOnItsOwnLine: 1000
PenaltyIndentedWhitespace: 0
PenaltyReturnTypeOnItsOwnLine: 1000
PointerAlignment: Left
PPIndentWidth: -1
QualifierAlignment: Left
ReferenceAlignment: Pointer
ReflowComments: true
RemoveBracesLLVM: false
RemoveParentheses: Leave
RemoveSemicolon: true
RequiresClausePosition: WithPreceding
RequiresExpressionIndentation: OuterScope
SeparateDefinitionBlocks: Leave
ShortNamespaceLines: 10
SkipMacroDefinitionBody: false
SortIncludes: CaseInsensitive
SortUsingDeclarations: true
SortUsingDeclarations: LexicographicNumeric
SpaceAfterCStyleCast: true
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceAroundPointerQualifiers: Default
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: false
Expand All @@ -177,27 +210,36 @@ SpaceBeforeParensOptions:
AfterFunctionDeclarationName: false
AfterIfMacros: true
AfterOverloadedOperator: false
AfterPlacementOperator: false
AfterRequiresInClause: false
AfterRequiresInExpression: false
BeforeNonEmptyParentheses: false
SpaceAroundPointerQualifiers: Default
SpaceBeforeRangeBasedForLoopColon: true
SpaceBeforeSquareBrackets: false
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: Never
SpacesInConditionalStatement: false
SpacesInContainerLiterals: false
SpacesInCStyleCastParentheses: false
SpacesInLineCommentPrefix:
Minimum: 1
Maximum: -1
SpacesInParentheses: false
SpacesInParens: Never
SpacesInSquareBrackets: false
SpaceBeforeSquareBrackets: false
BitFieldColonSpacing: After
Standard: Latest
TabWidth: 8
UseCRLF: false
TypeNames:
- ElementType
- GlobalElementIndex
- GlobalElementSize
- GlobalTileIndex
- GlobalTileSize
- LocalElementIndex
- LocalElementSize
- LocalTileIndex
- LocalTileSize
- SizeType
- TileElementIndex
- TileElementSize
UseTab: Never
VerilogBreakBetweenInstancePorts: true
...
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Reformat with clang-format-18
e92ebf89c466f3291f7e61134c37c996e2e94a3f

# Reformat with clang-format-15
7f35ac9fe6710addbf1003de547e272f329ec1c1

Expand Down
2 changes: 1 addition & 1 deletion .github/format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ do

case $FILE in
*.cpp|*.h|*.h.in|*.tpp|*.cu)
clang-format-15 -i --style=file $FILE
clang-format-18 -i --style=file $FILE
# The following is needed for regions in which clang-format is disabled.
# Note: clang-format removes trailing spaces even in disabled regions.
# Check if tab are present.
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/check_format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ jobs:
- name: Install tools
run: |
sudo apt-get update
sudo apt-get install --no-install-recommends clang-format-15 python3 python3-pip
pip3 install --break-system-packages black==23.03.0
sudo apt-get install --no-install-recommends clang-format-18 python3 python3-pip
pip3 install --break-system-packages black==24.4.2
pip3 install --break-system-packages cmakelang==0.6.13

- name: Fetch master
Expand Down
16 changes: 8 additions & 8 deletions include/dlaf/common/callable_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@
/// that all required overloads are found relative to the namespace where the
/// macro is used.

#define DLAF_MAKE_CALLABLE_OBJECT(fname) \
constexpr struct fname##_t { \
template <typename... Ts> \
auto operator()(Ts&&... ts) const noexcept(noexcept((fname) (std::forward<Ts>(ts)...))) \
-> decltype((fname) (std::forward<Ts>(ts)...)) { \
return (fname) (std::forward<Ts>(ts)...); \
} \
} fname##_o { \
#define DLAF_MAKE_CALLABLE_OBJECT(fname) \
constexpr struct fname##_t { \
template <typename... Ts> \
auto operator()(Ts&&... ts) const noexcept( \
noexcept((fname) (std::forward<Ts>(ts)...))) -> decltype((fname) (std::forward<Ts>(ts)...)) { \
return (fname) (std::forward<Ts>(ts)...); \
} \
} fname##_o { \
}
2 changes: 1 addition & 1 deletion include/dlaf/common/pipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class Pipeline {
}

return *this;
};
}

Pipeline(const Pipeline&) = delete;
Pipeline& operator=(const Pipeline&) = delete;
Expand Down
6 changes: 4 additions & 2 deletions include/dlaf/common/source_location.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ namespace internal {
///
/// It uses DLAF_FUNCTION_NAME that it is set to \_\_PRETTY_FUNCTION\_\_ or \_\_func\_\_ depending on
/// availability of the former one.
#define SOURCE_LOCATION() \
::dlaf::common::internal::source_location { __FILE__, __LINE__, DLAF_FUNCTION_NAME }
#define SOURCE_LOCATION() \
::dlaf::common::internal::source_location { \
__FILE__, __LINE__, DLAF_FUNCTION_NAME \
}

/// Anticipation of std::source_location from C++20.
///
Expand Down
2 changes: 1 addition & 1 deletion include/dlaf/common/unwrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ struct Unwrapping {

template <typename... Ts>
auto operator()(Ts&&... ts) && -> decltype(std::move(f)(
Unwrapper<std::decay_t<Ts>>::unwrap(std::forward<Ts>(ts))...)) {
Unwrapper<std::decay_t<Ts>>::unwrap(std::forward<Ts>(ts))...)) {
return std::move(f)(Unwrapper<std::decay_t<Ts>>::unwrap(std::forward<Ts>(ts))...);
}

Expand Down
2 changes: 1 addition & 1 deletion include/dlaf/communication/kernels/internal/all_reduce.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ template <Device DCommIn, Device DCommOut, class T, Device DIn, Device DOut>
auto all_reduce_final = [reduce_op, pcomm = std::move(pcomm),
tile_in = std::move(tile_in)](const auto& tile_out_comm) mutable {
auto all_reduce = [reduce_op, pcomm = std::move(pcomm),
&tile_out_comm](auto const& tile_in_comm) mutable {
&tile_out_comm](const auto& tile_in_comm) mutable {
return whenAllLift(std::move(pcomm), reduce_op, std::cref(tile_in_comm),
std::cref(tile_out_comm)) |
transformMPI(allReduce_o);
Expand Down
4 changes: 2 additions & 2 deletions include/dlaf/matrix/tile.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ class Tile<const T, D> {

Tile(Tile&& rhs) noexcept : data_(std::move(rhs.data_)), dep_tracker_(std::move(rhs.dep_tracker_)) {
rhs.dep_tracker_ = std::monostate();
};
}

/// Destroys the Tile.
///
Expand Down Expand Up @@ -303,7 +303,7 @@ class Tile<const T, D> {
return memory::MemoryView<T, D>(tile.data_.memoryView(),
spec.size.isEmpty() ? 0 : tile.data_.linearIndex(spec.origin),
tile.data_.linearSize(spec.size, tile.ld()));
};
}

Tile(const TileElementSize& size, const memory::MemoryView<ElementType, D>& memory_view,
SizeType ld) noexcept
Expand Down
4 changes: 2 additions & 2 deletions include/dlaf/sender/transform_mpi.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ template <typename F>
struct MPICallHelper {
std::decay_t<F> f;
template <typename... Ts>
auto operator()(Ts&&... ts)
-> decltype(std::move(f)(dlaf::common::internal::unwrap(ts)..., std::declval<MPI_Request*>())) {
auto operator()(Ts&&... ts) -> decltype(std::move(f)(dlaf::common::internal::unwrap(ts)...,
std::declval<MPI_Request*>())) {
MPI_Request req;
auto is_request_completed = [&req] {
int flag;
Expand Down
4 changes: 2 additions & 2 deletions include/dlaf/util_math.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ template <typename IntType>
constexpr IntType ceilDiv(const IntType num, const IntType den);
#else
template <typename IntType>
constexpr auto ceilDiv(const IntType num, const IntType den)
-> std::enable_if_t<std::is_integral_v<IntType>, IntType> {
constexpr auto ceilDiv(const IntType num,
const IntType den) -> std::enable_if_t<std::is_integral_v<IntType>, IntType> {
return (num + den - 1) / den;
}
#endif
Expand Down
8 changes: 4 additions & 4 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,21 +112,21 @@ template <class T>
struct parseFromString {
static std::optional<T> call(const std::string& val) {
return val;
};
}
};

template <>
struct parseFromString<std::size_t> {
static std::optional<std::size_t> call(const std::string& var) {
return std::stoull(var);
};
}
};

template <>
struct parseFromString<SizeType> {
static std::optional<SizeType> call(const std::string& var) {
return std::stoll(var);
};
}
};

template <>
Expand All @@ -137,7 +137,7 @@ struct parseFromString<bool> {
if (is_one_of_ignore_case(var, {"OFF", "FALSE", "NO", "0"}))
return false;
return std::nullopt;
};
}

private:
static bool is_one_of_ignore_case(std::string value, const std::array<std::string, 4>& values) {
Expand Down
Loading
Loading