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-2016, 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 <cmath>
79 #include <cstddef>
80 #include <cstdint>
81 #include <cstdlib>
82 #else
83 #include <math.h>
84 #include <stddef.h>
85 #include <stdint.h>
86 #include <stdlib.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_INT64
95 #define VSMC_INT64 long long
96 #endif
97 
98 #ifndef VSMC_HAS_X86
99 #if defined(i386) || defined(__i386) || defined(__i386__) || \
100  defined(_M_IX86) || defined(_X86_) || defined(__x86_64) || \
101  defined(__x86_64__) || defined(__amd64) || defined(__amd64__) || \
102  defined(_M_AMD64) || defined(_M_X64)
103 #define VSMC_HAS_X86 1
104 #else
105 #define VSMC_HAS_X86 0
106 #endif
107 #endif
108 
109 #ifndef VSMC_HAS_X86_64
110 #if defined(__x86_64) || defined(__x86_64__) || defined(__amd64) || \
111  defined(__amd64__) || defined(_M_AMD64) || defined(_M_X64)
112 #define VSMC_HAS_X86_64 1
113 #else
114 #define VSMC_HAS_X86_64 0
115 #endif
116 #endif
117 
118 #ifndef VSMC_HAS_INT128
119 #define VSMC_HAS_INT128 0
120 #endif
121 
122 #ifndef VSMC_HAS_SSE2
123 #define VSMC_HAS_SSE2 0
124 #endif
125 
126 #ifndef VSMC_HAS_AVX2
127 #define VSMC_HAS_AVX2 0
128 #endif
129 
130 #ifndef VSMC_HAS_AES_NI
131 #define VSMC_HAS_AES_NI 0
132 #endif
133 
134 #ifndef VSMC_HAS_RDRAND
135 #define VSMC_HAS_RDRAND 0
136 #endif
137 
138 #if defined(_OPENMP) && _OPENMP >= 200805
139 #ifndef VSMC_HAS_OMP
140 #define VSMC_HAS_OMP 1
141 #endif
142 #endif
143 
144 #endif // VSMC_INTERNAL_COMPILER_HPP