7. Static Utility Methods#
7.1. getCtx#
Extracts the user context from the callback handle.
static void* getCtx(const void* handle);
Parameters:
handle: Handle from the GET or PUT callback function.
Returns:
User context pointer that was passed to
cuObjGet()orcuObjPut().nullptrifhandleis null or no context is active for this callback.
Notes:
This API must be called within the callback to retrieve the user’s context.
The
handleparameter is the first parameter passed to the callback.
7.2. getMemoryType#
Determines the memory type of a pointer.
static cuObjMemoryType_t getMemoryType(const void* ptr);
Parameters:
ptr: Memory pointer to analyze.
Returns:
Memory type enumeration,
cuObjMemoryType_t.CUOBJ_MEMORY_INVALIDforptr == nullptr.
Possible values:
CUOBJ_MEMORY_SYSTEM: System or host memory.CUOBJ_MEMORY_CUDA_MANAGED: CUDA managed memory.CUOBJ_MEMORY_CUDA_DEVICE: CUDA device memory.CUOBJ_MEMORY_UNKNOWN: Unknown memory type.CUOBJ_MEMORY_INVALID: Invalid memory type.
Notes:
CUDA device memory returns
CUOBJ_MEMORY_CUDA_DEVICE.CUDA unified or array memory returns
CUOBJ_MEMORY_CUDA_MANAGED.Host memory, unregistered memory, and memory whose type cannot be determined return
CUOBJ_MEMORY_SYSTEM.