Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
N
nofib
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Glasgow Haskell Compiler
nofib
Commits
24a179b1
Commit
24a179b1
authored
3 years ago
by
Matthew Pickering
Browse files
Options
Downloads
Patches
Plain Diff
Rework smallpt stdout and add stdout file
parent
5973185b
No related branches found
No related tags found
No related merge requests found
Pipeline
#42584
passed
3 years ago
Stage: test
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
real/smallpt/Makefile
+3
-3
3 additions, 3 deletions
real/smallpt/Makefile
real/smallpt/smallpt.hs
+17
-6
17 additions, 6 deletions
real/smallpt/smallpt.hs
real/smallpt/smallpt.stdout
+1
-0
1 addition, 0 deletions
real/smallpt/smallpt.stdout
with
21 additions
and
9 deletions
real/smallpt/Makefile
+
3
−
3
View file @
24a179b1
...
...
@@ -3,9 +3,9 @@ include $(TOP)/mk/boilerplate.mk
SRC_DEPS
=
unboxed-ref
FAST_OPTS
=
1
NORM_OPTS
=
1
SLOW_OPTS
=
6
FAST_OPTS
=
hash
1
NORM_OPTS
=
hash
1
SLOW_OPTS
=
hash
6
include
$(TOP)/mk/target.mk
This diff is collapsed.
Click to expand it.
real/smallpt/smallpt.hs
+
17
−
6
View file @
24a179b1
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE ViewPatterns #-}
module
Main
(
main
)
where
import
Control.Monad
import
Control.Monad.ST
import
Data.List
(
foldl'
)
import
Data.Bits
import
Data.STRef.Unboxed
import
Data.Word
import
GHC.Float
(
castWord64ToDouble
)
import
Text.Printf
import
System.IO
(
Handle
,
stdout
)
import
System.IO
(
Handle
,
stdout
,
hPutStr
)
import
System.Environment
(
getArgs
)
-- position, also color (r,g,b)
data
Vec
=
Vec
{-# UNPACK #-}
!
Double
{-# UNPACK #-}
!
Double
{-# UNPACK #-}
!
Double
...
...
@@ -144,7 +146,7 @@ radiance ray@(Ray o d) depth xi = case intersects ray of
else
return
e
else
continue
c
smallpt
::
Int
->
Int
->
Int
->
IO
()
smallpt
::
Int
->
Int
->
Int
->
IO
[
Vec
]
smallpt
w
h
nsamps
=
do
let
samps
=
nsamps
org
=
Vec
50
52
295.6
...
...
@@ -167,7 +169,7 @@ smallpt w h nsamps = do
pure
$
(
r
`
addv
`
(
rad
`
mulvs
`
(
1
/
fromIntegral
samps
)))
pure
$
ci
`
addv
`
(
Vec
(
clamp
rr
)
(
clamp
rg
)
(
clamp
rb
)
`
mulvs
`
0.25
)
writeImage
stdout
(
w
,
h
)
img
return
img
writeImage
::
Handle
->
(
Int
,
Int
)
->
[
Vec
]
->
IO
()
writeImage
hdl
(
w
,
h
)
img
=
do
...
...
@@ -207,9 +209,18 @@ erand48 !t = do
writeSTRefU
t
r'
pure
d
-- Must be called as ./Main <n>
hashImage
::
[
Vec
]
->
String
hashImage
vecs
=
show
$
foldl'
(
\
n
(
Vec
a
b
c
)
->
n
+
a
+
b
+
c
)
0
vecs
-- Must be called as ./Main img/hash <n>
main
::
IO
()
main
=
do
samples
<-
read
.
head
<$>
getArgs
[
mode
,
read
->
samples
]
<-
getArgs
let
n
=
512
smallpt
n
(
round
$
realToFrac
n
/
1.3333
)
samples
w
=
n
h
=
(
round
$
realToFrac
n
/
1.3333
)
vec
<-
smallpt
w
h
samples
if
mode
==
"img"
then
writeImage
stdout
(
w
,
h
)
vec
else
hPutStr
stdout
(
hashImage
vec
)
This diff is collapsed.
Click to expand it.
real/smallpt/smallpt.stdout
0 → 100644
+
1
−
0
View file @
24a179b1
42517.5950581666
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Alex D
@nineonine
mentioned in issue
#23 (closed)
·
3 years ago
mentioned in issue
#23 (closed)
mentioned in issue #23
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment