Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion internal/server/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,16 @@ func (ps *PluginServer) registerHAMi() error {
apiDevices := make([]*device.DeviceInfo, 0, len(devs))
// hami currently believes that the index starts from 0 and is continuous.
for i, dev := range devs {
devcore := dev.AICore
if ps.mgr.IsHamiVnpuCore() {
devcore = HamiVnpuCoreMaxPercent
}
device := &device.DeviceInfo{
Index: uint(i),
ID: dev.UUID,
Count: int32(ps.mgr.VDeviceCount()),
Devmem: int32(dev.Memory),
Devcore: dev.AICore,
Devcore: devcore,
Type: ps.mgr.CommonWord(),
Numa: 0,
Health: dev.Health,
Expand Down
36 changes: 36 additions & 0 deletions internal/server/register_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,42 @@ func TestRegisterHAMi(t *testing.T) {
},
},
},
{
name: "IsHamiVnpuCore_Devcore100",
args: registerHAMiArgs{
nodeName: "test-node",
registerAnno: "hami.io/node-register-Ascend310P",
handshakeAnno: "hami.io/node-handshake-Ascend310P",
mgr: &FakeManager{
GetDevicesFunc: func() []*manager.Device {
return []*manager.Device{
{UUID: "uuid1", Memory: 21527, AICore: 8, Health: true},
}
},
VDeviceCountFunc: func() int { return 1 },
CommonWordFunc: func() string { return "Ascend310P" },
IsHamiVnpuCoreFunc: func() bool { return true },
},
nodes: []*v1.Node{
{ObjectMeta: metav1.ObjectMeta{Name: "test-node", Annotations: map[string]string{}}},
},
},
want: registerHAMiWant{
deviceCount: 1,
deviceCheck: func(t *testing.T, devs []*device.DeviceInfo) {
t.Helper()
if devs[0].Devcore != HamiVnpuCoreMaxPercent {
t.Fatalf("device Devcore = %d, want %d in hami-vnpu-core mode", devs[0].Devcore, HamiVnpuCoreMaxPercent)
}
},
annotationCheck: func(t *testing.T, annos map[string]string) {
t.Helper()
if annos[VNPUNodeSelectorAnnotation] != "true" {
t.Fatalf("VNPUNodeSelectorAnnotation = %q, want 'true'", annos[VNPUNodeSelectorAnnotation])
}
},
},
},
{
name: "IsHamiVnpuCore_False",
args: registerHAMiArgs{
Expand Down
3 changes: 3 additions & 0 deletions internal/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ const (
VNPUModeAnnotation = "huawei.com/vnpu-mode"
VNPUModeHamiCore = "hami-core"
VNPUNodeSelectorAnnotation = "hami-vnpu-core"
// HamiVnpuCoreMaxPercent is the total allocatable core units per device in
// soft-slice (hami-vnpu-core) mode, where core requests are percentages.
HamiVnpuCoreMaxPercent = 100
)

var (
Expand Down
Loading