-
Notifications
You must be signed in to change notification settings - Fork 801
[SYCL] Correction to accessor range indexing. #4556
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
16f8991
[SYCL] Correction to accessor range indexing.
rdeodhar 58a9fad
Merge branch 'sycl' of https://github.com/intel/llvm into ij30862
rdeodhar 1faa3a5
Added test. Currently expected to fail on L0.
rdeodhar 740bee6
Removed test, which will be added to llvm_test_suite.
rdeodhar 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
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,117 @@ | ||
| // RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out | ||
| // RUN: %CPU_RUN_PLACEHOLDER %t.out %CPU_CHECK_PLACEHOLDER | ||
| // RUN: %GPU_RUN_PLACEHOLDER %t.out %GPU_CHECK_PLACEHOLDER | ||
romanovvlad marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| // XFAIL: level_zero | ||
|
|
||
| #include <CL/sycl.hpp> | ||
| #include <CL/sycl/accessor.hpp> | ||
| #include <iostream> | ||
| using namespace sycl; | ||
| #define N 4 // dimensin | ||
| #define M 128 // dimension | ||
| #define C 4 // 4 channel | ||
| #define L 2 // 2 images | ||
|
|
||
| void try_1D(queue &Q) { | ||
| int X = -55; | ||
| buffer<int, 1> BX{&X, 1}; | ||
| int *host_array = new int[M * C]; | ||
| image im1(host_array, image_channel_order::rgba, | ||
| image_channel_type::unsigned_int8, range{M}); | ||
|
|
||
| Q.submit([&](handler &h) { | ||
| accessor<int4, 1, access::mode::read, access::target::image> acs1(im1, h); | ||
| accessor ABX{BX, h}; | ||
| auto R = acs1.get_range(); | ||
| std::cout << "Host acs1.get_range()=" << R[0] << "\n"; | ||
| assert(R[0] == M); | ||
| h.parallel_for(nd_range{range{M}, range{N}}, [=](nd_item<1> it) { | ||
| int idx = it.get_global_linear_id(); | ||
| if (idx == 0) { | ||
| auto R = acs1.get_range(); | ||
| ABX[0] = R[0]; | ||
| } | ||
| }); | ||
| }); | ||
| { | ||
| host_accessor HABX{BX, read_only}; | ||
| std::cout << "From Device acs1.get_range()=" << X << "\n"; | ||
| assert(X == M); | ||
| } | ||
| } | ||
|
|
||
| void try_2D(queue &Q) { | ||
| range<2> X = {55, 66}; | ||
| buffer<range<2>, 1> BX{&X, 1}; | ||
| int *host_array = new int[M * N * C]; | ||
| image im2(host_array, image_channel_order::rgba, | ||
| image_channel_type::unsigned_int8, range{M, N}); | ||
|
|
||
| Q.submit([&](handler &h) { | ||
| accessor<int4, 2, access::mode::read, access::target::image> acs2(im2, h); | ||
| accessor ABX{BX, h}; | ||
| auto R = acs2.get_range(); | ||
| std::cout << "Host acs2.get_range()=" << R[0] << "," << R[1] << "\n"; | ||
| assert(R[0] == M); | ||
| assert(R[1] == N); | ||
| h.parallel_for(nd_range{range{M, N}, range{N, N}}, [=](nd_item<2> it) { | ||
| int idx = it.get_global_linear_id(); | ||
| if (idx == 0) { | ||
| ABX[0] = acs2.get_range(); | ||
| } | ||
| }); | ||
| }); | ||
| { | ||
| host_accessor HABX{BX, read_only}; | ||
| std::cout << "From Device acs2.get_range()=" << HABX[0][0] << "," | ||
| << HABX[0][1] << "\n"; | ||
| assert(HABX[0][0] == M); | ||
| assert(HABX[0][1] == N); | ||
| } | ||
| } | ||
|
|
||
| void try_3D(queue &Q) { | ||
| range<3> X{55, 66, 77}; | ||
| buffer<range<3>, 1> BX{&X, 1}; | ||
| int *host_array3_2 = malloc_host<int>(N * M * C * L, Q); | ||
| image im3(host_array3_2, image_channel_order::rgba, | ||
| image_channel_type::unsigned_int8, range{M, N, L}); | ||
|
|
||
| Q.submit([&](handler &h) { | ||
| accessor<int4, 2, access::mode::read, access::target::image_array> acs3(im3, | ||
| h); | ||
| accessor ABX{BX, h}; | ||
| auto R = acs3.get_range(); | ||
| std::cout << "Host acs3.get_range()=" << R[0] << "," << R[1] << "," << R[2] | ||
| << "\n"; | ||
| assert(R[0] == M); | ||
| assert(R[1] == N); | ||
| assert(R[2] == L); | ||
| h.parallel_for(nd_range{range{M, N, L}, range{N, N, L}}, | ||
| [=](nd_item<3> it) { | ||
| int idx = it.get_global_linear_id(); | ||
| if (idx == 0) { | ||
| ABX[0] = acs3.get_range(); | ||
| } | ||
| }); | ||
| }); | ||
| { | ||
| host_accessor HABX{BX, read_only}; | ||
| std::cout << "From Device acs3.get_range()=" << HABX[0][0] << "," | ||
| << HABX[0][1] << "," << HABX[0][2] << "\n"; | ||
| assert(HABX[0][0] == M); | ||
| assert(HABX[0][1] == N); | ||
| assert(HABX[0][2] == L); | ||
| } | ||
| } | ||
|
|
||
| int main() { | ||
| queue Q; | ||
|
|
||
| try_1D(Q); | ||
| try_2D(Q); | ||
| try_3D(Q); | ||
|
|
||
| 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.
Uh oh!
There was an error while loading. Please reload this page.