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