From 4b7a0cd62909aed2cef9c9bc10130a12f30407a9 Mon Sep 17 00:00:00 2001 From: bcc829 Date: Mon, 30 Sep 2024 17:41:35 +0900 Subject: [PATCH] If all devices are pre-volta, skip setting set_default_device_pinned_mem_limit and set_default_active_thread_percentage. Signed-off-by: bcc829 --- cmd/mps-control-daemon/mps/daemon.go | 36 ++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/cmd/mps-control-daemon/mps/daemon.go b/cmd/mps-control-daemon/mps/daemon.go index 719d686ea..53c613c1f 100644 --- a/cmd/mps-control-daemon/mps/daemon.go +++ b/cmd/mps-control-daemon/mps/daemon.go @@ -116,19 +116,21 @@ func (d *Daemon) Start() error { return err } - for index, limit := range d.perDevicePinnedDeviceMemoryLimits() { - _, err := d.EchoPipeToControl(fmt.Sprintf("set_default_device_pinned_mem_limit %s %s", index, limit)) - if err != nil { - return fmt.Errorf("error setting pinned memory limit for device %v: %w", index, err) + if isAllDevicesPreVolta := d.isAllDevicesPreVolta(); !isAllDevicesPreVolta { + for index, limit := range d.perDevicePinnedDeviceMemoryLimits() { + _, err := d.EchoPipeToControl(fmt.Sprintf("set_default_device_pinned_mem_limit %s %s", index, limit)) + if err != nil { + return fmt.Errorf("error setting pinned memory limit for device %v: %w", index, err) + } } - } - if threadPercentage := d.activeThreadPercentage(); threadPercentage != "" { - _, err := d.EchoPipeToControl(fmt.Sprintf("set_default_active_thread_percentage %s", threadPercentage)) - if err != nil { - return fmt.Errorf("error setting active thread percentage: %w", err) + if threadPercentage := d.activeThreadPercentage(); threadPercentage != "" { + _, err := d.EchoPipeToControl(fmt.Sprintf("set_default_active_thread_percentage %s", threadPercentage)) + if err != nil { + return fmt.Errorf("error setting active thread percentage: %w", err) + } } } - + statusFile, err := os.Create(d.startedFile()) if err != nil { return err @@ -278,3 +280,17 @@ func (m *Daemon) activeThreadPercentage() string { return fmt.Sprintf("%d", 100/replicasPerDevice) } + +func (m *Daemon) isAllDevicesPreVolta() bool { + if len(m.Devices()) == 0 { + return false + } + + for _, device := range m.Devices() { + if isVoltaDevice := (*mpsDevice)(device).isAtLeastVolta(); isVoltaDevice { + return false + } + } + + return true +} \ No newline at end of file