Skip to content

[SYCL][Ext][Bindless] Initial implementation of image spirv builtins on HIP #16439

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 11 commits into from
Feb 6, 2025

Conversation

GeorgeWeb
Copy link
Contributor

@GeorgeWeb GeorgeWeb commented Dec 20, 2024

This PR implements the required spirv builtins in the libclc for AMD targets to support fetching (excluding sampled fetch for now), sampling, and writing for images and image arrays.

Additionally, End-to-end tests are updated to require the aspects corresponding to the feature that is being tested from the Bindless Images extension. This helps avoid having to manually say which backend adapter is supported or unsupported and instead rely on support based on aspect/device queries to drive the execution of the tests.

HIP adapter implementation in UR: oneapi-src/unified-runtime#2496

Signed-off-by: Georgi Mirazchiyski [email protected]

@GeorgeWeb
Copy link
Contributor Author

GeorgeWeb commented Jan 7, 2025

I appreciate that image.cl is quite large and can only grow more (e.g. mipmaps, cubemaps, etc.) in the future, so I can consider splitting into image.cl for image/sampling functions, image_array.cl for image array/array sampling functions and image_common.h to hold all the commonly shared macros and functions.

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.

LGTM.

This patch brings in a lot of new hand mangled names, was wondering if it would be at all possible to try and avoid those?

#endif

#ifdef _WIN32
#define _CLC_MANGLE_FUNC_IMG_HANDLE(namelength, name, prefix, postfix) \
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't that the kind of thing that the remangler should handle, as in m - y, long (long) unsigned?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jchlanda I agree that it should probably be the case.
We have that tendency of manually mangling these, for example, also in the atomics libspirv function implementations. This particular case here is adapted from the libspirv ptx image implementation. I think it is the perfect candidate to create a follow-up for, where we attempt to cleanup some of the manual mangling (at least for the image functions) across both ptx and amdgcn libspirv target implementations. I'll create an internal ticket for our team to follow this up. Does that sound okay?

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess it's fine. My point was that if the only reason for manually mangled string is the m - y difference, that should work out of the box now. I'm slightly worried that if you found yourself in the situation that it indeed is needed, that means that somehow that case has escaped remangler's attention, and so the remangler needs more work.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh I think I see what you meant.
Well I wasn't too sure on that because I was getting Unable to demangle name: errors without m/y.
Mind if I ask for a quick code change suggestion in case I've tested it somehow wrongly?
Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think you can get it to only skip the unsigned long/unsigned long long, the whole macro would need to be removed. So maybe it's best to do it as you suggest in a follow up.

If you have an easy way of reproducing that remangling error though, I'd be interested in that file (it should be possible to isolate it to a single function definition in IR).

@jchlanda
Copy link
Contributor

jchlanda commented Jan 8, 2025

I appreciate that image.cl is quite large and can only grow more (e.g. mipmaps, cubemaps, etc.) in the future, so I can consider splitting into image.cl for image/sampling functions, image_array.cl for image array/array sampling functions and image_common.h to hold all the commonly shared macros and functions.

I think that would be a good idea.

@GeorgeWeb GeorgeWeb force-pushed the georgi/bindless-hip branch from eadd947 to e5e0d35 Compare January 23, 2025 18:14
@GeorgeWeb GeorgeWeb force-pushed the georgi/bindless-hip branch from e5e0d35 to 3d7280b Compare January 27, 2025 12:13
GeorgeWeb added a commit to GeorgeWeb/unified-runtime that referenced this pull request Jan 27, 2025
This PR implements the entry points in the HIP adapter for the Bindless Images extension.

