Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If all devices are pre-volta, skip setting set_default_device_pinned_mem_limit and set_default_active_thread_percentage. #971

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
36 changes: 26 additions & 10 deletions cmd/mps-control-daemon/mps/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}