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 mpi launch for local launcher #508

Merged
merged 4 commits into from
Jan 27, 2025
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
47 changes: 47 additions & 0 deletions src/ansys/pyensight/core/launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ class implement specific launching paradigms.
# See: https://bugs.python.org/issue29288
"".encode("idna")

# The user doesn't know "eth" and "ib" what they mean. Use more meaningful
# keywords.
INTERCONNECT_MAP = {"ethernet": "eth", "infiniband": "ib"}

MPI_TYPES = ["intel2018", "intel2021", "openmpi"]


class Launcher:
"""Provides the EnSight ``Launcher`` base class.
Expand Down Expand Up @@ -63,6 +69,31 @@ class Launcher:
are not supported.
launch_web_ui : bool, optional
Whether to launch the webUI from EnSight
use_mpi: str, optional
If set, EnSight will be launched with the MPI type selected. The valid
values depend on the EnSight version to be used. The user can see
the specific list starting the EnSight Launcher manually and specifying the options
to launch EnSight in parallel and MPI. Here are reported the values for releases
2024R2 and 2025R1.

=================== =========================================
Release Valid MPI Types
=================== =========================================
2024R2 intel2021, intel2018, openmpi
2025R1 intel2021, intel2018, openmpi
=================== =========================================

The remote nodes must be Linux nodes.
This option is valid only if a LocalLauncher is used.
interconnet: str, optional
If set, EnSight will be launched with the MPI Interconnect selected. Valid values
are "ethernet", "infiniband". It requires use_mpi to be set.
If use_mpi is set and interconnect is not, "ethernet" will be used.
This option is valid only if a LocalLauncher is used.
server_hosts: List[str], optional
A list of hostnames where the server processes should be spawned on when MPI is selected.
If use_mpi is set and server_hosts not, it will default to "localhost".
This option is valid only if a LocalLauncher is used.
"""

def __init__(
Expand All @@ -73,10 +104,26 @@ def __init__(
enable_rest_api: bool = False,
additional_command_line_options: Optional[List] = None,
launch_webui: bool = False,
use_mpi: Optional[str] = None,
interconnect: Optional[str] = None,
server_hosts: Optional[List[str]] = None,
) -> None:
self._timeout = timeout
self._use_egl_param_val: bool = use_egl
self._use_sos = use_sos
self._use_mpi = use_mpi
self._interconnect = interconnect
if self._use_mpi and self._use_mpi not in MPI_TYPES:
raise RuntimeError(f"{self._use_mpi} is not a valid MPI option.")
if self._use_mpi and not self._interconnect:
self._interconnect = "ethernet"
if self._interconnect:
if self._interconnect not in list(INTERCONNECT_MAP.values()):
raise RuntimeError(f"{self._interconnect} is not a valid MPI interconnect option.")
self._interconnect = INTERCONNECT_MAP.get(self._interconnect)
self._server_hosts = server_hosts
if self._use_mpi and not self._server_hosts:
self._server_hosts = ["localhost"]
self._enable_rest_api = enable_rest_api

self._sessions: List[Session] = []
Expand Down
12 changes: 10 additions & 2 deletions src/ansys/pyensight/core/locallauncher.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,16 @@ def start(self) -> "pyensight.Session":
cmd.append("-egl")
if self._use_sos:
cmd.append("-sos")
cmd.append("-nservers")
cmd.append(str(int(self._use_sos)))
if not self._use_mpi:
cmd.append("-nservers")
cmd.append(str(int(self._use_sos)))
else:
cmd.append(f"--np={int(self._use_sos)+1}")
mariostieriansys marked this conversation as resolved.
Show resolved Hide resolved
cmd.append(f"--mpi={self._use_mpi}")
cmd.append(f"--ic={self._interconnect}")
hosts = ",".join(self._server_hosts)
cmd.append(f"--cnf={hosts}")

# cmd.append("-minimize_console")
logging.debug(f"Starting EnSight with : {cmd}\n")
self._ensight_pid = subprocess.Popen(cmd, **popen_common).pid
Expand Down
Loading