Some features, while implemented, only partially pass the End-to-end tests for them in
DPC++ (the PR that enables the support and testing in DPC++: intel/llvm#16439).
This is because the HIP runtime doesn't support, for example, some parameter combinations
with some image memory types. The not-fully supported features are marked with TODOs in
the device info queries for further work.

Signed-off-by: Georgi Mirazchiyski <[email protected]>

Co-authored-by: Peter Žužek <[email protected]>
@GeorgeWeb GeorgeWeb force-pushed the georgi/bindless-hip branch from 3d7280b to 0769128 Compare January 27, 2025 12:20
GeorgeWeb added a commit to GeorgeWeb/unified-runtime that referenced this pull request Jan 29, 2025
This PR implements the entry points in the HIP adapter for the Bindless Images extension.

Some features, while implemented, only partially pass the End-to-end tests for them in
DPC++ (the PR that enables the support and testing in DPC++: intel/llvm#16439).
This is because the HIP runtime doesn't support, for example, some parameter combinations
with some image memory types. The not-fully supported features are marked with TODOs in
the device info queries for further work.

Signed-off-by: Georgi Mirazchiyski <[email protected]>

Co-authored-by: Peter Žužek <[email protected]>
…on HIP

This PR implements the required spirv builtins in the libclc for AMD targets
to support image fetching (excluding sampled fetch for now) and sampling
as well as image array fetching and sampling.

Additionally, End-to-end tests are updated to require the aspects corresponding
to the feature that is being tested from the Bindless Images extension.
This helps avoid having to manually say which backend adapter is supported or
unsupported and instead rely on support based on aspect/device queries to drive
the execution of the tests.

Signed-off-by: Georgi Mirazchiyski <[email protected]>
Signed-off-by: Georgi Mirazchiyski <[email protected]>
@JackAKirk JackAKirk requested a review from a team as a code owner February 5, 2025 16:59
@JackAKirk JackAKirk marked this pull request as draft February 5, 2025 17:01
@JackAKirk
Copy link
Contributor

marking as draft due to cubemap aspect failure.

@JackAKirk JackAKirk marked this pull request as ready for review February 5, 2025 17:38
@JackAKirk
Copy link
Contributor

Apologies @cperkinsintel for the request. It was a mistake this doesn't require your review.

Signed-off-by: JackAKirk <[email protected]>
@ldrumm
Copy link
Contributor

ldrumm commented Feb 6, 2025

I'd like to get @frasercrmck's opinion on the libclc changes before we merge this

Copy link
Contributor

@frasercrmck frasercrmck left a comment

Choose a reason for hiding this comment

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

Generally LGTM. I've the same old quibbles about manually mangling things like types and address spaces. I hope we can move to C++ to define these builtins sooner rather than later. Not for this patch, though.

// defined in "image_common.cl"
extern _CLC_CONST_AS const unsigned int SAMPLER_OBJECT_OFFSET_DWORD;

// Helpers for casting between two builitin vector types and/or scalar types.
Copy link
Contributor

Choose a reason for hiding this comment

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

typo: builitin -> builtin (happens to me all the time)

@GeorgeWeb
Copy link
Contributor Author

GeorgeWeb commented Feb 6, 2025

I'd like to get @frasercrmck's opinion on the libclc changes before we merge this

Thanks for double checking, @ldrumm. I should’ve also requested Fraser to take a look knowing he started improving libclc->libspirv as a whole.
Appreciated!

Signed-off-by: JackAKirk <[email protected]>
@ldrumm ldrumm merged commit 3161af3 into intel:sycl Feb 6, 2025
6 checks passed
@ldrumm
Copy link
Contributor

ldrumm commented Feb 6, 2025

Not waiting for a full CI run on a comment change. This looks good to go

Chenyang-L pushed a commit that referenced this pull request Feb 18, 2025
This PR implements the entry points in the HIP adapter for the Bindless Images extension.

Some features, while implemented, only partially pass the End-to-end tests for them in
DPC++ (the PR that enables the support and testing in DPC++: #16439).
This is because the HIP runtime doesn't support, for example, some parameter combinations
with some image memory types. The not-fully supported features are marked with TODOs in
the device info queries for further work.

Signed-off-by: Georgi Mirazchiyski <[email protected]>

Co-authored-by: Peter Žužek <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sycl-bindless-images SYCL Bindless Images
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants