-
Notifications
You must be signed in to change notification settings - Fork 130
[SYCL] updating tests for SYCL2020 errc conformance #857
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,9 @@ | |
// RUN: %CPU_RUN_PLACEHOLDER %t.out | ||
// RUN: %GPU_RUN_PLACEHOLDER %t.out | ||
// RUN: %ACC_RUN_PLACEHOLDER %t.out | ||
|
||
// UNSUPPORTED: (opencl && gpu) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All changes in this file doesn't look related to SYCL2020 errc conformance, I couldn't find any errc checks in the file. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test was using an out-of-bounds range argument to an accessor. And, oddly, that was masking an error that is occurring over on OCL:GPU. I reduced that down and reported it, there is a ticket against it now. But in the interim, this test won't pass on OCL:GPU, not due to any bug in the error system, but due to a real bug that OCL:GPU has handling offsets. Strangely, that is the only device with the problem. L0, OCL:CPU, OCL:ACC and Host are all fine. |
||
|
||
// | ||
//==---------- subbuffer.cpp --- sub-buffer basic test ---------------------==// | ||
// | ||
|
@@ -71,26 +74,34 @@ void check1DSubBuffer(cl::sycl::queue &q) { | |
size *= 2; | ||
|
||
std::size_t offset = size / 2, subbuf_size = 10, offset_inside_subbuf = 3, | ||
subbuffer_access_range = 10; | ||
subbuffer_access_range = subbuf_size - offset_inside_subbuf; // 7. | ||
std::vector<int> vec(size); | ||
std::vector<int> vec2(subbuf_size, 0); | ||
std::iota(vec.begin(), vec.end(), 0); | ||
|
||
std::cout << "buffer size: " << size << ", subbuffer start: " << offset | ||
<< std::endl; | ||
|
||
try { | ||
cl::sycl::buffer<int, 1> buf(vec.data(), size); | ||
cl::sycl::buffer<int, 1> buf2(vec2.data(), subbuf_size); | ||
// subbuffer is 10 elements, starting at midpoint. (typically 32) | ||
cl::sycl::buffer<int, 1> subbuf(buf, cl::sycl::id<1>(offset), | ||
cl::sycl::range<1>(subbuf_size)); | ||
|
||
// test offset accessor against a subbuffer | ||
q.submit([&](cl::sycl::handler &cgh) { | ||
// accessor starts at the third element of the subbuffer | ||
// and can read for 7 more (ie to the end of the subbuffer) | ||
auto acc = subbuf.get_access<cl::sycl::access::mode::read_write>( | ||
cgh, cl::sycl::range<1>(subbuffer_access_range), | ||
cl::sycl::id<1>(offset_inside_subbuf)); | ||
cgh.parallel_for<class foobar>( | ||
cl::sycl::range<1>(subbuffer_access_range - offset_inside_subbuf), | ||
[=](cl::sycl::id<1> i) { acc[i] *= -1; }); | ||
// subrange is made negative. ( 32 33 34 -35 -36 -37 -38 -39 -40 -41) | ||
cgh.parallel_for<class foobar>(cl::sycl::range<1>(subbuffer_access_range), | ||
[=](cl::sycl::id<1> i) { acc[i] *= -1; }); | ||
}); | ||
|
||
// copy results of last operation back to buf2/vec2 | ||
q.submit([&](cl::sycl::handler &cgh) { | ||
auto acc_sub = subbuf.get_access<cl::sycl::access::mode::read>(cgh); | ||
auto acc_buf = buf2.get_access<cl::sycl::access::mode::write>(cgh); | ||
|
@@ -99,27 +110,48 @@ void check1DSubBuffer(cl::sycl::queue &q) { | |
[=](cl::sycl::id<1> i) { acc_buf[i] = acc_sub[i]; }); | ||
}); | ||
|
||
// multiple entire subbuffer by 10. | ||
// now original buffer will be | ||
// (..29 30 31 | 320 330 340 -350 -360 -370 -380 -390 -400 -410 | 42 43 44 | ||
// ...) | ||
q.submit([&](cl::sycl::handler &cgh) { | ||
auto acc_sub = subbuf.get_access<cl::sycl::access::mode::read_write>( | ||
cgh, cl::sycl::range<1>(subbuffer_access_range)); | ||
cgh, cl::sycl::range<1>(subbuf_size)); | ||
cgh.parallel_for<class foobar_1>( | ||
cl::sycl::range<1>(subbuffer_access_range), | ||
cl::sycl::range<1>(subbuf_size), | ||
[=](cl::sycl::id<1> i) { acc_sub[i] *= 10; }); | ||
}); | ||
q.wait_and_throw(); | ||
|
||
// buffers go out of scope. data must be copied back to vector no later than | ||
// this. | ||
} catch (const cl::sycl::exception &e) { | ||
std::cerr << e.what() << std::endl; | ||
assert(false && "Exception was caught"); | ||
} | ||
|
||
// check buffer data in the area of the subbuffer | ||
// OCL:GPU confused => 320 330 340 -350 -360 -370 -380 39 40 41 | ||
// every other device => 320 330 340 -350 -360 -370 -380 -390 -400 -410 | ||
for (int i = offset; i < offset + subbuf_size; ++i) | ||
assert(vec[i] == (i < offset + offset_inside_subbuf ? i * 10 : i * -10) && | ||
"Invalid result in 1d sub buffer"); | ||
"Invalid result in buffer overlapped by 1d sub buffer"); | ||
|
||
// check buffer data in the area OUTSIDE the subbuffer | ||
for (int i = 0; i < size; i++) { | ||
if (i < offset) | ||
assert(vec[i] == i && "data preceding subbuffer incorrectly altered"); | ||
|
||
if (i > offset + subbuf_size) | ||
assert(vec[i] == i && "data following subbuffer incorrectly altered"); | ||
} | ||
|
||
// check the copy of the subbuffer data after the first operation | ||
// OCL:GPU => 32 33 34 -35 -36 -37 -38 0 0 0 | ||
// everyone else => 32 33 34 -35 -36 -37 -38 -39 -40 -41 | ||
for (int i = 0; i < subbuf_size; ++i) | ||
assert(vec2[i] == (i < 3 ? (offset + i) : (offset + i) * -1) && | ||
"Invalid result in 1d sub buffer"); | ||
"Invalid result in captured 1d sub buffer, vec2"); | ||
} | ||
|
||
void checkExceptions() { | ||
|
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.
These changes look unrelated to SYCL2020 errc conformance. Can we remove them from this PR?
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.
One of the conformance checks is that out-of-bounds range args should trigger an exception in accessor construction. I added that. Without this change, this test triggers that error.