diff --git a/.flake8 b/.flake8 index 565d47b..b8aba99 100644 --- a/.flake8 +++ b/.flake8 @@ -13,8 +13,7 @@ exclude = build, dist, .conda, - .venv, - tests/autogenerated_* + .venv # Enable specific plugins or options # Example: Enabling flake8-docstrings @@ -22,4 +21,4 @@ select = C,E,F,W,D # Specify custom error codes to ignore or enable per-file-ignores = - tests/*: D \ No newline at end of file + tests/*: D, E712 \ No newline at end of file diff --git a/src/copapy/stencil_db.py b/src/copapy/stencil_db.py index 7593b0b..cd6b750 100644 --- a/src/copapy/stencil_db.py +++ b/src/copapy/stencil_db.py @@ -62,10 +62,12 @@ def get_last_call_in_function(func: elf_symbol) -> int: assert reloc, f'No call function in stencil function {func.name}.' return reloc.fields['r_offset'] - func.fields['st_value'] - reloc.fields['r_addend'] - LENGTH_CALL_INSTRUCTION + def symbol_is_stencil(sym: elf_symbol) -> bool: return (sym.info == 'STT_FUNC' and len(sym.relocations) > 0 and sym.relocations[-1].symbol.info == 'STT_NOTYPE') + class stencil_database(): """A class for loading and querying a stencil database from an ELF object file @@ -90,7 +92,7 @@ class stencil_database(): self.stencil_definitions = {s.name: get_return_function_type(s) for s in self.elf.symbols if s.info == 'STT_FUNC'} - + #self.data = {s.name: strip_function(s) # for s in self.elf.symbols # if s.info == 'STT_FUNC'} @@ -136,7 +138,7 @@ class stencil_database(): def get_stencil_code(self, name: str) -> bytes: """Return the striped function code for a provided function name - + Args: name: function name @@ -144,7 +146,7 @@ class stencil_database(): Striped function code """ return strip_function(self.elf.symbols[name]) - + def get_sub_functions(self, names: Iterable[str]) -> set[str]: name_set: set[str] = set() for name in names: @@ -172,4 +174,4 @@ class stencil_database(): index = get_last_call_in_function(func) return func.data[index + LENGTH_CALL_INSTRUCTION:] else: - return func.data \ No newline at end of file + return func.data diff --git a/tools/extract_code.py b/tools/extract_code.py index ab7d4ad..230f89a 100644 --- a/tools/extract_code.py +++ b/tools/extract_code.py @@ -59,7 +59,7 @@ if __name__ == "__main__": rel_entr_point = dr.read_int() print(f"ENTRY_POINT rel_entr_point={rel_entr_point}") elif com == Command.RUN_PROG: - print(f"RUN_PROG") + print("RUN_PROG") elif com == Command.READ_DATA: offs = dr.read_int() size = dr.read_int() diff --git a/tools/generate_stencils.py b/tools/generate_stencils.py index e88c5f6..caff4af 100644 --- a/tools/generate_stencils.py +++ b/tools/generate_stencils.py @@ -9,6 +9,7 @@ stencil_func_prefix = '__attribute__((naked)) ' # Remove callee prolog stack_size = 64 + def get_aux_funcs() -> str: return f""" {entry_func_prefix}int entry_function_shell(){{ @@ -17,8 +18,8 @@ def get_aux_funcs() -> str: result_int(0); return 1; }} - """ + \ - """ + + """ + """ __attribute__((noinline)) int floor_div(float arg1, float arg2) { float x = arg1 / arg2; int i = (int)x;