TRIQS/nda
2.0.0
Multi-dimensional array library for C++
Toggle main menu visibility
Loading...
Searching...
No Matches
policies.hpp
Go to the documentation of this file.
1
// Copyright (c) 2019--present, The Simons Foundation
2
// This file is part of TRIQS/nda and is licensed under the Apache License, Version 2.0.
3
// SPDX-License-Identifier: Apache-2.0
4
// See LICENSE in the root of this distribution for details.
5
10
11
#pragma once
12
13
#include "
./allocators.hpp
"
14
#include "
./handle.hpp
"
15
16
namespace
nda {
17
22
23
#ifdef NDA_TEST_DEFAULT_ALLOC_MBUCKET
// for testing only: use multi_bucket allocator
24
template
<
typename
Allocator =
25
mem::segregator<8 * NDA_TEST_DEFAULT_ALLOC_MBUCKET, mem::multi_bucket<8 * NDA_TEST_DEFAULT_ALLOC_MBUCKET>
,
mem::mallocator
>>
26
#else
// normal case
31
template
<
typename
Allocator>
32
#endif
33
struct
heap_basic
{
38
template
<
typename
T>
39
#ifdef NDA_TEST_DEFAULT_ALLOC_SSO
// for testing only: use a handle_sso if possible
40
using
handle
=
41
std::conditional_t<std::is_copy_constructible_v<T>,
mem::handle_sso<T, NDA_TEST_DEFAULT_ALLOC_SSO>
,
mem::handle_heap<T, Allocator>
>;
42
#else
43
using
handle
=
mem::handle_heap<T, Allocator>
;
44
#endif
45
};
46
51
template
<mem::AddressSpace AdrSp = mem::Host>
52
using
heap
=
heap_basic<mem::mallocator<AdrSp>
>;
53
58
template
<
size_t
Size>
59
struct
sso
{
64
template
<
typename
T>
65
using
handle
=
mem::handle_sso<T, Size>
;
66
};
67
72
template
<
size_t
Size>
73
struct
stack
{
78
template
<
typename
T>
79
using
handle
=
mem::handle_stack<T, Size>
;
80
};
81
83
struct
shared
{
88
template
<
typename
T>
89
using
handle
=
mem::handle_shared<T>
;
90
};
91
96
template
<mem::AddressSpace AdrSp = mem::Host>
97
struct
borrowed
{
102
template
<
typename
T>
103
using
handle
=
mem::handle_borrowed<T, AdrSp>
;
104
};
105
107
108
}
// namespace nda
allocators.hpp
Provides custom allocators for the nda library.
nda::mem::mallocator
Custom allocator that uses nda::mem::malloc to allocate memory.
Definition
allocators.hpp:60
nda::mem::segregator
Custom allocator that dispatches memory allocation to one of two allocators based on the size of the ...
Definition
allocators.hpp:380
nda::heap
heap_basic< mem::mallocator< AdrSp > > heap
Alias template of the nda::heap_basic policy using an nda::mem::mallocator.
Definition
policies.hpp:52
handle.hpp
Provides various handles to take care of memory management for nda::basic_array and nda::basic_array_...
nda::borrowed
Memory policy using an nda::mem::handle_borrowed.
Definition
policies.hpp:97
nda::borrowed< storage_t::address_space >::handle
mem::handle_borrowed< T, AdrSp > handle
Definition
policies.hpp:103
nda::heap_basic
Memory policy using an nda::mem::handle_heap.
Definition
policies.hpp:33
nda::heap_basic::handle
mem::handle_heap< T, Allocator > handle
Handle type for the policy.
Definition
policies.hpp:43
nda::mem::handle_borrowed
A non-owning handle for a memory block on the heap.
Definition
handle.hpp:845
nda::mem::handle_heap
A handle for a memory block on the heap.
Definition
handle.hpp:86
nda::mem::handle_shared
A handle for a memory block on the heap with shared ownership.
Definition
handle.hpp:741
nda::mem::handle_sso
A handle for a memory block on the heap or stack depending on the size of the data.
Definition
handle.hpp:479
nda::mem::handle_stack
A handle for a memory block on the stack.
Definition
handle.hpp:346
nda::shared
Memory policy using an nda::mem::handle_shared.
Definition
policies.hpp:83
nda::shared::handle
mem::handle_shared< T > handle
Handle type for the policy.
Definition
policies.hpp:89
nda::sso
Memory policy using an nda::mem::handle_sso.
Definition
policies.hpp:59
nda::sso::handle
mem::handle_sso< T, Size > handle
Handle type for the policy.
Definition
policies.hpp:65
nda::stack
Memory policy using an nda::mem::handle_stack.
Definition
policies.hpp:73
nda::stack::handle
mem::handle_stack< T, Size > handle
Handle type for the policy.
Definition
policies.hpp:79
nda
mem
policies.hpp
Generated by
1.17.0