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
7
#include "
alpaka/core/Common.hpp
"
8
#include "
alpaka/mem/alloc/Traits.hpp
"
9
10
namespace
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
alpaka::AllocCpuNew
The CPU new allocator.
Definition
AllocCpuNew.hpp:14
Common.hpp
ALPAKA_FN_HOST
#define ALPAKA_FN_HOST
Definition
Common.hpp:40
Traits.hpp
alpaka
The alpaka accelerator library.
Definition
AccCpuOmp2Blocks.hpp:49
alpaka::free
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::malloc
ALPAKA_FN_HOST auto malloc(TAlloc const &alloc, std::size_t const &sizeElems) -> T *
Definition
Traits.hpp:33
alpaka::interface::Implements
Tag used in class inheritance hierarchies that describes that a specific interface (TInterface) is im...
Definition
Interface.hpp:15
include
alpaka
mem
alloc
AllocCpuNew.hpp
Generated on Tue Feb 4 2025 09:02:23 for alpaka by
1.9.8