TMB Documentation  v1.9.11
TMBad/config.hpp
1 #ifndef HAVE_CONFIG_HPP
2 #define HAVE_CONFIG_HPP
3 
4 /* ========================================================================== */
5 /* === Configuration ======================================================== */
6 /* ========================================================================== */
7 
8 // Begin Configuration
9 #ifndef TMBAD_SCALAR_TYPE
10 #define TMBAD_SCALAR_TYPE double
11 #endif
12 #ifndef TMBAD_INDEX_TYPE
13 #define TMBAD_INDEX_TYPE unsigned int
14 #endif
15 #ifndef TMBAD_INDEX_VECTOR
16 #define TMBAD_INDEX_VECTOR std::vector<TMBAD_INDEX_TYPE>
17 #endif
18 #ifndef TMBAD_REPLAY_TYPE
19 #define TMBAD_REPLAY_TYPE ad_aug
20 #endif
21 #ifndef TMBAD_MAX_NUM_THREADS
22 #define TMBAD_MAX_NUM_THREADS 48
23 #endif
24 #ifndef TMBAD_COMPRESS_TOL
25 #define TMBAD_COMPRESS_TOL 16
26 #endif
27 #ifndef TMBAD_HASH_TYPE
28 #define TMBAD_HASH_TYPE unsigned int
29 #endif
30 #ifndef TMBAD_UNION_OR_STRUCT
31 #define TMBAD_UNION_OR_STRUCT union
32 #endif
33 #ifndef TMBAD_MIN_PERIOD_REP
34 #define TMBAD_MIN_PERIOD_REP 10
35 #endif
36 #ifdef __cpp_constexpr
37 #define CONSTEXPR constexpr
38 #else
39 #define CONSTEXPR
40 #endif
41 // End Configuration
42 
43 #ifdef _OPENMP
44 #include <omp.h>
45 #define TMBAD_THREAD_NUM omp_get_thread_num()
46 #define TMBAD_SHARED_PTR TMBad::omp_shared_ptr
47 #else
48 #define TMBAD_SHARED_PTR std::shared_ptr
49 #define TMBAD_THREAD_NUM 0
50 #endif
51 
52 /* ========================================================================== */
53 /* === Common macros ======================================================== */
54 /* ========================================================================== */
55 
56 #ifndef ASSERT
57 #define ASSERT(x) \
58  if (!(x)) { \
59  Rcerr << "ASSERTION FAILED: " << #x << "\n"; \
60  abort(); \
61  }
62 #define ASSERT2(x, msg) \
63  if (!(x)) { \
64  Rcerr << "ASSERTION FAILED: " << #x << "\n"; \
65  Rcerr << "POSSIBLE REASON: " << msg << "\n"; \
66  abort(); \
67  }
68 #endif
69 /* Test whether the maximum of TMBAD_INDEX_TYPE has been exceeded */
70 #define TMBAD_INDEX_OVERFLOW(x) \
71  ((size_t)(x) >= (size_t)std::numeric_limits<TMBAD_INDEX_TYPE>::max())
72 #define xstringify(s) stringify(s)
73 #define stringify(s) #s
74 
75 // Avoid typing nightmare.
76 #define INHERIT_CTOR(A, B) \
77  A() {} \
78  template <class T1> \
79  A(const T1 &x1) : B(x1) {} \
80  template <class T1, class T2> \
81  A(const T1 &x1, const T2 &x2) : B(x1, x2) {} \
82  template <class T1, class T2, class T3> \
83  A(const T1 &x1, const T2 &x2, const T3 &x3) : B(x1, x2, x3) {} \
84  template <class T1, class T2, class T3, class T4> \
85  A(const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4) \
86  : B(x1, x2, x3, x4) {}
87 
88 #endif // HAVE_CONFIG_HPP
License: GPL v2