Commit fa67477
peng.li24
feat: add NUMPYCPP_STD_ONLY backend; dual DEB packaging; dual CI jobs
Two interchangeable math backends, selected at cmake configure time:
cmake -DNUMPYCPP_STD_ONLY=OFF (default) → bitexact backend
• dlsym → npy_exp/npy_log/... + __svml_exp8/... from numpy .so
• OpenBLAS ILP64 cblas_sgemm/sdot via dlsym
• IEEE 754 bit-identical to numpy on all architectures
• DEB: numpycpp-dev-bitexact-<ver>-Linux.deb
cmake -DNUMPYCPP_STD_ONLY=ON → std backend
• std::exp/log/sin/... from <cmath>
• Pure C++ loops for dot/gemm (compiler auto-vectorises with -O3)
• 0-2 ULP from numpy, NOT bit-exact; no external dependencies
• DEB: numpycpp-dev-std-<ver>-Linux.deb
All public APIs (numpy::exp, numpy::dot, numpy::einsum, ...) are
identical in both backends. The split is fully encapsulated in detail/:
New files:
numpy/detail/math_backend.h — #ifdef selector (svml vs std)
numpy/detail/std_math_backend.h — std::exp/log/sin/... same API
numpy/detail/linalg_backend.h — #ifdef selector (blas vs std)
numpy/detail/std_linalg_backend.h — C++ loop dot/gemm same API
Modified:
numpy/elementwise.h — use math_backend.h; guard avx512_loops.h
numpy/linalg.h — use linalg_backend.h
CMakeLists.txt — option(NUMPYCPP_STD_ONLY); conditional DEB name
tests/CMakeLists.txt — option + conditional compile flags
.github/workflows/ci.yml — 3 jobs: test-bitexact, test-std, package
README.md — backend comparison table; compiler flag tables
Compiler flag differences:
bitexact: -ffp-contract=off -mavx512f -mprefer-vector-width=256 -ldl (all required)
std: -O3 -march=native (no -ffp-contract=off, no -ldl needed)
900 bitexact tests still pass.1 parent 4ee900e commit fa67477
10 files changed
Lines changed: 584 additions & 120 deletions
File tree
- .github/workflows
- numpy
- detail
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
10 | 15 | | |
11 | 16 | | |
12 | 17 | | |
| |||
17 | 22 | | |
18 | 23 | | |
19 | 24 | | |
20 | | - | |
21 | | - | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
22 | 28 | | |
23 | 29 | | |
24 | 30 | | |
25 | 31 | | |
26 | 32 | | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
| 33 | + | |
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
51 | | - | |
52 | 50 | | |
53 | 51 | | |
54 | 52 | | |
55 | 53 | | |
56 | 54 | | |
57 | 55 | | |
58 | 56 | | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
| 57 | + | |
| 58 | + | |
63 | 59 | | |
64 | 60 | | |
65 | 61 | | |
66 | 62 | | |
67 | | - | |
| 63 | + | |
68 | 64 | | |
69 | 65 | | |
70 | 66 | | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
9 | 25 | | |
10 | 26 | | |
11 | 27 | | |
| |||
14 | 30 | | |
15 | 31 | | |
16 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
17 | 43 | | |
18 | 44 | | |
19 | 45 | | |
| |||
53 | 79 | | |
54 | 80 | | |
55 | 81 | | |
56 | | - | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
57 | 94 | | |
58 | 95 | | |
59 | 96 | | |
60 | | - | |
| 97 | + | |
61 | 98 | | |
62 | 99 | | |
63 | 100 | | |
64 | 101 | | |
65 | 102 | | |
66 | | - | |
| 103 | + | |
| 104 | + | |
67 | 105 | | |
68 | 106 | | |
69 | 107 | | |
| |||
73 | 111 | | |
74 | 112 | | |
75 | 113 | | |
76 | | - | |
| 114 | + | |
77 | 115 | | |
78 | 116 | | |
79 | 117 | | |
| |||
0 commit comments