Skip to content

[SYCL] aligned_alloc_xxx<T> returns non-null when the alignment argument is not a power of 2  #11642

@wangdi4

Description

@wangdi4

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions