2 * Copyright 1993-2010 NVIDIA Corporation. All rights reserved.
6 * This source code is subject to NVIDIA ownership rights under U.S. and
7 * international Copyright laws. Users and possessors of this source code
8 * are hereby granted a nonexclusive, royalty-free license to use this code
9 * in individual and commercial software.
11 * NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOURCE
12 * CODE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR
13 * IMPLIED WARRANTY OF ANY KIND. NVIDIA DISCLAIMS ALL WARRANTIES WITH
14 * REGARD TO THIS SOURCE CODE, INCLUDING ALL IMPLIED WARRANTIES OF
15 * MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
16 * IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL,
17 * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
18 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
19 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
20 * OR PERFORMANCE OF THIS SOURCE CODE.
22 * U.S. Government End Users. This source code is a "commercial item" as
23 * that term is defined at 48 C.F.R. 2.101 (OCT 1995), consisting of
24 * "commercial computer software" and "commercial computer software
25 * documentation" as such terms are used in 48 C.F.R. 12.212 (SEPT 1995)
26 * and is provided to the U.S. Government only as a commercial end item.
27 * Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through
28 * 227.7202-4 (JUNE 1995), all U.S. Government End Users acquire the
29 * source code with only those rights set forth herein.
31 * Any use of this source code in individual and commercial software must
32 * include, in the user documentation and internal comments to the code,
33 * the above Disclaimer and U.S. Government End Users Notice.
36 #if !defined(__CUDA_INTERNAL_COMPILATION__)
38 #define __CUDA_INTERNAL_COMPILATION__
41 #define __name__shadow_var(c, cpp) \
43 #define __name__text_var(c, cpp) \
45 #define __host__shadow_var(c, cpp) \
47 #define __text_var(c, cpp) \
49 #define __device_fun(fun) \
51 #define __device_var(var) \
53 #define __device__text_var(c, cpp) \
55 #define __device__shadow_var(c, cpp) \
58 #if defined(_WIN32) && !defined(_WIN64)
63 #else /* _WIN32 && !_WIN64 */
67 #endif /* _WIN32 && !_WIN64 */
69 #include "builtin_types.h"
70 #include "storage_class.h"
72 #else /* !__CUDA_INTERNAL_COMPILATION__ */
75 static inline void *__cudaAddressOf(T &val)
77 return (void *)(&(const_cast<char &>(reinterpret_cast<const volatile char &>(val))));
80 #define __cudaRegisterBinary(X) \
81 __cudaFatCubinHandle = __cudaRegisterFatBinary((void*)&__fatDeviceText); \
82 { void (*callback_fp)(void **) = (void (*)(void **))(X); (*callback_fp)(__cudaFatCubinHandle); }\
83 atexit(__cudaUnregisterBinaryUtil)
85 #define __cudaRegisterVariable(handle, var, ext, size, constant, global) \
86 __cudaRegisterVar(handle, (char*)&__host##var, (char*)__device##var, __name##var, ext, size, constant, global)
87 #define __cudaRegisterGlobalTexture(handle, tex, dim, norm, ext) \
88 __cudaRegisterTexture(handle, (const struct textureReference*)&tex, (const void**)(void*)__device##tex, __name##tex, dim, norm, ext)
89 #define __cudaRegisterGlobalSurface(handle, surf, dim, ext) \
90 __cudaRegisterSurface(handle, (const struct surfaceReference*)&surf, (const void**)(void*)__device##surf, __name##surf, dim, ext)
91 #define __cudaRegisterEntry(handle, funptr, fun, thread_limit) \
92 __cudaRegisterFunction(handle, (const char*)funptr, (char*)__device_fun(fun), #fun, -1, (uint3*)0, (uint3*)0, (dim3*)0, (dim3*)0, (int*)0)
94 #define __cudaSetupArg(arg, offset) \
95 if (cudaSetupArgument(__cudaAddressOf(arg), sizeof(arg), (size_t)offset) != cudaSuccess) \
98 #define __cudaSetupArgSimple(arg, offset) \
99 if (cudaSetupArgument((void *)(char *)&arg, sizeof(arg), (size_t)offset) != cudaSuccess) \
102 #if defined(__GNUC__)
103 #define __cudaLaunch(fun) \
104 { volatile static char *__f __attribute__((unused)); __f = fun; (void)cudaLaunch(fun); }
106 #define __cudaLaunch(fun) \
107 { volatile static char *__f; __f = fun; (void)cudaLaunch(fun); }
108 #endif /* __GNUC__ */
110 #if defined(__GNUC__)
111 #define __nv_dummy_param_ref(param) \
112 { volatile static void **__ref __attribute__((unused)); __ref = (volatile void **)param; }
114 #define __nv_dummy_param_ref(param) \
115 { volatile static void **__ref; __ref = (volatile void **)param; }
116 #endif /* __GNUC__ */
118 static void ____nv_dummy_param_ref(void *param) __nv_dummy_param_ref(param)
120 #define __REGISTERFUNCNAME_CORE(X) __cudaRegisterLinkedBinary##X
121 #define __REGISTERFUNCNAME(X) __REGISTERFUNCNAME_CORE(X)
124 void __REGISTERFUNCNAME( __NV_MODULE_ID ) ( void (*)(void **), void *, void *, void (*)(void *));
127 #define __TO_STRING_CORE(X) #X
128 #define __TO_STRING(X) __TO_STRING_CORE(X)
132 #pragma data_seg("__nv_module_id")
133 static const __declspec(allocate("__nv_module_id")) unsigned char __module_id_str[] = __TO_STRING(__NV_MODULE_ID);
135 #elif defined(__APPLE__)
136 static const unsigned char __module_id_str[] __attribute__((section ("__NV_CUDA,__nv_module_id"))) = __TO_STRING(__NV_MODULE_ID);
138 static const unsigned char __module_id_str[] __attribute__((section ("__nv_module_id"))) = __TO_STRING(__NV_MODULE_ID);
141 #undef __FATIDNAME_CORE
143 #define __FATIDNAME_CORE(X) __fatbinwrap##X
144 #define __FATIDNAME(X) __FATIDNAME_CORE(X)
146 #define ____cudaRegisterLinkedBinary(X) \
147 { __REGISTERFUNCNAME(__NV_MODULE_ID) (( void (*)(void **))(X), (void *)&__FATIDNAME(__NV_MODULE_ID), (void *)&__module_id_str, (void (*)(void *))&____nv_dummy_param_ref); }
152 extern void** CUDARTAPI __cudaRegisterFatBinary(
156 extern void CUDARTAPI __cudaUnregisterFatBinary(
157 void **fatCubinHandle
160 extern void CUDARTAPI __cudaRegisterVar(
161 void **fatCubinHandle,
164 const char *deviceName,
171 extern void CUDARTAPI __cudaRegisterTexture(
172 void **fatCubinHandle,
173 const struct textureReference *hostVar,
174 const void **deviceAddress,
175 const char *deviceName,
181 extern void CUDARTAPI __cudaRegisterSurface(
182 void **fatCubinHandle,
183 const struct surfaceReference *hostVar,
184 const void **deviceAddress,
185 const char *deviceName,
190 extern void CUDARTAPI __cudaRegisterFunction(
191 void **fatCubinHandle,
194 const char *deviceName,
203 #if defined(__APPLE__)
204 extern "C" int atexit(void (*)(void));
206 #elif defined(__GNUC__) && !defined(__ANDROID__)
207 extern int atexit(void(*)(void)) throw();
209 #else /* __GNUC__ && !__ANDROID__ */
210 extern int __cdecl atexit(void(__cdecl *)(void));
215 static void **__cudaFatCubinHandle;
217 static void __cdecl __cudaUnregisterBinaryUtil(void)
219 ____nv_dummy_param_ref((void *)&__cudaFatCubinHandle);
220 __cudaUnregisterFatBinary(__cudaFatCubinHandle);
223 #include "common_functions.h"
225 #if defined(__APPLE__)
227 #pragma options align=natural
229 #else /* __APPLE__ */
235 #pragma warning(disable: 4099)
239 #pragma warning(disable: 4408)
245 #endif /* __APPLE__ */
247 #endif /* !__CUDA_INTERNAL_COMPILATION__ */