WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit e595d44

Browse files
authored
Merge pull request #131 from pyiron/connection
Use new pympipool interface
2 parents 256d0e3 + 2f1487d commit e595d44

File tree

5 files changed

+39
-68
lines changed

5 files changed

+39
-68
lines changed

.ci_support/environment-mpich.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ dependencies:
88
- mpich
99
- numpy =1.23.5
1010
- mpi4py =3.1.4
11-
- pympipool =0.5.6
11+
- pympipool =0.6.0
1212
- ase =3.22.1
1313
- scipy =1.10.1

.ci_support/environment-openmpi.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ dependencies:
88
- openmpi
99
- numpy =1.23.5
1010
- mpi4py =3.1.4
11-
- pympipool =0.5.6
11+
- pympipool =0.6.0
1212
- ase =3.22.1
1313
- scipy =1.10.1

pylammpsmpi/mpi/lmpmpi.py

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
import sys
99
from lammps import lammps
1010
from pympipool import (
11-
connect_to_socket_interface,
12-
send_result,
13-
close_connection,
14-
receive_instruction,
11+
interface_connect,
12+
interface_send,
13+
interface_shutdown,
14+
interface_receive,
1515
)
1616

1717
__author__ = "Sarath Menon, Jan Janssen"
@@ -463,37 +463,40 @@ def _gather_data_from_all_processors(data):
463463

464464

465465
def _run_lammps_mpi(argument_lst):
466+
index_selected = argument_lst.index("--zmqport")
467+
port_selected = argument_lst[index_selected + 1]
468+
if "--host" in argument_lst:
469+
index_selected = argument_lst.index("--host")
470+
host = argument_lst[index_selected + 1]
471+
else:
472+
host = "localhost"
473+
argument_red_lst = argument_lst[:index_selected]
466474
if MPI.COMM_WORLD.rank == 0:
467-
port_selected = argument_lst[argument_lst.index("--zmqport") + 1]
468-
if "--host" in argument_lst:
469-
host = argument_lst[argument_lst.index("--host") + 1]
470-
else:
471-
host = "localhost"
472-
context, socket = connect_to_socket_interface(host=host, port=port_selected)
475+
context, socket = interface_connect(host=host, port=port_selected)
473476
else:
474477
context, socket = None, None
475478
# Lammps executable
476479
args = ["-screen", "none"]
477-
if len(argument_lst) > 3:
478-
args.extend(argument_lst[3:])
480+
if len(argument_red_lst) > 1:
481+
args.extend(argument_red_lst[1:])
479482
job = lammps(cmdargs=args)
480483
while True:
481484
if MPI.COMM_WORLD.rank == 0:
482-
input_dict = receive_instruction(socket=socket)
485+
input_dict = interface_receive(socket=socket)
483486
else:
484487
input_dict = None
485488
input_dict = MPI.COMM_WORLD.bcast(input_dict, root=0)
486489
if "shutdown" in input_dict.keys() and input_dict["shutdown"]:
487490
job.close()
488491
if MPI.COMM_WORLD.rank == 0:
489-
send_result(socket=socket, result_dict={"result": True})
490-
close_connection(socket=socket, context=context)
492+
interface_send(socket=socket, result_dict={"result": True})
493+
interface_shutdown(socket=socket, context=context)
491494
break
492495
output = select_cmd(input_dict["command"])(
493496
job=job, funct_args=input_dict["args"]
494497
)
495498
if MPI.COMM_WORLD.rank == 0 and output is not None:
496-
send_result(socket=socket, result_dict={"result": output})
499+
interface_send(socket=socket, result_dict={"result": output})
497500

498501

499502
if __name__ == "__main__":

pylammpsmpi/wrapper/concurrent.py

Lines changed: 17 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import socket
77
from concurrent.futures import Future
88
from queue import Queue
9-
from pympipool import RaisingThread, SocketInterface, cancel_items_in_queue
9+
from pympipool import RaisingThread, cancel_items_in_queue, interface_bootup
1010

1111

1212
__author__ = "Sarath Menon, Jan Janssen"
@@ -21,67 +21,35 @@
2121
__date__ = "Feb 28, 2020"
2222

2323

24-
def _initialize_socket(
25-
interface,
26-
cmdargs,
27-
cwd,
28-
cores,
29-
oversubscribe=False,
30-
enable_flux_backend=False,
31-
enable_slurm_backend=False,
32-
):
33-
port_selected = interface.bind_to_random_port()
34-
executable = os.path.join(
35-
os.path.dirname(os.path.abspath(__file__)), "../mpi", "lmpmpi.py"
36-
)
37-
if enable_flux_backend:
38-
cmds = ["flux", "run"]
39-
elif enable_slurm_backend:
40-
cmds = ["srun"]
41-
else:
42-
cmds = ["mpiexec"]
43-
if oversubscribe:
44-
cmds += ["--oversubscribe"]
45-
cmds += [
46-
"-n",
47-
str(cores),
48-
"python",
49-
executable,
50-
"--zmqport",
51-
str(port_selected),
52-
]
53-
if enable_flux_backend or enable_slurm_backend:
54-
cmds += [
55-
"--host",
56-
socket.gethostname(),
57-
]
58-
if cmdargs is not None:
59-
cmds.extend(cmdargs)
60-
interface.bootup(command_lst=cmds, cwd=cwd)
61-
return interface
62-
63-
6424
def execute_async(
6525
future_queue,
66-
cmdargs,
67-
cores,
26+
cmdargs=None,
27+
cores=1,
6828
oversubscribe=False,
6929
enable_flux_backend=False,
7030
enable_slurm_backend=False,
7131
cwd=None,
7232
queue_adapter=None,
7333
queue_adapter_kwargs=None,
7434
):
75-
interface = _initialize_socket(
76-
interface=SocketInterface(
77-
queue_adapter=queue_adapter, queue_adapter_kwargs=queue_adapter_kwargs
78-
),
79-
cmdargs=cmdargs,
35+
executable = os.path.join(
36+
os.path.dirname(os.path.abspath(__file__)), "../mpi", "lmpmpi.py"
37+
)
38+
if cmdargs is not None:
39+
command_lst = ["python", executable] + cmdargs
40+
else:
41+
command_lst = ["python", executable]
42+
interface = interface_bootup(
43+
command_lst=command_lst,
8044
cwd=cwd,
8145
cores=cores,
46+
gpus_per_core=0,
47+
oversubscribe=oversubscribe,
8248
enable_flux_backend=enable_flux_backend,
8349
enable_slurm_backend=enable_slurm_backend,
84-
oversubscribe=oversubscribe,
50+
queue_adapter=queue_adapter,
51+
queue_type=None,
52+
queue_adapter_kwargs=queue_adapter_kwargs,
8553
)
8654
while True:
8755
task_dict = future_queue.get()

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
keywords='lammps, mpi4py',
2828
packages=find_packages(exclude=["*tests*"]),
2929
install_requires=[
30-
"mpi4py==3.1.4", "pympipool==0.5.6", "numpy==1.23.5"
30+
"mpi4py==3.1.4", "pympipool==0.6.0", "numpy==1.23.5"
3131
],
3232
extras_require={
3333
"ase": ["ase==3.22.1", "scipy==1.10.1"],

0 commit comments

Comments
 (0)