Skip to content

Commit

Permalink
Let the OS handle processor affinities.
Browse files Browse the repository at this point in the history
  • Loading branch information
zuckerruebe committed Apr 26, 2024
1 parent 5be7277 commit 7c7494c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
2 changes: 1 addition & 1 deletion pytrnsys/rsim/getConfigMixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def addParametricVariations(self, variations):
sizeCase = len(variations[n]) - 2
if sizeCase != sizeOneVariation:
raise ValueError(
"for combineAllCases=False all variations must have same lenght :%d case n:%d has a lenght of :%d"
"for combineAllCases=False all variations must have same length :%d case n:%d has a length of :%d"
% (sizeOneVariation, n + 1, sizeCase)
)

Expand Down
15 changes: 3 additions & 12 deletions pytrnsys/rsim/runParallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
logger = logging.getLogger("root")
import pytrnsys.trnsys_util.LogTrnsys as LogTrnsys

# from __future__ import print_function


def getNumberOfCPU():
"""Returns the number of CPUs in the system"""
num = 1
Expand All @@ -40,10 +37,6 @@ def getNumberOfCPU():
return num


def getExclusiveAffinityMask(cpu):
return 2 ** (cpu - 1)


def runParallel(
cmds, reduceCpu=0, outputFile=False, estimedCPUTime=0.33, delayTime=0.3, trackingFile=None, masterFile=None
):
Expand Down Expand Up @@ -102,7 +95,7 @@ def runParallel(
cpu = 1

for cmd in cmds:
newTask = "start /wait /affinity %s " % (getExclusiveAffinityMask(cpu)) + cmd
newTask = cmd

newCmds.append(newTask)

Expand Down Expand Up @@ -132,7 +125,7 @@ def runParallel(
for core in cP.keys():
# print cP[core]

cP[core]["cmd"] = "start /wait /affinity %s " % (getExclusiveAffinityMask(cP[core]["cpu"])) + openCmds.pop(0)
cP[core]["cmd"] = openCmds.pop(0)
cP[core]["case"] = caseNr
caseNr += 1

Expand Down Expand Up @@ -300,9 +293,7 @@ def fail():
# assign new command if there are open commands:

if openCmds:
cP[core]["cmd"] = "start /wait /affinity %s " % (
getExclusiveAffinityMask(cP[core]["cpu"])
) + openCmds.pop(0)
cP[core]["cmd"] = openCmds.pop(0)
cP[core]["case"] = caseNr
caseNr += 1
activeP[cP[core]["cpu"] - 1] = 1
Expand Down

0 comments on commit 7c7494c

Please sign in to comment.