Skip to content

Commit

Permalink
[clang-format] Reformat again
Browse files Browse the repository at this point in the history
  • Loading branch information
dnhsieh-intel committed Oct 18, 2024
1 parent bef73e1 commit eb1f931
Show file tree
Hide file tree
Showing 238 changed files with 58,492 additions and 58,527 deletions.
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
32 changes: 16 additions & 16 deletions examples/sparse_blas/run_time_dispatching/sparse_blas_spmv_usm.cpp
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.
//
template <typename fp, typename intType>
int run_sparse_matrix_vector_multiply_example(const sycl::device &dev) {
int run_sparse_matrix_vector_multiply_example(const sycl::device& dev) {
// Matrix data size
intType size = 4;
intType nrows = size * size * size;
Expand All @@ -72,11 +72,11 @@ int run_sparse_matrix_vector_multiply_example(const sycl::device &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 @@ -95,12 +95,12 @@ int run_sparse_matrix_vector_multiply_example(const sycl::device &dev) {
std::size_t sizevec = static_cast<std::size_t>(nrows);
auto sizevec_i64 = static_cast<std::int64_t>(sizevec);

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

if (!ia || !ja || !a || !x || !y || !z) {
throw std::runtime_error("Failed to allocate USM memory");
Expand All @@ -115,10 +115,10 @@ int run_sparse_matrix_vector_multiply_example(const sycl::device &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 @@ -160,7 +160,7 @@ int run_sparse_matrix_vector_multiply_example(const sycl::device &dev) {
std::size_t workspace_size = 0;
oneapi::mkl::sparse::spmv_buffer_size(main_queue, transA, &alpha, A_view, A_handle, x_handle,
&beta, y_handle, alg, descr, workspace_size);
void *workspace = sycl::malloc_device(workspace_size, main_queue);
void* workspace = sycl::malloc_device(workspace_size, main_queue);

// Optimize spmv
auto ev_opt =
Expand Down Expand Up @@ -189,7 +189,7 @@ int run_sparse_matrix_vector_multiply_example(const sycl::device &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 @@ -258,7 +258,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_sparse_matrix_vector_multiply_example<float, std::int32_t>(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

0 comments on commit eb1f931

Please sign in to comment.