llvm icon indicating copy to clipboard operation
llvm copied to clipboard

Redesign pointer handling for openCL kernel generation

Open elizabethandrews opened this issue 3 years ago • 3 comments

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. Trivial record types containing array or pointers or array of types with pointers have not been handled in this PR.
  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.

elizabethandrews avatar Sep 08 '22 03:09 elizabethandrews

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

elizabethandrews avatar Sep 15 '22 00:09 elizabethandrews

PR is ready for review.

elizabethandrews avatar Sep 20 '22 00:09 elizabethandrews

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.

elizabethandrews avatar Sep 21 '22 22:09 elizabethandrews

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

elizabethandrews avatar Sep 27 '22 17:09 elizabethandrews

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

pvchupin avatar Sep 27 '22 21:09 pvchupin

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

Fixed here - https://github.com/intel/llvm/pull/6895

elizabethandrews avatar Sep 28 '22 17:09 elizabethandrews