Skip to content

Commit 70e0b2b

Browse files
committed
Fix review comments
Signed-off-by: Ruslan Arutyunyan <ruslan.arutyunyan@intel.com>
1 parent d59bfdd commit 70e0b2b

File tree

3 files changed

+63
-64
lines changed

3 files changed

+63
-64
lines changed

sycl/include/CL/sycl/queue.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ class __SYCL_EXPORT queue {
443443
#ifdef DISABLE_SYCL_INSTRUMENTATION_METADATA
444444
const detail::code_location &CodeLoc = {};
445445
#endif
446-
return parallel_for_impl(NumWorkItems, KernelFunc, CodeLoc);
446+
return parallel_for_impl<KernelName>(NumWorkItems, KernelFunc, CodeLoc);
447447
}
448448

449449
/// parallel_for version with a kernel represented as a lambda + range that
@@ -463,7 +463,7 @@ class __SYCL_EXPORT queue {
463463
#ifdef DISABLE_SYCL_INSTRUMENTATION_METADATA
464464
const detail::code_location &CodeLoc = {};
465465
#endif
466-
return parallel_for_impl(NumWorkItems, KernelFunc, CodeLoc);
466+
return parallel_for_impl<KernelName>(NumWorkItems, KernelFunc, CodeLoc);
467467
}
468468

469469
/// parallel_for version with a kernel represented as a lambda + range that
@@ -483,7 +483,7 @@ class __SYCL_EXPORT queue {
483483
#ifdef DISABLE_SYCL_INSTRUMENTATION_METADATA
484484
const detail::code_location &CodeLoc = {};
485485
#endif
486-
return parallel_for_impl(NumWorkItems, KernelFunc, CodeLoc);
486+
return parallel_for_impl<KernelName>(NumWorkItems, KernelFunc, CodeLoc);
487487
}
488488

