Skip to content

Commit 87d07f1

Browse files
committed
feat: support vgpu
Signed-off-by: james <open4pd@4paradigm.com>
1 parent 331ee2b commit 87d07f1

5 files changed

Lines changed: 10 additions & 13 deletions

File tree

pkg/brgpu/kata.go

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -201,15 +201,10 @@ func vfDeviceDiscover() (PFDeviceInfoList, error) {
201201
}
202202

203203
vfs = append(vfs, VFDeviceInfo{
204-
DeviceID: deviceID,
205-
IOMMUGroup: iommuGroup,
206-
Addr: vfAddr,
207-
ResourceName: func() string {
208-
if vfNum == 1 {
209-
return "gpu"
210-
}
211-
return fmt.Sprintf("1-%d-gpu", vfNum)
212-
}(),
204+
DeviceID: deviceID,
205+
IOMMUGroup: iommuGroup,
206+
Addr: vfAddr,
207+
ResourceName: "gpu",
213208
})
214209
}
215210
pdl = append(pdl, PFDeviceInfo{

pkg/brgpu/plugin.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ func (p *Plugin) ListAndWatch(e *pluginapi.Empty, s pluginapi.DevicePlugin_ListA
245245
}
246246

247247
func (p *Plugin) Allocate(ctx context.Context, r *pluginapi.AllocateRequest) (*pluginapi.AllocateResponse, error) {
248+
logrus.Info("Allocate")
248249
var current *v1.Pod
249250
success := false
250251
defer func() {
@@ -287,6 +288,7 @@ func (p *Plugin) Allocate(ctx context.Context, r *pluginapi.AllocateRequest) (*p
287288
utils.PodAllocationFailed(GetNodeName(), current)
288289
return nil, err
289290
}
291+
logrus.Infof("Allocate request %v", devreq)
290292
if len(devreq) != len(req.DevicesIDs) {
291293
utils.PodAllocationFailed(GetNodeName(), current)
292294
return nil, fmt.Errorf("device number not matched")

pkg/brgpu/register.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ func RegisterHAMiWithRawDevice(devs DevicesInfoList) error {
6565
apiDevices := make([]*utils.DeviceInfo, 0, len(devs))
6666
// hami currently believes that the index starts from 0 and is continuous.
6767
index := 0
68-
for i, dev := range devs {
68+
for _, dev := range devs {
6969
for _, ins := range dev.Instances {
7070
device := &utils.DeviceInfo{
71-
Index: uint(i),
71+
Index: uint(index),
7272
ID: ins.CardID,
7373
Type: dev.Name,
7474
Health: true,

pkg/brgpu/runc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ func DeviceDiscover() (DevicesInfoList, error) {
263263
di.Instances = append(di.Instances, Instance{
264264
UUID: fmt.Sprintf("%s-instance-%d", phyUUID, j),
265265
Memory: int(mem.Total),
266-
ResourceName: fmt.Sprintf("1-%d-gpu", sviCount),
266+
ResourceName: "gpu",
267267
CardID: cardIDFormat(id),
268268
})
269269
}

pkg/utils/util.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ var (
5959
func init() {
6060
InRequestDevices = make(map[string]string)
6161
SupportDevices = make(map[string]string)
62-
InRequestDevices[DeviceType] = "hami.io/Biren-devices-allocated"
62+
InRequestDevices[DeviceType] = "hami.io/Biren-devices-to-allocate"
6363
SupportDevices[DeviceType] = "hami.io/Biren-devices-allocated"
6464
}
6565

0 commit comments

Comments
 (0)