alpaka
Abstraction Library for Parallel Kernel Acceleration
AlignedAlloc.hpp
Go to the documentation of this file.
1 /* Copyright 2022 RenĂ© Widera, Bernhard Manfred Gruber
2  * SPDX-License-Identifier: MPL-2.0
3  */
4 
5 #pragma once
6 
8 #include "alpaka/core/Common.hpp"
9 
10 #include <new>
11 
12 namespace alpaka::core
13 {
14  ALPAKA_FN_INLINE ALPAKA_FN_HOST auto alignedAlloc(size_t alignment, size_t size) -> void*
15  {
16  return ::operator new(size, std::align_val_t{alignment});
17  }
18 
19  ALPAKA_FN_INLINE ALPAKA_FN_HOST void alignedFree(size_t alignment, void* ptr)
20  {
21  ::operator delete(ptr, std::align_val_t{alignment});
22  }
23 } // namespace alpaka::core
#define ALPAKA_FN_HOST
Definition: Common.hpp:40
#define ALPAKA_FN_INLINE
Macro defining the inline function attribute.
Definition: Common.hpp:95
ALPAKA_FN_INLINE ALPAKA_FN_HOST void alignedFree(size_t alignment, void *ptr)
ALPAKA_FN_INLINE ALPAKA_FN_HOST auto alignedAlloc(size_t alignment, size_t size) -> void *