File: | cuda/cudadrv/_extras.c |
Warning: | line 41, column 53 PyObject ownership leak with reference count of 1 |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* | |||
2 | * Helper binding to call some CUDA Runtime API that cannot be directly | |||
3 | * encoded using ctypes. | |||
4 | */ | |||
5 | ||||
6 | #include "_pymodule.h" | |||
7 | ||||
8 | ||||
9 | #define CUDA_IPC_HANDLE_SIZE64 64 | |||
10 | ||||
11 | typedef int CUresult; | |||
12 | typedef void* CUdeviceptr; | |||
13 | ||||
14 | typedef struct CUipcMemHandle_st{ | |||
15 | char reserved[CUDA_IPC_HANDLE_SIZE64]; | |||
16 | } CUipcMemHandle; | |||
17 | ||||
18 | typedef CUresult (*cuIpcOpenMemHandle_t)(CUdeviceptr* pdptr, CUipcMemHandle handle, unsigned int flags ); | |||
19 | ||||
20 | static | |||
21 | cuIpcOpenMemHandle_t cuIpcOpenMemHandle = 0; | |||
22 | ||||
23 | static | |||
24 | void set_cuIpcOpenMemHandle(void* fnptr) | |||
25 | { | |||
26 | cuIpcOpenMemHandle = (cuIpcOpenMemHandle_t)fnptr; | |||
27 | } | |||
28 | ||||
29 | static | |||
30 | CUresult call_cuIpcOpenMemHandle(CUdeviceptr* pdptr, CUipcMemHandle* handle, unsigned int flags) | |||
31 | { | |||
32 | return cuIpcOpenMemHandle(pdptr, *handle, flags); | |||
33 | } | |||
34 | ||||
35 | ||||
36 | MOD_INIT(_extras)PyObject* PyInit__extras(void) { | |||
37 | PyObject *m; | |||
38 | MOD_DEF(m, "_extras", "No docs", NULL){ static struct PyModuleDef moduledef = { { { 1, ((void*)0) } , ((void*)0), 0, ((void*)0), }, "_extras", "No docs", -1, ((void *)0), ((void*)0), ((void*)0), ((void*)0), ((void*)0) }; m = PyModule_Create2 (&moduledef, 1013); } | |||
39 | if (m == NULL((void*)0)) | |||
| ||||
40 | return MOD_ERROR_VAL((void*)0); | |||
41 | PyModule_AddObject(m, "set_cuIpcOpenMemHandle", PyLong_FromVoidPtr(&set_cuIpcOpenMemHandle)); | |||
| ||||
42 | PyModule_AddObject(m, "call_cuIpcOpenMemHandle", PyLong_FromVoidPtr(&call_cuIpcOpenMemHandle)); | |||
43 | PyModule_AddIntConstant(m, "CUDA_IPC_HANDLE_SIZE", CUDA_IPC_HANDLE_SIZE64); | |||
44 | return MOD_SUCCESS_VAL(m)m; | |||
45 | } |
1 | #ifndef PyLong_FromVoidPtr |
2 | PyObject* clang_analyzer_PyObject_New_Reference(); |
3 | PyObject* PyLong_FromVoidPtr(void *p) { |
4 | return clang_analyzer_PyObject_New_Reference(); |
5 | } |
6 | #else |
7 | #warning "API PyLong_FromVoidPtr is defined as a macro." |
8 | #endif |