Project Alice
Loading...
Searching...
No Matches
iccfeatures.h
Go to the documentation of this file.
1/*
2Copyright 2010-2011, D. E. Shaw Research.
3All rights reserved.
4
5Redistribution and use in source and binary forms, with or without
6modification, are permitted provided that the following conditions are
7met:
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
20THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31*/
32#ifndef __icpcfeatures_dot_hpp
33#define __icpcfeatures_dot_hpp
34
35// icc relies on gcc libraries and other toolchain components.
36#define R123_GNUC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
37
38#if !defined(__x86_64__) && !defined(__i386__)
39#error "This code has only been tested on x86 platforms."
40{ // maybe an unbalanced brace will terminate the compilation
41// You are invited to try Easy123 on other architectures, by changing
42// the conditions that reach this error, but you should consider it a
43// porting exercise and expect to encounter bugs and deficiencies.
44// Please let the authors know of any successes (or failures).
45#endif
46
47#ifndef R123_STATIC_INLINE
48#define R123_STATIC_INLINE static inline
49#endif
50
51#ifndef R123_FORCE_INLINE
52#define R123_FORCE_INLINE(decl) decl __attribute__((always_inline))
53#endif
54
55#ifndef R123_CUDA_DEVICE
56#define R123_CUDA_DEVICE
57#endif
58
59#ifndef R123_ASSERT
60#include <assert.h>
61#define R123_ASSERT(x) assert(x)
62#endif
63
64#ifndef R123_BUILTIN_EXPECT
65#define R123_BUILTIN_EXPECT(expr, likely) __builtin_expect(expr, likely)
66#endif
67
68 // The basic idiom is:
69 // #ifndef R123_SOMETHING
70 // #if some condition
71 // #define R123_SOMETHING 1
72 // #else
73 // #define R123_SOMETHING 0
74 // #endif
75 // #endif
76 // This idiom allows an external user to override any decision
77 // in this file with a command-line -DR123_SOMETHING=1 or -DR123_SOMETHINE=0
78
79 // An alternative idiom is:
80 // #ifndef R123_SOMETHING
81 // #define R123_SOMETHING (some boolean expression)
82 // #endif
83 // where the boolean expression might contain previously-defined R123_SOMETHING_ELSE
84 // pp-symbols.
85
86#ifndef R123_USE_SSE4_2
87#ifdef __SSE4_2__
88#define R123_USE_SSE4_2 1
89#else
90#define R123_USE_SSE4_2 0
91#endif
92#endif
93
94#ifndef R123_USE_SSE4_1
95#ifdef __SSE4_1__
96#define R123_USE_SSE4_1 1
97#else
98#define R123_USE_SSE4_1 0
99#endif
100#endif
101
102#ifndef R123_USE_SSE
103#ifdef __SSE2__
104#define R123_USE_SSE 1
105#else
106#define R123_USE_SSE 0
107#endif
108#endif
109
110#ifndef R123_USE_AES_NI
111// Unlike gcc, icc (version 12) does not pre-define an __AES__
112// pp-symbol when -maes or -xHost is on the command line. This feels
113// like a defect in icc (it defines __SSE4_2__ in analogous
114// circumstances), but until Intel fixes it, we're better off erring
115// on the side of caution and not generating instructions that are
116// going to raise SIGILL when executed. To get the AES-NI
117// instructions with icc, the caller must puts something like
118// -DR123_USE_AES_NI=1 or -D__AES__ on the command line. FWIW, the
119// AES-NI Whitepaper by Gueron says that icc has supported AES-NI from
120// 11.1 onwards.
121//
122#if defined(__AES__)
123#define R123_USE_AES_NI ((__ICC >= 1101) && 1 /*defined(__AES__)*/)
124#else
125#define R123_USE_AES_NI ((__ICC >= 1101) && 0 /*defined(__AES__)*/)
126#endif
127#endif
128
129#ifndef R123_USE_AES_OPENSSL
130/* There isn't really a good way to tell at compile time whether
131 openssl is available. Without a pre-compilation configure-like
132 tool, it's less error-prone to guess that it isn't available. Add
133 -DR123_USE_AES_OPENSSL=1 and any necessary LDFLAGS or LDLIBS to
134 play with openssl */
135#define R123_USE_AES_OPENSSL 0
136#endif
137
138#ifndef R123_USE_GNU_UINT128
139#define R123_USE_GNU_UINT128 0
140#endif
141
142#ifndef R123_USE_ASM_GNU
143#define R123_USE_ASM_GNU 1
144#endif
145
146#ifndef R123_USE_CPUID_MSVC
147#define R123_USE_CPUID_MSVC 0
148#endif
149
150#ifndef R123_USE_X86INTRIN_H
151#define R123_USE_X86INTRIN_H 0
152#endif
153
154#ifndef R123_USE_IA32INTRIN_H
155#define R123_USE_IA32INTRIN_H 1
156#endif
157
158#ifndef R123_USE_XMMINTRIN_H
159#define R123_USE_XMMINTRIN_H 0
160#endif
161
162#ifndef R123_USE_EMMINTRIN_H
163#define R123_USE_EMMINTRIN_H 1
164#endif
165
166#ifndef R123_USE_SMMINTRIN_H
167#define R123_USE_SMMINTRIN_H 1
168#endif
169
170#ifndef R123_USE_WMMINTRIN_H
171#define R123_USE_WMMINTRIN_H 1
172#endif
173
174#ifndef R123_USE_INTRIN_H
175#define R123_USE_INTRIN_H 0
176#endif
177
178#ifndef R123_USE_MULHILO16_ASM
179#define R123_USE_MULHILO16_ASM 0
180#endif
181
182#ifndef R123_USE_MULHILO32_ASM
183#define R123_USE_MULHILO32_ASM 0
184#endif
185
186#ifndef R123_USE_MULHILO64_ASM
187#define R123_USE_MULHILO64_ASM 1
188#endif
189
190#ifndef R123_USE_MULHILO64_MSVC_INTRIN
191#define R123_USE_MULHILO64_MSVC_INTRIN 0
192#endif
193
194#ifndef R123_USE_MULHILO64_CUDA_INTRIN
195#define R123_USE_MULHILO64_CUDA_INTRIN 0
196#endif
197
198#ifndef R123_USE_MULHILO64_OPENCL_INTRIN
199#define R123_USE_MULHILO64_OPENCL_INTRIN 0
200#endif
201
202#ifndef __STDC_CONSTANT_MACROS
203#define __STDC_CONSTANT_MACROS
204#endif
205#include <stdint.h>
206#ifndef UINT64_C
207#error UINT64_C not defined. You must define __STDC_CONSTANT_MACROS before you #include <stdint.h>
208#endif
209
210// If you add something, it must go in all the other XXfeatures.hpp
211// and in ../ut_features.cpp
212#endif