Merge branch 'maint'
[hoomd-blue.git] / libhoomd / extern / cudacpu_host_defines.h
blob5324a8a73758ea07de46132f73f6f5191f0ada8e
1 /*
2 * Copyright 1993-2012 NVIDIA Corporation. All rights reserved.
4 * NOTICE TO LICENSEE:
6 * This source code and/or documentation ("Licensed Deliverables") are
7 * subject to NVIDIA intellectual property rights under U.S. and
8 * international Copyright laws.
10 * These Licensed Deliverables contained herein is PROPRIETARY and
11 * CONFIDENTIAL to NVIDIA and is being provided under the terms and
12 * conditions of a form of NVIDIA software license agreement by and
13 * between NVIDIA and Licensee ("License Agreement") or electronically
14 * accepted by Licensee. Notwithstanding any terms or conditions to
15 * the contrary in the License Agreement, reproduction or disclosure
16 * of the Licensed Deliverables to any third party without the express
17 * written consent of NVIDIA is prohibited.
19 * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
20 * LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
21 * SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
22 * PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
23 * NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
24 * DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
25 * NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
26 * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
27 * LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
28 * SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
29 * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
30 * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
31 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
32 * OF THESE LICENSED DELIVERABLES.
34 * U.S. Government End Users. These Licensed Deliverables are a
35 * "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
36 * 1995), consisting of "commercial computer software" and "commercial
37 * computer software documentation" as such terms are used in 48
38 * C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
39 * only as a commercial end item. Consistent with 48 C.F.R.12.212 and
40 * 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
41 * U.S. Government End Users acquire the Licensed Deliverables with
42 * only those rights set forth herein.
44 * Any use of the Licensed Deliverables in individual and commercial
45 * software must include, in the user documentation and internal
46 * comments to the code, the above Disclaimer and U.S. Government End
47 * Users Notice.
50 #if !defined(__HOST_DEFINES_H__)
51 #define __HOST_DEFINES_H__
53 #if defined(__GNUC__) || defined(__CUDA_LIBDEVICE__)
55 #define __no_return__ \
56 __attribute__((noreturn))
58 #if defined(__CUDACC__) || defined(__CUDA_ARCH__)
59 /* gcc allows users to define attributes with underscores,
60 e.g., __attribute__((__noinline__)).
61 Consider a non-CUDA source file (e.g. .cpp) that has the
62 above attribute specification, and includes this header file. In that case,
63 defining __noinline__ as below would cause a gcc compilation error.
64 Hence, only define __noinline__ when the code is being processed
65 by a CUDA compiler component.
67 #define __noinline__ \
68 __attribute__((noinline))
69 #endif /* __CUDACC__ || __CUDA_ARCH__ */
71 #define __forceinline__ \
72 __inline__ __attribute__((always_inline))
73 #define __align__(n) \
74 __attribute__((aligned(n)))
75 #define __thread__ \
76 __thread
77 #define __import__
78 #define __export__
79 #define __cdecl
80 #define __annotate__(a) \
81 __attribute__((a))
82 #define __location__(a) \
83 __annotate__(a)
84 #define CUDARTAPI
86 #elif defined(_MSC_VER)
88 #if _MSC_VER >= 1400
90 #define __restrict__ \
91 __restrict
93 #else /* _MSC_VER >= 1400 */
95 #define __restrict__
97 #endif /* _MSC_VER >= 1400 */
99 #define __inline__ \
100 __inline
101 #define __no_return__ \
102 __declspec(noreturn)
103 #define __noinline__ \
104 __declspec(noinline)
105 #define __forceinline__ \
106 __forceinline
107 #define __align__(n) \
108 __declspec(align(n))
109 #define __thread__ \
110 __declspec(thread)
111 #define __import__ \
112 __declspec(dllimport)
113 #define __export__ \
114 __declspec(dllexport)
115 #define __annotate__(a) \
116 __declspec(a)
117 #define __location__(a) \
118 __annotate__(__##a##__)
119 #define CUDARTAPI \
120 __stdcall
122 #else /* __GNUC__ || __CUDA_LIBDEVICE__ */
124 #define __inline__
126 #if !defined(__align__)
128 #error --- !!! UNKNOWN COMPILER: please provide a CUDA compatible definition for '__align__' !!! ---
130 #endif /* !__align__ */
132 #if !defined(CUDARTAPI)
134 #error --- !!! UNKNOWN COMPILER: please provide a CUDA compatible definition for 'CUDARTAPI' !!! ---
136 #endif /* !CUDARTAPI */
138 #endif /* !__GNUC__ */
140 #if !defined(__GNUC__) || __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 3 && !defined(__clang__) )
142 #define __specialization_static \
143 static
145 #else /* !__GNUC__ || __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 3) */
147 #define __specialization_static
149 #endif /* !__GNUC__ || __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 3) */
151 #if !defined(__CUDACC__) && !defined(__CUDABE__)
153 #undef __annotate__
154 #define __annotate__(a)
156 #else /* !__CUDACC__ && !__CUDABE__ */
158 #define __launch_bounds__(...) \
159 __annotate__(launch_bounds(__VA_ARGS__))
161 #endif /* !__CUDACC__ && !__CUDABE__ */
163 #if defined(__CUDACC__) || defined(__CUDABE__) || \
164 defined(__GNUC__) || defined(_WIN64)
166 #define __builtin_align__(a) \
167 __align__(a)
169 #else /* __CUDACC__ || __CUDABE__ || __GNUC__ || _WIN64 */
171 #define __builtin_align__(a)
173 #endif /* __CUDACC__ || __CUDABE__ || __GNUC__ || _WIN64 */
175 #define __host__ \
176 __location__(host)
177 #define __device__ \
178 __location__(device)
179 #define __global__ \
180 __location__(global)
181 #define __shared__ \
182 __location__(shared)
183 #define __constant__ \
184 __location__(constant)
186 #if defined(__CUDABE__) || !defined(__CUDACC__)
187 #define __device_builtin__
188 #define __device_builtin_texture_type__
189 #define __device_builtin_surface_type__
190 #define __cudart_builtin__
191 #else /* __CUDABE__ || !__CUDACC__ */
192 #define __device_builtin__ \
193 __location__(device_builtin)
194 #define __device_builtin_texture_type__ \
195 __location__(device_builtin_texture_type)
196 #define __device_builtin_surface_type__ \
197 __location__(device_builtin_surface_type)
198 #define __cudart_builtin__ \
199 __location__(cudart_builtin)
200 #endif /* __CUDABE__ || !__CUDACC__ */
203 #endif /* !__HOST_DEFINES_H__ */