alpaka
Abstraction Library for Parallel Kernel Acceleration
Traits.hpp
Go to the documentation of this file.
1 /* Copyright 2022 Benjamin Worpitz, Matthias Werner, Bernhard Manfred Gruber
2  * SPDX-License-Identifier: MPL-2.0
3  */
4 
5 #pragma once
6 
7 #include "alpaka/core/Common.hpp"
9 #include "alpaka/dev/Traits.hpp"
10 #include "alpaka/dim/Traits.hpp"
11 #include "alpaka/extent/Traits.hpp"
12 
13 namespace alpaka
14 {
16  {
17  };
18 
19  //! The allocator traits.
20  namespace trait
21  {
22  //! The memory allocation trait.
23  template<typename T, typename TAlloc, typename TSfinae = void>
24  struct Malloc;
25 
26  //! The memory free trait.
27  template<typename T, typename TAlloc, typename TSfinae = void>
28  struct Free;
29  } // namespace trait
30 
31  //! \return The pointer to the allocated memory.
32  template<typename T, typename TAlloc>
33  ALPAKA_FN_HOST auto malloc(TAlloc const& alloc, std::size_t const& sizeElems) -> T*
34  {
36  return trait::Malloc<T, ImplementationBase>::malloc(alloc, sizeElems);
37  }
38 
39  //! Frees the memory identified by the given pointer.
40  template<typename TAlloc, typename T>
41  ALPAKA_FN_HOST auto free(TAlloc const& alloc, T const* const ptr) -> void
42  {
45  }
46 } // namespace alpaka
#define ALPAKA_FN_HOST
Definition: Common.hpp:40
typename detail::ImplementationBaseType< TInterface, TDerived >::type ImplementationBase
Returns the type that implements the given interface in the inheritance hierarchy.
Definition: Interface.hpp:66
The alpaka accelerator library.
ALPAKA_FN_HOST auto free(TAlloc const &alloc, T const *const ptr) -> void
Frees the memory identified by the given pointer.
Definition: Traits.hpp:41
ALPAKA_FN_HOST auto malloc(TAlloc const &alloc, std::size_t const &sizeElems) -> T *
Definition: Traits.hpp:33
The memory free trait.
Definition: Traits.hpp:28
The memory allocation trait.
Definition: Traits.hpp:24