Skip to content

[SYCL][ESIMD] Add function to get reference to underlying data #8725

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
Apr 7, 2023

Conversation

sarnex
Copy link
Contributor

@sarnex sarnex commented Mar 21, 2023

This is required for inline assembly.

@sarnex sarnex temporarily deployed to aws March 22, 2023 15:46 — with GitHub Actions Inactive
@sarnex sarnex temporarily deployed to aws March 22, 2023 17:21 — with GitHub Actions Inactive
@sarnex
Copy link
Contributor Author

sarnex commented Mar 22, 2023

/summary:run

@sarnex sarnex marked this pull request as ready for review March 23, 2023 13:48
@sarnex sarnex requested a review from a team as a code owner March 23, 2023 13:48
@sarnex
Copy link
Contributor Author

sarnex commented Mar 23, 2023

Feedback from @v-klochkov

  1. Err for uses of data_ref() if not in inline asm

  2. Update esimd spec

I'm doing this now.

Edit: Implemented now

@sarnex sarnex requested a review from a team as a code owner March 24, 2023 16:24
@sarnex
Copy link
Contributor Author

sarnex commented Mar 24, 2023

@intel/dpcpp-cfe-reviewers Hi all, can you please review the CFE change? Basically we want to restrict the usage of a function to inline assembly. Let me know if there's a better way to do it. Thanks!

@sarnex sarnex temporarily deployed to aws March 24, 2023 17:31 — with GitHub Actions Inactive
@@ -11,6 +11,7 @@
#include "TreeTransform.h"
#include "clang/AST/AST.h"
#include "clang/AST/Mangle.h"
#include "clang/AST/ParentMapContext.h"
Copy link
Contributor

Choose a reason for hiding this comment

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

Why was this required?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh I guess this is required for the loop on L595

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah for the loop

@@ -11799,6 +11799,8 @@ def err_sycl_device_function_is_called_from_esimd : Error<
"SYCL device function cannot be called from an ESIMD context">;
def err_sycl_esimd_vectorize_unsupported_value : Error<
"%0 attribute argument must be 8, 16, or 32">;
def err_sycl_esimd_invalid_use_outline_inlineasm : Error<
Copy link
Contributor

Choose a reason for hiding this comment

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

What happens if we don't diagnose in the FE i.e. what happens when function is incorrectly called now (without FE code in this PR)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

responded to this below but tldr nothing happens and it works fine

@sarnex sarnex temporarily deployed to aws March 24, 2023 18:47 — with GitHub Actions Inactive
@@ -11,6 +11,7 @@
#include "TreeTransform.h"
#include "clang/AST/AST.h"
#include "clang/AST/Mangle.h"
#include "clang/AST/ParentMapContext.h"
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh I guess this is required for the loop on L595

SemaRef.getASTContext().getRecordType(Method->getParent());
if (isSyclType(Ty, SYCLTypeAttr::esimd_simd_or_simd_mask) &&
Method->getNameAsString() == "data_ref") {
for (auto Use : SemaRef.getASTContext().getParents(*e)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like this will do a full traversal of the AST, which we really don't want to do. If we need this to be diagnosed in the FE, we should investigate doing this via deferred diagnostics.

Copy link
Contributor Author

@sarnex sarnex Mar 24, 2023

Choose a reason for hiding this comment

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

Glad I had you review this to catch that, thanks!

Yes, i think we need to do this in FE. Once we get to the middle end, the function call is always inlined and we can't reliably detect the bad case anymore.. Can you point me to an example or test that uses deferred diagnostics, I'm not familiar with them.

Copy link
Contributor

Choose a reason for hiding this comment

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

For deferred diagnostics in the source code, start with SYCLDiagIfDeviceCode(...) in SemaSYCL.cpp and you can trace what we do there.

For a test that uses it, see e.g. SemaSYCL/sycl-restrict.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.

thanks, i think i see what to do. ill update this pr once i have something

Copy link
Contributor Author

@sarnex sarnex Mar 28, 2023

Choose a reason for hiding this comment

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

nevermind, im stuck again. i can't find anywhere where we have the expr of the use of the function call when doing deferred diagnostics, which is what need here since we only want to allow this function call for a particular use (directly inside an asm stmt). did i miss something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@premanandrao @elizabethandrews any ideas on the above? thanks!

@v-klochkov
Copy link
Contributor

@sarnex - I think the tests from intel/llvm-test-suite#1675 needs to be moved to this PR (sycl/test-e2e).

@sarnex
Copy link
Contributor Author

sarnex commented Apr 4, 2023

@v-klochkov ill move the tests, thanks

@sarnex sarnex temporarily deployed to aws April 4, 2023 15:59 — with GitHub Actions Inactive
@sarnex sarnex temporarily deployed to aws April 4, 2023 16:50 — with GitHub Actions Inactive
@sarnex sarnex temporarily deployed to aws April 4, 2023 17:32 — with GitHub Actions Inactive
@v-klochkov
Copy link
Contributor

@sarnex - unfortunately, asm_glb.cpp test needs some attention as it failed in CI.

@sarnex
Copy link
Contributor Author

sarnex commented Apr 4, 2023

@sarnex - unfortunately, asm_glb.cpp test needs some attention as it failed in CI.

yep, looking into it, thanks

This is required for inline assembly.

Signed-off-by: Sarnie, Nick <[email protected]>
@sarnex
Copy link
Contributor Author

sarnex commented Apr 6, 2023

@v-klochkov i looked into automatically inserting the vstore, but 1) the solution was super flaky and relied on very specific ir patterns and 2) fundamentally didn't work with opaque pointers, so i just went with your commit idea. please take a look when you get a chance. thanks

@sarnex sarnex temporarily deployed to aws April 6, 2023 14:58 — with GitHub Actions Inactive
@sarnex sarnex temporarily deployed to aws April 6, 2023 15:29 — with GitHub Actions Inactive
@v-klochkov v-klochkov merged commit f5a062d into intel:sycl Apr 7, 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.

6 participants