You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Inside @njit, math.sqrt/np.sqrt do lower to a libm sqrt call, but LLVM turns that into the native fsqrt whenever it can prove the argument non-negative (e.g. a sum of squares). Checking the optimized LLVM IR on main shows the four area.py sites, the gradient.py norms, and error_radius (inlined into _unique_points) already compile to fsqrt. Rewriting them as ** 0.5 adds a fabs and a -inf check and made the area Jacobian ~5% slower, so they are unchanged. The sites that really did call libm are acc_sqrt_re, compute_arc_length, haversine_distance, gradient's _compute_arc_length, neighborhood std and _numba_sqrt3. These now use ** 0.5, and _newton_quadrilateral compares norm2 < 1e-30 instead of taking a sqrt. The _numba_norm3 comment now gives the actual cause. The _unique_points denominator hoist was skipped: it costs an allocation and is slower for the 2–8 points callers pass. Results are bit-identical to main across 16 checked outputs, and new tests pin acc_sqrt_re's rounding, its rejection of degenerate inputs, and its compiling to llvm.sqrt without a libm call. Performance is unchanged within noise on arm64 macOS, including the batched SameBodyConstLat/SameBodyGcaGca asv benchmarks, zonal_mean and gradient; x86 is untested. Each changed sqrt is one operation among dozens in its kernel, so 2c should be dropped from the performance list.
Activity
uxarray/core#1789cmdupuis3 commentedon Nov 20, 2026
Optimization benefits seem to be minor, closing as not planned