Skip to content

‘-march=native’ causes compute_extrema to fail on some architectures #221

Description

@drew-parsons

PR #187 introduced default cffi compile options -march=native when into compute_extrema (eval.py).

This causes test_eval.py to fail on some architectures, since -march=native is not a universal flag. In particular powerpc (ppc64el) and sparc64,
https://buildd.debian.org/status/fetch.php?pkg=scifem&arch=ppc64el&ver=0.19.0-1&stamp=1779876989&raw=0
https://buildd.debian.org/status/fetch.php?pkg=scifem&arch=ppc64&ver=0.19.0-1&stamp=1779877925&raw=0
https://buildd.debian.org/status/fetch.php?pkg=scifem&arch=sparc64&ver=0.19.0-1&stamp=1779878936&raw=0

The error from ppc64el includes

        except DistutilsExecError as msg:
>           raise CompileError(msg)
E           distutils.compilers.C.errors.CompileError: command '/usr/bin/powerpc64le-linux-gnu-gcc' failed with exit code 1

/usr/lib/python3/dist-packages/setuptools/_distutils/compilers/C/unix.py:223: CompileError

During handling of the above exception, another exception occurred:
...
    def test_extrema_func(cell_type, extrema, dtype, degree: int):
...    
>       u_ex, _X_ex = compute_extrema(u, extrema, tol=tol)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

tests/test_eval.py:147: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
scifem/eval.py:350: in compute_extrema
    X_c, extrema = find_cell_extrema(
----------------------------- Captured stderr call -----------------------------
powerpc64le-linux-gnu-gcc: error: unrecognized command-line option ‘-march=native’; did you mean ‘-mcpu=native’?
____________ test_extrema_func[float64-CellType.tetrahedron-max-5] _____________
=========================== short test summary info ============================
FAILED tests/test_eval.py::test_extrema_func[float64-CellType.tetrahedron-min-5]
FAILED tests/test_eval.py::test_extrema_func[float64-CellType.tetrahedron-max-5]
FAILED tests/test_eval.py::test_extrema_func[float64-CellType.hexahedron-min-5]
FAILED tests/test_eval.py::test_extrema_func[float64-CellType.hexahedron-max-5]
FAILED tests/test_eval.py::test_extrema_func[float32-CellType.tetrahedron-min-5]
FAILED tests/test_eval.py::test_extrema_func[float32-CellType.tetrahedron-max-5]
FAILED tests/test_eval.py::test_extrema_func[float32-CellType.hexahedron-min-5]
FAILED tests/test_eval.py::test_extrema_func[float32-CellType.hexahedron-max-5]
===== 8 failed, 1699 passed, 6 xfailed, 257 warnings in 424.03s (0:07:04) ======

For end-users it can be managed manually by controlling the jit_options given to test_extrema_func. But that leaves the question of how to manage test_eval.py in scifem CI testing.

There could be a number of different ways to manage it

  • use a try: catch: block in test_eval.py::test_extrema_func to catch CompileError at the level of the tests, and then skip or rerun with alternative jit_options
  • refactor
    "cffi_extra_compile_args": ["-march=native", "-O3"],
    to set -march=native (either testing the flag at runtime, or taking the value from a grey-list dict and identifying which value to use via platform.machine())

In regards to setting alternative jit_options for the failing case, the error message suggests that -mcpu=native might work in these architectures.

What's your preferred solution?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions