Fix logic to optimize GRES topology with respect to allocated CPUs.