From d029950b267543a2a8d6d754afbe48013761a5b4 Mon Sep 17 00:00:00 2001
From: Andreas Klebinger <klebinger.andreas@gmx.at>
Date: Thu, 6 May 2021 11:36:40 +0200
Subject: [PATCH] smallpt - adhere to benchmark duration guidlines for nofib.

---
 real/smallpt/Makefile   | 4 ++++
 real/smallpt/smallpt.hs | 8 ++++++--
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/real/smallpt/Makefile b/real/smallpt/Makefile
index 2441df32..887636fe 100644
--- a/real/smallpt/Makefile
+++ b/real/smallpt/Makefile
@@ -3,5 +3,9 @@ include $(TOP)/mk/boilerplate.mk
 
 SRC_DEPS = unboxed-ref
 
+FAST_OPTS = 1
+NORM_OPTS = 1
+SLOW_OPTS = 6
+
 include $(TOP)/mk/target.mk
 
diff --git a/real/smallpt/smallpt.hs b/real/smallpt/smallpt.hs
index 7b5fa02d..216ed291 100644
--- a/real/smallpt/smallpt.hs
+++ b/real/smallpt/smallpt.hs
@@ -10,6 +10,7 @@ import Data.Word
 import GHC.Float (castWord64ToDouble)
 import Text.Printf
 import System.IO (Handle, stdout)
+import System.Environment (getArgs)
 -- position, also color (r,g,b)
 data Vec = Vec {-# UNPACK #-} !Double {-# UNPACK #-} !Double {-# UNPACK #-} !Double
 
@@ -206,6 +207,9 @@ erand48 !t =  do
   writeSTRefU t r'
   pure d
 
+-- Must be called as ./Main <n>
 main :: IO ()
-main = smallpt n (round $ realToFrac n/1.3333) 32
-  where n = 512
+main = do
+  samples <- read . head <$> getArgs
+  let n = 512
+  smallpt n (round $ realToFrac n/1.3333) samples
-- 
GitLab