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] aligned_alloc_xxx<T> returns non-null when the alignment argument is not a power of 2 #11642

Closed
wangdi4 opened this issue Oct 24, 2023 · 1 comment
Labels
bug Something isn't working confirmed

Comments

@wangdi4
Copy link
Contributor

wangdi4 commented Oct 24, 2023

Describe the bug
USM allocation functions aligned_alloc templated on allocation type T returns non-null when the alignment argument is not a power of 2 (source ), which conflicts with the SYCL2020 specification 4.8.3 USM allocations: Some of the allocation functions take an explicit alignment parameter. Like std::aligned_alloc, these functions return nullptr if the alignment is not supported by the implementation.

To Reproduce

  1. source code
    https://github.com/intel/llvm/blob/e75f21902a944c2776c43082d3f01843426a9525/sycl/test-e2e/USM/align.cpp
    This test checks that aligned_alloc_xxx and aligned_alloc_xxx<T> return nullptr when the alignment argument is not a power of 2

  2. Specify the command which should be used to compile the program
    compile: clang++ -fsycl -fsycl-targets=spir64 align.cpp -o align.cpp.tmp.out
    run: env ONEAPI_DEVICE_SELECTOR=opencl:cpu align.cpp.tmp.out

  3. Indicate what is wrong and what was expected
    CI SYCL E2E test shows that the non-templated aligned_alloc_xxx cases return nullptr as expected, but the templated aligned_alloc_xxx<T> cases return non-null

Environment (please complete the following information):

  • OS: Linux
  • Target device and vendor: Intel CPU
  • DPC++ version: clang version 18.0.0

Additional context
Add any other context about the problem here.

@wangdi4 wangdi4 added bug Something isn't working confirmed labels Oct 24, 2023
AlexeySachkov pushed a commit that referenced this issue Feb 8, 2024
…12569)

Implementation is supposed to return `nullptr` when requested alignment is not supported. Since our runtime performs all allocations through Unified Runtime that means for us that any alignment which is not a power of two is unsupported.

Note that the resulting alignment may not be the same as requested one (per the SYCL 2020 specification) and therefore we can't just rely on return value of underlying non-templated version of the alloc function and have to perform the check explicitly.

There is an issue with some backends not properly returning error on an unsupported alignment, it wis reported in #11642

---------

Signed-off-by: Hu, Peisen <peisen.hu@intel.com>
@HPS-1 HPS-1 closed this as completed Feb 8, 2024
@HPS-1
Copy link
Contributor

HPS-1 commented Feb 8, 2024

Fixed and merged in PR: #12569

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working confirmed
Projects
None yet
Development

No branches or pull requests

2 participants