Skip to content

Commit fbc58b7

Browse files
Add .clang-format file from xtensor and format all files
1 parent 7b96edd commit fbc58b7

18 files changed

+3799
-3676
lines changed

.clang-format

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
BasedOnStyle: Mozilla
2+
AccessModifierOffset: '-4'
3+
AlignAfterOpenBracket: BlockIndent
4+
AlignEscapedNewlines: Left
5+
AllowAllArgumentsOnNextLine: false
6+
AllowAllParametersOfDeclarationOnNextLine: false
7+
AllowShortBlocksOnASingleLine: false
8+
AllowShortCaseLabelsOnASingleLine: false
9+
AllowShortFunctionsOnASingleLine: false
10+
AllowShortIfStatementsOnASingleLine: false
11+
# Forbid one line lambdas because clang-format makes a weird split when
12+
# single instructions lambdas are too long.
13+
AllowShortLambdasOnASingleLine: Empty
14+
AllowShortLoopsOnASingleLine: false
15+
AlwaysBreakAfterReturnType: None
16+
AlwaysBreakAfterDefinitionReturnType: None
17+
AlwaysBreakTemplateDeclarations: Yes
18+
SpaceAfterTemplateKeyword: true
19+
BinPackArguments: false
20+
BinPackParameters: false
21+
BreakBeforeBinaryOperators: NonAssignment
22+
BreakBeforeBraces: Allman
23+
BreakBeforeTernaryOperators: true
24+
BreakConstructorInitializers: BeforeComma
25+
BreakInheritanceList: AfterComma
26+
BreakStringLiterals: false
27+
ColumnLimit: '110'
28+
ConstructorInitializerIndentWidth: '4'
29+
ContinuationIndentWidth: '4'
30+
Cpp11BracedListStyle: true
31+
DerivePointerAlignment: false
32+
DisableFormat: false
33+
ExperimentalAutoDetectBinPacking: true
34+
EmptyLineAfterAccessModifier: Always
35+
EmptyLineBeforeAccessModifier: Always
36+
IncludeBlocks: Regroup
37+
IncludeCategories:
38+
- Regex: <[^.]+>
39+
Priority: 1
40+
- Regex: <xtensor/.+>
41+
Priority: 3
42+
- Regex: <.+>
43+
Priority: 2
44+
- Regex: '"xtensor/.+"'
45+
Priority: 4
46+
- Regex: '".+"'
47+
Priority: 5
48+
IndentCaseLabels: true
49+
IndentWidth: '4'
50+
IndentWrappedFunctionNames: false
51+
InsertTrailingCommas: Wrapped
52+
KeepEmptyLinesAtTheStartOfBlocks: false
53+
LambdaBodyIndentation: Signature
54+
Language: Cpp
55+
MaxEmptyLinesToKeep: '2'
56+
NamespaceIndentation: All
57+
ObjCBlockIndentWidth: '4'
58+
ObjCSpaceAfterProperty: false
59+
ObjCSpaceBeforeProtocolList: false
60+
PointerAlignment: Left
61+
PackConstructorInitializers: Never
62+
PenaltyBreakAssignment: 100000
63+
PenaltyBreakBeforeFirstCallParameter: 0
64+
PenaltyBreakComment: 10
65+
PenaltyBreakOpenParenthesis: 0
66+
PenaltyBreakTemplateDeclaration: 0
67+
PenaltyExcessCharacter: 10
68+
PenaltyIndentedWhitespace: 0
69+
PenaltyReturnTypeOnItsOwnLine: 10
70+
ReflowComments: true
71+
SeparateDefinitionBlocks: Always
72+
SortIncludes: CaseInsensitive
73+
SortUsingDeclarations: true
74+
SpaceAfterCStyleCast: true
75+
SpaceBeforeAssignmentOperators: true
76+
SpaceBeforeParens: ControlStatements
77+
SpaceInEmptyParentheses: false
78+
SpacesBeforeTrailingComments: '2'
79+
SpacesInAngles: false
80+
SpacesInCStyleCastParentheses: false
81+
SpacesInContainerLiterals: false
82+
SpacesInParentheses: false
83+
SpacesInSquareBrackets: false
84+
Standard: c++14
85+
TabWidth: '4'
86+
UseTab: Never

benchmark/benchmark_blas.hpp

+15-16
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
/***************************************************************************
2-
* Copyright (c) 2016, Johan Mabille, Sylvain Corlay and Wolf Vollprecht *
3-
* *
4-
* Distributed under the terms of the BSD 3-Clause License. *
5-
* *
6-
* The full license is in the file LICENSE, distributed with this software. *
7-
****************************************************************************/
2+
* Copyright (c) 2016, Johan Mabille, Sylvain Corlay and Wolf Vollprecht *
3+
* *
4+
* Distributed under the terms of the BSD 3-Clause License. *
5+
* *
6+
* The full license is in the file LICENSE, distributed with this software. *
7+
****************************************************************************/
88

