xref: /dpdk/doc/guides/prog_guide/gpudev.rst (revision e818c4e2bf5010944fc5b4ef9a52b37df6e47c1a)
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
36
37API Overview
38------------
39
40Child Device
41~~~~~~~~~~~~
42
43By default, DPDK PCIe module detects and registers physical GPU devices
44in the system.
45With the gpudev library is also possible to add additional non-physical devices
46through an ``uint64_t`` generic handler (e.g. CUDA Driver context)
47that will be registered internally by the driver as an additional device (child)
48connected to a physical device (parent).
49Each device (parent or child) is represented through a ID
50required to indicate which device a given operation should be executed on.
51
52Memory Allocation
53~~~~~~~~~~~~~~~~~
54
55gpudev can allocate on an input given GPU device a memory area
56returning the pointer to that memory.
57Later, it's also possible to free that memory with gpudev.
58GPU memory allocated outside of the gpudev library
59(e.g. with GPU-specific library) cannot be freed by the gpudev library.
60
61Memory Registration
62~~~~~~~~~~~~~~~~~~~
63
64gpudev can register a CPU memory area to make it visible from a GPU device.
65Later, it's also possible to unregister that memory with gpudev.
66CPU memory registered outside of the gpudev library
67(e.g. with GPU specific library) cannot be unregistered by the gpudev library.
68