Skip to content

Linux missing aligned_alloc #2650

@jeffhammond

Description

@jeffhammond

There should be a CMake test for aligned_malloc that causes the following preprocessor logic to drop from Linux into POSIX when it's missing.

I will work on this if it is the only blocking issue for compiling on CentOS 6 systems (using a much newer compiler than the default, obviously).

void *OSUtil::alignedAlloc(size_t Alignment, size_t NumBytes) {
#if defined(SYCL_RT_OS_LINUX) && 0
  return aligned_alloc(Alignment, NumBytes);
#elif defined(SYCL_RT_OS_POSIX_SUPPORT)
  void *Addr = nullptr;
  int ReturnCode = posix_memalign(&Addr, Alignment, NumBytes);
  return (ReturnCode == 0) ? Addr : nullptr;
#elif defined(SYCL_RT_OS_WINDOWS)
  return _aligned_malloc(NumBytes, Alignment);
#endif
}
FAILED: tools/sycl/source/CMakeFiles/sycl_object.dir/detail/os_util.cpp.o 
/opt/gcc/9.2.0/bin/g++-9 -DCL_TARGET_OPENCL_VERSION=220 -DUSE_PI_CUDA -DXPTI_ENABLE_INSTRUMENTATION -DXPTI_STATIC_LIBRARY -D_DEBUG -D_GLIBCXX_ASSERTIONS=1 -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Itools/sycl/source -I/tmp/sycl/sycl/source -Iinclude -I/tmp/sycl/llvm/include -I/tmp/sycl/xpti/include -I/tmp/sycl/sycl/include -Itools/sycl/OpenCL/inc -fPIC -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-class-memaccess -Wno-redundant-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -fdiagnostics-color -ffunction-sections -fdata-sections -Wall -Wextra -Wno-deprecated-declarations -Werror -O3  -UNDEBUG -fvisibility=hidden -fvisibility-inlines-hidden -std=c++14 -MD -MT tools/sycl/source/CMakeFiles/sycl_object.dir/detail/os_util.cpp.o -MF tools/sycl/source/CMakeFiles/sycl_object.dir/detail/os_util.cpp.o.d -o tools/sycl/source/CMakeFiles/sycl_object.dir/detail/os_util.cpp.o -c /tmp/sycl/sycl/source/detail/os_util.cpp
/tmp/sycl/sycl/source/detail/os_util.cpp: In static member function ‘static void* cl::sycl::detail::OSUtil::alignedAlloc(size_t, size_t)’:
/tmp/sycl/sycl/source/detail/os_util.cpp:246:10: error: ‘aligned_alloc’ was not declared in this scope; did you mean ‘alignedAlloc’?
  246 |   return aligned_alloc(Alignment, NumBytes);
      |          ^~~~~~~~~~~~~
      |          alignedAlloc

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions