Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

Commit 4b7e2e1

Browse files
committed
clang-format
Signed-off-by: Sergey V Maslov <[email protected]>
1 parent 7117f04 commit 4b7e2e1

File tree

1 file changed

+52
-47
lines changed

1 file changed

+52
-47
lines changed

SYCL/Plugin/retain_events.cpp

Lines changed: 52 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -2,74 +2,79 @@
22
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
33
// RUN: %GPU_RUN_PLACEHOLDER %t.out
44

5+
#include <CL/sycl.hpp>
6+
#include <algorithm>
57
#include <cstdio>
68
#include <numeric>
7-
#include <algorithm>
8-
#include <CL/sycl.hpp>
99

1010
namespace {
1111

12-
void print_device_properties(sycl::device const & dev) {
13-
auto plat_name = dev.get_platform().template get_info<sycl::info::platform::name>();
14-
auto dev_name = dev.template get_info<sycl::info::device::name>();
15-
auto driver_version = dev.template get_info<sycl::info::device::driver_version>();
12+
void print_device_properties(sycl::device const &dev) {
13+
auto plat_name =
14+
dev.get_platform().template get_info<sycl::info::platform::name>();
15+
auto dev_name = dev.template get_info<sycl::info::device::name>();
16+
auto driver_version =
17+
dev.template get_info<sycl::info::device::driver_version>();
1618

17-
fprintf(stdout, " platform name: %s\n", plat_name.c_str());
18-
fprintf(stdout, " device name: %s\n", dev_name.c_str());
19-
fprintf(stdout, "driver version: %s\n", driver_version.c_str());
19+
fprintf(stdout, " platform name: %s\n", plat_name.c_str());
20+
fprintf(stdout, " device name: %s\n", dev_name.c_str());
21+
fprintf(stdout, "driver version: %s\n", driver_version.c_str());
2022
}
2123

2224
void async_sycl_error(cl::sycl::exception_list el) {
23-
fprintf(stderr,"async exceptions caught:\n");
24-
for (auto l = el.begin(); l != el.end(); ++l) {
25-
try {
26-
std::rethrow_exception(*l);
27-
} catch(const cl::sycl::exception & e) {
28-
fprintf(stderr, "what: %s code: %d\n", e.what(), e.get_cl_code());
29-
std::exit(-1);
30-
}
25+
fprintf(stderr, "async exceptions caught:\n");
26+
for (auto l = el.begin(); l != el.end(); ++l) {
27+
try {
28+
std::rethrow_exception(*l);
29+
} catch (const cl::sycl::exception &e) {
30+
fprintf(stderr, "what: %s code: %d\n", e.what(), e.get_cl_code());
31+
std::exit(-1);
3132
}
33+
}
3234
}
3335

34-
}
36+
} // namespace
3537

36-
int test(sycl::device & D) {
37-
sycl::context C ( D );
38-
constexpr size_t N = 1024 * 1000;
38+
int test(sycl::device &D) {
39+
sycl::context C(D);
40+
constexpr size_t N = 1024 * 1000;
3941

40-
int * src = sycl::malloc_shared<int>(N, D, C);
41-
int * dst = sycl::malloc_shared<int>(N, D, C);
42+
int *src = sycl::malloc_shared<int>(N, D, C);
43+
int *dst = sycl::malloc_shared<int>(N, D, C);
4244

43-
std::iota(src, src + N, 0);
44-
std::fill(dst, dst + N, 0);
45+
std::iota(src, src + N, 0);
46+
std::fill(dst, dst + N, 0);
4547

46-
for (int i = 0; i < 256; ++i) {
47-
sycl::queue Q { C , D, async_sycl_error };//, sycl::property::queue::enable_profiling() };
48+
for (int i = 0; i < 256; ++i) {
49+
sycl::queue Q{
50+
C, D,
51+
async_sycl_error}; //, sycl::property::queue::enable_profiling() };
4852

49-
Q.submit([&](sycl::handler &SH) {
50-
sycl::range<1> r (N);
51-
SH.parallel_for<class X>(r, [=](sycl::id<1> id) {
52-
size_t i = id.get(0);
53-
dst[i] = src[i] + 1;
54-
});
55-
});
56-
}
53+
Q.submit([&](sycl::handler &SH) {
54+
sycl::range<1> r(N);
55+
SH.parallel_for<class X>(r, [=](sycl::id<1> id) {
56+
size_t i = id.get(0);
57+
dst[i] = src[i] + 1;
58+
});
59+
});
60+
}
5761

58-
sycl::free(dst, C);
59-
sycl::free(src, C);
62+
sycl::free(dst, C);
63+
sycl::free(src, C);
6064

61-
return 0;
65+
return 0;
6266
}
6367

6468
int main() {
65-
try {
66-
sycl::device D1 { sycl::gpu_selector {} };
67-
print_device_properties(D1);
68-
for (int i = 0; i < 10; ++i) { test(D1); }
69+
try {
70+
sycl::device D1{sycl::gpu_selector{}};
71+
print_device_properties(D1);
72+
for (int i = 0; i < 10; ++i) {
73+
test(D1);
6974
}
70-
catch (sycl::exception & e) {
71-
fprintf(stderr, "...sycl failed to entertain with \"%s\" (%d) \n", e.what(), e.get_cl_code());
72-
}
73-
return 0;
75+
} catch (sycl::exception &e) {
76+
fprintf(stderr, "...sycl failed to entertain with \"%s\" (%d) \n", e.what(),
77+
e.get_cl_code());
78+
}
79+
return 0;
7480
}
75-

0 commit comments

Comments
 (0)