1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright (c) 2021 NVIDIA Corporation & Affiliates
12 #include <rte_compat.h>
16 * Generic library to interact with GPU computing device.
18 * The API is not thread-safe.
19 * Device management must be done by a single thread.
22 * @b EXPERIMENTAL: this API may change without prior notice.
29 /** Maximum number of devices if rte_gpu_init() is not called. */
30 #define RTE_GPU_DEFAULT_MAX 32
32 /** Empty device ID. */
33 #define RTE_GPU_ID_NONE -1
35 /** Store device info. */
37 /** Unique identifier name. */
41 /** Total processors available on device. */
42 uint32_t processor_count;
43 /** Total memory available on device. */
45 /* Local NUMA memory ID. -1 if unknown. */
51 * @b EXPERIMENTAL: this API may change without prior notice.
53 * Initialize the device array before probing devices.
54 * If not called, the maximum of probed devices is RTE_GPU_DEFAULT_MAX.
57 * Maximum number of devices.
60 * 0 on success, -rte_errno otherwise:
61 * - ENOMEM if out of memory
63 * - EBUSY if already initialized
66 int rte_gpu_init(size_t dev_max);
70 * @b EXPERIMENTAL: this API may change without prior notice.
72 * Return the number of GPU detected and associated to DPDK.
75 * The number of available computing devices.
78 uint16_t rte_gpu_count_avail(void);
82 * @b EXPERIMENTAL: this API may change without prior notice.
84 * Check if the device is valid and initialized in DPDK.
87 * The input device ID.
90 * - True if dev_id is a valid and initialized computing device.
94 bool rte_gpu_is_valid(int16_t dev_id);
98 * @b EXPERIMENTAL: this API may change without prior notice.
100 * Get the ID of the next valid GPU initialized in DPDK.
103 * The initial device ID to start the research.
106 * Next device ID corresponding to a valid and initialized computing device,
107 * RTE_GPU_ID_NONE if there is none.
110 int16_t rte_gpu_find_next(int16_t dev_id);
114 * @b EXPERIMENTAL: this API may change without prior notice.
116 * Macro to iterate over all valid GPU devices.
119 * The ID of the next possible valid device, usually 0 to iterate all.
121 #define RTE_GPU_FOREACH(dev_id) \
122 for (dev_id = rte_gpu_find_next(0); \
124 dev_id = rte_gpu_find_next(dev_id + 1))
128 * @b EXPERIMENTAL: this API may change without prior notice.
131 * All resources are released.
134 * Device ID to close.
137 * 0 on success, -rte_errno otherwise:
138 * - ENODEV if invalid dev_id
139 * - EPERM if driver error
142 int rte_gpu_close(int16_t dev_id);
146 * @b EXPERIMENTAL: this API may change without prior notice.
148 * Return device specific info.
151 * Device ID to get info.
153 * Memory structure to fill with the info.
156 * 0 on success, -rte_errno otherwise:
157 * - ENODEV if invalid dev_id
158 * - EINVAL if NULL info
159 * - EPERM if driver error
162 int rte_gpu_info_get(int16_t dev_id, struct rte_gpu_info *info);
168 #endif /* RTE_GPUDEV_H */