Skip to content

Commit

Permalink
implemented wi4mpi support to barebones support
Browse files Browse the repository at this point in the history
  • Loading branch information
FrederickDeny committed Feb 22, 2024
1 parent 3e5b664 commit a1bf344
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions e4s_cl/cf/containers/barebones.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from e4s_cl.util import run_subprocess, create_symlink, empty_dir, list_directory_sofiles
from e4s_cl.cf.libraries import cache_libraries
from e4s_cl.cf.containers import Container, FileOptions, BackendNotAvailableError
from e4s_cl.cf.wi4mpi import wi4mpi_root

LOGGER = logger.get_logger(__name__)

Expand Down Expand Up @@ -66,11 +67,16 @@ def _prepare(self, command: List[str], overload: bool = True) -> List[str]:
"""
Return the command to run in a list of string
"""
to_be_preloaded = list_directory_sofiles(Path(BAREBONES_LIBRARY_DIR))
for file_path in to_be_preloaded:
self.add_ld_preload(str(file_path))
self.env.update(
{'LD_PRELOAD': ":".join(self.ld_preload)})

# Chech the environment for the use of Wi4MPI
wi4mpi_install_dir = wi4mpi_root()
# If WI4MPI is to be used, we don't preload the mpi's libraries
if wi4mpi_install_dir is None:
to_be_preloaded = list_directory_sofiles(Path(BAREBONES_LIBRARY_DIR))
for file_path in to_be_preloaded:
self.add_ld_preload(str(file_path))
self.env.update(
{'LD_PRELOAD': ":".join(self.ld_preload)})

# LD_LIBRARY_PATH override does not respect container's values.
# Enabling this may prevent crashes with nvidia library import
Expand All @@ -92,6 +98,8 @@ def bind_file(self,
This doesn't bind files, but does the equivalent preparation
of making required files available for the final process to
run using them for the barebones container.
Instead of binding files it creates a symlink of them to a
specific directory for e4s-cl to find them.
"""
file_to_bind = Path(path)
file_basename = file_to_bind.name
Expand All @@ -114,7 +122,6 @@ def _has_nvidia(self):

def run(self, command: List[str], overload: bool = True) -> int:


container_cmd = [*self._prepare(command, overload)]

return run_subprocess(container_cmd, env=self.env)
Expand Down

0 comments on commit a1bf344

Please sign in to comment.