| 354 | } |
| 355 | |
| 356 | CPPSPMD_FORCE_INLINE vfloat spmd_kernel::recip_est1_pn(const vfloat& t) |
| 357 | { |
| 358 | //const int mag = 0x7EF312AC; // 2 NR iters, 3 is 0x7EEEEBB3 |
| 359 | const int mag = 0x7EF311C3; |
| 360 | const float fMinThresh = .0000125f; |
| 361 | |
| 362 | vfloat s = sign(t); |
| 363 | vfloat q = abs(t); |
| 364 | |
| 365 | vfloat l = spmd_ternaryf(q >= fMinThresh, q, cast_vint_to_vfloat(vint(mag))); |
| 366 | |
| 367 | vint x_l = vint(mag) - cast_vfloat_to_vint(l); |
| 368 | |
| 369 | vfloat rcp_l = cast_vint_to_vfloat(x_l); |
| 370 | |
| 371 | return rcp_l * vfnma(rcp_l, q, 2.0f) * s; |
| 372 | } |
| 373 | |
| 374 | // https://basesandframes.files.wordpress.com/2020/04/even_faster_math_functions_green_2020.pdf |
| 375 | // https://github.com/hcs0/Hackers-Delight/blob/master/rsqrt.c.txt |
nothing calls this directly
no test coverage detected