dolfinx icon indicating copy to clipboard operation
dolfinx copied to clipboard

python geometry GJK test fails on non-Intel (arm64)

Open drew-parsons opened this issue 4 years ago • 3 comments

One of the python geometry tests, test_cube_distance in test_gjk.py, fails on non-Intel (arm64) systems. The same test seems to be passing on Intel (amd64).

This is with numpy 1.19.1 and scipy 1.5.2.

Test logs can be found at https://ci.debian.net/packages/d/dolfinx/unstable/arm64/, in particular https://ci.debian.net/data/autopkgtest/unstable/arm64/d/dolfinx/6531870/log.gz

The Failure report is:

_______________________ test_cube_distance[1000.0-1e-06] _______________________

delta = 1e-06, scale = 1000.0

    @pytest.mark.parametrize("delta", [1e8, 1.0, 1e-6, 1e-12])
    @pytest.mark.parametrize("scale", [1000.0, 1.0, 1e-4])
    def test_cube_distance(delta, scale):
        cubes = [scale * np.array([[-1, -1, -1], [1, -1, -1], [-1, 1, -1], [1, 1, -1],
                                   [-1, -1, 1], [1, -1, 1], [-1, 1, 1], [1, 1, 1]],
                                  dtype=np.float64)]
    
        # Rotate cube 45 degrees around z, so that an edge faces along
        # x-axis (vertical)
        r = Rotation.from_euler('z', 45, degrees=True)
        cubes.append(r.apply(cubes[0]))
    
        # Rotate cube around y, so that a corner faces along the x-axis
        r = Rotation.from_euler('y', np.arctan2(1.0, np.sqrt(2)))
        cubes.append(r.apply(cubes[1]))
    
        # Rotate cube 45 degrees around y, so that an edge faces along
        # x-axis (horizontal)
        r = Rotation.from_euler('y', 45, degrees=True)
        cubes.append(r.apply(cubes[0]))
    
        # Rotate scene through an arbitrary angle
        r = Rotation.from_euler('xyz', [22, 13, -47], degrees=True)
    
        for c0 in range(4):
            for c1 in range(4):
                dx = cubes[c0][:, 0].max() - cubes[c1][:, 0].min()
                cube0 = cubes[c0]
                # Separate cubes along x-axis by distance delta
                cube1 = cubes[c1] + np.array([dx + delta, 0, 0])
                c0rot = r.apply(cube0)
                c1rot = r.apply(cube1)
>               distance = np.linalg.norm(compute_distance_gjk(c0rot, c1rot))
E               RuntimeError: GJK error: max iteration limit reached

python/test/unit/geometry/test_gjk.py:156: RuntimeError

drew-parsons avatar Aug 04 '20 13:08 drew-parsons

OK, it's probably just due to machine precision and rounding. It is a bit difficult to control. Maybe we need to supply the precision as an argument.

chrisrichardson avatar Aug 04 '20 17:08 chrisrichardson

I’ve also seen it fail on amd64 with different compilers.

garth-wells avatar Sep 11 '20 05:09 garth-wells

See disabled test at https://github.com/FEniCS/dolfinx/blob/master/.github/workflows/spack.yml#L76.

@jorgensd could you take a look?

garth-wells avatar Sep 11 '20 06:09 garth-wells

@drew-parsons is this still happening for dolfinx 0.7.0?

francesco-ballarin avatar Oct 08 '23 05:10 francesco-ballarin

Need to wait for debian to finish processing dolfinx 0.7.

drew-parsons avatar Oct 08 '23 08:10 drew-parsons

Seems to be fixed now

(experimental_arm64-dchroot)~/dolfinx/fenics-dolfinx-0.7.0/python/test/unit/geometry$ uname -a
Linux amdahl 5.10.0-26-arm64 #1 SMP Debian 5.10.197-1 (2023-09-29) aarch64 GNU/Linux
(experimental_arm64-dchroot)~/dolfinx/fenics-dolfinx-0.7.0/python/test/unit/geometry$ pytest-3 -v test_gjk.py -k test_cube_distance
================================================================================================================================== test session starts ===================================================================================================================================
platform linux -- Python 3.11.6, pytest-7.4.2, pluggy-1.3.0 -- /usr/bin/python3
cachedir: .pytest_cache
rootdir: /home/dparsons/dolfinx/fenics-dolfinx-0.7.0/python
configfile: setup.cfg
collected 63 items / 51 deselected / 12 selected                                                                                                                                                                                                                                         

test_gjk.py::test_cube_distance[float64-1000.0-100000000.0] PASSED                                                                                                                                                                                                                 [  8%]
test_gjk.py::test_cube_distance[float64-1000.0-1.0] PASSED                                                                                                                                                                                                                         [ 16%]
test_gjk.py::test_cube_distance[float64-1000.0-1e-06] PASSED                                                                                                                                                                                                                       [ 25%]
test_gjk.py::test_cube_distance[float64-1000.0-1e-12] PASSED                                                                                                                                                                                                                       [ 33%]
test_gjk.py::test_cube_distance[float64-1.0-100000000.0] PASSED                                                                                                                                                                                                                    [ 41%]
test_gjk.py::test_cube_distance[float64-1.0-1.0] PASSED                                                                                                                                                                                                                            [ 50%]
test_gjk.py::test_cube_distance[float64-1.0-1e-06] PASSED                                                                                                                                                                                                                          [ 58%]
test_gjk.py::test_cube_distance[float64-1.0-1e-12] PASSED                                                                                                                                                                                                                          [ 66%]
test_gjk.py::test_cube_distance[float64-0.0001-100000000.0] PASSED                                                                                                                                                                                                                 [ 75%]
test_gjk.py::test_cube_distance[float64-0.0001-1.0] PASSED                                                                                                                                                                                                                         [ 83%]
test_gjk.py::test_cube_distance[float64-0.0001-1e-06] PASSED                                                                                                                                                                                                                       [ 91%]
test_gjk.py::test_cube_distance[float64-0.0001-1e-12] PASSED                                                                                                                                                                                                                       [100%]

==================================================================================================================================== warnings summary ====================================================================================================================================
../../../../../../../../usr/lib/python3/dist-packages/ufl/core/ufl_type.py:56
../../../../../../../../usr/lib/python3/dist-packages/ufl/core/ufl_type.py:56
../../../../../../../../usr/lib/python3/dist-packages/ufl/core/ufl_type.py:56
../../../../../../../../usr/lib/python3/dist-packages/ufl/core/ufl_type.py:56
../../../../../../../../usr/lib/python3/dist-packages/ufl/core/ufl_type.py:56
../../../../../../../../usr/lib/python3/dist-packages/ufl/core/ufl_type.py:56
../../../../../../../../usr/lib/python3/dist-packages/ufl/core/ufl_type.py:56
../../../../../../../../usr/lib/python3/dist-packages/ufl/core/ufl_type.py:56
  /usr/lib/python3/dist-packages/ufl/core/ufl_type.py:56: DeprecationWarning: attach_operators_from_hash_data deprecated, please use UFLObject instead.
    warnings.warn("attach_operators_from_hash_data deprecated, please use UFLObject instead.", DeprecationWarning)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
===================================================================================================================== 12 passed, 51 deselected, 8 warnings in 2.17s ======================================================================================================================

Might as well close this issue in that case.

drew-parsons avatar Oct 10 '23 11:10 drew-parsons