def computejobcpus(self):
""" stats for the cores on the nodes that were assigend to the job (if available) """
proc = self._job.getdata('proc')
if proc == None:
return {"error": ProcessingError.CPUSET_UNKNOWN}, {"error": ProcessingError.CPUSET_UNKNOWN}
cpusallowed = self._job.getdata('proc')['cpusallowed']
ratios = numpy.empty((self._ncpumetrics, self._totalcores), numpy.double)
coreindex = 0
for host, last in self._last.iteritems():
elapsed = last - self._first[host]
if host in cpusallowed and 'error' not in cpusallowed[host]:
elapsed = elapsed[:, cpusallowed[host]]
else:
return {"error": ProcessingError.CPUSET_UNKNOWN}, {"error": ProcessingError.CPUSET_UNKNOWN}
coresperhost = len(elapsed[0, :])
ratios[:, coreindex:(coreindex+coresperhost)] = 1.0 * elapsed / numpy.sum(elapsed, 0)
coreindex += coresperhost
allowedcores = numpy.array(ratios[:, :coreindex])
results = {}
for i, name in enumerate(self._outnames):
results[name] = calculate_stats(allowedcores[i, :])
results['all'] = {"cnt": coreindex}
effective = numpy.compress(allowedcores[1, :] < 0.95, allowedcores , axis=1)
effectiveresults = {
'all': len(effective[i, :])
}
if effectiveresults['all'] > 0:
for i, name in enumerate(self._outnames):
effectiveresults[name] = calculate_stats(effective[i, :])
return results, effectiveresults
评论列表
文章目录