Tinker9
70bd052 (Thu Nov 9 12:11:35 2023 -0800)
Loading...
Searching...
No Matches
include
tool
macro.h
1
#pragma once
2
3
// C++11
4
#ifdef __cplusplus
5
#if __cplusplus < 201103L
6
#error Must enable C++11.
7
#endif
8
#endif
9
10
#if defined(__INTEL_COMPILER)
11
#define TINKER_ICPC
12
13
#elif defined(__PGIC__)
14
#define TINKER_PGI
15
16
#elif defined(__clang__)
17
#define TINKER_CLANG
18
// xcode clang is different from llvm clang
19
#ifdef __apple_build_version__
20
#define TINKER_APPLE_CLANG
21
#else
22
#define TINKER_LLVM_CLANG
23
#endif
24
25
#elif defined(__GNUC__)
26
#define TINKER_GCC
27
#if __GNUC__ <= 4 && __GNUC_MINOR__ <= 8
28
#warning Your default GNU version is 4.8 where C++11 is incomplete.
29
#endif
30
31
#endif
32
33
// Suppress Warnings
34
#ifdef TINKER_ICPC
35
// #161: unrecognized #pragma
36
#pragma warning disable 161
37
#endif
38
#ifdef TINKER_CLANG
39
#pragma clang diagnostic ignored "-Wextern-c-compat"
40
#endif
41
#ifdef __NVCC_DIAG_PRAGMA_SUPPORT__
42
// // #20199-D: unrecognized #pragma in device code
43
// #pragma nv_diag_suppress 20199
44
#endif
45
46
//====================================================================//
47
50
#ifdef __cplusplus
51
#define restrict __restrict__
52
#endif
53
58
#if __cplusplus >= 201703L && defined(__cpp_if_constexpr)
59
#define CONSTEXPR constexpr
60
#else
61
#define CONSTEXPR
62
#endif
63
66
#ifdef __has_cpp_attribute
67
#if __has_cpp_attribute(maybe_unused)
68
#define MAYBE_UNUSED [[maybe_unused]]
69
#else
70
#define MAYBE_UNUSED
71
#endif
72
#elif defined(TINKER_ICPC) || defined(TINKER_CLANG) || defined(TINKER_GCC)
73
#define MAYBE_UNUSED __attribute__((unused))
74
#else
75
#define MAYBE_UNUSED
76
#endif
77
80
#define TINKER_STR(s) TINKER_STR1_(s)
81
#define TINKER_STR1_(s) #s
82
83
#define TINKER_GET_1ST_ARG(a1, ...) a1
84
#define TINKER_GET_2ND_ARG(a1, a2, ...) a2
85
#define TINKER_GET_3RD_ARG(a1, a2, a3, ...) a3
86
#define TINKER_GET_4TH_ARG(a1, a2, a3, a4, ...) a4
87
#define TINKER_GET_5TH_ARG(a1, a2, a3, a4, a5, ...) a5
88
#define TINKER_GET_6TH_ARG(a1, a2, a3, a4, a5, a6, ...) a6
89
#define TINKER_GET_7TH_ARG(a1, a2, a3, a4, a5, a6, a7, ...) a7
90
102
#ifndef TINKER_EXTERN_DEFINITION_FILE
103
#define TINKER_EXTERN_DEFINITION_FILE 0
104
#endif
105
#if TINKER_EXTERN_DEFINITION_FILE
106
#define TINKER_EXTERN
107
#else
108
#define TINKER_EXTERN extern
109
#endif
110
114
#ifdef NDEBUG
115
#define TINKER_DEBUG 0
116
#else
117
#define TINKER_DEBUG 1
118
#endif
119
123
#ifndef TINKER9_DIR
124
#error TINKER9_DIR is not set.
125
#else
126
#define TINKER9_DIRSTR TINKER_STR(TINKER9_DIR)
127
#endif
128
129
//====================================================================//
130
135
#ifdef TINKER_CUDART
136
#undef TINKER_CUDART
137
#define TINKER_CUDART 1
138
#else
139
#define TINKER_CUDART 0
140
#endif
141
148
#ifdef TINKER_GPULANG_OPENACC
149
#undef TINKER_GPULANG_OPENACC
150
#define TINKER_GPULANG_OPENACC 1
151
#else
152
#define TINKER_GPULANG_OPENACC 0
153
#endif
154
161
#ifdef TINKER_GPULANG_CUDA
162
#undef TINKER_GPULANG_CUDA
163
#define TINKER_GPULANG_CUDA 1
164
#else
165
#define TINKER_GPULANG_CUDA 0
166
#endif
167
189
#ifdef TINKER_DOUBLE_PRECISION
190
#undef TINKER_DOUBLE_PRECISION
191
#define TINKER_DOUBLE_PRECISION 1
192
#else
193
#define TINKER_DOUBLE_PRECISION 0
194
#endif
195
#ifdef TINKER_MIXED_PRECISION
196
#undef TINKER_MIXED_PRECISION
197
#define TINKER_MIXED_PRECISION 1
198
#else
199
#define TINKER_MIXED_PRECISION 0
200
#endif
201
#ifdef TINKER_SINGLE_PRECISION
202
#undef TINKER_SINGLE_PRECISION
203
#define TINKER_SINGLE_PRECISION 1
204
#else
205
#define TINKER_SINGLE_PRECISION 0
206
#endif
207
#if (TINKER_DOUBLE_PRECISION + TINKER_MIXED_PRECISION + TINKER_SINGLE_PRECISION) != 1
208
#error Detected errors in TINKER_?_PRECISION macros.
209
#endif
Generated by
1.9.5