In numpy float128 is typically a long double (not a 128 bit float). But I can’t tell if numba has support for this. The docs don’t seem to mention long doubles or the numpy type float128.
1 Answers
No, Numba does not support this type yet. There is an open issue on this topic. The 80-bit extended precision is generally not well supported, even in Numpy. On mainstream x86-64 architecture, such numbers are computed by the x87 FPU unit which is pretty slow and rather obsolete nowadays.
If you want an extended precision, it may be better to use a double-double data-type like here (though you certainly need to port this into Numba yourself). Note that this data-type is not as precise as a 128-bit float but it can benefit from SIMD units (i.e. it is fast).
Another alternative is to just use double precision with numerically stable algorithms. The later solution is generally much better. Most people requesting for higher precision generally use numerically unstable algorithms where the error grows exponentially (possibly due to catastrophic cancellation). Using a bigger precision does not really solve this issue : it just defer the problem at the expense of a much slower computation. Actually, double precision is sufficient for physicists to simulate the universe with a pretty-high resolution. For example, double precision is enough for precisely locating atoms in a 1 meter domain. Using a 3-level hierarchical clustering, atoms can be precisely located in the Milky Way (with the size of 87_400 light-years). Note that clustering also tends to help to design faster programs (typically due to better algorithms, more cache-friendly accesses).

- 17,852
- 6
- 57
- 85

- 41,678
- 6
- 29
- 59
-
The open issue is about 128 bit floats not long doubles. – Simd Apr 02 '23 at 13:24
-
There is no long-double explicit direct support in Numpy so not in Numba either. Numpy typically implements the float128 as long-double internally which is 80-bit wide on x86-64 processors (they do not support 128-bit floats). Numba only supports the 32-bit and 64-bit floating point data-type. The discussion in the issue also applies for 80-bit floats (which are actually platform-specific). – Jérôme Richard Apr 02 '23 at 13:54