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 131
[SYCL] E2E test for interop_task with Level-Zero and OpenCL #252
Merged
Merged
Changes from 6 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
db42e36
[SYCL] E2E test fot interop_task with Level-Zero and OpenCL
mikhail-nikolskiy df07c9e
Update interop-level-zero-interop-task-mem.cpp
mikhail-nikolskiy 07a90e8
Update interop-opencl-interop-task-mem.cpp
mikhail-nikolskiy 3e8fe24
address review comments
mikhail-nikolskiy e4a60b0
Merge branch 'interop-task-mem' of https://github.com/mikhail-nikolsk…
mikhail-nikolskiy 7c083a5
Update SYCL/Plugin/interop-level-zero-interop-task-mem.cpp
bader b7a7083
OpenCL ICD loader is also needed to resolve direct OpenCL calls
mikhail-nikolskiy b82c649
add %opencl_lib and remove clang-format off/on
mikhail-nikolskiy 22b2c8e
Merge branch 'intel' into interop-task-mem
mikhail-nikolskiy 4239d5e
check ptr via zeMemGetAllocProperties
mikhail-nikolskiy 4421eb1
clang-format
mikhail-nikolskiy c1afbee
clang-format
mikhail-nikolskiy 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,53 @@ | ||
| // REQUIRES: level_zero, level_zero_dev_kit | ||
| // RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %level_zero_options %s -o %t.out | ||
| // RUN: %GPU_RUN_PLACEHOLDER %t.out | ||
|
|
||
| // Test for Level Zero interop_task. | ||
|
|
||
| #include <CL/sycl.hpp> | ||
| // clang-format off | ||
| #include <level_zero/ze_api.h> | ||
| #include <CL/sycl/backend/level_zero.hpp> | ||
| // clang-format on | ||
|
|
||
| using namespace sycl; | ||
|
|
||
| constexpr size_t SIZE = 16; | ||
|
|
||
| int main() { | ||
| queue queue{}; | ||
|
|
||
| try { | ||
| buffer<uint8_t, 1> buffer(SIZE); | ||
| image<2> image(image_channel_order::rgba, image_channel_type::fp32, | ||
| {SIZE, SIZE}); | ||
|
|
||
| ze_context_handle_t ze_context = | ||
| queue.get_context().get_native<backend::level_zero>(); | ||
|
|
||
| queue | ||
| .submit([&](handler &cgh) { | ||
| auto buffer_acc = buffer.get_access<access::mode::write>(cgh); | ||
| auto image_acc = image.get_access<float4, access::mode::write>(cgh); | ||
| cgh.interop_task([&](const interop_handler &ih) { | ||
| void *device_ptr = ih.get_mem<backend::level_zero>(buffer_acc); | ||
| size_t size = 0; | ||
| zeMemGetAddressRange(ze_context, device_ptr, NULL, &size); | ||
| assert(size == SIZE); | ||
|
|
||
| ze_image_handle_t ze_image = | ||
| ih.get_mem<backend::level_zero>(image_acc); | ||
| assert(ze_image != nullptr); | ||
| }); | ||
| }) | ||
| .wait(); | ||
| } catch (exception const &e) { | ||
| std::cout << "SYCL exception caught: " << e.what() << std::endl; | ||
| return e.get_cl_code(); | ||
| } catch (const char *msg) { | ||
| std::cout << "Exception caught: " << msg << std::endl; | ||
| return 1; | ||
| } | ||
|
|
||
| return 0; | ||
| } | ||
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,52 @@ | ||
| // REQUIRES: opencl | ||
|
mikhail-nikolskiy marked this conversation as resolved.
Outdated
|
||
|
|
||
| // RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out | ||
|
vladimirlaz marked this conversation as resolved.
Outdated
|
||
| // RUN: %GPU_RUN_PLACEHOLDER %t.out | ||
|
|
||
| // Test for OpenCL interop_task. | ||
|
|
||
| #include <CL/opencl.h> | ||
| #include <CL/sycl.hpp> | ||
| #include <CL/sycl/backend/opencl.hpp> | ||
|
|
||
| using namespace sycl; | ||
|
|
||
| constexpr size_t SIZE = 16; | ||
|
|
||
| int main() { | ||
| queue queue{}; | ||
|
|
||
| try { | ||
| buffer<uint8_t, 1> buffer(SIZE); | ||
| image<2> image(image_channel_order::rgba, image_channel_type::fp32, | ||
| {SIZE, SIZE}); | ||
|
|
||
| queue | ||
| .submit([&](handler &cgh) { | ||
| auto buffer_acc = buffer.get_access<access::mode::write>(cgh); | ||
| auto image_acc = image.get_access<float4, access::mode::write>(cgh); | ||
| cgh.interop_task([=](const interop_handler &ih) { | ||
| cl_mem buffer_mem = ih.get_mem<backend::opencl>(buffer_acc); | ||
| size_t size = 0; | ||
| clGetMemObjectInfo(buffer_mem, CL_MEM_SIZE, sizeof(size), | ||
| (void *)&size, nullptr); | ||
| assert(size == SIZE); | ||
|
|
||
| cl_mem mem = ih.get_mem<backend::opencl>(image_acc); | ||
| size_t width = 0; | ||
| clGetImageInfo(mem, CL_IMAGE_WIDTH, sizeof(width), (void *)&width, | ||
| nullptr); | ||
| assert(width == SIZE); | ||
| }); | ||
| }) | ||
| .wait(); | ||
| } catch (exception const &e) { | ||
| std::cout << "SYCL exception caught: " << e.what() << std::endl; | ||
| return e.get_cl_code(); | ||
| } catch (const char *msg) { | ||
| std::cout << "Exception caught: " << msg << std::endl; | ||
| return 1; | ||
| } | ||
|
|
||
| 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.
Could you clarify why clang-format comments are needed here, please?
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.
clang-format puts <level_zero/ze_api.h> after <CL/sycl/backend/level_zero.hpp> and compilation fails because
backend/level_zero.hppuses Level-zero types and expectsze_api.hincluded beforeThere 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.
I see. Alternative way to handle this is to put an empty line between
ze_api.handlevel_zero.hppincludes: