Skip to content

Commit

Permalink
clang-format-19.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Rbiessy committed Oct 21, 2024
1 parent 0f677b4 commit ca37c38
Show file tree
Hide file tree
Showing 405 changed files with 73,086 additions and 72,570 deletions.
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
repos:

- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v19.1.0
hooks:
- id: clang-format
files: \.(c|cxx|cpp|h|hxx|hpp)$
exclude: ^deps/
96 changes: 25 additions & 71 deletions _clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -21,31 +21,31 @@
Language: Cpp
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignConsecutiveMacros: true
AlignConsecutiveAssignments:
Enabled: false
AlignConsecutiveDeclarations:
Enabled: false
AlignConsecutiveMacros:
Enabled: true
AlignEscapedNewlines: Left
AlignOperands: true
AlignTrailingComments: false
AlignOperands: Align
AlignTrailingComments:
Kind: Never
AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: Inline
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: false
AfterControlStatement: Never
AfterEnum: false
AfterFunction: false
AfterNamespace: false
Expand All @@ -59,46 +59,33 @@ BraceWrapping:
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: false
BreakAfterReturnType: Automatic
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: BeforeColon
BreakStringLiterals: false
BreakTemplateDeclarations: Yes
ColumnLimit: 100
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 8
ContinuationIndentWidth: 4
Cpp11BracedListStyle: false
DerivePointerAlignment: true
DerivePointerAlignment: false
DisableFormat: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^<ext/.*\.h>'
Priority: 2
- Regex: '^<.*\.h>'
Priority: 1
- Regex: '^<.*'
Priority: 2
- Regex: '.*'
Priority: 3
IncludeIsMainRegex: '([-_](test|unittest))?$'
IndentCaseLabels: true
IndentPPDirectives: None
IndentWidth: 4
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
KeepEmptyLines:
AtEndOfFile: false
AtStartOfBlock: false
AtStartOfFile: false
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
PackConstructorInitializers: CurrentLine
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 1
PenaltyBreakComment: 300
Expand All @@ -108,57 +95,24 @@ PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Left
RawStringFormats:
- Language: Cpp
Delimiters:
- cc
- CC
- cpp
- Cpp
- CPP
- 'c++'
- 'C++'
CanonicalDelimiter: ''
BasedOnStyle: google
- Language: TextProto
Delimiters:
- pb
- PB
- proto
- PROTO
EnclosingFunctions:
- EqualsProto
- EquivToProto
- PARSE_PARTIAL_TEXT_PROTO
- PARSE_TEST_PROTO
- PARSE_TEXT_PROTO
- ParseTextOrDie
- ParseTextProtoOrDie
CanonicalDelimiter: ''
BasedOnStyle: google
ReflowComments: false
SortIncludes: false
SortUsingDeclarations: false
SortIncludes: Never
SortUsingDeclarations: Never
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInAngles: Never
SpacesInContainerLiterals: false
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInParens: Never
SpacesInSquareBrackets: false
Standard: Cpp11
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
TabWidth: 1
Standard: c++17
UseTab: Never
...
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
//
// is performed and finally the results are post processed.
//
void run_gemm_example(const sycl::device &cpu_dev, const sycl::device &gpu_dev) {
void run_gemm_example(const sycl::device& cpu_dev, const sycl::device& gpu_dev) {
//
// Initialize data for Gemm
//
Expand Down Expand Up @@ -89,11 +89,11 @@ void run_gemm_example(const sycl::device &cpu_dev, const sycl::device &gpu_dev)

// Catch asynchronous exceptions for CPU and GPU
auto cpu_exception_handler = [](sycl::exception_list exceptions) {
for (std::exception_ptr const &e : exceptions) {
for (std::exception_ptr const& e : exceptions) {
try {
std::rethrow_exception(e);
}
catch (sycl::exception const &e) {
catch (sycl::exception const& e) {
std::cerr << "Caught asynchronous SYCL exception on CPU device during GEMM:"
<< std::endl;
std::cerr << "\t" << e.what() << std::endl;
Expand All @@ -102,11 +102,11 @@ void run_gemm_example(const sycl::device &cpu_dev, const sycl::device &gpu_dev)
std::exit(2);
};
auto gpu_exception_handler = [](sycl::exception_list exceptions) {
for (std::exception_ptr const &e : exceptions) {
for (std::exception_ptr const& e : exceptions) {
try {
std::rethrow_exception(e);
}
catch (sycl::exception const &e) {
catch (sycl::exception const& e) {
std::cerr << "Caught asynchronous SYCL exception on GPU device during GEMM:"
<< std::endl;
std::cerr << "\t" << e.what() << std::endl;
Expand Down Expand Up @@ -141,9 +141,9 @@ void run_gemm_example(const sycl::device &cpu_dev, const sycl::device &gpu_dev)
sycl::context cpu_cxt = cpu_queue.get_context();

// allocate on CPU device and copy data from host to SYCL CPU device
float *cpu_A = sycl::malloc_device<float>(sizea * sizeof(float), cpu_queue);
float *cpu_B = sycl::malloc_device<float>(sizeb * sizeof(float), cpu_queue);
float *cpu_C = sycl::malloc_device<float>(sizec * sizeof(float), cpu_queue);
float* cpu_A = sycl::malloc_device<float>(sizea * sizeof(float), cpu_queue);
float* cpu_B = sycl::malloc_device<float>(sizeb * sizeof(float), cpu_queue);
float* cpu_C = sycl::malloc_device<float>(sizec * sizeof(float), cpu_queue);
if (!cpu_A || !cpu_B || !cpu_C) {
throw std::runtime_error("Failed to allocate USM memory.");
}
Expand All @@ -159,9 +159,9 @@ void run_gemm_example(const sycl::device &cpu_dev, const sycl::device &gpu_dev)
sycl::context gpu_cxt = gpu_queue.get_context();

// allocate on GPU device and copy data from host to SYCL GPU device
float *gpu_A = sycl::malloc_device<float>(sizea * sizeof(float), gpu_queue);
float *gpu_B = sycl::malloc_device<float>(sizeb * sizeof(float), gpu_queue);
float *gpu_C = sycl::malloc_device<float>(sizec * sizeof(float), gpu_queue);
float* gpu_A = sycl::malloc_device<float>(sizea * sizeof(float), gpu_queue);
float* gpu_B = sycl::malloc_device<float>(sizeb * sizeof(float), gpu_queue);
float* gpu_C = sycl::malloc_device<float>(sizec * sizeof(float), gpu_queue);
if (!gpu_A || !gpu_B || !gpu_C) {
throw std::runtime_error("Failed to allocate USM memory.");
}
Expand All @@ -174,11 +174,11 @@ void run_gemm_example(const sycl::device &cpu_dev, const sycl::device &gpu_dev)
//
// add oneapi::math::blas::gemm to execution queue
cpu_gemm_done = oneapi::math::blas::column_major::gemm(
oneapi::math::backend_selector<oneapi::math::backend::mklcpu>{ cpu_queue }, transA, transB, m,
n, k, alpha, cpu_A, ldA, cpu_B, ldB, beta, cpu_C, ldC);
oneapi::math::backend_selector<oneapi::math::backend::mklcpu>{ cpu_queue }, transA, transB,
m, n, k, alpha, cpu_A, ldA, cpu_B, ldB, beta, cpu_C, ldC);
gpu_gemm_done = oneapi::math::blas::column_major::gemm(
oneapi::math::backend_selector<oneapi::math::backend::cublas>{ gpu_queue }, transA, transB, m,
n, k, alpha, gpu_A, ldA, gpu_B, ldB, beta, gpu_C, ldC);
oneapi::math::backend_selector<oneapi::math::backend::cublas>{ gpu_queue }, transA, transB,
m, n, k, alpha, gpu_A, ldA, gpu_B, ldB, beta, gpu_C, ldC);

// Wait until calculations are done
cpu_gemm_done.wait_and_throw();
Expand Down Expand Up @@ -260,7 +260,7 @@ void print_example_banner() {
//
// Main entry point for example.
//
int main(int argc, char **argv) {
int main(int argc, char** argv) {
print_example_banner();

try {
Expand All @@ -279,13 +279,13 @@ int main(int argc, char **argv) {
run_gemm_example(cpu_dev, gpu_dev);
std::cout << "BLAS GEMM USM example ran OK on MKLCPU and CUBLAS" << std::endl;
}
catch (sycl::exception const &e) {
catch (sycl::exception const& e) {
std::cerr << "Caught synchronous SYCL exception during GEMM:" << std::endl;
std::cerr << "\t" << e.what() << std::endl;
std::cerr << "\tSYCL error code: " << e.code().value() << std::endl;
return 1;
}
catch (std::exception const &e) {
catch (std::exception const& e) {
std::cerr << "Caught std::exception during GEMM:";
std::cerr << "\t" << e.what() << std::endl;
return 1;
Expand Down
2 changes: 1 addition & 1 deletion examples/blas/run_time_dispatching/level3/gemm_usm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ void run_gemm_example(const sycl::device& dev) {
//
// add oneapi::math::blas::gemm to execution queue
gemm_done = oneapi::math::blas::column_major::gemm(main_queue, transA, transB, m, n, k, alpha,
dev_A, ldA, dev_B, ldB, beta, dev_C, ldC);
dev_A, ldA, dev_B, ldB, beta, dev_C, ldC);

// Wait until calculations are done
main_queue.wait_and_throw();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ void run_example(const sycl::device& cpu_device, const sycl::device& gpu_device)
// enabling
// 1. create descriptors
oneapi::math::dft::descriptor<oneapi::math::dft::precision::SINGLE,
oneapi::math::dft::domain::COMPLEX>
oneapi::math::dft::domain::COMPLEX>
desc(static_cast<std::int64_t>(N));

// 2. variadic set_value
Expand Down
2 changes: 1 addition & 1 deletion examples/dft/run_time_dispatching/real_fwd_usm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void run_example(const sycl::device& dev) {

// 1. create descriptors
oneapi::math::dft::descriptor<oneapi::math::dft::precision::SINGLE,
oneapi::math::dft::domain::REAL>
oneapi::math::dft::domain::REAL>
desc(static_cast<std::int64_t>(N));

// 2. variadic set_value
Expand Down
6 changes: 3 additions & 3 deletions examples/include/example_helper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ fp rand_scalar() {
}

template <typename vec>
void rand_matrix(vec &M, oneapi::math::transpose trans, int m, int n, int ld) {
void rand_matrix(vec& M, oneapi::math::transpose trans, int m, int n, int ld) {
using fp = typename vec::value_type;

if (trans == oneapi::math::transpose::nontrans) {
Expand All @@ -104,7 +104,7 @@ void rand_matrix(vec &M, oneapi::math::transpose trans, int m, int n, int ld) {
}

template <typename fp, typename intType>
intType generate_sparse_matrix(const intType nx, intType *ia, intType *ja, fp *a,
intType generate_sparse_matrix(const intType nx, intType* ia, intType* ja, fp* a,
const intType index = 0) {
intType nz = nx, ny = nx;
intType nnz = 0;
Expand Down Expand Up @@ -172,7 +172,7 @@ bool check_result(fp res, fp ref, intType nFlops, intType index) {
}

template <typename T>
void free_vec(std::vector<T *> &ptr_vec, sycl::queue queue) {
void free_vec(std::vector<T*>& ptr_vec, sycl::queue queue) {
for (auto ptr : ptr_vec) {
sycl::free(ptr, queue);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ void run_getrs_example(const sycl::device& cpu_device, const sycl::device& gpu_d
std::int64_t gpu_getrf_scratchpad_size = oneapi::math::lapack::getrf_scratchpad_size<float>(
oneapi::math::backend_selector<oneapi::math::backend::cusolver>{ gpu_queue }, m, n, lda);
std::int64_t gpu_getrs_scratchpad_size = oneapi::math::lapack::getrs_scratchpad_size<float>(
oneapi::math::backend_selector<oneapi::math::backend::cusolver>{ gpu_queue }, trans, n, nrhs,
lda, ldb);
oneapi::math::backend_selector<oneapi::math::backend::cusolver>{ gpu_queue }, trans, n,
nrhs, lda, ldb);
float* gpu_getrf_scratchpad = sycl::malloc_device<float>(
gpu_getrf_scratchpad_size * sizeof(float), gpu_device, gpu_context);
float* gpu_getrs_scratchpad = sycl::malloc_device<float>(
Expand All @@ -197,8 +197,8 @@ void run_getrs_example(const sycl::device& cpu_device, const sycl::device& gpu_d
//

cpu_getrf_done = oneapi::math::lapack::getrf(
oneapi::math::backend_selector<oneapi::math::backend::mklcpu>{ cpu_queue }, m, n, cpu_A, lda,
cpu_ipiv, cpu_getrf_scratchpad, cpu_getrf_scratchpad_size);
oneapi::math::backend_selector<oneapi::math::backend::mklcpu>{ cpu_queue }, m, n, cpu_A,
lda, cpu_ipiv, cpu_getrf_scratchpad, cpu_getrf_scratchpad_size);
cpu_getrs_done = oneapi::math::lapack::getrs(
oneapi::math::backend_selector<oneapi::math::backend::mklcpu>{ cpu_queue }, trans, n, nrhs,
cpu_A, lda, cpu_ipiv, cpu_B, ldb, cpu_getrs_scratchpad, cpu_getrs_scratchpad_size,
Expand All @@ -207,8 +207,8 @@ void run_getrs_example(const sycl::device& cpu_device, const sycl::device& gpu_d
oneapi::math::backend_selector<oneapi::math::backend::cusolver>{ gpu_queue }, m, n, gpu_A,
lda, gpu_ipiv, gpu_getrf_scratchpad, gpu_getrf_scratchpad_size);
gpu_getrs_done = oneapi::math::lapack::getrs(
oneapi::math::backend_selector<oneapi::math::backend::cusolver>{ gpu_queue }, trans, n, nrhs,
gpu_A, lda, gpu_ipiv, gpu_B, ldb, gpu_getrs_scratchpad, gpu_getrs_scratchpad_size,
oneapi::math::backend_selector<oneapi::math::backend::cusolver>{ gpu_queue }, trans, n,
nrhs, gpu_A, lda, gpu_ipiv, gpu_B, ldb, gpu_getrs_scratchpad, gpu_getrs_scratchpad_size,
{ gpu_getrf_done });

// Wait until calculations are done
Expand Down
4 changes: 2 additions & 2 deletions examples/lapack/run_time_dispatching/getrs_usm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,10 @@ void run_getrs_example(const sycl::device& device) {

// Execute on device
getrf_done = oneapi::math::lapack::getrf(queue, m, n, dev_A, lda, dev_ipiv, getrf_scratchpad,
getrf_scratchpad_size);
getrf_scratchpad_size);
getrs_done =
oneapi::math::lapack::getrs(queue, trans, n, nrhs, dev_A, lda, dev_ipiv, dev_B, ldb,
getrs_scratchpad, getrs_scratchpad_size, { getrf_done });
getrs_scratchpad, getrs_scratchpad_size, { getrf_done });

// Wait until calculations are done
queue.wait_and_throw();
Expand Down
Loading

0 comments on commit ca37c38

Please sign in to comment.