Commit 20780f30 authored by Pierre Augier's avatar Pierre Augier
Browse files

Bad fix MPI (to be improved using another package)

--HG--
branch : dev
parent a2d08a554ff9
......@@ -8,7 +8,7 @@ Future
0.1.2 (?)
---------
- Private command line :code:`.pythran-fluid` to call Pythran
- Private command line :code:`_pythran-fluid` to call Pythran
- MPI aware (only process rank == 0 doing IO and compilation)
- Fix bug C-style `[][]`
- :code:`Array[float, "2d"]` supported
......
......@@ -336,8 +336,12 @@ class CachedJIT:
if path_pythran_header.exists():
# get the old signature(s)
with open(path_pythran_header) as file:
exports_old = [export.strip() for export in file.readlines()]
exports_old = None
if mpi.rank == 0:
with open(path_pythran_header) as file:
exports_old = [export.strip() for export in file.readlines()]
exports_old = mpi.bcast(exports_old)
# FIXME: what do we do with the old signatures?
exports.update(exports_old)
......@@ -369,8 +373,11 @@ class CachedJIT:
openmp=self.openmp,
)
glob_name_ext_file = func_name + "_" + hex_src + "_*" + ext_suffix
ext_files = list(path_pythran.parent.glob(glob_name_ext_file))
ext_files = None
if mpi.rank == 0:
glob_name_ext_file = func_name + "_" + hex_src + "_*" + ext_suffix
ext_files = list(path_pythran.parent.glob(glob_name_ext_file))
ext_files = mpi.bcast(ext_files)
if not ext_files:
if has_to_pythranize_at_import() and _COMPILE_CACHEDJIT:
......
......@@ -3,23 +3,31 @@
"""
try:
from fluiddyn.util import mpi as _mpi
except ImportError:
import os
if "__FLUIDPYTHRAN_NO_MPI" in os.environ:
nb_proc = 1
rank = 0
else:
try:
from mpi4py import MPI
from fluiddyn.util import mpi as _mpi
except ImportError:
nb_proc = 1
rank = 0
try:
from mpi4py import MPI
except ImportError:
nb_proc = 1
rank = 0
else:
comm = MPI.COMM_WORLD
nb_proc = comm.size
rank = comm.Get_rank()
else:
comm = MPI.COMM_WORLD
nb_proc = comm.size
rank = comm.Get_rank()
else:
rank = _mpi.rank
nb_proc = _mpi.nb_proc
if nb_proc > 1:
comm = _mpi.comm
rank = _mpi.rank
nb_proc = _mpi.nb_proc
if nb_proc > 1:
comm = _mpi.comm
from .log import logger
def barrier():
......
......@@ -30,6 +30,7 @@ from pathlib import Path
from typing import Union, Iterable, Optional
import sysconfig
import hashlib
import os
from .compat import open, implementation
from . import mpi
......@@ -134,10 +135,13 @@ class SchedulerPopen:
process = None
if mpi.rank == 0:
os.environ["__FLUIDPYTHRAN_NO_MPI"] = "1"
process = subprocess.Popen(words_command, cwd=cwd)
process = mpi.ShellProcessMPI(process)
self.processes.append(process)
if mpi.rank == 0:
self.processes.append(process)
return process
......
......@@ -175,4 +175,4 @@ def pythran_fluid():
path_tmp.rename(path_out)
logger.info(f"file {Path.cwd() / path_out.name} created")
else:
logger.error(f"file {Path.cwd() / path_tmp.name} has not been created by Pythran")
\ No newline at end of file
logger.error(f"file {Path.cwd() / path_tmp.name} has not been created by Pythran")
......@@ -56,7 +56,6 @@ try:
except ImportError:
pass
from .compat import implementation
from .pythranizer import (
ext_suffix,
name_ext_from_path_pythran,
......@@ -257,10 +256,11 @@ def clear_cached_extensions(module_name: str, force: bool = False):
return
if path_pythran_dir_jit.exists() and query_yes_no(
f"Do you confirm that you want to delete the JIT cache for {module_name}",
f"Do you confirm that you want to delete the cached files for {module_name}",
default="y",
force=force,
):
print(f"Remove directory {path_pythran_dir_jit}")
shutil.rmtree(path_pythran_dir_jit)
if path_pythran.exists() or path_ext.exists():
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment