@@ -34,7 +34,7 @@ extern int pidfound;
34
34
extern int env_utilization_switch ;
35
35
36
36
/* context size for a certain task, we need to add it into device-memory usage*/
37
- extern int context_size ;
37
+ extern size_t context_size ;
38
38
39
39
/* This is the symbol search function */
40
40
fp_dlsym real_dlsym = NULL ;
@@ -75,7 +75,12 @@ FUNC_ATTR_VISIBLE void* dlsym(void* handle, const char* symbol) {
75
75
pthread_once (& dlsym_init_flag ,init_dlsym );
76
76
if (real_dlsym == NULL ) {
77
77
real_dlsym = dlvsym (RTLD_NEXT ,"dlsym" ,"GLIBC_2.2.5" );
78
- vgpulib = dlopen ("/usr/local/vgpu/libvgpu.so" ,RTLD_LAZY );
78
+ char * path_search = getenv ("CUDA_REDIRECT" );
79
+ if ((path_search != NULL ) && (strlen (path_search )> 0 )){
80
+ vgpulib = dlopen (path_search ,RTLD_LAZY );
81
+ }else {
82
+ vgpulib = dlopen ("/usr/local/vgpu/libvgpu.so" ,RTLD_LAZY );
83
+ }
79
84
if (real_dlsym == NULL ) {
80
85
LOG_ERROR ("real dlsym not found" );
81
86
real_dlsym = _dl_sym (RTLD_NEXT , "dlsym" , dlsym );
@@ -127,8 +132,11 @@ void* __dlsym_hook_section(void* handle, const char* symbol) {
127
132
}
128
133
}
129
134
}
135
+ DLSYM_HOOK_FUNC (cuInit );
136
+ DLSYM_HOOK_FUNC (cuGetProcAddress );
137
+ DLSYM_HOOK_FUNC (cuGetProcAddress_v2 );
130
138
//Context
131
- DLSYM_HOOK_FUNC (cuCtxGetDevice );
139
+ // DLSYM_HOOK_FUNC(cuCtxGetDevice);
132
140
DLSYM_HOOK_FUNC (cuCtxCreate_v2 );
133
141
DLSYM_HOOK_FUNC (cuCtxCreate_v3 );
134
142
DLSYM_HOOK_FUNC (cuDevicePrimaryCtxGetState );
@@ -139,12 +147,10 @@ void* __dlsym_hook_section(void* handle, const char* symbol) {
139
147
DLSYM_HOOK_FUNC (cuDeviceGetTexture1DLinearMaxWidth );
140
148
DLSYM_HOOK_FUNC (cuDeviceSetMemPool );
141
149
DLSYM_HOOK_FUNC (cuFlushGPUDirectRDMAWrites );
142
-
143
150
DLSYM_HOOK_FUNC (cuCtxDestroy_v2 );
144
151
DLSYM_HOOK_FUNC (cuCtxGetApiVersion );
145
152
DLSYM_HOOK_FUNC (cuCtxGetCacheConfig );
146
153
DLSYM_HOOK_FUNC (cuCtxGetCurrent );
147
- DLSYM_HOOK_FUNC (cuCtxGetDevice );
148
154
DLSYM_HOOK_FUNC (cuCtxGetFlags );
149
155
DLSYM_HOOK_FUNC (cuCtxGetLimit );
150
156
DLSYM_HOOK_FUNC (cuCtxGetSharedMemConfig );
@@ -158,9 +164,6 @@ void* __dlsym_hook_section(void* handle, const char* symbol) {
158
164
DLSYM_HOOK_FUNC (cuCtxSynchronize );
159
165
//DLSYM_HOOK_FUNC(cuCtxEnablePeerAccess);
160
166
//DLSYM_HOOK_FUNC(cuGetExportTable);
161
-
162
-
163
- DLSYM_HOOK_FUNC (cuInit );
164
167
DLSYM_HOOK_FUNC (cuArray3DCreate_v2 );
165
168
DLSYM_HOOK_FUNC (cuArrayCreate_v2 );
166
169
DLSYM_HOOK_FUNC (cuArrayDestroy );
@@ -178,6 +181,8 @@ void* __dlsym_hook_section(void* handle, const char* symbol) {
178
181
DLSYM_HOOK_FUNC (cuStreamCreate );
179
182
DLSYM_HOOK_FUNC (cuStreamDestroy_v2 );
180
183
DLSYM_HOOK_FUNC (cuStreamSynchronize );
184
+ DLSYM_HOOK_FUNC (cuDeviceGet );
185
+ DLSYM_HOOK_FUNC (cuCtxGetDevice );
181
186
DLSYM_HOOK_FUNC (cuDeviceGetAttribute );
182
187
DLSYM_HOOK_FUNC (cuDeviceGetCount );
183
188
DLSYM_HOOK_FUNC (cuDeviceGet );
@@ -191,7 +196,6 @@ void* __dlsym_hook_section(void* handle, const char* symbol) {
191
196
DLSYM_HOOK_FUNC (cuDeviceGetUuid );
192
197
DLSYM_HOOK_FUNC (cuDeviceGetMemPool );
193
198
DLSYM_HOOK_FUNC (cuDeviceTotalMem_v2 );
194
-
195
199
DLSYM_HOOK_FUNC (cuPointerGetAttributes );
196
200
DLSYM_HOOK_FUNC (cuPointerGetAttribute );
197
201
DLSYM_HOOK_FUNC (cuPointerSetAttribute );
@@ -231,7 +235,6 @@ void* __dlsym_hook_section(void* handle, const char* symbol) {
231
235
DLSYM_HOOK_FUNC (cuMemsetD8_v2 );
232
236
DLSYM_HOOK_FUNC (cuMemsetD8Async );
233
237
DLSYM_HOOK_FUNC (cuMemAdvise );
234
-
235
238
DLSYM_HOOK_FUNC (cuEventCreate );
236
239
DLSYM_HOOK_FUNC (cuEventDestroy_v2 );
237
240
DLSYM_HOOK_FUNC (cuModuleLoad );
@@ -248,14 +251,11 @@ void* __dlsym_hook_section(void* handle, const char* symbol) {
248
251
DLSYM_HOOK_FUNC (cuLinkAddFile_v2 );
249
252
DLSYM_HOOK_FUNC (cuLinkComplete );
250
253
DLSYM_HOOK_FUNC (cuLinkDestroy );
251
-
252
254
DLSYM_HOOK_FUNC (cuMemAddressReserve );
253
255
DLSYM_HOOK_FUNC (cuMemCreate );
254
256
DLSYM_HOOK_FUNC (cuMemMap );
255
257
DLSYM_HOOK_FUNC (cuMemAllocAsync );
256
- DLSYM_HOOK_FUNC (cuGetProcAddress );
257
- DLSYM_HOOK_FUNC (cuGetProcAddress_v2 );
258
- /* cuda 11.7 new memory ops */
258
+ // cuda 11.7 new memory ops
259
259
DLSYM_HOOK_FUNC (cuMemHostGetDevicePointer_v2 );
260
260
DLSYM_HOOK_FUNC (cuMemHostGetFlags );
261
261
DLSYM_HOOK_FUNC (cuMemPoolTrimTo );
@@ -279,7 +279,7 @@ void* __dlsym_hook_section(void* handle, const char* symbol) {
279
279
DLSYM_HOOK_FUNC (cuMemPrefetchAsync );
280
280
DLSYM_HOOK_FUNC (cuMemRangeGetAttribute );
281
281
DLSYM_HOOK_FUNC (cuMemRangeGetAttributes );
282
- /* cuda 11.7 external resource interoperability */
282
+ // cuda 11.7 external resource interoperability
283
283
DLSYM_HOOK_FUNC (cuImportExternalMemory );
284
284
DLSYM_HOOK_FUNC (cuExternalMemoryGetMappedBuffer );
285
285
DLSYM_HOOK_FUNC (cuExternalMemoryGetMappedMipmappedArray );
@@ -288,7 +288,7 @@ void* __dlsym_hook_section(void* handle, const char* symbol) {
288
288
DLSYM_HOOK_FUNC (cuSignalExternalSemaphoresAsync );
289
289
DLSYM_HOOK_FUNC (cuWaitExternalSemaphoresAsync );
290
290
DLSYM_HOOK_FUNC (cuDestroyExternalSemaphore );
291
- /* cuda Graph */
291
+ // cuda Graph
292
292
DLSYM_HOOK_FUNC (cuGraphCreate );
293
293
DLSYM_HOOK_FUNC (cuGraphAddKernelNode_v2 );
294
294
DLSYM_HOOK_FUNC (cuGraphKernelNodeGetParams_v2 );
0 commit comments