Read about our upcoming Code of Conduct on this issue

Commit 029f3b96 authored by Pierre Augier's avatar Pierre Augier
Browse files

Try to solve MPI bug

parent 173b04470e28
......@@ -66,10 +66,19 @@ if nb_proc > 1:
class PathMPI(type(Path())):
def exists(self):
respons = None
answer = None
if rank == 0:
respons = super().exists()
return comm.bcast(respons)
answer = super().exists()
ret = comm.bcast(("exists", answer))
if len(ret) != 2 and ret[0] != "exists":
print(rank, "bug!!!!", ret, flush=1)
raise RuntimeError
kind, answer = ret
return answer
def unlink(self):
if rank == 0:
......
......@@ -16,19 +16,24 @@ from .util import (
name_ext_from_path_pythran,
)
from .aheadoftime import modules
from .mpi import Path
from . import mpi
module_name = "fluidpythran.for_test_init"
class TestsInit(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.path_for_test = mpi.Path(__file__).parent / "for_test_init.py"
path_for_test = Path(__file__).parent / "for_test_init.py"
assert path_for_test.exists()
assert cls.path_for_test.exists()
path_pythran = path_for_test.parent / "__pythran__" / path_for_test.name
path_ext = path_pythran.with_name(name_ext_from_path_pythran(path_pythran))
cls.path_pythran = path_pythran = (
cls.path_for_test.parent / "__pythran__" / cls.path_for_test.name
)
cls.path_ext = path_pythran.with_name(
name_ext_from_path_pythran(path_pythran)
)
@classmethod
def tearDownClass(cls):
......@@ -45,8 +50,12 @@ class TestsInit(unittest.TestCase):
except KeyError:
pass
print(mpi.rank, "end tearDownClass")
def test_fluidpythranized(self):
print(mpi.rank, "start test", flush=1)
try:
os.environ.pop("PYTHRANIZE_AT_IMPORT")
except KeyError:
......@@ -59,10 +68,20 @@ class TestsInit(unittest.TestCase):
assert not has_to_pythranize_at_import()
print(mpi.rank, "before if self.path_pythran.exists()", flush=1)
if self.path_pythran.exists():
print(mpi.rank, "before self.path_pythran.unlink()", flush=1)
self.path_pythran.unlink()
make_pythran_file(self.path_for_test)
print(mpi.rank, "before make_pythran_file(self.path_for_test)", flush=1)
if mpi.rank == 0:
make_pythran_file(self.path_for_test)
print(mpi.rank, "after make_pythran_file(self.path_for_test)", flush=1)
mpi.barrier()
from . import for_test_init
......
......@@ -45,6 +45,7 @@ from runpy import run_module, run_path
import sys
from unittest.mock import MagicMock as Mock
from contextlib import contextmanager
from pathlib import Path
from typing import Iterable, Optional
......@@ -61,7 +62,6 @@ from .util import (
find_module_name_from_path,
)
from .compat import open
from .mpi import Path
import fluidpythran
......
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