1.. SPDX-License-Identifier: BSD-3-Clause 2 Copyright (c) 2021 NVIDIA Corporation & Affiliates 3 4General-Purpose Graphics Processing Unit Library 5================================================ 6 7When mixing networking activity with task processing on a GPU device, 8there may be the need to put in communication the CPU with the device 9in order to manage the memory, synchronize operations, exchange info, etc.. 10 11By means of the generic GPU interface provided by this library, 12it is possible to allocate a chunk of GPU memory and use it 13to create a DPDK mempool with external mbufs having the payload 14on the GPU memory, enabling any network interface card 15(which support this feature like Mellanox NIC) 16to directly transmit and receive packets using GPU memory. 17 18Additionally, this library provides a number of functions 19to enhance the dialog between CPU and GPU. 20 21Out of scope of this library is to provide a wrapper for GPU specific libraries 22(e.g. CUDA Toolkit or OpenCL), thus it is not possible to launch workload 23on the device or create GPU specific objects 24(e.g. CUDA Driver context or CUDA Streams in case of NVIDIA GPUs). 25 26 27Features 28-------- 29 30This library provides a number of features: 31 32- Interoperability with device-specific library through generic handlers. 33- Allocate and free memory on the device. 34- Register CPU memory to make it visible from the device. 35- Communication between the CPU and the device. 36 37The whole CPU - GPU communication is implemented 38using CPU memory visible from the GPU. 39 40 41API Overview 42------------ 43 44Child Device 45~~~~~~~~~~~~ 46 47By default, DPDK PCIe module detects and registers physical GPU devices 48in the system. 49With the gpudev library is also possible to add additional non-physical devices 50through an ``uint64_t`` generic handler (e.g. CUDA Driver context) 51that will be registered internally by the driver as an additional device (child) 52connected to a physical device (parent). 53Each device (parent or child) is represented through a ID 54required to indicate which device a given operation should be executed on. 55 56Memory Allocation 57~~~~~~~~~~~~~~~~~ 58 59gpudev can allocate on an input given GPU device a memory area 60returning the pointer to that memory. 61Later, it's also possible to free that memory with gpudev. 62GPU memory allocated outside of the gpudev library 63(e.g. with GPU-specific library) cannot be freed by the gpudev library. 64 65Memory Registration 66~~~~~~~~~~~~~~~~~~~ 67 68gpudev can register a CPU memory area to make it visible from a GPU device. 69Later, it's also possible to unregister that memory with gpudev. 70CPU memory registered outside of the gpudev library 71(e.g. with GPU specific library) cannot be unregistered by the gpudev library. 72 73Memory Barrier 74~~~~~~~~~~~~~~ 75 76Some GPU drivers may need, under certain conditions, 77to enforce the coherency of external devices writes (e.g. NIC receiving packets) 78into the GPU memory. 79gpudev abstracts and exposes this capability. 80 81Communication Flag 82~~~~~~~~~~~~~~~~~~ 83 84Considering an application with some GPU task 85that's waiting to receive a signal from the CPU 86to move forward with the execution. 87The communication flag allocates a CPU memory GPU-visible ``uint32_t`` flag 88that can be used by the CPU to communicate with a GPU task. 89