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] Redesign pointer handling for OpenCL kernel generation #6728

Merged
merged 19 commits into from
Sep 27, 2022

Conversation

elizabethandrews
Copy link
Contributor

@elizabethandrews elizabethandrews commented Sep 8, 2022

Requirement - Do not decompose types with pointers when generating OpenCL kernel arguments.

This PR adds logic to stop decomposing trivial types containing pointers. For every SYCL kernel argument which is a record type containing a pointer (or has a field or a base class with a pointer), we generate a new record type with all pointers in __global address space. This compiler generated type is the openCL kernel argument. In the kernel body, we initialize the local clone via memcpy.

Limitations:

  1. Array of pointers or array of types with pointers are still decomposed to it's elements.
  2. Due to current implementation restrictions, types which are not default constructible, continue to trigger decomposition if they contain pointers.

Both limitations above will hopefully be fixed in follow-up PRs.

Signed-off-by: Elizabeth Andrews <elizabeth.andrews@intel.com>
Signed-off-by: Elizabeth Andrews <elizabeth.andrews@intel.com>
Signed-off-by: Elizabeth Andrews <elizabeth.andrews@intel.com>
@elizabethandrews elizabethandrews temporarily deployed to aws September 8, 2022 03:54 Inactive
@Fznamznon Fznamznon changed the title {WIP] Redesign pointer handling for openCL kernel generation [WIP] Redesign pointer handling for openCL kernel generation Sep 8, 2022
Signed-off-by: Elizabeth Andrews <elizabeth.andrews@intel.com>
Signed-off-by: Elizabeth Andrews <elizabeth.andrews@intel.com>
Signed-off-by: Elizabeth Andrews <elizabeth.andrews@intel.com>
@elizabethandrews elizabethandrews temporarily deployed to aws September 11, 2022 23:59 Inactive
Copy link
Contributor

@Fznamznon Fznamznon left a comment

Choose a reason for hiding this comment

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

Although I've spent noticeable amount of time to understand the code, I'm not opposed to the approach itself. We just need to make sure that everything works fine, I see that some LIT tests are failing and llvm-test-suite tests didn't run.

clang/lib/Sema/SemaSYCL.cpp Outdated Show resolved Hide resolved
clang/lib/Sema/SemaSYCL.cpp Outdated Show resolved Hide resolved
clang/lib/Sema/SemaSYCL.cpp Show resolved Hide resolved
clang/lib/Sema/SemaSYCL.cpp Outdated Show resolved Hide resolved
clang/lib/Sema/SemaSYCL.cpp Outdated Show resolved Hide resolved
Signed-off-by: Elizabeth Andrews <elizabeth.andrews@intel.com>
@elizabethandrews elizabethandrews temporarily deployed to aws September 12, 2022 23:59 Inactive
Signed-off-by: Elizabeth Andrews <elizabeth.andrews@intel.com>
Signed-off-by: Elizabeth Andrews <elizabeth.andrews@intel.com>
@elizabethandrews elizabethandrews temporarily deployed to aws September 15, 2022 00:00 Inactive
@elizabethandrews
Copy link
Contributor Author

There's still some Clang tests to fix. I fix one test to illustrate what this PR does. Before fixing the others, I figured I should ensure memcpy is actually working as expected via a runtime test. I'll take a look at that tomorrow

Signed-off-by: Elizabeth Andrews <elizabeth.andrews@intel.com>
Signed-off-by: Elizabeth Andrews <elizabeth.andrews@intel.com>
Signed-off-by: Elizabeth Andrews <elizabeth.andrews@intel.com>
Signed-off-by: Elizabeth Andrews <elizabeth.andrews@intel.com>
Signed-off-by: Elizabeth Andrews <elizabeth.andrews@intel.com>
@elizabethandrews elizabethandrews changed the title [WIP] Redesign pointer handling for openCL kernel generation Redesign pointer handling for openCL kernel generation Sep 20, 2022
@elizabethandrews elizabethandrews marked this pull request as ready for review September 20, 2022 00:28
@elizabethandrews elizabethandrews requested a review from a team as a code owner September 20, 2022 00:28
@elizabethandrews
Copy link
Contributor Author

PR is ready for review.

clang/lib/Sema/SemaSYCL.cpp Outdated Show resolved Hide resolved
clang/lib/Sema/SemaSYCL.cpp Outdated Show resolved Hide resolved
clang/lib/Sema/SemaSYCL.cpp Outdated Show resolved Hide resolved
clang/lib/Sema/SemaSYCL.cpp Outdated Show resolved Hide resolved
clang/lib/Sema/SemaSYCL.cpp Outdated Show resolved Hide resolved
clang/lib/Sema/SemaSYCL.cpp Outdated Show resolved Hide resolved
clang/lib/Sema/SemaSYCL.cpp Show resolved Hide resolved
clang/lib/Sema/SemaSYCL.cpp Outdated Show resolved Hide resolved
clang/test/SemaSYCL/decomposition.cpp Show resolved Hide resolved
clang/test/SemaSYCL/decomposition.cpp Show resolved Hide resolved
Signed-off-by: Elizabeth Andrews <elizabeth.andrews@intel.com>
clang/lib/Sema/SemaSYCL.cpp Outdated Show resolved Hide resolved
clang/lib/Sema/SemaSYCL.cpp Show resolved Hide resolved
Signed-off-by: Elizabeth Andrews <elizabeth.andrews@intel.com>
@elizabethandrews elizabethandrews marked this pull request as draft September 21, 2022 22:49
@elizabethandrews
Copy link
Contributor Author

elizabethandrews commented Sep 21, 2022

Reverted PR to Draft because arrays of type containing pointer is broken. The code to exclude such cases from this logic is incorrect. Looking into a possible solution now.

…ents

Signed-off-by: Elizabeth Andrews <elizabeth.andrews@intel.com>
Signed-off-by: Elizabeth Andrews <elizabeth.andrews@intel.com>
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.

Thank you for the detailed review @Fznamznon.

@bader bader changed the title Redesign pointer handling for openCL kernel generation [SYCL] Redesign pointer handling for openCL kernel generation Sep 27, 2022
@bader bader changed the title [SYCL] Redesign pointer handling for openCL kernel generation [SYCL] Redesign pointer handling for OpenCL kernel generation Sep 27, 2022
@elizabethandrews
Copy link
Contributor Author

ping @intel/llvm-gatekeepers. This PR is ready for review and merge. The failing CUDA Test suite looks like an infrastructure issue.

@pvchupin pvchupin merged commit 3916d3b into intel:sycl Sep 27, 2022
@pvchupin
Copy link
Contributor

@elizabethandrews, can you follow up on post commit issues on windows? https://github.com/intel/llvm/actions/runs/3137630364/jobs/5096023697

@elizabethandrews
Copy link
Contributor Author

@elizabethandrews, can you follow up on post commit issues on windows? https://github.com/intel/llvm/actions/runs/3137630364/jobs/5096023697

Fixed here - #6895

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