Skip to content

Commit 51d92a3

Browse files
[SYCL][NATIVECPU] Implement events on Native CPU (#15926)
Testing PR for oneapi-src/unified-runtime#2254 --------- Co-authored-by: Callum Fare <[email protected]>
1 parent f2c557d commit 51d92a3

File tree

2 files changed

+55
-32
lines changed

2 files changed

+55
-32
lines changed
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# commit 9a209aa5fe6f438b682b3a999b9ee505e202f9b7
2-
# Merge: 2eae687a 9339e374
1+
# commit cd92e72bbc4ebddef63c63c0f7e66a410f4b9552
2+
# Merge: 9a209aa5 b1222f08
33
# Author: Callum Fare <[email protected]>
4-
# Date: Tue Nov 12 11:47:03 2024 +0000
5-
# Merge pull request #2179 from Maetveis/wrap_icx_linker_flags
6-
# Wrap linker flags on Windows for IntelLLLVM
7-
set(UNIFIED_RUNTIME_TAG 9a209aa5fe6f438b682b3a999b9ee505e202f9b7)
4+
# Date: Wed Nov 13 09:57:16 2024 +0000
5+
# Merge pull request #2254 from PietroGhg/pietro/events_rr
6+
# [NATIVECPU] Implement events on Native CPU
7+
set(UNIFIED_RUNTIME_TAG cd92e72bbc4ebddef63c63c0f7e66a410f4b9552)

sycl/test/native_cpu/scalar_args.cpp

Lines changed: 49 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,39 +12,62 @@ const size_t N = 10;
1212

1313
template <typename T> class init_a;
1414

15-
template <typename T> bool test(queue myQueue) {
16-
{
17-
buffer<float, 1> a(range<1>{N});
18-
const T test = rand() % 10;
19-
20-
myQueue.submit([&](handler &cgh) {
21-
auto A = a.get_access<access::mode::write>(cgh);
22-
cgh.parallel_for<init_a<T>>(range<1>{N},
23-
[=](id<1> index) { A[index] = test; });
24-
});
25-
26-
auto A = a.get_access<access::mode::read>();
27-
std::cout << "Result:" << std::endl;
28-
for (size_t i = 0; i < N; i++) {
29-
if (A[i] != test) {
30-
std::cout << "ERROR at pos " << i << " expected " << test << ", got "
31-
<< A[i] << "\n";
32-
return false;
33-
}
34-
}
15+
template <typename T, int M>
16+
bool compare(const sycl::vec<T, M> a, const sycl::vec<T, M> truth) {
17+
bool res = true;
18+
for (int i = 0; i < M; i++) {
19+
res &= a[i] == truth[i];
3520
}
21+
return res;
22+
}
3623

37-
std::cout << "Good computation!" << std::endl;
24+
template <typename T> bool compare(const T a, const T truth) {
25+
return a == truth;
26+
}
27+
28+
template <typename T> bool check(buffer<T, 1> &result, const T truth) {
29+
auto A = result.get_host_access();
30+
for (size_t i = 0; i < N; i++) {
31+
if (!compare(A[i], truth)) {
32+
return false;
33+
}
34+
}
3835
return true;
3936
}
4037

38+
template <typename T> bool test(queue myQueue) {
39+
buffer<T, 1> a(range<1>{N});
40+
const T test{42};
41+
42+
myQueue.submit([&](handler &cgh) {
43+
auto A = a.template get_access<access::mode::write>(cgh);
44+
cgh.parallel_for<init_a<T>>(range<1>{N},
45+
[=](id<1> index) { A[index] = test; });
46+
});
47+
48+
return check(a, test);
49+
}
50+
4151
int main() {
4252
queue q;
43-
int res1 = test<int>(q);
44-
int res2 = test<unsigned>(q);
45-
int res3 = test<float>(q);
46-
int res4 = test<double>(q);
47-
if (!(res1 && res2 && res3 && res4)) {
53+
54+
std::vector<bool> res;
55+
res.push_back(test<int>(q));
56+
res.push_back(test<unsigned>(q));
57+
res.push_back(test<float>(q));
58+
res.push_back(test<double>(q));
59+
res.push_back(test<sycl::vec<int, 2>>(q));
60+
res.push_back(test<sycl::vec<int, 3>>(q));
61+
res.push_back(test<sycl::vec<int, 4>>(q));
62+
res.push_back(test<sycl::vec<int, 8>>(q));
63+
res.push_back(test<sycl::vec<int, 16>>(q));
64+
res.push_back(test<sycl::vec<double, 2>>(q));
65+
res.push_back(test<sycl::vec<double, 3>>(q));
66+
res.push_back(test<sycl::vec<double, 4>>(q));
67+
res.push_back(test<sycl::vec<double, 8>>(q));
68+
res.push_back(test<sycl::vec<double, 16>>(q));
69+
70+
if (std::any_of(res.begin(), res.end(), [](bool b) { return !b; })) {
4871
return 1;
4972
}
5073
return 0;

0 commit comments

Comments
 (0)