fixed

Pure Haskell large fixed-width integers and Montgomery arithmetic.
git clone git://git.ppad.tech/fixed.git
Log | Files | Refs | README | LICENSE

commit b35970d2b8b04d934d1cab7e93e6aafe27d020fb
parent 22a632874f72b50eb68dfca99f636ec2f2a7c0b3
Author: Jared Tobin <jared@jtobin.io>
Date:   Fri, 26 Dec 2025 13:10:46 -0330

bench: vartime updates for sqrt

Diffstat:
MREADME.md | 6+++---
Mbench/Main.hs | 6+++---
Mbench/Weight.hs | 6+++---
3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/README.md b/README.md @@ -163,9 +163,9 @@ sqrt ``` Note that 'sqrt' for example allocates 16 additional bytes as it returns -a value of type 'Maybe Montgomery', which involves using either a Just -or Nothing constructor (the analogous function in the unboxed API, -'sqrt#', avoids allocation by returning an unboxed sum). +a value of type 'Maybe Montgomery', which involves allocating a Just +constructor and a pointer to its payload (the analogous function in the +unboxed API, 'sqrt#', avoids allocation by returning an unboxed sum). You can compile with GHC's LLVM backend and filter on specific benchmarks via e.g.: diff --git a/bench/Main.hs b/bench/Main.hs @@ -98,9 +98,9 @@ sqrt :: Benchmark sqrt = let !c2 = 2 :: C.Montgomery !c_big = (2 ^ 255 - 19) :: C.Montgomery - in bgroup "sqrt" [ - bench "curve: sqrt M(2)" $ nf C.sqrt_vartime c2 - , bench "curve: sqrt M(2 ^ 255 - 19)" $ nf C.sqrt_vartime c_big + in bgroup "sqrt_vartime" [ + bench "curve: sqrt_vartime M(2)" $ nf C.sqrt_vartime c2 + , bench "curve: sqrt_vartime M(2 ^ 255 - 19)" $ nf C.sqrt_vartime c_big ] exp :: Benchmark diff --git a/bench/Weight.hs b/bench/Weight.hs @@ -124,9 +124,9 @@ sqrt :: Weigh () sqrt = let !c2 = 2 :: C.Montgomery !c_big = (2 ^ 255 - 19) :: C.Montgomery - in wgroup "sqrt" $ do - func "curve: sqrt M(2)" C.sqrt_vartime c2 - func "curve: sqrt M(2 ^ 255 - 19)" C.sqrt_vartime c_big + in wgroup "sqrt_vartime" $ do + func "curve: sqrt_vartime M(2)" C.sqrt_vartime c2 + func "curve: sqrt_vartime M(2 ^ 255 - 19)" C.sqrt_vartime c_big redc :: Weigh () redc =