This repository was archived by the owner on Mar 28, 2023. It is now read-only.
forked from llvm/llvm-test-suite
-
Notifications
You must be signed in to change notification settings - Fork 130
[SYCL] E2E test to retain PI events until they have signaled #180
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// REQUIRES: gpu | ||
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out | ||
// RUN: %GPU_RUN_PLACEHOLDER %t.out | ||
|
||
#include <CL/sycl.hpp> | ||
#include <algorithm> | ||
#include <cstdio> | ||
#include <numeric> | ||
|
||
namespace { | ||
|
||
void print_device_properties(sycl::device const &dev) { | ||
auto plat_name = | ||
dev.get_platform().template get_info<sycl::info::platform::name>(); | ||
auto dev_name = dev.template get_info<sycl::info::device::name>(); | ||
auto driver_version = | ||
dev.template get_info<sycl::info::device::driver_version>(); | ||
|
||
fprintf(stdout, " platform name: %s\n", plat_name.c_str()); | ||
fprintf(stdout, " device name: %s\n", dev_name.c_str()); | ||
fprintf(stdout, "driver version: %s\n", driver_version.c_str()); | ||
} | ||
|
||
void async_sycl_error(cl::sycl::exception_list el) { | ||
fprintf(stderr, "async exceptions caught:\n"); | ||
for (auto l = el.begin(); l != el.end(); ++l) { | ||
try { | ||
std::rethrow_exception(*l); | ||
} catch (const cl::sycl::exception &e) { | ||
fprintf(stderr, "what: %s code: %d\n", e.what(), e.get_cl_code()); | ||
std::exit(-1); | ||
} | ||
} | ||
} | ||
|
||
} // namespace | ||
|
||
int test(sycl::device &D) { | ||
sycl::context C(D); | ||
constexpr size_t N = 1024 * 1000; | ||
|
||
int *src = sycl::malloc_shared<int>(N, D, C); | ||
int *dst = sycl::malloc_shared<int>(N, D, C); | ||
|
||
std::iota(src, src + N, 0); | ||
std::fill(dst, dst + N, 0); | ||
|
||
for (int i = 0; i < 256; ++i) { | ||
sycl::queue Q{ | ||
C, D, | ||
async_sycl_error}; //, sycl::property::queue::enable_profiling() }; | ||
|
||
Q.submit([&](sycl::handler &SH) { | ||
sycl::range<1> r(N); | ||
SH.parallel_for<class X>(r, [=](sycl::id<1> id) { | ||
size_t i = id.get(0); | ||
dst[i] = src[i] + 1; | ||
}); | ||
}); | ||
} | ||
|
||
sycl::free(dst, C); | ||
sycl::free(src, C); | ||
|
||
return 0; | ||
} | ||
|
||
int main() { | ||
try { | ||
sycl::device D1{sycl::gpu_selector{}}; | ||
print_device_properties(D1); | ||
for (int i = 0; i < 10; ++i) { | ||
test(D1); | ||
} | ||
} catch (sycl::exception &e) { | ||
fprintf(stderr, "...sycl failed to entertain with \"%s\" (%d) \n", e.what(), | ||
e.get_cl_code()); | ||
} | ||
return 0; | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@smaslov-intel, @againull, shouldn't we set SYCL_PI_LEVEL_ZERO_TRACK_INDIRECT_ACCESS_MEMORY or wait for all kernels to complete before freeing USM memory to make this test valid?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alexbatashev FYI.