99
#ifndef BENCHMARK_BLAS_HPP
1010
#define BENCHMARK_BLAS_HPP
1111

1212
#include <benchmark/benchmark.h>
1313

14+
#include "xtensor/xarray.hpp"
1415
#include "xtensor/xnoalias.hpp"
1516
#include "xtensor/xtensor.hpp"
16-
#include "xtensor/xarray.hpp"
1717

1818
#include "xtensor-blas/xlinalg.hpp"
1919

@@ -41,11 +41,10 @@ namespace xt
4141
}
4242

4343
template <class V>
44-
inline void init_xtensor_benchmark(V& lhs, V& rhs,
45-
std::size_t size0, size_t size1)
44+
inline void init_xtensor_benchmark(V& lhs, V& rhs, std::size_t size0, size_t size1)
4645
{
47-
lhs.reshape({ size0, size1 });
48-
rhs.reshape({ size0, size1 });
46+
lhs.reshape({size0, size1});
47+
rhs.reshape({size0, size1});
4948
init_benchmark_data(lhs, rhs, size0, size1);
5049
}
5150

@@ -95,10 +94,10 @@ namespace xt
9594
}
9695
}
9796

98-
BENCHMARK_TEMPLATE(benchmark_dot, xt::xtensor<double, 2>)->Range(32, 32<<3);
99-
BENCHMARK_TEMPLATE(benchmark_transpose_dot, xt::xtensor<double, 2>)->Range(32, 32<<3);
100-
BENCHMARK_TEMPLATE(benchmark_transpose_with_assign_dot, xt::xtensor<double, 2>)->Range(32, 32<<3);
101-
}
102-
}
97+
BENCHMARK_TEMPLATE(benchmark_dot, xt::xtensor<double, 2>)->Range(32, 32 << 3);
98+
BENCHMARK_TEMPLATE(benchmark_transpose_dot, xt::xtensor<double, 2>)->Range(32, 32 << 3);
99+
BENCHMARK_TEMPLATE(benchmark_transpose_with_assign_dot, xt::xtensor<double, 2>)->Range(32, 32 << 3);
100+
} // namespace benchmark_dot
101+
} // namespace xt
103102

104103
#endif

benchmark/main.cpp

+18-14
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,32 @@
77
// ****************************************************************************/
88

99
#include <iostream>
10+
1011
#include <benchmark/benchmark.h>
1112

1213
#include "benchmark_blas.hpp"
1314

1415
#ifdef WITH_OPENBLAS
1516
void blas_stats()
1617
{
17-
std::cout << "\nSTATS FOR OPENBLAS\n---------------------------------------------------------------\n\n";
18+
std::cout << "\nSTATS FOR "
19+
"OPENBLAS\n-----------------------------------------------------"
20+
"----------\n\n";
1821

19-
openblas_set_num_threads(4);
20-
std::cout << "NUMBER OF THREADS: " << openblas_get_num_threads() << std::endl;
22+
openblas_set_num_threads(4);
23+
std::cout << "NUMBER OF THREADS: " << openblas_get_num_threads() << std::endl;
2124

22-
// Get the number of physical processors (cores)
23-
std::cout << "NUMBER OF PROCESSORS: " << openblas_get_num_procs() << std::endl;
24-
// Get the build configure on runtime.
25-
std::cout << "CONFIG: " << openblas_get_config() << std::endl;
25+
// Get the number of physical processors (cores)
26+
std::cout << "NUMBER OF PROCESSORS: " << openblas_get_num_procs() << std::endl;
27+
// Get the build configure on runtime.
28+
std::cout << "CONFIG: " << openblas_get_config() << std::endl;
2629

27-
/*Get the CPU corename on runtime.*/
28-
std::cout << "CORE NAME: " << openblas_get_corename() << std::endl;
30+
/*Get the CPU corename on runtime.*/
31+
std::cout << "CORE NAME: " << openblas_get_corename() << std::endl;
2932

30-
// Get the parallelization type which is used by OpenBLAS
31-
std::cout << "PARALLEL: " << openblas_get_parallel() << std::endl;
32-
std::cout << "\n\n";
33+
// Get the parallelization type which is used by OpenBLAS
34+
std::cout << "PARALLEL: " << openblas_get_parallel() << std::endl;
35+
std::cout << "\n\n";
3336
}
3437
#else
3538
void blas_stats(){};
@@ -38,8 +41,9 @@ void blas_stats(){};
3841
// Custom main function to print BLAS config
3942
int main(int argc, char** argv)
4043
{
41-
blas_stats();
44+
blas_stats();
4245
benchmark::Initialize(&argc, argv);
43-
if (benchmark::ReportUnrecognizedArguments(argc, argv)) return 1;
46+
if (benchmark::ReportUnrecognizedArguments(argc, argv))
47+
return 1;
4448
benchmark::RunSpecifiedBenchmarks();
4549
}

0 commit comments

Comments
 (0)