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--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
16namespace nda {
17
22
23#ifdef NDA_TEST_DEFAULT_ALLOC_MBUCKET // for testing only: use multi_bucket allocator
24 template <typename Allocator =
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
44#endif
45 };
46
51 template <mem::AddressSpace AdrSp = mem::Host>
53
58 template <size_t Size>
59 struct sso {
64 template <typename T>
66 };
67
72 template <size_t Size>
73 struct stack {
78 template <typename T>
80 };
81
83 struct shared {
88 template <typename T>
90 };
91
96 template <mem::AddressSpace AdrSp = mem::Host>
97 struct borrowed {
102 template <typename T>
104 };
105
107
108} // namespace nda
Provides custom allocators for the nda library.
Custom allocator that uses nda::mem::malloc to allocate memory.
Custom allocator that dispatches memory allocation to one of two allocators based on the size of the ...
heap_basic< mem::mallocator< AdrSp > > heap
Alias template of the nda::heap_basic policy using an nda::mem::mallocator.
Definition policies.hpp:52
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:97
mem::handle_borrowed< T, AdrSp > handle
Definition policies.hpp:103
Memory policy using an nda::mem::handle_heap.
Definition policies.hpp:33
mem::handle_heap< T, Allocator > handle
Handle type for the policy.
Definition policies.hpp:43
A non-owning handle for a memory block on the heap.
Definition handle.hpp:845
A handle for a memory block on the heap.
Definition handle.hpp:86
A handle for a memory block on the heap with shared ownership.
Definition handle.hpp:741
A handle for a memory block on the heap or stack depending on the size of the data.
Definition handle.hpp:479
A handle for a memory block on the stack.
Definition handle.hpp:346
Memory policy using an nda::mem::handle_shared.
Definition policies.hpp:83
mem::handle_shared< T > handle
Handle type for the policy.
Definition policies.hpp:89
Memory policy using an nda::mem::handle_sso.
Definition policies.hpp:59
mem::handle_sso< T, Size > handle
Handle type for the policy.
Definition policies.hpp:65
Memory policy using an nda::mem::handle_stack.
Definition policies.hpp:73
mem::handle_stack< T, Size > handle
Handle type for the policy.
Definition policies.hpp:79