func ParseSMPFlags() (int, error) { var smp, maxcpus, cores, threads, sockets uint64 = 1, 1, 1, 1, 1 m, e := util.ParseFlagsSubst(smpflag, "smp") for k, v := range m { switch k { case "maxcpus": maxcpus, e = strconv.ParseUint(v, 0, 0) case "cores": cores, e = strconv.ParseUint(v, 0, 0) case "threads": threads, e = strconv.ParseUint(v, 0, 0) case "sockets": sockets, e = strconv.ParseUint(v, 0, 0) case "smp": smp, e = strconv.ParseUint(v, 0, 0) default: fmt.Printf("Dont understand options", k, v) continue } if e != nil { goto out } } // Suppress error untill we figure out the meaning of 'maxcpus' _ = maxcpus // smp is number of cores pers socket, number threads per core // and number of such sockets // smp = cores * threads * sockets // Need to compute the SMP options form what ever is given // If alone smp is given, using above equation calculate other values // sockets = 1 // cores = smp / (sockets * threads) // threads = smp / (sockets * cores) // Recalculate if smp != sockets*cores*threads { if sockets > 1 { smp = sockets * cores * threads } else { cores = smp / (sockets * threads) threads = smp / (sockets * cores) } } out: return int(smp), e }
/* Try to process as much as possible, rest send to specific platform for interpretation */ func ParsePlatFlags() (map[string]string, error) { m, e := util.ParseFlagsSubst(platflags, "plat") if e != nil { goto out } for k, v := range m { switch k { case "mem": //p.SetMem(memParse(v)) memSize, _ = util.ParseMem(v) case "?": var s string for i := range availPlats { s += " vendor: " + availPlats[i].vendor + " model: " + availPlats[i].model + "\n" } e = errors.New(s) case "vendor": vendor = v case "model": model = v case "plat": platname = v default: continue } // if any cases returns non-nil if e != nil { goto out } // Delete the consumed options delete(m, k) } out: return m, e }