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

[SYCL] Add tests for code location print in case of exception in execution #1545

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions SYCL/Tracing/code_location_queue_copy.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// UNSUPPORTED: windows
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
// RUN: %CPU_RUN_PLACEHOLDER sycl-trace --sycl %t.out %CPU_CHECK_PLACEHOLDER

// Test tracing of the code location data for queue.copy in case of failure
// (exception generation)
//
// CHECK: code_location_queue_copy.cpp:18 main

#include <sycl/sycl.hpp>

int main() {
sycl::queue Q;
bool ExceptionCaught = false;
unsigned char *HostAllocSrc = (unsigned char *)sycl::malloc_host(1, Q);
unsigned char *HostAllocDst = NULL;
try {
Q.copy(HostAllocDst, HostAllocSrc, 1);
} catch (sycl::exception &e) {
std::ignore = e;
ExceptionCaught = true;
}
Q.wait();
sycl::free(HostAllocSrc, Q);

return !ExceptionCaught;
}
28 changes: 28 additions & 0 deletions SYCL/Tracing/code_location_queue_parallel_for.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// UNSUPPORTED: windows
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
// RUN: %CPU_RUN_PLACEHOLDER sycl-trace --sycl %t.out %CPU_CHECK_PLACEHOLDER

// Test tracing of the code location data for queue.parallel_for in case of
// failure (exception generation)
//
// CHECK: code_location_queue_parallel_for.cpp:22 E2ETestKernel

#include <sycl/sycl.hpp>

int main() {
sycl::queue Queue;
sycl::buffer<int, 1> Buf(8);
sycl::device Dev = Queue.get_device();
sycl::id<1> MaxWISizes =
Dev.get_info<sycl::info::device::max_work_item_sizes<1>>();
bool ExceptionCaught = false;
try {
Queue.parallel_for<class E2ETestKernel>(
sycl::nd_range<1>{MaxWISizes.get(0), 2 * MaxWISizes.get(0)},
[](sycl::id<1> idx) {});
} catch (...) {
ExceptionCaught = true;
}
Queue.wait();
return !ExceptionCaught;
}
28 changes: 28 additions & 0 deletions SYCL/Tracing/code_location_queue_submit.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// UNSUPPORTED: windows
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
// RUN: %CPU_RUN_PLACEHOLDER sycl-trace --sycl %t.out %CPU_CHECK_PLACEHOLDER

// Test tracing of the code location data for queue.submit in case of failure
// (exception generation)
//
// CHECK: code_location_queue_submit.cpp:18 main

#include <sycl/sycl.hpp>

int main() {
sycl::queue Q;
bool ExceptionCaught = false;
unsigned char *HostAllocSrc = (unsigned char *)sycl::malloc_host(1, Q);
unsigned char *HostAllocDst = NULL;
try {
Q.submit(
[&](sycl::handler &cgh) { cgh.copy(HostAllocDst, HostAllocSrc, 1); });
} catch (sycl::exception &e) {
std::ignore = e;
ExceptionCaught = true;
}
Q.wait();
sycl::free(HostAllocSrc, Q);

return !ExceptionCaught;
}