Initial Numba support#626
Conversation
✅ 7 CodeQL alerts resolved compared to main
Review the full CodeQL report for details. |
Clang-Tidy Check Results55 new issue(s) introduced by this patch (5842 total). New issues on modified lines:
All issues by check:
See inline comments for details. Comment |
Codecov Report❌ Patch coverage is ❌ Your patch check has failed because the patch coverage (58.64%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage. @@ Coverage Diff @@
## main #626 +/- ##
==========================================
- Coverage 82.66% 81.33% -1.34%
==========================================
Files 161 165 +4
Lines 5920 6016 +96
Branches 681 703 +22
==========================================
- Hits 4894 4893 -1
- Misses 806 885 +79
- Partials 220 238 +18
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 21 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
Clang-Tidy Check Results3 new issue(s) introduced by this patch (5777 total). New issues on modified lines:
All issues by check:
See inline comments for details. Comment |
Clang-Tidy Check Results2 new issue(s) introduced by this patch (5769 total). New issues on modified lines:
All issues by check:
See inline comments for details. Comment |
|
@phlexbot header-guards-fix |
|
Automatic header-guards fixes pushed (commit ea7dff7). |
Clang-Tidy Check Results2 new issue(s) introduced by this patch (5767 total). New issues on modified lines:
All issues by check:
See inline comments for details. Comment |
Clang-Tidy Check ResultsFound 5765 issue(s); none are newly introduced by this patch. All issues by check:
See inline comments for details. Comment |
| } | ||
|
|
||
| template <size_t N, typename Cf> | ||
| static bool unroll_switch(size_t rt_size, Cf&& func) |
There was a problem hiding this comment.
I think this function is essentially mp_with_index from MP11. Using that should hopefully shut up clang-tidy.
I wouldn't be surprised if the whole n_arg logic could be expressed somewhat concisely in MP11 but I'd have to think about it a bit more.
There was a problem hiding this comment.
Looks like it, but the fact remains that clang-tidy is wrong b/c it simply doesn't analyze the predicate deeply enough. Note that I considered removing the forward, but func being a lambda function itself, I'm not sure whether that's appropriate (it would be for just a function pointer) and anyway, then you get a different clang-tidy warning (can't have a move without a forward; it does still run fine, of course, since it's only used once).
Aside, the implementation of mp_with_index simply spells everything out up to an index of 16 using template specializations. :} Likely more efficient (not sure what the compiler makes of it), but also fugly (which is fine if hidden in the boost header; not so much if I take the same approach in modulewrap.cpp). It would be clang-tidy approved, however.
This PR adds "native" Numba support to phlex.
Numba was usable out-of-the-box already, through Python, but even if the Numba function itself didn't use the GIL, it still needed it at the start of every call (through the wrapper) and all Python/C++ converters required them, too. The implementation in this PR allows for calling the Numba JITed C-function directly, using converters that do not involve Python, and a dispatch through libffi. That sets up a workflow that doesn't require the GIL anywhere beyond configuration/registration time, thus enabling strong scaling (as far as Phlex is concerned) during graph execution.
This PR is for transforms only (observers and providers to follow) and only supports builtin types. Arrays and PODs (by member copy) should be doable as well, but Numba does not support arbitrary C++ classes.
The code in the module wrapper was significantly refactored, to maximize code reuse.
Note: it requires libffi, which will be available on most Linux boxes, but probably needs to be installed with spack in other places, so the spack recipe would need updating as well.