OSDN Git Service

modified: utilsrc/src/Admin/Makefile
[eos/others.git] / utiltools / X86MAC64 / cuda / include / crt / host_runtime.h
1 /*
2  * Copyright 1993-2010 NVIDIA Corporation.  All rights reserved.
3  *
4  * NOTICE TO USER:   
5  *
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.
10  *
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.  
21  *
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. 
30  *
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.
34  */
35
36 #if !defined(__CUDA_INTERNAL_COMPILATION__)
37
38 #define __CUDA_INTERNAL_COMPILATION__
39 #define __text__
40 #define __surf__
41 #define __name__shadow_var(c, cpp) \
42         #c
43 #define __name__text_var(c, cpp) \
44         #cpp
45 #define __host__shadow_var(c, cpp) \
46         cpp
47 #define __text_var(c, cpp) \
48         cpp
49 #define __device_fun(fun) \
50         #fun
51 #define __device_var(var) \
52         #var
53 #define __device__text_var(c, cpp) \
54         #c
55 #define __device__shadow_var(c, cpp) \
56         #c
57
58 #if defined(_WIN32) && !defined(_WIN64)
59
60 #define __pad__(f) \
61         f
62
63 #else /* _WIN32 && !_WIN64 */
64
65 #define __pad__(f)
66
67 #endif /* _WIN32 && !_WIN64 */
68
69 #include "builtin_types.h"
70 #include "storage_class.h"
71
72 #else /* !__CUDA_INTERNAL_COMPILATION__ */
73
74 template <typename T>
75 static inline void *__cudaAddressOf(T &val) 
76 {
77     return (void *)(&(const_cast<char &>(reinterpret_cast<const volatile char &>(val))));
78 }
79
80 #define __cudaRegisterBinary(X)                                                   \
81         __cudaFatCubinHandle = __cudaRegisterFatBinary((void*)&__fatDeviceText); \
82         { void (*callback_fp)(void **) =  (void (*)(void **))(X); (*callback_fp)(__cudaFatCubinHandle); }\
83         atexit(__cudaUnregisterBinaryUtil)
84         
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)
93           
94 #define __cudaSetupArg(arg, offset) \
95         if (cudaSetupArgument(__cudaAddressOf(arg), sizeof(arg), (size_t)offset) != cudaSuccess) \
96           return
97           
98 #define __cudaSetupArgSimple(arg, offset) \
99         if (cudaSetupArgument((void *)(char *)&arg, sizeof(arg), (size_t)offset) != cudaSuccess) \
100           return
101
102 #if defined(__GNUC__)
103 #define __cudaLaunch(fun) \
104         { volatile static char *__f __attribute__((unused)); __f = fun; (void)cudaLaunch(fun); }
105 #else /* __GNUC__ */
106 #define __cudaLaunch(fun) \
107         { volatile static char *__f; __f = fun; (void)cudaLaunch(fun); }
108 #endif /* __GNUC__ */
109
110 #if defined(__GNUC__)
111 #define __nv_dummy_param_ref(param) \
112         { volatile static void **__ref __attribute__((unused)); __ref = (volatile void **)param; }
113 #else /* __GNUC__ */
114 #define __nv_dummy_param_ref(param) \
115         { volatile static void **__ref; __ref = (volatile void **)param; }
116 #endif /* __GNUC__ */
117
118 static void ____nv_dummy_param_ref(void *param) __nv_dummy_param_ref(param)
119
120 #define __REGISTERFUNCNAME_CORE(X) __cudaRegisterLinkedBinary##X
121 #define __REGISTERFUNCNAME(X) __REGISTERFUNCNAME_CORE(X)
122
123 extern "C" {
124 void __REGISTERFUNCNAME( __NV_MODULE_ID ) ( void (*)(void **), void *, void *, void (*)(void *));
125 }
126
127 #define __TO_STRING_CORE(X) #X
128 #define __TO_STRING(X) __TO_STRING_CORE(X)
129
130 extern "C" {
131 #if defined(_WIN32)
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);
134 #pragma data_seg()
135 #elif defined(__APPLE__)
136   static const unsigned char __module_id_str[] __attribute__((section ("__NV_CUDA,__nv_module_id"))) = __TO_STRING(__NV_MODULE_ID);
137 #else
138   static const unsigned char __module_id_str[] __attribute__((section ("__nv_module_id"))) = __TO_STRING(__NV_MODULE_ID);
139 #endif
140
141 #undef __FATIDNAME_CORE
142 #undef __FATIDNAME
143 #define __FATIDNAME_CORE(X) __fatbinwrap##X
144 #define __FATIDNAME(X) __FATIDNAME_CORE(X)
145
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); }
148
149 }
150
151 extern "C" {
152 extern void** CUDARTAPI __cudaRegisterFatBinary(
153   void *fatCubin
154 );
155
156 extern void CUDARTAPI __cudaUnregisterFatBinary(
157   void **fatCubinHandle
158 );
159
160 extern void CUDARTAPI __cudaRegisterVar(
161         void **fatCubinHandle,
162         char  *hostVar,
163         char  *deviceAddress,
164   const char  *deviceName,
165         int    ext,
166         int    size,
167         int    constant,
168         int    global
169 );
170
171 extern void CUDARTAPI __cudaRegisterTexture(
172         void                    **fatCubinHandle,
173   const struct textureReference  *hostVar,
174   const void                    **deviceAddress,
175   const char                     *deviceName,
176         int                       dim,       
177         int                       norm,      
178         int                       ext        
179 );
180
181 extern void CUDARTAPI __cudaRegisterSurface(
182         void                    **fatCubinHandle,
183   const struct surfaceReference  *hostVar,
184   const void                    **deviceAddress,
185   const char                     *deviceName,
186         int                       dim,       
187         int                       ext        
188 );
189
190 extern void CUDARTAPI __cudaRegisterFunction(
191         void   **fatCubinHandle,
192   const char    *hostFun,
193         char    *deviceFun,
194   const char    *deviceName,
195         int      thread_limit,
196         uint3   *tid,
197         uint3   *bid,
198         dim3    *bDim,
199         dim3    *gDim,
200         int     *wSize
201 );
202
203 #if defined(__APPLE__)
204 extern "C" int atexit(void (*)(void));
205
206 #elif  defined(__GNUC__) && !defined(__ANDROID__)
207 extern int atexit(void(*)(void)) throw();
208
209 #else /* __GNUC__ && !__ANDROID__ */
210 extern int __cdecl atexit(void(__cdecl *)(void));
211 #endif
212
213 }
214
215 static void **__cudaFatCubinHandle;
216
217 static void __cdecl __cudaUnregisterBinaryUtil(void)
218 {
219   ____nv_dummy_param_ref((void *)&__cudaFatCubinHandle);
220   __cudaUnregisterFatBinary(__cudaFatCubinHandle);
221 }
222
223 #include "common_functions.h"
224
225 #if defined(__APPLE__)
226
227 #pragma options align=natural
228
229 #else /* __APPLE__ */
230
231 #pragma pack()
232
233 #if defined(_WIN32)
234
235 #pragma warning(disable: 4099)
236
237 #if !defined(_WIN64)
238
239 #pragma warning(disable: 4408)
240
241 #endif /* !_WIN64 */
242
243 #endif /* _WIN32 */
244
245 #endif /* __APPLE__ */
246
247 #endif /* !__CUDA_INTERNAL_COMPILATION__ */