threads_allocators.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2014 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 "tbb/scalable_allocator.h"
29 #endif
30 
31 // C++ includes
32 #include <memory> // for std::allocator
33 #include <cstddef>
34 
35 namespace libMesh
36 {
37 
38 
43 namespace Threads
44 {
45 #ifdef LIBMESH_HAVE_TBB_API
46 
47  //-------------------------------------------------------------------
53  template <typename T>
54  class scalable_allocator : public tbb::scalable_allocator<T>
55  {
56  public:
57  typedef T* pointer;
58  typedef const T* const_pointer;
59 // typedef T& reference; // Intel 7.1 tries to instantiate an allocator<void>,
60 // typedef const T& const_reference; // so we can't typedef a reference to void.
61  typedef T value_type;
62  typedef size_t size_type;
63  typedef ptrdiff_t difference_type;
64 
65  template<typename U>
66  struct rebind
67  {
69  };
70 
72  tbb::scalable_allocator<T>() {}
73 
75  tbb::scalable_allocator<T>(a) {}
76 
77  template<typename U>
79  tbb::scalable_allocator<T>(a) {}
80  };
81 
82 
83 
84 #else //LIBMESH_HAVE_TBB_API
85 
86 
87 
88  //-------------------------------------------------------------------
92  template <typename T>
93  class scalable_allocator : public std::allocator<T>
94  {
95  public:
96  typedef T* pointer;
97  typedef const T* const_pointer;
98 // typedef T& reference; // Intel 7.1 tries to instantiate an allocator<void>,
99 // typedef const T& const_reference; // so we can't typedef a reference to void.
100  typedef T value_type;
101  typedef size_t size_type;
102  typedef ptrdiff_t difference_type;
103 
104  template<typename U>
105  struct rebind
106  {
108  };
109 
111  std::allocator<T>() {}
112 
114  std::allocator<T>(a) {}
115 
116  template<typename U>
118  std::allocator<T>(a) {}
119  };
120 
121 
122 #endif // #ifdef LIBMESH_HAVE_TBB_API
123 
124 } // namespace Threads
125 
126 } // namespace libMesh
127 
128 #endif // LIBMESH_THREADS_ALLOCATORS_H

Site Created By: libMesh Developers
Last modified: February 07 2014 16:57:07 UTC

Hosted By:
SourceForge.net Logo