gtsam  4.1.0
gtsam
FastDefaultAllocator.h
Go to the documentation of this file.
1 /* ----------------------------------------------------------------------------
2 
3  * GTSAM Copyright 2010, Georgia Tech Research Corporation,
4  * Atlanta, Georgia 30332-0415
5  * All Rights Reserved
6  * Authors: Frank Dellaert, et al. (see THANKS for the full author list)
7 
8  * See LICENSE for the license information
9 
10  * -------------------------------------------------------------------------- */
11 
19 #pragma once
20 #include <gtsam/config.h> // Configuration from CMake
21 
22 #if !defined GTSAM_ALLOCATOR_BOOSTPOOL && !defined GTSAM_ALLOCATOR_TBB && !defined GTSAM_ALLOCATOR_STL
23 # ifdef GTSAM_USE_TBB
24 // Use TBB allocator by default if we have TBB, otherwise boost pool
25 # define GTSAM_ALLOCATOR_TBB
26 # else
27 # define GTSAM_ALLOCATOR_BOOSTPOOL
28 # endif
29 #endif
30 
31 #if defined GTSAM_ALLOCATOR_BOOSTPOOL
32 # include <boost/pool/pool_alloc.hpp>
33 #elif defined GTSAM_ALLOCATOR_TBB
34 # include <tbb/tbb_allocator.h>
35 # undef min // TBB seems to include Windows.h which defines these macros that cause problems
36 # undef max
37 # undef ERROR
38 #elif defined GTSAM_ALLOCATOR_STL
39 # include <memory>
40 #endif
41 
42 namespace gtsam
43 {
44 
45  namespace internal
46  {
48  template<typename T>
50  {
51 #if defined GTSAM_ALLOCATOR_BOOSTPOOL
52  typedef boost::fast_pool_allocator<T> type;
53  static const bool isBoost = true;
54  static const bool isTBB = false;
55  static const bool isSTL = false;
56 #elif defined GTSAM_ALLOCATOR_TBB
57  typedef tbb::tbb_allocator<T> type;
58  static const bool isBoost = false;
59  static const bool isTBB = true;
60  static const bool isSTL = false;
61 #elif defined GTSAM_ALLOCATOR_STL
62  typedef std::allocator<T> type;
63  static const bool isBoost = false;
64  static const bool isTBB = false;
65  static const bool isSTL = true;
66 #endif
67  };
68 
70  template<typename T>
72  {
73 #if defined GTSAM_ALLOCATOR_TBB
74  typedef tbb::tbb_allocator<T> type;
75  static const bool isBoost = false;
76  static const bool isTBB = true;
77  static const bool isSTL = false;
78 #else
79  typedef std::allocator<T> type;
80  static const bool isBoost = false;
81  static const bool isTBB = false;
82  static const bool isSTL = true;
83 #endif
84  };
85  }
86 
87 }
gtsam::internal::FastDefaultAllocator
Default allocator for list, map, and set types.
Definition: FastDefaultAllocator.h:50
gtsam
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
gtsam::internal::FastDefaultVectorAllocator
Default allocator for vector types (we never use boost pool for vectors)
Definition: FastDefaultAllocator.h:72