Skip to content

[SYCL] Add group local memory call lowering pass #3329

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 8 commits into from
Mar 26, 2021

Conversation

mlychkov
Copy link
Contributor

@mlychkov mlychkov commented Mar 9, 2021

The following call is included into device code for work group
by SYCL headers to declare static local memory allocation in SYCL kernel:
'attribute((opencl_local)) uint8_t *Ptr = __sycl_allocateLocalMemory(sizeof(T), alignof(T))'.
Then during compilation it should be transformed somewhere to
equivalent of the following code:
'__local alignas(alignof(T)) uint8_t Mem[sizeof(T)];
__local uint8_t *Ptr = &Mem;'

Add a pass that handles creation of fixed-size allocations in local
address space at the kernel scope.

Signed-off-by: Mikhail Lychkov [email protected]

Copy link
Contributor

@kbobrovs kbobrovs left a comment

Choose a reason for hiding this comment

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

  • Why is this needed, what problem does this patch solve?
  • Why this is part of post-link?
  • Please add tests

@mlychkov mlychkov changed the title [SYCL] Add WG local memory call lowering pass [SYCL] Add group local memory call lowering pass Mar 16, 2021
@mlychkov mlychkov force-pushed the private/mlychkov/kernel_local_mem_pass branch from 053ff77 to 3e2f205 Compare March 16, 2021 12:32
@mlychkov
Copy link
Contributor Author

  • Why is this needed, what problem does this patch solve?
  • Why this is part of post-link?
  • Please add tests
  • Updated commit message.
  • Moved pass to clang FE.
  • Added test.

@mlychkov mlychkov marked this pull request as ready for review March 16, 2021 12:55
@mlychkov mlychkov requested a review from kbobrovs March 16, 2021 12:55
Copy link
Contributor

@bader bader left a comment

Choose a reason for hiding this comment

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

@mlychkov, please, resolve merge conflicts.

The following call is included into device code for work group
by SYCL headers to declare static local memory allocation in SYCL kernel:
'__attribute__((opencl_local)) uint8_t *Ptr = __sycl_allocateLocalMemory(sizeof(T), alignof(T))'.
Then during compilation it should be transformed somewhere to
equivalent of the following code:
'__local alignas(alignof(T)) uint8_t Mem[sizeof(T)];
 __local uint8_t *Ptr = &Mem;'

Add a pass that handles creation of fixed-size allocations in local
address space at the kernel scope.

Signed-off-by: Mikhail Lychkov <[email protected]>
@mlychkov mlychkov force-pushed the private/mlychkov/kernel_local_mem_pass branch from 3e2f205 to 162cc19 Compare March 18, 2021 13:21
Signed-off-by: Mikhail Lychkov <[email protected]>
Copy link
Contributor

@kbobrovs kbobrovs left a comment

Choose a reason for hiding this comment

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

Thanks for moving. Few more comments.

Do you have end-to-end test, BTW or this is WIP? It is necessary for such functionality.

@mlychkov
Copy link
Contributor Author

Thanks for moving. Few more comments.

Do you have end-to-end test, BTW or this is WIP? It is necessary for such functionality.

End-to-end test for this feature is added by Semenov Sergey: intel/llvm-test-suite#176.

Signed-off-by: Mikhail Lychkov <[email protected]>
@mlychkov mlychkov requested a review from kbobrovs March 22, 2021 12:24
bader
bader previously approved these changes Mar 23, 2021
Copy link
Contributor

@bader bader left a comment

Choose a reason for hiding this comment

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

LGTM, although I'm not sure if it works for NVPTX target.

AlexeySachkov
AlexeySachkov previously approved these changes Mar 23, 2021
Copy link
Contributor

@AlexeySachkov AlexeySachkov left a comment

Choose a reason for hiding this comment

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

LGTM, but the main LIT test for this change seems to be failing

DenisBakhvalov
DenisBakhvalov previously approved these changes Mar 23, 2021
@mlychkov mlychkov dismissed stale reviews from DenisBakhvalov, AlexeySachkov, and bader via 4f34903 March 24, 2021 08:47
@mlychkov mlychkov requested review from AlexeySachkov and bader March 24, 2021 11:19
@bader bader requested a review from DenisBakhvalov March 24, 2021 11:41
bader
bader previously approved these changes Mar 24, 2021
AlexeySachkov
AlexeySachkov previously approved these changes Mar 24, 2021
premanandrao
premanandrao previously approved these changes Mar 24, 2021
Copy link
Contributor

@premanandrao premanandrao 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 look okay to me.

@mlychkov
Copy link
Contributor Author

@kbobrovs Could you please review last changes?

@sergey-semenov
Copy link
Contributor

LGTM, although I'm not sure if it works for NVPTX target.

@mlychkov @bader The calling convention assertion https://github.com/intel/llvm/pull/3329/files#diff-a107684934906a250c3dc947338a6a685dc924e9246d6a33adc0b82f9b9de756R66-R68 fails for NVPTX (the default C convention is returned instead of the expected SPIR_FUNC/SPIR_KERNEL), but the E2E test passes after commenting the assertion out.

@bader
Copy link
Contributor

bader commented Mar 25, 2021

LGTM, although I'm not sure if it works for NVPTX target.

@mlychkov @bader The calling convention assertion https://github.com/intel/llvm/pull/3329/files#diff-a107684934906a250c3dc947338a6a685dc924e9246d6a33adc0b82f9b9de756R66-R68 fails for NVPTX (the default C convention is returned instead of the expected SPIR_FUNC/SPIR_KERNEL), but the E2E test passes after commenting the assertion out.

I suggest removing the assert then.

@mlychkov mlychkov dismissed stale reviews from premanandrao, AlexeySachkov, and bader via 8350829 March 25, 2021 16:14
@mlychkov mlychkov requested review from bader and premanandrao March 25, 2021 16:15
@bader
Copy link
Contributor

bader commented Mar 25, 2021

@kbobrovs, ping.

@kbobrovs
Copy link
Contributor

@kbobrovs, ping.

@bader, @mlychkov - LGTM, except the diagnostics - I'd request at least TODO + issue (see my comment above).

Copy link
Contributor

@kbobrovs kbobrovs left a comment

Choose a reason for hiding this comment

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

Approved. As agreed with @mlychkov, TODO + issue will follow.

@bader bader merged commit 9a734f6 into intel:sycl Mar 26, 2021
@mlychkov mlychkov deleted the private/mlychkov/kernel_local_mem_pass branch March 30, 2021 09:28
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.

9 participants