@@ -215,28 +215,40 @@ func Compute(env Env, params Params) (Values, Score, error) {
215215 return params .DefaultAllocation (), Score {}, err
216216 }
217217
218- smtLevel := params .SMTLevel ()
219218 totCPUs := params .TotalCPUs ()
220219 score := Score {Cost : result .F }
221- x_cr := int (math .Round (result .Location .X [0 ]))
222- x_c := asMultipleOf (x_cr , smtLevel )
223- env .Log .Printf ("Optimization value: Xc=%v -> Xc=%v (SMTLevel=%v)" , x_cr , x_c , smtLevel )
220+ x_c := int (math .Round (result .Location .X [0 ]))
224221
225- vals := Values {
222+ opt := Values {
226223 ReservedCPUCount : x_c ,
227224 IsolatedCPUCount : totCPUs - x_c , // we can use x_w, but we just leverage invariants
228225 }
229- env .Log .Printf ("Optimization result: %s" , vals .String ())
226+ env .Log .Printf ("Optimization result: %s" , opt .String ())
230227
231- if err := Validate (params , vals ); err != nil {
228+ if err := Validate (params , opt ); err != nil {
232229 env .Log .Printf ("Optimization invalid: %v" , err )
233230 return params .DefaultAllocation (), Score {}, err
234231 }
235232
233+ // postprocessing must be done after successfull validation
234+ vals := postProcess (params , opt )
235+ env .Log .Printf ("Optimization postprocess. %s => %s" , opt .String (), vals .String ())
236+
236237 env .Log .Printf ("Optimization done. Score: %v %s totalCPUs=%d" , score .String (), vals .String (), totCPUs )
237238 return vals , score , nil
238239}
239240
241+ func postProcess (params Params , vals Values ) Values {
242+ Tc := params .TotalCPUs ()
243+ sl := params .SMTLevel ()
244+ x_c := asMultipleOf (vals .ReservedCPUCount , sl )
245+ ret := Values {
246+ ReservedCPUCount : x_c ,
247+ IsolatedCPUCount : Tc - x_c ,
248+ }
249+ return ret
250+ }
251+
240252func asMultipleOf (v , x int ) int {
241253 r := v % x
242254 if r == 0 {
0 commit comments