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

Add SLURM backend #130

Merged
merged 2 commits into from
Jul 26, 2023
Merged
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
17 changes: 15 additions & 2 deletions pylammpsmpi/wrapper/concurrent.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,22 @@


def _initialize_socket(
interface, cmdargs, cwd, cores, oversubscribe=False, enable_flux_backend=False
interface,
cmdargs,
cwd,
cores,
oversubscribe=False,
enable_flux_backend=False,
enable_slurm_backend=False,
):
port_selected = interface.bind_to_random_port()
executable = os.path.join(
os.path.dirname(os.path.abspath(__file__)), "../mpi", "lmpmpi.py"
)
if enable_flux_backend:
cmds = ["flux", "run"]
elif enable_slurm_backend:
cmds = ["srun"]
else:
cmds = ["mpiexec"]
if oversubscribe:
Expand All @@ -42,7 +50,7 @@ def _initialize_socket(
"--zmqport",
str(port_selected),
]
if enable_flux_backend:
if enable_flux_backend or enable_slurm_backend:
cmds += [
"--host",
socket.gethostname(),
Expand All @@ -59,6 +67,7 @@ def execute_async(
cores,
oversubscribe=False,
enable_flux_backend=False,
enable_slurm_backend=False,
cwd=None,
queue_adapter=None,
queue_adapter_kwargs=None,
Expand All @@ -71,6 +80,7 @@ def execute_async(
cwd=cwd,
cores=cores,
enable_flux_backend=enable_flux_backend,
enable_slurm_backend=enable_slurm_backend,
oversubscribe=oversubscribe,
)
while True:
Expand All @@ -90,6 +100,7 @@ def __init__(
cores=8,
oversubscribe=False,
enable_flux_backend=False,
enable_slurm_backend=False,
working_directory=".",
cmdargs=None,
queue_adapter=None,
Expand All @@ -101,6 +112,7 @@ def __init__(
self._process = None
self._oversubscribe = oversubscribe
self._enable_flux_backend = enable_flux_backend
self._enable_slurm_backend = enable_slurm_backend
self._cmdargs = cmdargs
self._queue_adapter = queue_adapter
self._queue_adapter_kwargs = queue_adapter_kwargs
Expand All @@ -115,6 +127,7 @@ def _start_process(self):
"cores": self.cores,
"oversubscribe": self._oversubscribe,
"enable_flux_backend": self._enable_flux_backend,
"enable_slurm_backend": self._enable_slurm_backend,
"cwd": self.working_directory,
"queue_adapter": self._queue_adapter,
"queue_adapter_kwargs": self._queue_adapter_kwargs,
Expand Down
3 changes: 3 additions & 0 deletions pylammpsmpi/wrapper/extended.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ def __init__(
cores=1,
oversubscribe=False,
enable_flux_backend=False,
enable_slurm_backend=False,
working_directory=".",
client=None,
mode="local",
Expand All @@ -256,12 +257,14 @@ def __init__(
self.working_directory = working_directory
self.oversubscribe = oversubscribe
self.enable_flux_backend = enable_flux_backend
self.enable_slurm_backend = enable_slurm_backend
self.client = client
self.mode = mode
self.lmp = LammpsConcurrent(
cores=self.cores,
oversubscribe=self.oversubscribe,
enable_flux_backend=self.enable_flux_backend,
enable_slurm_backend=self.enable_slurm_backend,
working_directory=self.working_directory,
cmdargs=cmdargs,
queue_adapter=queue_adapter,
Expand Down