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

[clang-format] Reformat due to transition from v9.0.0 to v19.1.0 and update of style configuration #594

Merged
merged 3 commits into from
Oct 23, 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
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 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
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::mkl::transpose trans, int m, int n, int ld) {
void rand_matrix(vec& M, oneapi::mkl::transpose trans, int m, int n, int ld) {
using fp = typename vec::value_type;

if (trans == oneapi::mkl::transpose::nontrans) {
Expand All @@ -104,7 +104,7 @@ void rand_matrix(vec &M, oneapi::mkl::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 @@ -60,7 +60,7 @@
// is performed and finally the results are post processed.
//
template <typename fp, typename intType>
int run_sparse_matrix_vector_multiply_example(const sycl::device &cpu_dev) {
int run_sparse_matrix_vector_multiply_example(const sycl::device& cpu_dev) {
// Matrix data size
intType size = 4;
intType nrows = size * size * size;
Expand All @@ -71,11 +71,11 @@ int run_sparse_matrix_vector_multiply_example(const sycl::device &cpu_dev) {

// Catch asynchronous exceptions
auto 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::cout << "Caught asynchronous SYCL "
"exception during sparse::spmv:\n"
<< e.what() << std::endl;
Expand All @@ -94,12 +94,12 @@ int run_sparse_matrix_vector_multiply_example(const sycl::device &cpu_dev) {
std::size_t sizeia = static_cast<std::size_t>(nrows + 1);
std::size_t sizevec = static_cast<std::size_t>(nrows);

ia = (intType *)sycl::malloc_shared(sizeia * sizeof(intType), cpu_queue);
ja = (intType *)sycl::malloc_shared(sizeja * sizeof(intType), cpu_queue);
a = (fp *)sycl::malloc_shared(sizea * sizeof(fp), cpu_queue);
x = (fp *)sycl::malloc_shared(sizevec * sizeof(fp), cpu_queue);
y = (fp *)sycl::malloc_shared(sizevec * sizeof(fp), cpu_queue);
z = (fp *)sycl::malloc_shared(sizevec * sizeof(fp), cpu_queue);
ia = (intType*)sycl::malloc_shared(sizeia * sizeof(intType), cpu_queue);
ja = (intType*)sycl::malloc_shared(sizeja * sizeof(intType), cpu_queue);
a = (fp*)sycl::malloc_shared(sizea * sizeof(fp), cpu_queue);
x = (fp*)sycl::malloc_shared(sizevec * sizeof(fp), cpu_queue);
y = (fp*)sycl::malloc_shared(sizevec * sizeof(fp), cpu_queue);
z = (fp*)sycl::malloc_shared(sizevec * sizeof(fp), cpu_queue);

if (!ia || !ja || !a || !x || !y || !z) {
throw std::runtime_error("Failed to allocate USM memory");
Expand All @@ -114,10 +114,10 @@ int run_sparse_matrix_vector_multiply_example(const sycl::device &cpu_dev) {
z[i] = set_fp_value(fp(0.0));
}

std::vector<intType *> int_ptr_vec;
std::vector<intType*> int_ptr_vec;
int_ptr_vec.push_back(ia);
int_ptr_vec.push_back(ja);
std::vector<fp *> fp_ptr_vec;
std::vector<fp*> fp_ptr_vec;
fp_ptr_vec.push_back(a);
fp_ptr_vec.push_back(x);
fp_ptr_vec.push_back(y);
Expand Down Expand Up @@ -159,7 +159,7 @@ int run_sparse_matrix_vector_multiply_example(const sycl::device &cpu_dev) {
std::size_t workspace_size = 0;
oneapi::mkl::sparse::spmv_buffer_size(cpu_selector, transA, &alpha, A_view, A_handle, x_handle,
&beta, y_handle, alg, descr, workspace_size);
void *workspace = sycl::malloc_device(workspace_size, cpu_queue);
void* workspace = sycl::malloc_device(workspace_size, cpu_queue);

// Optimize spmv
auto ev_opt =
Expand Down Expand Up @@ -188,7 +188,7 @@ int run_sparse_matrix_vector_multiply_example(const sycl::device &cpu_dev) {
// Post Processing
//

fp *res = y;
fp* res = y;
const bool isConj = (transA == oneapi::mkl::transpose::conjtrans);
for (intType row = 0; row < nrows; row++) {
z[row] *= beta;
Expand Down Expand Up @@ -254,7 +254,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 @@ -269,13 +269,13 @@ int main(int /*argc*/, char ** /*argv*/) {
run_sparse_matrix_vector_multiply_example<float, std::int32_t>(cpu_dev);
std::cout << "Sparse BLAS SPMV USM example ran OK." << std::endl;
}
catch (sycl::exception const &e) {
catch (sycl::exception const& e) {
std::cerr << "Caught synchronous SYCL exception during Sparse SPMV:" << 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 Sparse SPMV:" << std::endl;
std::cerr << "\t" << e.what() << std::endl;
return 1;
Expand Down
Loading