Skip to content

Commit

Permalink
Add .clang-format file from xtensor and format all files
Browse files Browse the repository at this point in the history
  • Loading branch information
james-d-mitchell committed Jan 16, 2023
1 parent 7b96edd commit fbc58b7
Show file tree
Hide file tree
Showing 18 changed files with 3,799 additions and 3,676 deletions.
86 changes: 86 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
BasedOnStyle: Mozilla
AccessModifierOffset: '-4'
AlignAfterOpenBracket: BlockIndent
AlignEscapedNewlines: Left
AllowAllArgumentsOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: false
AllowShortIfStatementsOnASingleLine: false
# Forbid one line lambdas because clang-format makes a weird split when
# single instructions lambdas are too long.
AllowShortLambdasOnASingleLine: Empty
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: None
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakTemplateDeclarations: Yes
SpaceAfterTemplateKeyword: true
BinPackArguments: false
BinPackParameters: false
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeBraces: Allman
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeComma
BreakInheritanceList: AfterComma
BreakStringLiterals: false
ColumnLimit: '110'
ConstructorInitializerIndentWidth: '4'
ContinuationIndentWidth: '4'
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: true
EmptyLineAfterAccessModifier: Always
EmptyLineBeforeAccessModifier: Always
IncludeBlocks: Regroup
IncludeCategories:
- Regex: <[^.]+>
Priority: 1
- Regex: <xtensor/.+>
Priority: 3
- Regex: <.+>
Priority: 2
- Regex: '"xtensor/.+"'
Priority: 4
- Regex: '".+"'
Priority: 5
IndentCaseLabels: true
IndentWidth: '4'
IndentWrappedFunctionNames: false
InsertTrailingCommas: Wrapped
KeepEmptyLinesAtTheStartOfBlocks: false
LambdaBodyIndentation: Signature
Language: Cpp
MaxEmptyLinesToKeep: '2'
NamespaceIndentation: All
ObjCBlockIndentWidth: '4'
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: false
PointerAlignment: Left
PackConstructorInitializers: Never
PenaltyBreakAssignment: 100000
PenaltyBreakBeforeFirstCallParameter: 0
PenaltyBreakComment: 10
PenaltyBreakOpenParenthesis: 0
PenaltyBreakTemplateDeclaration: 0
PenaltyExcessCharacter: 10
PenaltyIndentedWhitespace: 0
PenaltyReturnTypeOnItsOwnLine: 10
ReflowComments: true
SeparateDefinitionBlocks: Always
SortIncludes: CaseInsensitive
SortUsingDeclarations: true
SpaceAfterCStyleCast: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: '2'
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: c++14
TabWidth: '4'
UseTab: Never
31 changes: 15 additions & 16 deletions benchmark/benchmark_blas.hpp
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
/***************************************************************************
* Copyright (c) 2016, Johan Mabille, Sylvain Corlay and Wolf Vollprecht *
* *
* Distributed under the terms of the BSD 3-Clause License. *
* *
* The full license is in the file LICENSE, distributed with this software. *
****************************************************************************/
* Copyright (c) 2016, Johan Mabille, Sylvain Corlay and Wolf Vollprecht *
* *
* Distributed under the terms of the BSD 3-Clause License. *
* *
* The full license is in the file LICENSE, distributed with this software. *
****************************************************************************/

#ifndef BENCHMARK_BLAS_HPP
#define BENCHMARK_BLAS_HPP

#include <benchmark/benchmark.h>

#include "xtensor/xarray.hpp"
#include "xtensor/xnoalias.hpp"
#include "xtensor/xtensor.hpp"
#include "xtensor/xarray.hpp"

#include "xtensor-blas/xlinalg.hpp"

Expand Down Expand Up @@ -41,11 +41,10 @@ namespace xt
}

template <class V>
inline void init_xtensor_benchmark(V& lhs, V& rhs,
std::size_t size0, size_t size1)
inline void init_xtensor_benchmark(V& lhs, V& rhs, std::size_t size0, size_t size1)
{
lhs.reshape({ size0, size1 });
rhs.reshape({ size0, size1 });
lhs.reshape({size0, size1});
rhs.reshape({size0, size1});
init_benchmark_data(lhs, rhs, size0, size1);
}

Expand Down Expand Up @@ -95,10 +94,10 @@ namespace xt
}
}

BENCHMARK_TEMPLATE(benchmark_dot, xt::xtensor<double, 2>)->Range(32, 32<<3);
BENCHMARK_TEMPLATE(benchmark_transpose_dot, xt::xtensor<double, 2>)->Range(32, 32<<3);
BENCHMARK_TEMPLATE(benchmark_transpose_with_assign_dot, xt::xtensor<double, 2>)->Range(32, 32<<3);
}
}
BENCHMARK_TEMPLATE(benchmark_dot, xt::xtensor<double, 2>)->Range(32, 32 << 3);
BENCHMARK_TEMPLATE(benchmark_transpose_dot, xt::xtensor<double, 2>)->Range(32, 32 << 3);
BENCHMARK_TEMPLATE(benchmark_transpose_with_assign_dot, xt::xtensor<double, 2>)->Range(32, 32 << 3);
} // namespace benchmark_dot
} // namespace xt

#endif
32 changes: 18 additions & 14 deletions benchmark/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,32 @@
// ****************************************************************************/

#include <iostream>

#include <benchmark/benchmark.h>

#include "benchmark_blas.hpp"

#ifdef WITH_OPENBLAS
void blas_stats()
{
std::cout << "\nSTATS FOR OPENBLAS\n---------------------------------------------------------------\n\n";
std::cout << "\nSTATS FOR "
"OPENBLAS\n-----------------------------------------------------"
"----------\n\n";

openblas_set_num_threads(4);
std::cout << "NUMBER OF THREADS: " << openblas_get_num_threads() << std::endl;
openblas_set_num_threads(4);
std::cout << "NUMBER OF THREADS: " << openblas_get_num_threads() << std::endl;

// Get the number of physical processors (cores)
std::cout << "NUMBER OF PROCESSORS: " << openblas_get_num_procs() << std::endl;
// Get the build configure on runtime.
std::cout << "CONFIG: " << openblas_get_config() << std::endl;
// Get the number of physical processors (cores)
std::cout << "NUMBER OF PROCESSORS: " << openblas_get_num_procs() << std::endl;
// Get the build configure on runtime.
std::cout << "CONFIG: " << openblas_get_config() << std::endl;

/*Get the CPU corename on runtime.*/
std::cout << "CORE NAME: " << openblas_get_corename() << std::endl;
/*Get the CPU corename on runtime.*/
std::cout << "CORE NAME: " << openblas_get_corename() << std::endl;

// Get the parallelization type which is used by OpenBLAS
std::cout << "PARALLEL: " << openblas_get_parallel() << std::endl;
std::cout << "\n\n";
// Get the parallelization type which is used by OpenBLAS
std::cout << "PARALLEL: " << openblas_get_parallel() << std::endl;
std::cout << "\n\n";
}
#else
void blas_stats(){};
Expand All @@ -38,8 +41,9 @@ void blas_stats(){};
// Custom main function to print BLAS config
int main(int argc, char** argv)
{
blas_stats();
blas_stats();
benchmark::Initialize(&argc, argv);
if (benchmark::ReportUnrecognizedArguments(argc, argv)) return 1;
if (benchmark::ReportUnrecognizedArguments(argc, argv))
return 1;
benchmark::RunSpecifiedBenchmarks();
}
Loading

0 comments on commit fbc58b7

Please sign in to comment.