Skip to content

[SYCL] Fix address space for spec constants buffer #3521

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

Conversation

dm-vodopyanov
Copy link
Contributor

@dm-vodopyanov dm-vodopyanov commented Apr 9, 2021

This patch sets OpenCL global address space for specialization constants
buffer instead of generic one.

This buffer passes to the kernel function as kernel argument through
clSetKernelArg. According to OpenCL spec, if the argument is declared
to be a pointer of a built-in or user defined type with the __global or
__constant qualifier, the memory object specified as argument value
must be a buffer object (or nullptr).

The buffer had generic address space, so there was a crash in run time
due to wrong address space.

Although OpenCL specification explicitly states that a string literal
should reside in constant address space, it does not work for SYCL
with "generic by default" address space rules.

Co-authored-by: Vlad Romanov vlad.romanov@intel.com

This patch sets OpenCL global address space for specialization constants
buffer instead of generic one. It fixes the crash which happens during
passing nullptr to piKernelSetArg PI API func

Co-authored-by: Vlad Romanov <vlad.romanov@intel.com>
Copy link
Contributor

@AaronBallman AaronBallman left a comment

Choose a reason for hiding this comment

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

Adding @bader as reviewer because this seems somewhat related to existing upstream work in https://reviews.llvm.org/D89909.

It looks like you're missing test coverage for the change. Also, I would appreciate a bit more information about why this is the correct fix (as opposed to checking for nullptr in the crashing API).

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.
It looks like we already have tests, but they were checking for wrong IR.
Please, update kernel-handler.cpp tests.

@dm-vodopyanov
Copy link
Contributor Author

Thanks, fixed tests and updated description.

Copy link
Contributor

@AaronBallman AaronBallman left a comment

Choose a reason for hiding this comment

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

LGTM!

@bader bader merged commit 5f115a4 into intel:sycl Apr 13, 2021
alexbatashev pushed a commit to alexbatashev/llvm that referenced this pull request Apr 14, 2021
* upstream/sycl: (39 commits)
  [CI] Switch to default clang-format version. (intel#3540)
  [Driver][NFC] Cleanup some option setting for SYCL offload (intel#3542)
  [GitHub Actions] Update main branch sync schedule
  [SYCL][NFC] Fix potential namespace conflicts with PSTL in tuple.hpp (intel#3541)
  [SYCL] Bump sycl library minor version (intel#3538)
  [SYCL][CUDA] Implemented cuda_piextUSMEnqueueMemAdvise (intel#3365)
  [SYCL][FPGA] Add mutual diagnostic of max_concurrency attribute in conjunction of disable_loop_pipelining attribute (intel#3512)
  [SYCL] [MATRIX] Enable joint_matrix_load, joint_matrix_store, and joint_matrix_mad for AMX (intel#3503)
  [ESIMD] Skip rewriting functions used through function pointers (intel#3527)
  [SYCL] Fix address space for spec constants buffer (intel#3521)
  [SYCL] Correct the tablegen for checking mutually exclusive stmt attrs (intel#3519)
  [SYCL][PI][L0][NFC] Refactor setting of LastCommandEvent (intel#3528)
  [SYCL] Fix group local memory sharing issue (intel#3489)
  [SYCL][NFC] Fix post-commit failure (intel#3532)
  [SYCL][Doc] Remove extension mechanism (intel#3526)
  [SYCL] Move sycl.hpp in install directory and adjust driver to match (intel#3523)
  [SYCL][ESIMD] Update ESIMD docs to address recent user comments: (intel#3516)
  [NFCI][SYCL] Correct -fdeclare-spirv-builtins to use marshalling (intel#3515)
  [SYCL] Rework MarkDevice and children (intel#3475)
  [SYCL] Fix StringLiteral Ctor issue from intel#3504. (intel#3520)
  ...
@dm-vodopyanov dm-vodopyanov deleted the private/dvodopya/fix_addr_space_for_spec_const_buffer branch February 10, 2022 14:07
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.

3 participants