Skip to content

Commit ca301c0

Browse files
authored
Merge pull request #1670 from tkatila/xe-driver-support
GPU: Add support for the new xe KMD
2 parents 7d00cf0 + 4946b26 commit ca301c0

File tree

18 files changed

+856
-246
lines changed

18 files changed

+856
-246
lines changed

.github/workflows/lib-e2e.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ jobs:
2525
- name: e2e-gpu
2626
runner: gpu
2727
images: intel-gpu-plugin intel-gpu-initcontainer
28+
targetJob: e2e-gpu SKIP=Resource:xe
2829
- name: e2e-iaa-spr
2930
targetjob: e2e-iaa
3031
runner: simics-spr

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ The summary of resources available via plugins in this repository is given in th
229229
* [dsa-accel-config-demo-pod.yaml](demo/dsa-accel-config-demo-pod.yaml)
230230
* `fpga.intel.com` : custom, see [mappings](cmd/fpga_admissionwebhook/README.md#mappings)
231231
* [intelfpga-job.yaml](demo/intelfpga-job.yaml)
232-
* `gpu.intel.com` : `i915`
232+
* `gpu.intel.com` : `i915`, `i915_monitoring`, `xe` or `xe_monitoring`
233233
* [intelgpu-job.yaml](demo/intelgpu-job.yaml)
234234
* `iaa.intel.com` : `wq-user-[shared or dedicated]`
235235
* [iaa-accel-config-demo-pod.yaml](demo/iaa-accel-config-demo-pod.yaml)

cmd/gpu_plugin/README.md

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Table of Contents
1616
* [Running GPU plugin as non-root](#running-gpu-plugin-as-non-root)
1717
* [Labels created by GPU plugin](#labels-created-by-gpu-plugin)
1818
* [SR-IOV use with the plugin](#sr-iov-use-with-the-plugin)
19+
* [KMD and UMD](#kmd-and-umd)
1920
* [Issues with media workloads on multi-GPU setups](#issues-with-media-workloads-on-multi-gpu-setups)
2021
* [Workaround for QSV and VA-API](#workaround-for-qsv-and-va-api)
2122

@@ -36,11 +37,23 @@ For example containers with Intel media driver (and components using that), can
3637
video transcoding operations, and containers with the Intel OpenCL / oneAPI Level Zero
3738
backend libraries can offload compute operations to GPU.
3839

40+
Intel GPU plugin may register four node resources to the Kubernetes cluster:
41+
| Resource | Description |
42+
|:---- |:-------- |
43+
| gpu.intel.com/i915 | GPU instance running legacy `i915` KMD |
44+
| gpu.intel.com/i915_monitoring | Monitoring resource for the legacy `i915` KMD devices |
45+
| gpu.intel.com/xe | GPU instance running new `xe` KMD |
46+
| gpu.intel.com/xe_monitoring | Monitoring resource for the new `xe` KMD devices |
47+
48+
While GPU plugin basic operations support nodes having both (`i915` and `xe`) KMDs on the same node, its resource management (=GAS) does not, for that node needs to have only one of the KMDs present.
49+
50+
For workloads on different KMDs, see [KMD and UMD](#kmd-and-umd).
51+
3952
## Modes and Configuration Options
4053

4154
| Flag | Argument | Default | Meaning |
4255
|:---- |:-------- |:------- |:------- |
43-
| -enable-monitoring | - | disabled | Enable 'i915_monitoring' resource that provides access to all Intel GPU devices on the node |
56+
| -enable-monitoring | - | disabled | Enable '*_monitoring' resource that provides access to all Intel GPU devices on the node, [see use](./monitoring.md) |
4457
| -resource-manager | - | disabled | Enable fractional resource management, [see use](./fractional.md) |
4558
| -shared-dev-num | int | 1 | Number of containers that can share the same GPU device |
4659
| -allocation-policy | string | none | 3 possible values: balanced, packed, none. For shared-dev-num > 1: _balanced_ mode spreads workloads among GPU devices, _packed_ mode fills one GPU fully before moving to next, and _none_ selects first available device from kubelet. Default is _none_. Allocation policy does not have an effect when resource manager is enabled. |
@@ -205,6 +218,31 @@ GPU plugin does __not__ setup SR-IOV. It has to be configured by the cluster adm
205218
206219
GPU plugin does however support provisioning Virtual Functions (VFs) to containers for a SR-IOV enabled GPU. When the plugin detects a GPU with SR-IOV VFs configured, it will only provision the VFs and leaves the PF device on the host.
207220
221+
### KMD and UMD
222+
223+
There are 3 different Kernel Mode Drivers (KMD) available: `i915 upstream`, `i915 backport` and `xe`:
224+
* `i915 upstream` is a vanilla driver that comes from the upstream kernel and is included in the common Linux distributions, like Ubuntu.
225+
* `i915 backport` is an [out-of-tree driver](https://github.com/intel-gpu/intel-gpu-i915-backports/) for older enterprise / LTS kernel versions, having better support for new HW before upstream kernel does. API it provides to user-space can differ from the eventual upstream version.
226+
* `xe` is a new KMD that is intended to support future GPUs. While it has [experimental support for latest current GPUs](https://docs.kernel.org/gpu/rfc/xe.html) (starting from Tigerlake), it will not support them officially.
227+
228+
For optimal performance, the KMD should be paired with the same UMD variant. When creating a workload container, depending on the target hardware, the UMD packages should be selected approriately.
229+
230+
| KMD | UMD packages | Support notes |
231+
|:---- |:-------- |:------- |
232+
| `i915 upstream` | Distro Repository | For Integrated GPUs. Newer Linux kernels will introduce support for Arc, Flex or Max series. |
233+
| `i915 backport` | [Intel Repository](https://dgpu-docs.intel.com/driver/installation.html#install-steps) | Best for Arc, Flex and Max series. Untested for Integrated GPUs. |
234+
| `xe` | Source code only | Experimental support for Arc, Flex and Max series. |
235+
236+
> *NOTE*: Xe UMD is in active development and should be considered as experimental.
237+
238+
Creating a workload that would support all the different KMDs is not currently possible. Below is a table that clarifies how each domain supports different KMDs.
239+
240+
| Domain | i915 upstream | i915 backport | xe | Notes |
241+
|:---- |:-------- |:------- |:------- |:------- |
242+
| Compute | Default | [NEO_ENABLE_i915_PRELIM_DETECTION](https://github.com/intel/compute-runtime/blob/3341de7a0d5fddd2ea5f505b5d2ef5c13faa0681/CMakeLists.txt#L496-L502) | [NEO_ENABLE_XE_DRM_DETECTION](https://github.com/intel/compute-runtime/blob/3341de7a0d5fddd2ea5f505b5d2ef5c13faa0681/CMakeLists.txt#L504-L510) | All three KMDs can be supported at the same time. |
243+
| Media | Default | [ENABLE_PRODUCTION_KMD](https://github.com/intel/media-driver/blob/a66b076e83876fbfa9c9ab633ad9c5517f8d74fd/CMakeLists.txt#L58) | [ENABLE_XE_KMD](https://github.com/intel/media-driver/blob/a66b076e83876fbfa9c9ab633ad9c5517f8d74fd/media_driver/cmake/linux/media_feature_flags_linux.cmake#L187-L190) | Xe with upstream or backport i915, not all three. |
244+
| Graphics | Default | Unknown | [intel-xe-kmd](https://gitlab.freedesktop.org/mesa/mesa/-/blob/e9169881dbd1f72eab65a68c2b8e7643f74489b7/meson_options.txt#L708) | i915 and xe KMDs can be supported at the same time. |
245+
208246
### Issues with media workloads on multi-GPU setups
209247
210248
OneVPL media API, 3D and compute APIs provide device discovery

cmd/gpu_plugin/device_props.go

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
// Copyright 2024 Intel Corporation. All Rights Reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package main
16+
17+
import (
18+
"slices"
19+
20+
"github.com/intel/intel-device-plugins-for-kubernetes/cmd/internal/labeler"
21+
"github.com/intel/intel-device-plugins-for-kubernetes/cmd/internal/pluginutils"
22+
"k8s.io/klog/v2"
23+
)
24+
25+
type DeviceProperties struct {
26+
currentDriver string
27+
drmDrivers map[string]bool
28+
tileCounts []uint64
29+
isPfWithVfs bool
30+
}
31+
32+
type invalidTileCountErr struct {
33+
error
34+
}
35+
36+
func newDeviceProperties() *DeviceProperties {
37+
return &DeviceProperties{
38+
drmDrivers: make(map[string]bool),
39+
}
40+
}
41+
42+
func (d *DeviceProperties) fetch(cardPath string) {
43+
d.isPfWithVfs = pluginutils.IsSriovPFwithVFs(cardPath)
44+
45+
d.tileCounts = append(d.tileCounts, labeler.GetTileCount(cardPath))
46+
47+
driverName, err := pluginutils.ReadDeviceDriver(cardPath)
48+
if err != nil {
49+
klog.Warningf("card (%s) doesn't have driver, using default: %s", cardPath, deviceTypeDefault)
50+
51+
driverName = deviceTypeDefault
52+
}
53+
54+
d.currentDriver = driverName
55+
d.drmDrivers[d.currentDriver] = true
56+
}
57+
58+
func (d *DeviceProperties) drmDriverCount() int {
59+
return len(d.drmDrivers)
60+
}
61+
62+
func (d *DeviceProperties) driver() string {
63+
return d.currentDriver
64+
}
65+
66+
func (d *DeviceProperties) monitorResource() string {
67+
return d.currentDriver + monitorSuffix
68+
}
69+
70+
func (d *DeviceProperties) maxTileCount() (uint64, error) {
71+
if len(d.tileCounts) == 0 {
72+
return 0, invalidTileCountErr{}
73+
}
74+
75+
minCount := slices.Min(d.tileCounts)
76+
maxCount := slices.Max(d.tileCounts)
77+
78+
if minCount != maxCount {
79+
klog.Warningf("Node's GPUs are heterogenous (min: %d, max: %d tiles)", minCount, maxCount)
80+
81+
return 0, invalidTileCountErr{}
82+
}
83+
84+
return maxCount, nil
85+
}

0 commit comments

Comments
 (0)