cuquantum.custatevec.set_device_mem_handler¶
- cuquantum.custatevec.set_device_mem_handler(intptr_t handle, handler)[source]¶
Set the device memory handler for cuStateVec.
The
handler
object can be passed in multiple ways:If
handler
is anint
, it refers to the address of a fully initializedcustatevecDeviceMemHandler_t
struct.If
handler
is a Python sequence:If
handler
is a sequence of length 4, it is interpreted as(ctx, device_alloc, device_free, name)
, where the first three elements are the pointer addresses (int
) of the corresponding members.name
is astr
as the name of the handler.If
handler
is a sequence of length 3, it is interpreted as(malloc, free, name)
, where the first two objects are Python callables with the following calling convention:ptr = malloc(size, stream)
free(ptr, size, stream)
with all arguments and return value (
ptr
) being Pythonint
.name
is the same as above.
Note
Only when
handler
is a length-3 sequence will the GIL be held whenever a routine requires memory allocation and deallocation, so for all other cases be sure yourhandler
does not manipulate any Python objects.- Parameters
handle (intptr_t) – The library handle.
handler – The memory handler object, see above.
See also