Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.0] set env variable OMP_NUM_THREADS corresponding to number of processors #7313

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/DIRAC/Resources/Computing/InProcessComputingElement.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ def submitJob(self, executableFile, proxy=None, inputs=None, **kwargs):
:return: S_OK(payload exit code) / S_ERROR() if submission issue
"""
payloadEnv = dict(os.environ)
if mp_threads := kwargs.get("numberOfProcessors"):
payloadEnv["OMP_NUM_THREADS"] = str(mp_threads)
chaen marked this conversation as resolved.
Show resolved Hide resolved
payloadProxy = ""
if proxy:
self.log.verbose("Setting up proxy for payload")
Expand Down
8 changes: 1 addition & 7 deletions src/DIRAC/Resources/Computing/PoolComputingElement.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,7 @@ def submitJob(self, executableFile, proxy=None, inputs=None, **kwargs):
# Here we define task kwargs: adding complex objects like thread.Lock can trigger errors in the task
taskKwargs = {"InnerCESubmissionType": self.innerCESubmissionType}
taskKwargs["jobDesc"] = kwargs.get("jobDesc", {})
if self.innerCESubmissionType == "Sudo":
for nUser in range(MAX_NUMBER_OF_SUDO_UNIX_USERS):
if nUser not in self.userNumberPerTask.values():
break
taskKwargs["NUser"] = nUser
if "USER" in os.environ:
taskKwargs["PayloadUser"] = os.environ["USER"] + f"p{str(nUser).zfill(2)}"
taskKwargs["numberOfProcessors"] = kwargs.get("numberOfProcessors")

# Submission
future = self.pPool.submit(executeJob, executableFile, proxy, self.taskID, inputs, **taskKwargs)
Expand Down
4 changes: 4 additions & 0 deletions src/DIRAC/Resources/Computing/SingularityComputingElement.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
r"Xrd.*",
r"DIRAC_.*",
r"BEARER_TOKEN.*",
r"OMP_NUM_TREADS",
]
ENV_VAR_WHITELIST = re.compile(r"^(" + r"|".join(ENV_VAR_WHITELIST) + r")$")

Expand Down Expand Up @@ -374,6 +375,9 @@ def submitJob(self, executableFile, proxy=None, **kwargs):
baseDir = ret["baseDir"]
tmpDir = ret["tmpDir"]

if mp_threads := kwargs.get("numberOfProcessors"):
os.environ["OMP_NUM_THREADS"] = str(mp_threads)

if proxy:
payloadProxyLoc = ret["proxyLocation"]

Expand Down
Loading