489489
/// parallel_for version with a kernel represented as a lambda + range that
Lines changed: 41 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
// UNSUPPORTED: cuda
2-
// CUDA does not support unnamed lambdas.
1+
// XFAIL: cuda
2+
// piextUSM*Alloc functions for CUDA are not behaving as described in
3+
// https://github.com/intel/llvm/blob/sycl/sycl/doc/extensions/USM/USM.adoc
4+
// https://github.com/intel/llvm/blob/sycl/sycl/doc/extensions/USM/cl_intel_unified_shared_memory.asciidoc
35
//
4-
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple -fsycl-unnamed-lambda %s -o %t.out
6+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
57
// RUN: env SYCL_DEVICE_TYPE=HOST %t.out
68
// RUN: %ACC_RUN_PLACEHOLDER %t.out
79
// RUN: %CPU_RUN_PLACEHOLDER %t.out
@@ -25,48 +27,48 @@ int main() {
2527
auto ctx = q.get_context();
2628
constexpr int N = 8;
2729

28-
if (dev.get_info<sycl::info::device::usm_shared_allocations>()) {
29-
auto A = static_cast<int *>(sycl::malloc_shared(N * sizeof(int), dev, ctx));
30+
if (!dev.get_info<sycl::info::device::usm_shared_allocations>()) {
31+
return 0;
32+
}
33+
34+
auto A = static_cast<int *>(sycl::malloc_shared(N * sizeof(int), dev, ctx));
3035

31-
for (int i = 0; i < N; i++) {
32-
A[i] = 1;
33-
}
36+
for (int i = 0; i < N; i++) {
37+
A[i] = 1;
38+
}
3439

35-
q.parallel_for(N, [=](auto i) {
36-
static_assert(std::is_same<decltype(i), sycl::item<1>>::value,
37-
"lambda arg type is unexpected");
38-
A[i]++;
39-
});
40+
q.parallel_for<class Bar>(N, [=](auto i) {
41+
static_assert(std::is_same<decltype(i), sycl::item<1>>::value,
42+
"lambda arg type is unexpected");
43+
A[i]++;
44+
});
4045

41-
q.parallel_for<class Foo>({N}, [=](auto i) {
42-
static_assert(std::is_same<decltype(i), sycl::item<1>>::value,
43-
"lambda arg type is unexpected");
44-
A[i]++;
45-
});
46+
q.parallel_for<class Foo>({N}, [=](auto i) {
47+
static_assert(std::is_same<decltype(i), sycl::item<1>>::value,
48+
"lambda arg type is unexpected");
49+
A[i]++;
50+
});
4651

47-
sycl::id<1> offset(0);
48-
q.parallel_for<class Baz>(sycl::range<1>{N}, offset, [=](auto i) {
49-
static_assert(std::is_same<decltype(i), sycl::item<1>>::value,
50-
"lambda arg type is unexpected");
51-
A[i]++;
52-
});
52+
sycl::id<1> offset(0);
53+
q.parallel_for<class Baz>(sycl::range<1>{N}, offset, [=](auto i) {
54+
static_assert(std::is_same<decltype(i), sycl::item<1>>::value,
55+
"lambda arg type is unexpected");
56+
A[i]++;
57+
});
5358

54-
sycl::nd_range<1> NDR(sycl::range<1>{N}, sycl::range<1>{2});
55-
q.parallel_for<class NDFoo>(NDR, [=](auto nd_i) {
56-
static_assert(std::is_same<decltype(nd_i), sycl::nd_item<1>>::value,
57-
"lambda arg type is unexpected");
58-
auto i = nd_i.get_global_id(0);
59-
A[i]++;
60-
});
59+
sycl::nd_range<1> NDR(sycl::range<1>{N}, sycl::range<1>{2});
60+
q.parallel_for<class NDFoo>(NDR, [=](auto nd_i) {
61+
static_assert(std::is_same<decltype(nd_i), sycl::nd_item<1>>::value,
62+
"lambda arg type is unexpected");
63+
auto i = nd_i.get_global_id(0);
64+
A[i]++;
65+
});
6166

62-
q.wait();
67+
q.wait();
6368

64-
for (int i = 0; i < N; i++) {
65-
if (A[i] != 5)
66-
return 1;
67-
}
68-
sycl::free(A, ctx);
69+
for (int i = 0; i < N; i++) {
70+
if (A[i] != 5)
71+
return 1;
6972
}
70-
71-
return 0;
73+
sycl::free(A, ctx);
7274
}
Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
// UNSUPPORTED: cuda
2-
// CUDA does not support unnamed lambdas.
3-
//
4-
// RUN: %clangxx -fsycl -fsyntax-only -fsycl-unnamed-lambda %s -o %t.out
1+
// RUN: %clangxx -fsycl -fsyntax-only %s -o %t.out
52

63
//==- queue_parallel_for_generic.cpp - SYCL queue parallel_for interface test -=//
74
//
@@ -15,53 +12,53 @@
1512
#include <iostream>
1613
#include <type_traits>
1714

18-
template <std::size_t... Is>
15+
template <typename KernelName, std::size_t... Is>
1916
void test_range_impl(sycl::queue q, std::index_sequence<Is...>,
2017
sycl::range<sizeof...(Is)> *) {
2118
constexpr auto dims = sizeof...(Is);
2219

23-
q.parallel_for(sycl::range<dims>{Is...}, [=](auto i) {
20+
q.parallel_for<KernelName>(sycl::range<dims>{Is...}, [=](auto i) {
2421
static_assert(std::is_same<decltype(i), sycl::item<dims>>::value,
2522
"lambda arg type is unexpected");
2623
});
2724
}
2825

29-
template <std::size_t... Is>
26+
template <typename KernelName, std::size_t... Is>
3027
void test_range_impl(sycl::queue q, std::index_sequence<Is...>,
3128
sycl::nd_range<sizeof...(Is)> *) {
3229
constexpr auto dims = sizeof...(Is);
3330

3431
sycl::nd_range<dims> ndr{sycl::range<dims>{Is...}, sycl::range<dims>{Is...}};
35-
q.parallel_for(ndr, [=](auto i) {
32+
q.parallel_for<KernelName>(ndr, [=](auto i) {
3633
static_assert(std::is_same<decltype(i), sycl::nd_item<dims>>::value,
3734
"lambda arg type is unexpected");
3835
});
3936
}
4037

41-
template <template <int> class Range, std::size_t Dims>
38+
template <typename KernelName, template <int> class Range, std::size_t Dims>
4239
void test_range(sycl::queue q) {
43-
test_range_impl(q, std::make_index_sequence<Dims>{},
44-
static_cast<Range<Dims> *>(nullptr));
40+
test_range_impl<KernelName>(q, std::make_index_sequence<Dims>{},
41+
static_cast<Range<Dims> *>(nullptr));
4542
}
4643

4744
void test_number_braced_init_list(sycl::queue q) {
4845
constexpr auto n = 1;
49-
q.parallel_for(n, [=](auto i) {
46+
q.parallel_for<class Number>(n, [=](auto i) {
5047
static_assert(std::is_same<decltype(i), sycl::item<1>>::value,
5148
"lambda arg type is unexpected");
5249
});
5350

54-
q.parallel_for({n}, [=](auto i) {
51+
q.parallel_for<class BracedInitList1>({n}, [=](auto i) {
5552
static_assert(std::is_same<decltype(i), sycl::item<1>>::value,
5653
"lambda arg type is unexpected");
5754
});
5855

59-
q.parallel_for({n, n}, [=](auto i) {
56+
q.parallel_for<class BracedInitList2>({n, n}, [=](auto i) {
6057
static_assert(std::is_same<decltype(i), sycl::item<2>>::value,
6158
"lambda arg type is unexpected");
6259
});
6360

64-
q.parallel_for({n, n, n}, [=](auto i) {
61+
q.parallel_for<class BracedInitList3>({n, n, n}, [=](auto i) {
6562
static_assert(std::is_same<decltype(i), sycl::item<3>>::value,
6663
"lambda arg type is unexpected");
6764
});
@@ -70,12 +67,12 @@ void test_number_braced_init_list(sycl::queue q) {
7067
int main() {
7168
sycl::queue q{};
7269

73-
test_number_braced_init_list(q);
70+
test_range<class test_range1, sycl::range, 1>(q);
71+
test_range<class test_range2, sycl::range, 2>(q);
72+
test_range<class test_range3, sycl::range, 3>(q);
73+
test_range<class test_nd_range1, sycl::nd_range, 1>(q);
74+
test_range<class test_nd_range2, sycl::nd_range, 2>(q);
75+
test_range<class test_nd_range3, sycl::nd_range, 3>(q);
7476

75-
test_range<sycl::range, 1>(q);
76-
test_range<sycl::range, 2>(q);
77-
test_range<sycl::range, 3>(q);
78-
test_range<sycl::nd_range, 1>(q);
79-
test_range<sycl::nd_range, 2>(q);
80-
test_range<sycl::nd_range, 3>(q);
77+
test_number_braced_init_list(q);
8178
}

0 commit comments

Comments
 (0)