Skip to content

Commit

Permalink
Merge branch 'tickets/DM-36831'
Browse files Browse the repository at this point in the history
  • Loading branch information
leeskelvin committed Nov 3, 2022
2 parents cd6daec + 8d8c832 commit f60f162
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 1 deletion.
3 changes: 3 additions & 0 deletions doc/changes/DM-36831.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Always disable implicit threading (e.g. in OpenBLAS) by default in `pipetask run`, even when not using `-j`.

The new `--enable-implicit-threading` can be used to turn it back on.
1 change: 1 addition & 0 deletions python/lsst/ctrl/mpexec/cli/opt/optionGroups.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ def __init__(self) -> None:
ctrlMpExecOpts.graph_fixup_option(),
ctrlMpExecOpts.mock_option(),
ctrlMpExecOpts.summary_option(),
ctrlMpExecOpts.enable_implicit_threading_option(),
]


Expand Down
10 changes: 10 additions & 0 deletions python/lsst/ctrl/mpexec/cli/opt/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,16 @@
)


enable_implicit_threading_option = MWOptionDecorator(
"--enable-implicit-threading",
help=unwrap(
"""Do not disable implicit threading use by third-party libraries (e.g. OpenBLAS).
Implicit threading is always disabled during execution with multiprocessing."""
),
is_flag=True,
)


task_option = MWOptionDecorator(
"-t",
"--task",
Expand Down
8 changes: 7 additions & 1 deletion python/lsst/ctrl/mpexec/cli/script/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def run( # type: ignore
summary,
mock,
mock_configs,
enable_implicit_threading,
**kwargs,
):
"""Implements the command line interface `pipetask run` subcommand, should
Expand Down Expand Up @@ -148,10 +149,14 @@ def run( # type: ignore
If `True` then run mock pipeline instead of real one.
mock_configs : `list` [ `PipelineAction` ]
A list of config overrides for mock tasks.
enable_implicit_threading : `bool`, optional
If `True`, do not disable implicit threading by third-party libraries.
Implicit threading is always disabled during actual quantum execution
if ``processes > 1``.
kwargs : `dict` [`str`, `str`]
Ignored; click commands may accept options for more than one script
function and pass all the option kwargs to each of the script functions
which ingore these unused kwargs.
which ignore these unused kwargs.
"""
args = SimpleNamespace(
pdb=pdb,
Expand Down Expand Up @@ -180,6 +185,7 @@ def run( # type: ignore
summary=summary,
mock=mock,
mock_configs=mock_configs,
enable_implicit_threading=enable_implicit_threading,
)

f = CmdLineFwk()
Expand Down
4 changes: 4 additions & 0 deletions python/lsst/ctrl/mpexec/cmdLineFwk.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
buildExecutionButler,
)
from lsst.utils import doImportType
from lsst.utils.threads import disable_implicit_threading

from . import util
from .dotTools import graph2dot, pipeline2dot
Expand Down Expand Up @@ -676,6 +677,9 @@ def runPipeline(
if args.extend_run:
args.skip_existing = True

if not args.enable_implicit_threading:
disable_implicit_threading()

# make butler instance
if butler is None:
butler = _ButlerFactory.makeWriteButler(args, graph.iterTaskGraph())
Expand Down
3 changes: 3 additions & 0 deletions tests/test_cmdLineFwk.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,9 @@ def testSimpleQGraph(self):
fwk.runPipeline(qgraph, taskFactory, args)
self.assertEqual(taskFactory.countExec, self.nQuanta)

# test that we've disabled implicit threading
self.assertEqual(os.environ["OMP_NUM_THREADS"], "1")

def testEmptyQGraph(self):
"""Test that making an empty QG produces the right error messages."""
# We make QG generation fail by populating one input collection in the
Expand Down

0 comments on commit f60f162

Please sign in to comment.