Skip to content

Switch to using a fork of f2c and remove most of _f2c_fixes.py#4920

Merged
hoodmane merged 12 commits intopyodide:mainfrom
hoodmane:f2c-fork
Jul 16, 2024
Merged

Switch to using a fork of f2c and remove most of _f2c_fixes.py#4920
hoodmane merged 12 commits intopyodide:mainfrom
hoodmane:f2c-fork

Conversation

@hoodmane
Copy link
Member

@hoodmane hoodmane commented Jul 6, 2024

I made https://github.com/hoodmane/f2c/ which has some improvements that make it work much better for us including:

  1. support for the recursive keyword
  2. support for variable length arrays that are not arguments in recursive functions
  3. /COMMON/ blocks are labeled with __attribute__((weak))
  4. automatically omits ftn_len arguments from calls to clapack

This allows us to delete most of _f2c_fixes.py.

Thanks to @ilayn for writing scipy/scipy#20558, id_dist was going to be a huge pain to deal with.

cc @rgommers @agriyakhetarpal

  • Add a CHANGELOG entry
  • Add / update tests
  • Add new / update outdated documentation

@hoodmane
Copy link
Member Author

hoodmane commented Jul 6, 2024

Also, I still am amazed every time I build scipy in 5 minutes. Meson is so great.

Copy link
Member

@ryanking13 ryanking13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool! I've skimmed through your f2c modifications, and TBH I don't understand it very much. Still, I think it is a great improvement if we can remove _f2c_fixes.py which is one of our pain point in pyodide-build.

Please ping me again when the PR is ready, I would like to review again.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe passing F2C_PATH in the cmd line would work without setting it here, then we won't need to modify pyodide-build.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried removing this and it didn't work so I think it's needed. Is there something specific you're suggesting?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, that's strange. Let me check locally.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I opened a PR in your fork: hoodmane#9. The build passes while tests fail.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you didn't make the tests fail any worse than they already do though. Thanks!

@ilayn
Copy link

ilayn commented Jul 7, 2024

Thanks to @ilayn for writing scipy/scipy#20558, id_dist was going to be a huge pain to deal with.

My pleasure. Please let me know if you encounter any bugs because these translations make it extremely easy to make mistakes and I am very good at making those mistakes.

@hoodmane
Copy link
Member Author

hoodmane commented Jul 9, 2024

@lesteve could you run the scipy tests against this?

@lesteve
Copy link
Contributor

lesteve commented Jul 9, 2024

It seems like there are Pyodide fatal errors on this PR mostly around scipy.sparse, for example when running the equivalent of pytest --pyargs scipy.sparse.tests.test_array_api, there is a Pyodide fatal error (the last output I get is about test_eigs[bsr] so maybe this is the culprit?)

