GeNN  4.9.0
GPU enhanced Neuronal Networks (GeNN)
compilerfeatures.h
Go to the documentation of this file.
1 /*
2 Copyright 2010-2011, D. E. Shaw Research.
3 All rights reserved.
4 
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are
7 met:
8 
9 * Redistributions of source code must retain the above copyright
10  notice, this list of conditions, and the following disclaimer.
11 
12 * Redistributions in binary form must reproduce the above copyright
13  notice, this list of conditions, and the following disclaimer in the
14  documentation and/or other materials provided with the distribution.
15 
16 * Neither the name of D. E. Shaw Research nor the names of its
17  contributors may be used to endorse or promote products derived from
18  this software without specific prior written permission.
19 
20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
190 /*
191 N.B. When something is added to the list of features, it should be
192 added to each of the *features.h files, AND to examples/ut_features.cpp.
193 */
194 
195 /* N.B. most other compilers (icc, nvcc, open64, llvm) will also define __GNUC__, so order matters. */
196 #if defined(__OPENCL_VERSION__) && __OPENCL_VERSION__ > 0
197 #include "openclfeatures.h"
198 #elif defined(__OPEN64__)
199 #include "open64features.h"
200 #elif defined(__clang__)
201 #include "clangfeatures.h"
202 #elif defined(__GNUC__)
203 #include "gccfeatures.h"
204 #elif defined(_MSC_FULL_VER)
205 #include "msvcfeatures.h"
206 #else
207 #error "Can't identify compiler. You'll need to add a new xxfeatures.hpp"
208 { /* maybe an unbalanced brace will terminate the compilation */
209 #endif
210 
211 #ifndef R123_USE_CXX11
212 #define R123_USE_CXX11 (__cplusplus >= 201103L)
213 #endif
214 
215 #ifndef R123_USE_CXX11_UNRESTRICTED_UNIONS
216 #define R123_USE_CXX11_UNRESTRICTED_UNIONS R123_USE_CXX11
217 #endif
218 
219 #ifndef R123_USE_CXX11_STATIC_ASSERT
220 #define R123_USE_CXX11_STATIC_ASSERT R123_USE_CXX11
221 #endif
222 
223 #ifndef R123_USE_CXX11_CONSTEXPR
224 #define R123_USE_CXX11_CONSTEXPR R123_USE_CXX11
225 #endif
226 
227 #ifndef R123_USE_CXX11_EXPLICIT_CONVERSIONS
228 #define R123_USE_CXX11_EXPLICIT_CONVERSIONS R123_USE_CXX11
229 #endif
230 
231 #ifndef R123_USE_CXX11_RANDOM
232 #define R123_USE_CXX11_RANDOM R123_USE_CXX11
233 #endif
234 
235 #ifndef R123_USE_CXX11_TYPE_TRAITS
236 #define R123_USE_CXX11_TYPE_TRAITS R123_USE_CXX11
237 #endif
238 
239 #ifndef R123_USE_CXX11_LONG_LONG
240 #define R123_USE_CXX11_LONG_LONG R123_USE_CXX11
241 #endif
242 
243 #ifndef R123_USE_MULHILO64_C99
244 #define R123_USE_MULHILO64_C99 0
245 #endif
246 
247 #ifndef R123_USE_MULHILO64_MULHI_INTRIN
248 #define R123_USE_MULHILO64_MULHI_INTRIN 0
249 #endif
250 
251 #ifndef R123_USE_MULHILO32_MULHI_INTRIN
252 #define R123_USE_MULHILO32_MULHI_INTRIN 0
253 #endif
254 
255 #ifndef R123_STATIC_ASSERT
256 #if R123_USE_CXX11_STATIC_ASSERT
257 #define R123_STATIC_ASSERT(expr, msg) static_assert(expr, msg)
258 #else
259  /* if msg always_looked_like_this, we could paste it into the name. Worth it? */
260 #define R123_STATIC_ASSERT(expr, msg) typedef char static_assertion[(!!(expr))*2-1]
261 #endif
262 #endif
263 
264 #ifndef R123_CONSTEXPR
265 #if R123_USE_CXX11_CONSTEXPR
266 #define R123_CONSTEXPR constexpr
267 #else
268 #define R123_CONSTEXPR
269 #endif
270 #endif
271 
272 #ifndef R123_USE_PHILOX_64BIT
273 #if defined(R123_USE_MULHILO64_ASM) || defined(R123_USE_MULHILO64_MSVC_INTRIN) || defined(R123_USE_MULHILO64_CUDA_INTRIN) || defined(R123_USE_GNU_UINT128) || defined(R123_USE_MULHILO64_C99) || defined(R123_USE_MULHILO64_OPENCL_INTRIN) || defined(R123_USE_MULHILO64_MULHI_INTRIN)
274 #define R123_USE_PHILOX_64BIT 1
275 #endif
276 #endif
277 
278 #ifndef R123_ULONG_LONG
279 #if defined(__cplusplus) && !R123_USE_CXX11_LONG_LONG
280 /* C++98 doesn't have long long. It doesn't have uint64_t either, but
281  we will have typedef'ed uint64_t to something in the xxxfeatures.h.
282  With luck, it won't elicit complaints from -pedantic. Cross your
283  fingers... */
284 #define R123_ULONG_LONG uint64_t
285 #else
286 #define R123_ULONG_LONG unsigned long long
287 #endif
288 #endif
289 
290 /* UINT64_C should have been #defined by XXXfeatures.h, either by
291  #include <stdint.h> or through compiler-dependent hacks */
292 #ifndef R123_64BIT
293 #define R123_64BIT(x) UINT64_C(x)
294 #endif
295 
296 #ifndef R123_THROW
297 #define R123_THROW(x) throw (x)
298 #endif
299 
300 /*
301  * Windows.h (and perhaps other "well-meaning" code define min and
302  * max, so there's a high chance that our definition of min, max
303  * methods or use of std::numeric_limits min and max will cause
304  * complaints in any program that happened to include Windows.h or
305  * suchlike first. We use the null macro below in our own header
306  * files definition or use of min, max to defensively preclude
307  * this problem. It may not be enough; one might need to #define
308  * NOMINMAX before including Windows.h or compile with -DNOMINMAX.
309  */
310 #define R123_NO_MACRO_SUBST
311