MCPcopy Create free account
hub / github.com/LMCache/LMCache / alloc_pinned_ptr

Function alloc_pinned_ptr

lmcache/python_ops_fallback.py:420–427  ·  view source on GitHub ↗

Non-CUDA equivalent of allocating pinned memory and returning pointer to it. On XPU, uses pin_memory=True (SYCL USM host allocation) for fast DMA transfers. On other non-CUDA platforms, pinning is not supported.

(size: int, device_id: int = 0)

Source from the content-addressed store, hash-verified

418
419
420def alloc_pinned_ptr(size: int, device_id: int = 0) -> int:
421 """Non-CUDA equivalent of allocating pinned memory and returning pointer
422 to it. On XPU, uses pin_memory=True (SYCL USM host allocation) for
423 fast DMA transfers. On other non-CUDA platforms, pinning is not supported."""
424
425 view, aligned_ptr = _alloc_page_aligned_pinned_view(size)
426 _tensor_registry[aligned_ptr] = view
427 return aligned_ptr
428
429
430def free_pinned_ptr(ptr: int) -> None:

Callers 1

Calls 1

Tested by

no test coverage detected