Skip to content

Commit

Permalink
Fix wrongly reported CUE_HT attribute (#1630)
Browse files Browse the repository at this point in the history
This attribute is only used on the GUI and API to report whether a host
CPU architecture is hyperthreaded or not. For some reason I couldn't get
to the bottom of, this attribute was always hardcoded to true.
  • Loading branch information
DiegoTavares authored Feb 13, 2025
1 parent edcec64 commit 8517a85
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
5 changes: 4 additions & 1 deletion rqd/rqd/rqcore.py
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,10 @@ def __createEnvVariables(self):
self.frameEnv['CUE_THREADS'] = str(max(
int(self.frameEnv['CUE_THREADS']),
len(self.runFrame.attributes['CPU_LIST'].split(','))))
self.frameEnv['CUE_HT'] = "True"
if self.rqCore.machine.getHyperthreadingMultiplier() > 1:
self.frameEnv['CUE_HT'] = "True"
else:
self.frameEnv['CUE_HT'] = "False"

# Add GPU's to use all assigned GPU cores
if 'GPU_LIST' in self.runFrame.attributes:
Expand Down
8 changes: 6 additions & 2 deletions rqd/rqd/rqmachine.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ def getLoadAvg(self):
with open(rqd.rqconstants.PATH_LOADAVG, "r", encoding='utf-8') as loadAvgFile:
loadAvg = int(float(loadAvgFile.read().split()[0]) * 100)
if self.__enabledHT():
loadAvg = loadAvg // self.__getHyperthreadingMultiplier()
loadAvg = loadAvg // self.getHyperthreadingMultiplier()
loadAvg = loadAvg + rqd.rqconstants.LOAD_MODIFIER
loadAvg = max(loadAvg, 0)
return loadAvg
Expand Down Expand Up @@ -894,7 +894,11 @@ def getBootReport(self):
def __enabledHT(self):
return 'hyperthreadingMultiplier' in self.__renderHost.attributes

def __getHyperthreadingMultiplier(self):
def getHyperthreadingMultiplier(self):
"""
Multiplied used to compute the number of threads that can be allocated simultaneously
on a core
"""
return int(self.__renderHost.attributes['hyperthreadingMultiplier'])

def setupTaskset(self):
Expand Down
2 changes: 1 addition & 1 deletion rqd/tests/rqmachine_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ def test_getLoadAvg(self):
@mock.patch.object(
rqd.rqmachine.Machine, '_Machine__enabledHT', new=mock.MagicMock(return_value=True))
@mock.patch.object(
rqd.rqmachine.Machine, '_Machine__getHyperthreadingMultiplier',
rqd.rqmachine.Machine, 'getHyperthreadingMultiplier',
new=mock.MagicMock(return_value=2))
def test_getLoadAvgHT(self):
self.loadavg.set_contents(LOADAVG_HIGH_USAGE)
Expand Down

0 comments on commit 8517a85

Please sign in to comment.