Skip to content

Commit 96e92a8

Browse files
author
Sergey Kanaev
committed
[SYCL] Add test
Signed-off-by: Sergey Kanaev <[email protected]>
1 parent eb8f4f5 commit 96e92a8

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// RUN: %clangxx -fsycl %s -o %t.out
2+
// RUN: %CPU_RUN_PLACEHOLDER %t.out
3+
4+
#include <CL/sycl.hpp>
5+
// FIXME do not use internal methods in tests.
6+
#include <CL/sycl/detail/program_impl.hpp>
7+
8+
namespace RT = cl::sycl::RT;
9+
namespace detail = cl::sycl::detail;
10+
namespace pi = detail::pi;
11+
12+
using ProgramCacheT = detail::KernelProgramCache::ProgramCacheT;
13+
using KernelCacheT = detail::KernelProgramCache::KernelCacheT;
14+
15+
class Functor {
16+
public:
17+
void operator()(cl::sycl::item<1> Item) { (void)Item; }
18+
};
19+
20+
SYCL_EXTERNAL
21+
void undefined();
22+
23+
void test() {
24+
cl::sycl::queue Queue;
25+
26+
auto Kernel = []() {
27+
#ifdef __SYCL_DEVICE_ONLY__
28+
undefined();
29+
#endif
30+
};
31+
32+
std::string Msg;
33+
int Result;
34+
35+
for (int Idx = 0; Idx < 2; ++Idx) {
36+
try {
37+
Queue.submit([&](cl::sycl::handler &CGH) {
38+
CGH.single_task<class SingleTask>(Kernel);
39+
});
40+
assert(false && "There must be compilation error");
41+
} catch (const cl::sycl::compile_program_error &e) {
42+
fprintf(stderr, "Exception: %s, %d\n", e.what(), e.get_cl_code());
43+
if (Idx == 0) {
44+
Msg = e.what();
45+
Result = e.get_cl_code();
46+
} else {
47+
// Exception constantly adds info on its error code in the message
48+
assert(Msg.find_first_of(e.what()) == 0 && "Exception text differs");
49+
assert(Result == e.get_cl_code() && "Exception code differs");
50+
}
51+
} catch (...) {
52+
assert(false && "There must be cl::sycl::compile_program_error");
53+
}
54+
}
55+
}
56+
57+
int main() {
58+
test();
59+
60+
return 0;
61+
}

0 commit comments

Comments
 (0)