vSMC  v3.0.0
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 #if defined(__OPENCL_VERSION__)
40 #define VSMC_OPENCL
42 #elif defined(__INTEL_COMPILER)
43 #define VSMC_INTEL
45 #elif defined(__clang__)
46 #define VSMC_CLANG
48 #elif defined(__GNUC__)
49 #define VSMC_GCC
51 #elif defined(_MSC_VER)
52 #define VSMC_MSVC
54 #endif
55 
56 #ifndef VSMC_OPENCL
57 #ifdef __cplusplus
58 #include <cmath>
59 #include <cstddef>
60 #include <cstdint>
61 #include <cstdlib>
62 #else
63 #include <math.h>
64 #include <stddef.h>
65 #include <stdint.h>
66 #include <stdlib.h>
67 #endif
68 #endif
69 
70 #ifndef UINT64_C
71 #error __STDC_CONSTANT_MACROS not defined before #include<stdint.h>
72 #endif
73 
74 #ifndef VSMC_HAS_X86
75 #if defined(i386) || defined(__i386) || defined(__i386__) || \
76  defined(_M_IX86) || defined(_X86_) || defined(__x86_64) || \
77  defined(__x86_64__) || defined(__amd64) || defined(__amd64__) || \
78  defined(_M_AMD64) || defined(_M_X64)
79 #define VSMC_HAS_X86 1
80 #else
81 #define VSMC_HAS_X86 0
82 #endif
83 #endif
84 
85 #ifndef VSMC_HAS_X86_64
86 #if defined(__x86_64) || defined(__x86_64__) || defined(__amd64) || \
87  defined(__amd64__) || defined(_M_AMD64) || defined(_M_X64)
88 #define VSMC_HAS_X86_64 1
89 #else
90 #define VSMC_HAS_X86_64 0
91 #endif
92 #endif
93 
94 #ifndef VSMC_HAS_AES_NI
95 #define VSMC_HAS_AES_NI 0
96 #endif
97 
98 #ifndef VSMC_HAS_RDRAND
99 #define VSMC_HAS_RDRAND 0
100 #endif
101 
102 #ifndef VSMC_HAS_INT128
103 #define VSMC_HAS_INT128 0
104 #endif
105 
106 #endif // VSMC_INTERNAL_COMPILER_HPP