libMesh
include
parallel
threads_allocators.h
Go to the documentation of this file.
1
// The libMesh Finite Element Library.
2
// Copyright (C) 2002-2019 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3
4
// This library is free software; you can redistribute it and/or
5
// modify it under the terms of the GNU Lesser General Public
6
// License as published by the Free Software Foundation; either
7
// version 2.1 of the License, or (at your option) any later version.
8
9
// This library is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
// Lesser General Public License for more details.
13
14
// You should have received a copy of the GNU Lesser General Public
15
// License along with this library; if not, write to the Free Software
16
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
18
19
#ifndef LIBMESH_THREADS_ALLOCATORS_H
20
#define LIBMESH_THREADS_ALLOCATORS_H
21
22
// Local includes
23
#include "libmesh/libmesh_config.h"
24
#include "libmesh/threads.h"
25
26
// Threading building blocks includes
27
#ifdef LIBMESH_HAVE_TBB_API
28
# include "libmesh/ignore_warnings.h"
29
# include "tbb/scalable_allocator.h"
30
# include "libmesh/restore_warnings.h"
31
#endif
32
33
// C++ includes
34
#include <memory>
// for std::allocator
35
#include <cstddef>
// std::ptrdiff_t
36
37
namespace
libMesh
38
{
39
40
45
namespace
Threads
46
{
47
#ifdef LIBMESH_HAVE_TBB_API
48
49
//-------------------------------------------------------------------
55
template
<
typename
T>
56
class
scalable_allocator
:
public
tbb::scalable_allocator<T>
57
{
58
public
:
59
typedef
T *
pointer
;
60
typedef
const
T *
const_pointer
;
61
// typedef T & reference; // Intel 7.1 tries to instantiate an allocator<void>,
62
// typedef const T & const_reference; // so we can't typedef a reference to void.
63
typedef
T
value_type
;
64
typedef
size_t
size_type
;
65
typedef
std::ptrdiff_t
difference_type
;
66
67
template
<
typename
U>
68
struct
rebind
69
{
70
typedef
scalable_allocator<U>
other
;
71
};
72
73
scalable_allocator
() :
74
tbb::
scalable_allocator
<T>() {}
75
76
scalable_allocator
(
const
scalable_allocator
& a) :
77
tbb::
scalable_allocator
<T>(a) {}
78
79
template
<
typename
U>
80
scalable_allocator
(
const
scalable_allocator<U>
& a) :
81
tbb::
scalable_allocator
<T>(a) {}
82
};
83
84
85
86
#else //LIBMESH_HAVE_TBB_API
87
88
89
90
//-------------------------------------------------------------------
94
template
<
typename
T>
95
class
scalable_allocator :
public
std::allocator<T>
96
{
97
public
:
98
typedef
T *
pointer
;
99
typedef
const
T *
const_pointer
;
100
// typedef T & reference; // Intel 7.1 tries to instantiate an allocator<void>,
101
// typedef const T & const_reference; // so we can't typedef a reference to void.
102
typedef
T
value_type
;
103
typedef
size_t
size_type
;
104
typedef
std::ptrdiff_t
difference_type
;
105
106
template
<
typename
U>
107
struct
rebind
108
{
109
typedef
scalable_allocator<U>
other
;
110
};
111
112
scalable_allocator
() :
113
std
::allocator<T>() {}
114
115
scalable_allocator
(
const
scalable_allocator
& a) :
116
std
::allocator<T>(a) {}
117
118
template
<
typename
U>
119
scalable_allocator
(
const
scalable_allocator<U>
& a) :
120
std
::allocator<T>(a) {}
121
};
122
123
124
#endif // #ifdef LIBMESH_HAVE_TBB_API
125
126
}
// namespace Threads
127
128
}
// namespace libMesh
129
130
#endif // LIBMESH_THREADS_ALLOCATORS_H
libMesh::Threads::scalable_allocator::difference_type
std::ptrdiff_t difference_type
Definition:
threads_allocators.h:65
libMesh::Threads::scalable_allocator
Scalable allocator to be used in multithreaded code chunks which allocate a lot of dynamic memory.
Definition:
threads_allocators.h:56
libMesh
The libMesh namespace provides an interface to certain functionality in the library.
Definition:
factoryfunction.C:55
libMesh::Threads::scalable_allocator::rebind::other
scalable_allocator< U > other
Definition:
threads_allocators.h:70
libMesh::Threads::scalable_allocator::value_type
T value_type
Definition:
threads_allocators.h:63
libMesh::Threads::scalable_allocator::scalable_allocator
scalable_allocator(const scalable_allocator &a)
Definition:
threads_allocators.h:76
libMesh::Threads::scalable_allocator::rebind
Definition:
threads_allocators.h:68
libMesh::Threads::scalable_allocator::scalable_allocator
scalable_allocator()
Definition:
threads_allocators.h:73
std
Definition:
float128_shims.h:27
libMesh::Threads::scalable_allocator::scalable_allocator
scalable_allocator(const scalable_allocator< U > &a)
Definition:
threads_allocators.h:80
libMesh::Threads::scalable_allocator::pointer
T * pointer
Definition:
threads_allocators.h:59
libMesh::Threads::scalable_allocator::const_pointer
const typedef T * const_pointer
Definition:
threads_allocators.h:60
libMesh::Threads::scalable_allocator::size_type
size_t size_type
Definition:
threads_allocators.h:64
Generated on Sat Jan 25 2020 12:06:54 for libMesh by
1.8.16