|
3 | 3 |
|
4 | 4 | from libc.stdint cimport intptr_t, int32_t, uint32_t, int64_t |
5 | 5 |
|
| 6 | +from cuquantum.utils cimport Stream |
| 7 | + |
6 | 8 |
|
7 | 9 | # The C types are prefixed with an underscore because we are not |
8 | 10 | # yet protected by the module namespaces as done in CUDA Python. |
9 | 11 | # Once we switch over the names would be prettier (in the Cython |
10 | 12 | # layer). |
11 | 13 |
|
| 14 | + |
| 15 | +# Cython limitation: need standalone typedef if we wanna use it for casting |
| 16 | +ctypedef int (*DeviceAllocType)(void*, void**, size_t, Stream) |
| 17 | +ctypedef int (*DeviceFreeType)(void*, void*, size_t, Stream) |
| 18 | + |
| 19 | + |
12 | 20 | cdef extern from '<custatevec.h>' nogil: |
13 | 21 | # cuStateVec types |
14 | 22 | ctypedef void* _Handle 'custatevecHandle_t' |
15 | 23 | ctypedef int64_t _Index 'custatevecIndex_t' |
16 | 24 | ctypedef int _Status 'custatevecStatus_t' |
17 | | - ctypedef struct _SamplerDescriptor 'custatevecSamplerDescriptor_t': |
18 | | - pass |
19 | | - ctypedef struct _AccessorDescriptor 'custatevecAccessorDescriptor': |
20 | | - pass |
| 25 | + ctypedef void* _SamplerDescriptor 'custatevecSamplerDescriptor_t' |
| 26 | + ctypedef void* _AccessorDescriptor 'custatevecAccessorDescriptor_t' |
21 | 27 | ctypedef enum _ComputeType 'custatevecComputeType_t': |
22 | 28 | pass |
23 | | - # ctypedef void(*custatevecLoggerCallback_t)( |
24 | | - # int32_t logLevel, |
25 | | - # const char* functionName, |
26 | | - # const char* message) |
27 | | - # ctypedef custatevecLoggerCallback_t LoggerCallback |
| 29 | + ctypedef struct _DeviceMemHandler 'custatevecDeviceMemHandler_t': |
| 30 | + void* ctx |
| 31 | + DeviceAllocType device_alloc |
| 32 | + DeviceFreeType device_free |
| 33 | + |
| 34 | + # Cython limitation: cannot use C defines in declaring a static array, |
| 35 | + # so we just have to hard-code CUSTATEVEC_ALLOCATOR_NAME_LEN here... |
| 36 | + char name[64] |
| 37 | + ctypedef void(*LoggerCallbackData 'custatevecLoggerCallbackData_t')( |
| 38 | + int32_t logLevel, |
| 39 | + const char* functionName, |
| 40 | + const char* message, |
| 41 | + void* userData) |
28 | 42 |
|
29 | 43 | # cuStateVec enums |
30 | 44 | ctypedef enum _Pauli 'custatevecPauli_t': |
@@ -55,3 +69,4 @@ cdef extern from '<custatevec.h>' nogil: |
55 | 69 | int CUSTATEVEC_VER_MINOR |
56 | 70 | int CUSTATEVEC_VER_PATCH |
57 | 71 | int CUSTATEVEC_VERSION |
| 72 | + int CUSTATEVEC_ALLOCATOR_NAME_LEN |
0 commit comments