On 2021/7/22 23:05, Andrew Jones wrote:
On Thu, Jul 22, 2021 at 10:59:11PM +0800, wangyanan (Y) wrote:
Ok. If we remove the rounding, then the calculation code has to be modified
to be like the following. We have to separately consider the case that cpus
and maxcpus are both omitted (e.g. -smp sockets=16).

maxcpus = maxcpus > 0 ? maxcpus : cpus;

if (cpus == 0 && maxcpus == 0) {
     sockets = sockets > 0 ? sockets : 1;
     cores = cores > 0 ? cores : 1;
     threads = threads > 0 ? threads : 1;
     goto cal;
}

if (sockets == 0) {
...
} else if (cores == 0) {
...
} else if (threads == 0) {
...
}

cal:
maxcpus = maxcpus > 0 ? maxcpus : sockets * cores * threads;
cpus = cpus > 0 ? cpus : maxcpus;
Whatever works, but hopefully you can avoid an ugly goto.

Well, it can be avoided.

Thanks,
Yanan


Reply via email to