Skip to content

Commit 1e5cb5f

Browse files
authored
Merge pull request #5993 from aldbr/cherry-pick-2-b2c7cbff9-integration
[sweep:integration] dirac-wms-get-cpu-norm: support multi-core allocations
2 parents 3e312f8 + 1c1e05d commit 1e5cb5f

File tree

1 file changed

+26
-9
lines changed

1 file changed

+26
-9
lines changed

src/DIRAC/WorkloadManagementSystem/scripts/dirac_wms_cpu_normalization.py

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@
1111
CPUNormalizationFactor = 23.7 # corrected value (by JobScheduling/CPUNormalizationCorrection)
1212
DB12measured = 15.4
1313
}
14-
15-
DB12measured is up to now wrote down but never used.
1614
"""
17-
from db12 import single_dirac_benchmark
15+
from db12 import multiple_dirac_benchmark
1816

1917
import DIRAC
2018
from DIRAC.Core.Base.Script import Script
@@ -25,36 +23,55 @@
2523

2624
@Script()
2725
def main():
26+
Script.registerSwitch("N:", "NumberOfProcessors=", "Run n parallel copies of the benchmark")
2827
Script.registerSwitch("U", "Update", "Update dirac.cfg with the resulting value")
2928
Script.registerSwitch("R:", "Reconfig=", "Update given configuration file with the resulting value")
3029
Script.parseCommandLine(ignoreErrors=True)
3130

3231
update = False
3332
configFile = None
33+
numberOfProcessors = 0
3434

3535
for unprocSw in Script.getUnprocessedSwitches():
3636
if unprocSw[0] in ("U", "Update"):
3737
update = True
3838
elif unprocSw[0] in ("R", "Reconfig"):
3939
configFile = unprocSw[1]
40+
elif unprocSw[0] in ("N", "NumberOfProcessors"):
41+
try:
42+
numberOfProcessors = int(unprocSw[1])
43+
except ValueError:
44+
gLogger.warn("Cannot make benchmark measurements: NumberOfProcessors is not a number")
45+
46+
# if numberOfProcessors has not been provided, try to get it from the configuration
47+
if not numberOfProcessors:
48+
numberOfProcessors = gConfig.getValue("/Resources/Computing/CEDefaults/NumberOfProcessors", 1)
49+
50+
gLogger.info("Computing benchmark measurements on", "%d processor(s)..." % numberOfProcessors)
4051

4152
# we want to get the logs coming from db12
4253
gLogger.enableLogsFromExternalLibs()
43-
result = single_dirac_benchmark()
54+
55+
# multiprocessor allocations generally have a CPU Power lower than single core one.
56+
# in order to avoid having wrong estimations, we run multiple copies of the benchmark simultaneously
57+
result = multiple_dirac_benchmark(numberOfProcessors)
4458

4559
if result is None:
4660
gLogger.error("Cannot make benchmark measurements")
4761
DIRAC.exit(1)
4862

49-
db12Measured = round(result["NORM"], 1)
63+
# we take a conservative approach and use the minimum value returned as the CPU Power
64+
db12Result = min(result["raw"])
65+
# because hardware is continuously evolving, original benchmark scores might need a correction
5066
corr = Operations().getValue("JobScheduling/CPUNormalizationCorrection", 1.0)
51-
norm = round(result["NORM"] / corr, 1)
5267

53-
gLogger.notice("Estimated CPU power is %.1f HS06" % norm)
68+
gLogger.info("Applying a correction on the CPU power:", corr)
69+
cpuPower = round(db12Result / corr, 1)
70+
71+
gLogger.notice("Estimated CPU power is %.1f HS06" % cpuPower)
5472

5573
if update:
56-
gConfig.setOptionValue("/LocalSite/CPUNormalizationFactor", norm)
57-
gConfig.setOptionValue("/LocalSite/DB12measured", db12Measured)
74+
gConfig.setOptionValue("/LocalSite/CPUNormalizationFactor", cpuPower)
5875

5976
if configFile:
6077
gConfig.dumpLocalCFGToFile(configFile)

0 commit comments

Comments
 (0)