how use mapped page-locked memory should in nvidia orin
- User
how use mapped page-locked memory should in nvidia orin
- Assistant
Using mapped page-locked memory (also called pinned memory with mapping to the device address space) on NVIDIA Orin (which is based on the NVIDIA Ampere architecture for embedded systems) allows zero-copy access from the GPU to host memory, improving data transfer efficiency between CPU and GPU.
Here's how you can use mapped page-locked memory on NVIDIA Orin (or in CUDA in general):
What is Mapped Page-Locked Memory?
- Page-locked (pinned) memory is host memory that won't be swapped out and is physically contiguous.
- Mapped memory means the pinned memory is automatically mapped into the GPU address space.
- This enables zero-copy memory access, where the GPU can access host memory directly without explicit
cudaMemcpy.
Why Use Mapped Page-Locked Memory on Orin?
- Orin uses a unified memory architecture internally but explicit mapped pinned memory still offers better latency and bandwidth for host-to-device communication, critical in embedded low-latency applications.
- Useful when:
- Your data size is small/medium
- You want to avoid extra memcpy steps
- You want faster setup
How to Allocate and Use Mapped Page-Locked Memory
Step 1: Allocate pinned mapped memory on the host using
cudaHostAlloccppfloat* hostPtr = nullptr; size_t size = N * sizeof(float); // Allocate pinned, mapped memory accessible to device cudaError_t err = cudaHostAlloc((void**)&hostPtr, size, cudaHostAllocMapped); if (err != cudaSuccess) { printf("cudaHostAlloc failed: %s\n", cudaGetErrorString(err)); // handle error }cudaHostAllocMappedflags allocate pinned memory and map it into the device's address space.Step 2: Get the device pointer corresponding to the mapped host memory
cppfloat* devicePtr = nullptr; err = cudaHostGetDevicePointer((void**)&devicePtr, (void*)hostPtr, 0); if (err != cudaSuccess) { printf("cudaHostGetDevicePointer failed: %s\n", cudaGetErrorString(err)); // handle error } - User
on which site can I read this?
- Assistant
You can read about mapped page-locked (pinned) memory in CUDA on the official NVIDIA CUDA documentation and developer resources, which are the authoritative sources:
Official NVIDIA resources
-
CUDA C++ Programming Guide (Memory Management section):
https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#host-memory-management -
CUDA Runtime API Reference for
cudaHostAlloc:
https://docs.nvidia.com/cuda/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1gafefff03f0ff82a14e011ee4f164b37f
-