The cause of the fatal error was:
RuntimeError: null function or function signature mismatch
    at wasm://wasm/000facae:wasm-function[187]:0x8cdf
    at wasm://wasm/0003e6d6:wasm-function[107]:0xbfa0
    at _PyEM_TrampolineCall_JS (/home/lesteve/dev/scipy-tests-pyodide/node_modules/pyodide/pyodide.asm.js:1735:83)
    at pyodide.asm.wasm._PyObject_MakeTpCall (wasm://wasm/pyodide.asm.wasm-029e027e:wasm-function[1136]:0x1c2631)
    at pyodide.asm.wasm.PyObject_Vectorcall (wasm://wasm/pyodide.asm.wasm-029e027e:wasm-function[1145]:0x1c2e37)
    at pyodide.asm.wasm._PyEval_EvalFrameDefault (wasm://wasm/pyodide.asm.wasm-029e027e:wasm-function[3411]:0x29f694)
    at pyodide.asm.wasm._PyEval_Vector (wasm://wasm/pyodide.asm.wasm-029e027e:wasm-function[3412]:0x2a409a)
    at pyodide.asm.wasm._PyFunction_Vectorcall (wasm://wasm/pyodide.asm.wasm-029e027e:wasm-function[1150]:0x1c31e0)
    at pyodide.asm.wasm._PyObject_FastCallDictTstate (wasm://wasm/pyodide.asm.wasm-029e027e:wasm-function[1137]:0x1c2748)
    at pyodide.asm.wasm._PyObject_Call_Prepend (wasm://wasm/pyodide.asm.wasm-029e027e:wasm-function[1154]:0x1c3405) {
  pyodide_fatal_error: true
}

The output from running all the scipy tests using https://github.com/lesteve/scipy-tests-pyodide:

--------------------------------------------------------------------------------
Grouped by category
--------------------------------------------------------------------------------
category fatal error or timeout (4 modules)
    scipy.sparse.linalg._eigen.arpack.tests
    scipy.sparse.linalg._eigen.lobpcg.tests
    scipy.sparse.linalg._eigen.tests
    scipy.sparse.tests
category passed (28 modules)
    scipy.cluster.tests
    scipy.constants.tests
    scipy.fftpack.tests
    scipy.fft._pocketfft.tests
    scipy.fft.tests
    scipy.integrate._ivp.tests
    scipy.integrate.tests
    scipy.interpolate.tests
    scipy.io.arff.tests
    scipy.io._harwell_boeing.tests
    scipy.io.matlab.tests
    scipy.io.tests
    scipy._lib.tests
    scipy.linalg.tests
    scipy.misc.tests
    scipy.ndimage.tests
    scipy.odr.tests
    scipy.optimize.tests
    scipy.optimize._trustregion_constr.tests
    scipy.signal.tests
    scipy.sparse.csgraph.tests
    scipy.sparse.linalg._dsolve.tests
    scipy.sparse.linalg._isolve.tests
    scipy.sparse.linalg.tests
    scipy.spatial.tests
    scipy.spatial.transform.tests
    scipy.special.tests
    scipy.stats.tests

--------------------------------------------------------------------------------
Unexpected test results
--------------------------------------------------------------------------------
scipy.sparse.linalg._eigen.arpack.tests result expected in ['passed'], got 'fatal error or timeout' instead
scipy.sparse.linalg._eigen.lobpcg.tests result expected in ['passed'], got 'fatal error or timeout' instead
scipy.sparse.linalg._eigen.tests result expected in ['passed'], got 'fatal error or timeout' instead
scipy.sparse.tests result expected in ['passed'], got 'fatal error or timeout' instead

@hoodmane
Copy link
Member Author

hoodmane commented Jul 9, 2024

Thanks @lesteve. I fixed one problem with scipy.sparse, how does it look now?

@lesteve
Copy link
Contributor

lesteve commented Jul 9, 2024

Yep the scipy.sparse.tests works now, but there are still some Pyodide fatal errors in the equivalent of pytest --pyargs scipy.sparse.linalg

@lesteve
Copy link
Contributor

lesteve commented Jul 9, 2024

The remaining issue seems related to cneupd_, call_indirect is calling it with 25 i32 arguments but its signature has 26 i32 arguments.

@hoodmane
Copy link
Member Author

Great, thanks @lesteve!

Copy link
Member

@ryanking13 ryanking13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codewise looks good to me. Thanks for improving this!

@agriyakhetarpal
Copy link
Member

I'll rebase #4719 as soon as this is merged, it looks like there are a lot of simplifications, thanks!

@ilayn
Copy link

ilayn commented Jul 16, 2024

In the meantime, we merged MINPACK in scipy/scipy#21131; FYI if that is causing any issues and QUADPACK is next in line, then ARPACK hopefully all in v1.15 timeline.

@hoodmane
Copy link
Member Author

We have special workarounds for ARPACK, PROPACK, SUPERLU, fitpack, blas and lapack. Also, there are a bunch of test failures in different parts of scipy but I don't really know were or why.

@hoodmane hoodmane merged commit 5ff2f8e into pyodide:main Jul 16, 2024
@hoodmane hoodmane deleted the f2c-fork branch July 16, 2024 11:41
@hoodmane
Copy link
Member Author

id_dist was by far the worst though.

ryanking13 added a commit to ryanking13/pyodide-build that referenced this pull request Jul 17, 2024
hoodmane added a commit to hoodmane/pyodide that referenced this pull request Jul 24, 2024
…de#4920)

I made https://github.com/hoodmane/f2c/ which has some improvements that make it
work much better for us including:
1. support for the `recursive` keyword
2. support for variable length arrays that are not arguments in recursive functions
3. `/COMMON/` blocks are labeled with `__attribute__((weak))`
4. automatically omits `ftn_len` arguments from calls to clapack

This allows us to delete most of `_f2c_fixes.py`.

Thanks to @ilayn for writing scipy/scipy#20558,
`id_dist` was going to be a huge pain to deal with.
@agriyakhetarpal agriyakhetarpal mentioned this pull request Jul 30, 2024
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants