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

Allow switching between MPI and srun as backends #203

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 7 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: 1 addition & 1 deletion .ci_support/environment-old.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ dependencies:
- openmpi
- numpy =1.23.5
- mpi4py =3.1.4
- pympipool =0.7.0
- pympipool =0.7.2
- ase =3.20.1
- scipy =1.9.3
5 changes: 4 additions & 1 deletion pylammpsmpi/wrapper/ase.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def __init__(
log_file=None,
library=None,
diable_log_file=True,
use_srun=False,
):
self._logger = logger
self._prism = None
Expand All @@ -45,7 +46,9 @@ def __init__(
)
else:
self._interactive_library = LammpsBase(
cores=self._cores, working_directory=working_directory
cores=self._cores,
working_directory=working_directory,
use_srun=use_srun,
)

def interactive_lib_command(self, command):
Expand Down
21 changes: 17 additions & 4 deletions pylammpsmpi/wrapper/concurrent.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
interface_bootup,
cancel_items_in_queue,
MpiExecInterface,
SrunInterface,
)


Expand All @@ -32,20 +33,29 @@ def execute_async(
cores=1,
oversubscribe=False,
cwd=None,
use_srun=False,
):
executable = os.path.join(
os.path.dirname(os.path.abspath(__file__)), "..", "mpi", "lmpmpi.py"
)
cmds = [sys.executable, executable]
if cmdargs is not None:
cmds.extend(cmdargs)
interface = interface_bootup(
command_lst=cmds,
connections=MpiExecInterface(
if use_srun:
connection_interface = SrunInterface(
cwd=cwd,
cores=cores,
oversubscribe=oversubscribe,
),
)
else:
connection_interface = MpiExecInterface(
cwd=cwd,
cores=cores,
oversubscribe=oversubscribe,
)
interface = interface_bootup(
command_lst=cmds,
connections=connection_interface,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix the syntax error due to incorrect indentation.

-        connections=connection_interface),
+        connections=connection_interface,

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
connections=connection_interface,
connections=connection_interface,

)
jan-janssen marked this conversation as resolved.
Show resolved Hide resolved
while True:
task_dict = future_queue.get()
Expand All @@ -65,13 +75,15 @@ def __init__(
oversubscribe=False,
working_directory=".",
cmdargs=None,
use_srun=False,
):
self.cores = cores
self.working_directory = working_directory
self._future_queue = Queue()
self._process = None
self._oversubscribe = oversubscribe
self._cmdargs = cmdargs
self._use_srun = use_srun
self._start_process()

def _start_process(self):
Expand All @@ -83,6 +95,7 @@ def _start_process(self):
"cores": self.cores,
"oversubscribe": self._oversubscribe,
"cwd": self.working_directory,
"use_srun": self._use_srun,
},
)
self._process.start()
Expand Down
2 changes: 2 additions & 0 deletions pylammpsmpi/wrapper/extended.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ def __init__(
client=None,
mode="local",
cmdargs=None,
use_srun=False,
):
self.cores = cores
self.working_directory = working_directory
Expand All @@ -259,6 +260,7 @@ def __init__(
oversubscribe=self.oversubscribe,
working_directory=self.working_directory,
cmdargs=cmdargs,
use_srun=use_srun,
)

def __getattr__(self, name):
Expand Down
Loading