TRIQS/nda 1.3.0
Multi-dimensional array library for C++
Loading...
Searching...
No Matches
policies.hpp
Go to the documentation of this file.
1// Copyright (c) 2019-2024 Simons Foundation
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0.txt
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15// Authors: Thomas Hahn, Olivier Parcollet, Nils Wentzell
16
22#pragma once
23
24#include "./allocators.hpp"
25#include "./handle.hpp"
26
27namespace nda {
28
34#ifdef NDA_TEST_DEFAULT_ALLOC_MBUCKET // for testing only: use multi_bucket allocator
35 template <typename Allocator =
36 mem::segregator<8 * NDA_TEST_DEFAULT_ALLOC_MBUCKET, mem::multi_bucket<8 * NDA_TEST_DEFAULT_ALLOC_MBUCKET>, mem::mallocator>>
37#else // normal case
42 template <typename Allocator>
43#endif
44 struct heap_basic {
49 template <typename T>
50#ifdef NDA_TEST_DEFAULT_ALLOC_SSO // for testing only: use a handle_sso if possible
51 using handle =
52 std::conditional_t<std::is_copy_constructible_v<T>, mem::handle_sso<T, NDA_TEST_DEFAULT_ALLOC_SSO>, mem::handle_heap<T, Allocator>>;
53#else
55#endif
56 };
57
62 template <mem::AddressSpace AdrSp = mem::Host>
64
69 template <size_t Size>
70 struct sso {
75 template <typename T>
77 };
78
83 template <size_t Size>
84 struct stack {
89 template <typename T>
91 };
92
94 struct shared {
99 template <typename T>
101 };
102
107 template <mem::AddressSpace AdrSp = mem::Host>
108 struct borrowed {
113 template <typename T>
115 };
116
119} // namespace nda
Provides custom allocators for the nda library.
Provides various handles to take care of memory management for nda::basic_array and nda::basic_array_...
Memory policy using an nda::mem::handle_borrowed.
Definition policies.hpp:108
Memory policy using an nda::mem::handle_heap.
Definition policies.hpp:44
A non-owning handle for a memory block on the heap.
Definition handle.hpp:858
A handle for a memory block on the heap.
Definition handle.hpp:99
A handle for a memory block on the heap with shared ownership.
Definition handle.hpp:754
A handle for a memory block on the heap or stack depending on the size of the data.
Definition handle.hpp:492
A handle for a memory block on the stack.
Definition handle.hpp:359
Memory policy using an nda::mem::handle_shared.
Definition policies.hpp:94
Memory policy using an nda::mem::handle_sso.
Definition policies.hpp:70
Memory policy using an nda::mem::handle_stack.
Definition policies.hpp:84