-
Notifications
You must be signed in to change notification settings - Fork 787
[SYCL][E2E][BINDLESS] Add ptr to ptr of image_handle test failing on level zero only #18721
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 all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f40184d
Add ptr to handle ptr test failing on l0
JackAKirk a4e2aae
Fix format
JackAKirk 7d07c29
Fix CI failures, address review comments
JackAKirk 6bb5373
Fix format
JackAKirk ad7e312
Remove l0 XFAIL
JackAKirk 47bcc0a
Xfail windows
JackAKirk 2308810
Use unsampled_image_handle
JackAKirk 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
119 changes: 119 additions & 0 deletions
119
sycl/test-e2e/bindless_images/array/fetch_handle_carray2d.cpp
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,119 @@ | ||
// REQUIRES: aspect-ext_oneapi_bindless_images | ||
// XFAIL: level_zero && windows | ||
// XFAIL-TRACKER: https://github.com/intel/llvm/issues/18727 | ||
// UNSUPPORTED: hip | ||
// UNSUPPORTED-INTENDED: Undetermined issue in 'create_image' in this test. | ||
|
||
// RUN: %{build} -o %t.out | ||
// RUN: %{run} env NEOReadDebugKeys=1 UseBindlessMode=1 UseExternalAllocatorForSshAndDsh=1 %t.out | ||
|
||
#include <sycl/detail/core.hpp> | ||
#include <sycl/ext/oneapi/bindless_images.hpp> | ||
#include <sycl/usm.hpp> | ||
|
||
namespace syclexp = sycl::ext::oneapi::experimental; | ||
|
||
int main() { | ||
|
||
sycl::queue q{}; | ||
|
||
// Initialize input data | ||
constexpr size_t width = 512; | ||
std::vector<float> dataIn(width); | ||
std::vector<float> dataOut(width); | ||
for (int i = 0; i < width; i++) { | ||
dataIn[i] = static_cast<float>(i); | ||
} | ||
|
||
// Image descriptor - can use the same for both images | ||
syclexp::image_descriptor desc(sycl::range{width}, 1, | ||
sycl::image_channel_type::fp32); | ||
|
||
// Extension: returns the device pointer to the allocated memory | ||
syclexp::image_mem imgMemoryIn(desc, q); | ||
syclexp::image_mem imgMemoryOut(desc, q); | ||
|
||
q.ext_oneapi_copy(dataIn.data(), imgMemoryIn.get_handle(), desc); | ||
q.wait_and_throw(); | ||
// Extension: create the image and return the handle | ||
syclexp::unsampled_image_handle imgIn = | ||
syclexp::create_image(imgMemoryIn, desc, q); | ||
syclexp::unsampled_image_handle imgOut = | ||
syclexp::create_image(imgMemoryOut, desc, q); | ||
|
||
// Copy the input data to the image_mem of the device unsampled_image_handle | ||
q.ext_oneapi_copy(dataIn.data(), imgMemoryIn.get_handle(), desc); | ||
q.wait_and_throw(); | ||
|
||
// Allocate an unsampled_image_handle manually instead of using create_image | ||
// so we can allocate it on the heap | ||
void *imageHandlePtrGen = | ||
sycl::malloc_device(sizeof(syclexp::unsampled_image_handle), q); | ||
|
||
// Copy the create_image returned device unsampled_image_handle to the | ||
// contents of the void* pointing to the heap allocated | ||
// unsampled_image_handle | ||
q.memcpy(static_cast<void *>(imageHandlePtrGen), | ||
static_cast<const void *>(&imgIn), | ||
sizeof(syclexp::unsampled_image_handle)); | ||
|
||
q.wait_and_throw(); | ||
|
||
// Allocate a device generic pointer pointing to an unsampled_image_handle* | ||
void *imageHandlePtrPtrGen = | ||
sycl::malloc_device(sizeof(syclexp::unsampled_image_handle *), q); | ||
|
||
// Copy the address of the manually allocated unsampled_image_handle to the | ||
// contents of the generic device pointer allocated above | ||
q.memcpy(static_cast<void *>(imageHandlePtrPtrGen), | ||
static_cast<const void *>(&imageHandlePtrGen), | ||
sizeof(syclexp::unsampled_image_handle *)); | ||
|
||
q.wait_and_throw(); | ||
|
||
q.submit([&](sycl::handler &cgh) { | ||
cgh.parallel_for( | ||
sycl::nd_range<1>{{width}, {width}}, [=](sycl::nd_item<1> it) { | ||
syclexp::unsampled_image_handle **imageHandlePtrPtr = | ||
static_cast<syclexp::unsampled_image_handle **>( | ||
imageHandlePtrPtrGen); | ||
// Dereference the generic pointer to the unsampled_image_handle | ||
// pointer | ||
syclexp::unsampled_image_handle *imageHandlePtr = | ||
static_cast<syclexp::unsampled_image_handle *>( | ||
imageHandlePtrPtr[0]); | ||
// Dereference the unsampled_image_handle pointer | ||
syclexp::unsampled_image_handle imageHandle = imageHandlePtr[0]; | ||
|
||
size_t dim0 = it.get_local_id(0); | ||
// Extension: read image data from handle | ||
float pixel = syclexp::fetch_image<float>(imageHandle, int(dim0)); | ||
|
||
// Extension: write to image data using handle | ||
syclexp::write_image(imgOut, int(dim0), pixel); | ||
}); | ||
}); | ||
|
||
q.wait_and_throw(); | ||
|
||
// Copy data written to imgOut to host | ||
q.ext_oneapi_copy(imgMemoryOut.get_handle(), dataOut.data(), desc); | ||
|
||
// Ensure copying data from the device to host is finished before validate | ||
q.wait_and_throw(); | ||
|
||
// Cleanup | ||
syclexp::destroy_image_handle(imgIn, q); | ||
syclexp::destroy_image_handle(imgOut, q); | ||
sycl::free(imageHandlePtrGen, q); | ||
sycl::free(imageHandlePtrPtrGen, q); | ||
|
||
for (size_t i = 0; i < width; i++) { | ||
if (dataOut[i] != dataIn[i]) { | ||
std::cout << "Test failed" | ||
<< "\n"; | ||
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.
Uh oh!
There was an error while loading. Please reload this page.