vSMC
vSMC: Scalable Monte Carlo
compiler.h
Go to the documentation of this file.
1 //============================================================================
2 // vSMC/include/vsmc/internal/compiler.h
3 //----------------------------------------------------------------------------
4 // vSMC: Scalable Monte Carlo
5 //----------------------------------------------------------------------------
6 // Copyright (c) 2013-2015, Yan Zhou
7 // All rights reserved.
8 //
9 // Redistribution and use in source and binary forms, with or without
10 // modification, are permitted provided that the following conditions are met:
11 //
12 // Redistributions of source code must retain the above copyright notice,
13 // this list of conditions and the following disclaimer.
14 //
15 // Redistributions in binary form must reproduce the above copyright notice,
16 // this list of conditions and the following disclaimer in the documentation
17 // and/or other materials provided with the distribution.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS
20 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 // POSSIBILITY OF SUCH DAMAGE.
30 //============================================================================
31 
32 #ifndef VSMC_INTERNAL_COMPILER_H
33 #define VSMC_INTERNAL_COMPILER_H
34 
35 #ifndef __STDC_CONSTANT_MACROS
36 #define __STDC_CONSTANT_MACROS
37 #endif
38 
39 #ifndef __has_attribute
40 #define __has_attribute(x) 0
41 #endif
42 
43 #ifndef __has_builtin
44 #define __has_builtin(x) 0
45 #endif
46 
47 #ifndef __has_cpp_attribute
48 #define __has_cpp_attribute(x) 0
49 #endif
50 
51 #ifndef __has_extension
52 #define __has_extension(x) 0
53 #endif
54 
55 #ifndef __has_feature
56 #define __has_feature(x) 0
57 #endif
58 
59 #if defined(__OPENCL_VERSION__)
60 #define VSMC_OPENCL
62 #elif defined(__INTEL_COMPILER)
63 #define VSMC_INTEL
65 #elif defined(__clang__)
66 #define VSMC_CLANG
68 #elif defined(__GNUC__)
69 #define VSMC_GCC
71 #elif defined(_MSC_VER)
72 #define VSMC_MSVC
74 #endif
75 
76 #ifndef VSMC_OPENCL
77 #ifdef __cplusplus
78 #include <cstdlib>
79 #include <cstddef>
80 #include <cstdint>
81 #include <cmath>
82 #else
83 #include <stdlib.h>
84 #include <stddef.h>
85 #include <stdint.h>
86 #include <math.h>
87 #endif
88 #endif
89 
90 #ifndef UINT64_C
91 #error __STDC_CONSTANT_MACROS not defined before #include<stdint.h>
92 #endif
93 
94 #ifndef VSMC_HAS_RNGC_DOUBLE
95 #define VSMC_HAS_RNGC_DOUBLE 1
96 #endif
97 
98 #ifndef VSMC_STATIC_INLINE
99 #ifdef __cplusplus
100 #define VSMC_STATIC_INLINE inline
101 #else
102 #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
103 #define VSMC_STATIC_INLINE static inline
104 #else
105 #define VSMC_STATIC_INLINE static
106 #endif
107 #endif
108 #endif
109 
110 #ifndef VSMC_INT64
111 #define VSMC_INT64 long long
112 #endif
113 
114 #ifndef VSMC_HAS_X86
115 #if defined(__x86__) || defined(__x86_64__)
116 #define VSMC_HAS_X86 1
117 #else
118 #define VSMC_HAS_X86 0
119 #endif
120 #endif
121 
122 #ifndef VSMC_HAS_INT128
123 #define VSMC_HAS_INT128 0
124 #endif
125 
126 #ifndef VSMC_HAS_SSE2
127 #define VSMC_HAS_SSE2 0
128 #endif
129 
130 #ifndef VSMC_HAS_AVX2
131 #define VSMC_HAS_AVX2 0
132 #endif
133 
134 #ifndef VSMC_HAS_AES_NI
135 #define VSMC_HAS_AES_NI 0
136 #endif
137 
138 #ifndef VSMC_HAS_RDRAND
139 #define VSMC_HAS_RDRAND 0
140 #endif
141 
142 #if defined(_OPENMP) && _OPENMP >= 200805
143 #ifndef VSMC_HAS_OMP
144 #define VSMC_HAS_OMP 1
145 #endif
146 #endif
147 
148 #endif // VSMC_INTERNAL_COMPILER_HPP