Skip to content

Commit

Permalink
Merge pull request #1650 from maryamtahhan/cleanup-models
Browse files Browse the repository at this point in the history
refactor: CreateProcessPowerEstimatorModel()
  • Loading branch information
maryamtahhan authored Sep 11, 2024
2 parents 097541c + 697d27c commit 14708e1
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions pkg/model/process_energy.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,25 +109,26 @@ func createProcessPowerModelConfig(powerSourceTarget string, processFeatureNames
}

func CreateProcessPowerEstimatorModel(processFeatureNames []string, bpfSupportedMetrics bpf.SupportedMetrics) {
var err error
modelConfig := createProcessPowerModelConfig(config.ProcessPlatformPowerKey(), processFeatureNames, types.PlatformEnergySource, bpfSupportedMetrics)
modelConfig.IsNodePowerModel = false
processPlatformPowerModel, err = createPowerModelEstimator(modelConfig)
if err == nil {
klog.V(1).Infof("Using the %s Power Model to estimate Process Platform Power", modelConfig.ModelType.String()+"/"+modelConfig.ModelOutputType.String())
klog.V(1).Infof("Process feature names: %v", modelConfig.ProcessFeatureNames)
} else {
klog.Infof("Failed to create %s Power Model to estimate Process Platform Power: %v\n", modelConfig.ModelType.String()+"/"+modelConfig.ModelOutputType.String(), err)
keys := map[string]string{
config.ProcessPlatformPowerKey(): types.PlatformEnergySource,
config.ProcessComponentsPowerKey(): types.ComponentEnergySource,
}

modelConfig = createProcessPowerModelConfig(config.ProcessComponentsPowerKey(), processFeatureNames, types.ComponentEnergySource, bpfSupportedMetrics)
modelConfig.IsNodePowerModel = false
processComponentPowerModel, err = createPowerModelEstimator(modelConfig)
if err == nil {
klog.V(1).Infof("Using the %s Power Model to estimate Process Component Power", modelConfig.ModelType.String()+"/"+modelConfig.ModelOutputType.String())
klog.V(1).Infof("Process feature names: %v", modelConfig.ProcessFeatureNames)
} else {
klog.Infof("Failed to create %s Power Model to estimate Process Component Power: %v\n", modelConfig.ModelType.String()+"/"+modelConfig.ModelOutputType.String(), err)
for k, v := range keys {
modelConfig := createProcessPowerModelConfig(k, processFeatureNames, v, bpfSupportedMetrics)
modelConfig.IsNodePowerModel = false
m, err := createPowerModelEstimator(modelConfig)
switch k {
case config.ProcessPlatformPowerKey():
processPlatformPowerModel = m
case config.ProcessComponentsPowerKey():
processComponentPowerModel = m
}
if err != nil {
klog.Infof("Failed to create %s Power Model to estimate %s Power: %v\n", modelConfig.ModelType.String()+"/"+modelConfig.ModelOutputType.String(), k, err)
} else {
klog.V(1).Infof("Using the %s Power Model to estimate %s Power", m.GetModelType(), k)
klog.V(1).Infof("Feature names: %v", m.GetProcessFeatureNamesList())
}
}
}

Expand Down

0 comments on commit 14708e1

Please sign in to comment.