alpaka
Abstraction Library for Parallel Kernel Acceleration
Loading...
Searching...
No Matches
AllocCpuNew.hpp
Go to the documentation of this file.
1/* Copyright 2022 Axel Huebl, Benjamin Worpitz, Bernhard Manfred Gruber
2 * SPDX-License-Identifier: MPL-2.0
3 */
4
5#pragma once
6
9
10namespace alpaka
11{
12 //! The CPU new allocator.
13 class AllocCpuNew : public interface::Implements<ConceptMemAlloc, AllocCpuNew>
14 {
15 };
16
17 namespace trait
18 {
19 //! The CPU new allocator memory allocation trait specialization.
20 template<typename T>
21 struct Malloc<T, AllocCpuNew>
22 {
23 ALPAKA_FN_HOST static auto malloc(AllocCpuNew const& /* alloc */, std::size_t const& sizeElems) -> T*
24 {
25 return new T[sizeElems];
26 }
27 };
28
29 //! The CPU new allocator memory free trait specialization.
30 template<typename T>
31 struct Free<T, AllocCpuNew>
32 {
33 ALPAKA_FN_HOST static auto free(AllocCpuNew const& /* alloc */, T const* const ptr) -> void
34 {
35 return delete[] ptr;
36 }
37 };
38 } // namespace trait
39} // namespace alpaka
The CPU new allocator.
#define ALPAKA_FN_HOST
Definition Common.hpp:40
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
Tag used in class inheritance hierarchies that describes that a specific interface (TInterface) is im...
Definition Interface.hpp:15