Read about our upcoming Code of Conduct on this issue

Commit 7dfb9139 authored by Pierre Augier's avatar Pierre Augier
Browse files

Debug for fluidsim

parent cb53ec3d4d8e
......@@ -25,6 +25,6 @@ doc/ipynb/*.rst
*.egg-info/*
**/__pythran__/_*
**/__pythran__/*
fluidpythran/_path_data_tests.py
\ No newline at end of file
......@@ -59,11 +59,11 @@
Let's first clean all FluidPythran cache files...
%% Cell type:code id: tags:
``` python
paths = Path("__pythran__").glob("_tmp*.*")
paths = Path("__pythran__").glob("tmp*.*")
for path in paths:
path.unlink()
```
%% Cell type:markdown id: tags:
......
......@@ -36,7 +36,11 @@ from .util import (
modification_date,
)
from .pythranizer import compile_pythran_file, name_ext_from_path_pythran
from .pythranizer import (
compile_pythran_file,
name_ext_from_path_pythran,
ext_suffix,
)
from .annotation import (
make_signature_from_template_variables,
......@@ -79,7 +83,7 @@ def _get_fluidpythran_calling_module(index_frame: int = 2):
if module_name in modules:
fp = modules[module_name]
if (
fp._created_while_transpiling != is_transpiling
fp.is_transpiling != is_transpiling
or fp._pythranize_at_import_at_creation
!= has_to_pythranize_at_import()
or hasattr(fp, "path_mod")
......@@ -196,7 +200,7 @@ class FluidPythran:
self.names_template_variables = {}
self._created_while_transpiling = is_transpiling
self.is_transpiling = is_transpiling
if is_transpiling:
self.functions = {}
......@@ -218,11 +222,11 @@ class FluidPythran:
module_short_name = module_name
module_pythran_name = ""
module_pythran_name += "__pythran__._" + module_short_name
module_pythran_name += "__pythran__." + module_short_name
self.path_mod = path_mod = Path(frame.filename)
self.path_pythran = path_pythran = (
path_mod.parent / "__pythran__" / ("_" + module_short_name + ".py")
path_mod.parent / "__pythran__" / (module_short_name + ".py")
)
path_ext = None
......@@ -288,6 +292,12 @@ class FluidPythran:
self.is_compiled = False
self.is_transpiled = True
if not path_ext.exists() and not self.is_compiling:
path_ext_alt = path_pythran.with_suffix(ext_suffix)
if path_ext_alt.exists():
self.path_extension = path_ext = path_ext_alt
if path_ext.exists() and not self.is_compiling:
self.module_pythran = import_from_path(
self.path_extension, module_pythran_name
......
import numpy as np
# pythran import numpy as np
......
......@@ -88,7 +88,9 @@ modules = {}
path_cachedjit = mpi.Path(path_root) / "__cachedjit__"
path_cachedjit.mkdir(parents=True, exist_ok=True)
if mpi.rank == 0:
path_cachedjit.mkdir(parents=True, exist_ok=True)
mpi.barrier()
_COMPILE_CACHEDJIT = strtobool(os.environ.get("FLUID_COMPILE_CACHEDJIT", "True"))
......@@ -252,7 +254,10 @@ class CachedJIT:
module_name = mod.module_name
path_pythran = path_cachedjit / module_name.replace(".", os.path.sep)
path_pythran.mkdir(parents=True, exist_ok=True)
if mpi.rank == 0:
path_pythran.mkdir(parents=True, exist_ok=True)
mpi.barrier()
path_pythran = (path_pythran / func_name).with_suffix(".py")
path_pythran_header = path_pythran.with_suffix(".pythran")
......
......@@ -59,9 +59,11 @@ class ShellProcessMPI:
def is_alive_root(self):
return self.process.poll() is None
PathSeq = Path
if nb_proc > 1:
class PathMPI(type(Path())):
def exists(self):
respons = None
......@@ -74,16 +76,11 @@ if nb_proc > 1:
super().unlink()
comm.barrier()
def mkdir(self, *args, **kwargs):
if rank == 0:
super().mkdir(*args, **kwargs)
comm.barrier()
Path = PathMPI
def has_to_build(output_file: Path, input_file: Path):
from . import util
ret = None
if rank == 0:
ret = util.has_to_build(output_file, input_file)
......@@ -91,6 +88,7 @@ if nb_proc > 1:
def modification_date(filename):
from . import util
ret = None
if rank == 0:
ret = util.modification_date(filename)
......
......@@ -175,7 +175,7 @@ def compile_pythran_files(
paths: Iterable[Path], str_pythran_flags: str, parallel=True
):
for path in paths:
print("pythranize file", path)
print("Schedule pythranization of file", path)
scheduler.compile_with_pythran(
path, str_pythran_flags=str_pythran_flags, parallel=parallel
)
......
......@@ -8,15 +8,11 @@ Internal API
.. autofunction:: parse_args
.. autofunction:: pythran_fluid
"""
import argparse
from pathlib import Path
from glob import glob
import subprocess
import sys
from . import __version__
from .transpiler import make_pythran_files
......@@ -87,7 +83,7 @@ def run():
pythran_paths = []
for path in paths:
path = Path(path)
pythran_path = path.parent / "__pythran__" / ("_" + path.name)
pythran_path = path.parent / "__pythran__" / path.name
ext_path = pythran_path.with_suffix(ext_suffix)
if has_to_build(ext_path, pythran_path):
pythran_paths.append(pythran_path)
......
import shutil
import pytest
......
import importlib
from . import FluidPythran, mpi
......
import importlib
import unittest
import os
......@@ -28,7 +27,7 @@ class TestsInit(unittest.TestCase):
assert path_for_test.exists()
path_pythran = path_for_test.parent / ("__pythran__/_" + path_for_test.name)
path_pythran = path_for_test.parent / "__pythran__" / path_for_test.name
path_ext = path_pythran.with_name(name_ext_from_path_pythran(path_pythran))
@classmethod
......
......@@ -60,7 +60,7 @@ def test_create_pythran_classic():
run()
path_file_pythran = path_data_tests / "__pythran__/_classic.py"
path_file_pythran = path_data_tests / "__pythran__/classic.py"
path_file_pythran.unlink()
print("after unlink")
......
......@@ -466,7 +466,7 @@ def make_pythran_file(
)
path_dir = path_py.parent / "__pythran__"
path_pythran = path_dir / ("_" + path_py.name)
path_pythran = path_dir / path_py.name
if not has_to_build(path_pythran, path_py) and not force:
logger.info(f"File {path_pythran} already up-to-date.")
......
......@@ -235,7 +235,7 @@ def clear_cached_extensions(module_name: str, force: bool = False):
relative_path = Path(relative_path)
path_pythran = relative_path.parent / (
"__pythran__/_" + relative_path.name + ".py"
"__pythran__/" + relative_path.name + ".py"
)
path_ext = path_pythran.with_name(name_ext_from_path_pythran(path_pythran))
......
......@@ -28,7 +28,7 @@ def main():
args = sys.argv[1:]
path = Path.cwd() / args[0]
logger.info(f"Pythranize {path}")
print(f"Pythranize {path}")
if "-o" in args:
index_output = args.index("-o") + 1
......@@ -44,7 +44,7 @@ def main():
if path_tmp.exists():
path_out = path_tmp.with_suffix(ext_suffix)
path_tmp.rename(path_out)
logger.info(f"file {Path.cwd() / path_out.name} created")
print(f"file {Path.cwd() / path_out.name} created")
else:
logger.error(
f"file {Path.cwd() / path_tmp.name} has not been created by Pythran"
......
......@@ -35,7 +35,7 @@ source = ./fluidpythran
data_file = .coverage/coverage
omit = */test*.py
*/_try_*.py
fluidpythran/__pythran__/_for_test_init.py
fluidpythran/__pythran__/for_test_init.py
[coverage:report]
show_missing = True
......
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