Skip to content
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

[SYCL][Bindless][Exp] Add Support For Unsampled Image Arrays #12464

Merged

Conversation

isaacault
Copy link
Contributor

@isaacault isaacault commented Jan 23, 2024

  • Creation / destruction of unsampled image arrays
  • Fetching / writing of unsampled image arrays
  • sycl::ext::oneapi::experimental::image_type::array enum value added
  • sycl::ext::oneapi::experimental::image_descriptor::array_size member added
  • sycl::ext::oneapi::experimental::image_descriptor::verify() member function added

Correlated UR PR: [Bindless][Exp] Add Support For Image Arrays #1274

- Creation / destruction of unsampled image arrays
- Reading / writing of unsampled image arrays
- sycl::ext::oneapi::experimental::image_type::array enum value added
- sycl::ext::oneapi::experimental::image_descriptor::array_size member added
- sycl::ext::oneapi::experimental::image_descriptor::verify() member function added
- Use bindless_helpers funcs for vulkan interop testing
- Rename fill_rand func to conform to snake case
- Use new assertion on unsampled coords in read_image_array
- Declare and use syclexp namespace in image array test
@isaacault isaacault marked this pull request as ready for review January 30, 2024 09:28
@isaacault isaacault requested review from a team as code owners January 30, 2024 09:28
Copy link
Contributor

@jchlanda jchlanda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've only gone through libclc changes.

libclc/ptx-nvidiacl/libspirv/images/image.cl Outdated Show resolved Hide resolved
libclc/ptx-nvidiacl/libspirv/images/image.cl Outdated Show resolved Hide resolved
libclc/ptx-nvidiacl/libspirv/images/image.cl Outdated Show resolved Hide resolved
libclc/ptx-nvidiacl/libspirv/images/image.cl Outdated Show resolved Hide resolved
libclc/ptx-nvidiacl/libspirv/images/image.cl Outdated Show resolved Hide resolved
libclc/ptx-nvidiacl/libspirv/images/image.cl Outdated Show resolved Hide resolved
libclc/ptx-nvidiacl/libspirv/images/image.cl Outdated Show resolved Hide resolved
* Remove cast reshuffling
* Wrap image array read/write intrinsics in macros
@isaacault
Copy link
Contributor Author

@jchlanda My apologies, I accidentally rebased. I believe I've corrected my mistake, and you can see my changes addressing your feedback in 6b2ca14.


#ifdef __SYCL_DEVICE_ONLY__
#if defined(__NVPTX__)
__invoke__ImageArrayWrite((uint64_t)imageHandle.raw_handle, coords,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use more C++'ish cast here? I'd expect it to be sycl::bit_cast or static_cast.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. Done.

"Standard images cannot have num_levels greater than 1! Use "
"image_type::mipmap for mipmap images.");
}
} else if (this->type == image_type::array) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
} else if (this->type == image_type::array) {
return;
}
if (this->type == image_type::array) {

same below. That way the reader would know immediately that there are no other checks after the "cascade" of "if"s. Or maybe even change to the switch(this->type).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point- changed to switch statement with returns.

Comment on lines 59 to 65
set(UNIFIED_RUNTIME_REPO "https://github.com/isaacault/unified-runtime.git")
# commit f6ab4ed9846a472d8cb173c12fb9affae21c0fd0
# Author: Isaac Ault <[email protected]>
# Date: Tue Jan 23 12:34:08 2024 +0000
#
# [Bindless][Exp] Add Support For Image Arrays
set(UNIFIED_RUNTIME_TAG f6ab4ed9846a472d8cb173c12fb9affae21c0fd0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't approve before it's fixed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/orgs/intel/teams/unified-runtime-reviewers will not approve until this is updated, but we do have a policy in our repo to get approvals from other reviewers here before contributions there can proceed. We take full responsibility for blocking this kind of change

: PI_MEM_TYPE_IMAGE1D);

if (desc.array_size > 1) {
// Image Array
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add periods after each comment here and in other places/fiels.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

// Image Array
if (desc.depth > 0) {
// Image arrays must be 1D or 2D
throw sycl::exception(sycl::make_error_code(sycl::errc::invalid),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it missing support or they simply can't be per the specification? If the latter, why can't we rely on verify to throw instead? Same in handler.cpp.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is the latter. I've removed this here and in handler.cpp and added calls to verify(). Note, there isn't a call added here as the calling functions in this file all call verify() themselves.

// REQUIRES: linux
// REQUIRES: cuda

// RUN: %clangxx -fsycl -fsycl-targets=%{sycl_triple} %s -o %t.out
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// RUN: %clangxx -fsycl -fsycl-targets=%{sycl_triple} %s -o %t.out
// RUN: %{build} -o %t.out

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

// REQUIRES: cuda

// RUN: %clangxx -fsycl -fsycl-targets=%{sycl_triple} %s -o %t.out
// RUN: %t.out
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// RUN: %t.out
// RUN: %{run} %t.out

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment on lines +15 to +16
// Uncomment to print additional test information
// #define VERBOSE_PRINT
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Uncomment to print additional test information
// #define VERBOSE_PRINT
#define VERBOSE_PRINT 0

and update the checks accordingly. Or (even better) switch to inline constexpr bool and if constexpr.

Copy link
Contributor Author

@isaacault isaacault Feb 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to leave this as is. It's how we're implementing verbosity in all of the bindless images tests, and we have an internal task tracking this to be cleaned up.

// parallel_for 2D
template <int NDims, typename DType, int NChannels, typename KernelName,
typename = std::enable_if_t<NDims == 2>>
static void run_ndim_test(sycl::queue q, sycl::range<2> globalSize,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think metaprogramming magic can unify these two versions neatly, but I won't insist.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keeping as is, for consistency with other bindless images tests.

sycl::queue q(dev);
auto ctxt = q.get_context();

// skip half tests if not supported
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd add a static_assert against double that would otherwise require aspect:fp64.

Copy link
Contributor Author

@isaacault isaacault Feb 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We actively don't use doubles in our tests, and this keeps consistency with the rest. I'd like to keep this as is.

@jchlanda
Copy link
Contributor

jchlanda commented Feb 7, 2024

@jchlanda My apologies, I accidentally rebased. I believe I've corrected my mistake, and you can see my changes addressing your feedback in 6b2ca14.

Not a problem, I've left one more question, otherwise the libclc part looks good. Thank you.

* Use image descriptor verify where applicable
* Periods after comments
Copy link
Contributor

@aelovikov-intel aelovikov-intel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SYCL RT changes are good, cursory reading of e2e tests is fine stylistically, I'd expect the logic/completeness of the tests to be checked by images domain experts from Codeplay.

Copy link
Contributor

@jchlanda jchlanda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

libclc 👍

* Vulkan test passing
* `read_image_array` accepts `HintT` template
* Use convertToOpenCLType helper
Copy link
Contributor

@kbenzie kbenzie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oneapi-src/unified-runtime#1274 has been merged, please pull in the latest sycl branch changes and update the UR tag as suggested.

sycl/plugins/unified_runtime/CMakeLists.txt Outdated Show resolved Hide resolved
@isaacault
Copy link
Contributor Author

@intel/llvm-gatekeepers Can this get merged? CI failure unrelated & already reported in #12797 and #12798

@kbenzie
Copy link
Contributor

kbenzie commented Feb 26, 2024

@intel/llvm-gatekeepers please merge, the Windows failure is being tracked in #12798

@aelovikov-intel aelovikov-intel merged commit 76ec3f0 into intel:sycl Feb 26, 2024
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants