Skip to content

[SYCL][HIP][libclc] Fix wrong address spaces for HIP #4966

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 1 commit into from
Jan 11, 2022

Conversation

t4c1
Copy link
Contributor

@t4c1 t4c1 commented Nov 16, 2021

Fixes wrong address spaces for event_t. It should be private, but in SYCL it was defaulting to generic. On the other hand in libclc pointer to event_t was private, while it should be generic. (We don't see similar issues on NVPTX, as there private address space is in fact implemented as generic in IR).

Change to test suite: intel/llvm-test-suite#570


#include <spirv/spirv.h>

_CLC_DEF void _Z23__spirv_GroupWaitEventsjiP9ocl_event(unsigned int scope,
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
_CLC_DEF void _Z23__spirv_GroupWaitEventsjiP9ocl_event(unsigned int scope,
_CLC_DEF _CLC_OVERLOAD void __spirv_GroupWaitEvents(unsigned int scope,

it is also missing the overload for private

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried adding that, but I can't get it to work (linker is not finding this).

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/intel/llvm/blob/sycl/clang/lib/AST/ItaniumMangle.cpp#L2560 is causing different mangling.

In SYCL mode, Default will be 0, so no UAS0 will be added, by in CL mode, Default is 5 (private) causing the addition of UAS0.

This could either be recovered by the remangler (a bit dirty but more scalable) or handled by manual mangling (not great).


_CLC_DEF void _Z23__spirv_GroupWaitEventsjiP9ocl_event(unsigned int scope,
int num_events,
event_t __attribute__((address_space(0)))* event_list) {
Copy link
Contributor

@bader bader Nov 16, 2021

Choose a reason for hiding this comment

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

I think using __private is better here.
OTOH, I don't fully understand the problem. If we compile this code with -cl-std=CL2.0, event_list will point to generic address space.
What exactly is the problem here?

Copy link
Contributor

Choose a reason for hiding this comment

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

0 is generic here (5 is private)

If we compile this code with -cl-std=CL2.0

there is a need for selective enabling of 2.0. The lib is tailored for 1.2 so that will probably not turned as expected (you suddenly make pointers to private pointers to generic).

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh... wait. Are we calling OpenCL 1.2 built-in here? Shouldn't we apply private address space attribute on SYCL side in this case and explicitly cast to correct AS?

Copy link
Contributor

Choose a reason for hiding this comment

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

Well there is an overload for generic. Never mattered for PTX because the target address space for private and generic overlap.

The runtime header could be patch to call the privare overload (it will always be a pointer to private AFAIK).

But TBH, there is an issue in the device event design as the stored pointer is a dangling one #4959

Copy link
Contributor

Choose a reason for hiding this comment

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

The runtime header could be patch to call the privare overload (it will always be a pointer to private AFAIK).

So, which way do you think is better to handle this issue: update the runtime to call correct overload overload or apply this patch?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Naghasan I think the question above was meant for you.

Copy link
Contributor

Choose a reason for hiding this comment

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

oups sorry

So, which way do you think is better to handle this issue: update the runtime to call correct overload overload or apply this patch?

There is a need for a broader course of action regarding generic address space handling here, so as the patch is ready, I would say ship it. Once the generic is better handled, this will go away.

@bader bader requested a review from Naghasan November 30, 2021 13:11
Copy link
Contributor

@smanna12 smanna12 left a comment

Choose a reason for hiding this comment

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

FE changes LGTM

@bader bader merged commit 22532c2 into intel:sycl Jan 11, 2022
bader pushed a commit to intel/llvm-test-suite that referenced this pull request Jan 11, 2022
@bader
Copy link
Contributor

bader commented Jan 11, 2022

@t4c1, this patch breaks check-libclc https://github.com/intel/llvm/runs/4773520788?check_suite_focus=true. Please, fix as soon as possible.

@t4c1
Copy link
Contributor Author

t4c1 commented Jan 11, 2022

I looked into this, but I am not even sure what that test is supposed to be checking. It seems completely broken - for both CUDA and HIP backends it is only passing because the code does not compile and the test only checks with FileCheck and CHECK-NOT.

@bader
Copy link
Contributor

bader commented Jan 11, 2022

I'm reverting this patch to fix pre-commit checks in CI blocking other PRs.
I suggest talking to @Naghasan. Probably you just need to re-generate the checks with gen-libclc-test.py.

bader added a commit that referenced this pull request Jan 11, 2022
bader added a commit that referenced this pull request Jan 11, 2022
…#5284)

This reverts commit 22532c2.

This patch breaks check-libclc tests.
bader added a commit to intel/llvm-test-suite that referenced this pull request Jan 11, 2022
…t_t address spaces (#570)" (#724)

This reverts commit 367e10e.

Reverting due to intel/llvm#4966 revert.
t4c1 added a commit to t4c1/llvm that referenced this pull request Jan 12, 2022
bader pushed a commit that referenced this pull request Jan 13, 2022
…5293)

Reverts #5284 , reintroducing the reverted #4966 and adds fixes the failing libclc test.
@t4c1 t4c1 deleted the group_async_copy_aperture branch March 15, 2022 08:51
aelovikov-intel pushed a commit to aelovikov-intel/llvm that referenced this pull request Mar 27, 2023
aelovikov-intel pushed a commit to aelovikov-intel/llvm that referenced this pull request Mar 27, 2023
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.

4 participants