commit 208a7d6e3b506a77dbc06227cdf610c34edc6aef
parent 6cf12743e3da3806e7cd2fbb354a83c418d0a413
Author: Jared Tobin <jared@jtobin.io>
Date: Wed, 29 Jan 2025 15:12:20 +0400
src: profiling tweak
Diffstat:
2 files changed, 28 insertions(+), 19 deletions(-)
diff --git a/ppad-fixed.cabal b/ppad-fixed.cabal
@@ -89,4 +89,5 @@ executable fixed-profile
base
, criterion
, ppad-fixed
+ , primitive
diff --git a/src/Main.hs b/src/Main.hs
@@ -2,25 +2,33 @@
module Main where
+import qualified Data.Primitive.PrimArray as PA
import Data.Word.Extended
main :: IO ()
-main = pure ()
---main :: IO ()
---main = do
--- let !u = Word576
--- 5152276743337338587
--- 6823823105342984773
--- 12649096328525870222
--- 8811572179372364942
--- 0 0 0 0 0
---
--- !d = Word256
--- 8849385646123010679
--- 653197174784954101
--- 1286679968202709238
--- 3741537094902495500
---
--- let foo = quotrem u d
--- print foo
---
+main = do
+ let !u = PA.primArrayFromList [
+ 5152276743337338587
+ , 6823823105342984773
+ , 12649096328525870222
+ , 8811572179372364942
+ ]
+ !d = Word256
+ 8849385646123010679
+ 653197174784954101
+ 1286679968202709238
+ 3741537094902495500
+
+ quo <- PA.newPrimArray 5
+ let go !j _
+ | j == 50000 = pure ()
+ | otherwise = do
+ PA.setPrimArray quo 0 5 0
+ w <- quotrem quo u d
+ go (succ j) w
+
+ r <- go (0 :: Int) (PA.primArrayFromList [0, 0, 0, 0])
+ q <- PA.unsafeFreezePrimArray quo
+ print r
+ print q
+