Skip to content

Commit 9dcb901

Browse files
committed
Proper tests using futhark-test.
1 parent 1b5d357 commit 9dcb901

File tree

7 files changed

+16
-7
lines changed

7 files changed

+16
-7
lines changed

main.tex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ \chapter{The Futhark Language}
284284
this program computes the dot product $\Sigma_{i} x_{i}\cdot{}y_{i}$
285285
of two vectors of integers:
286286

287-
\inplisting{src/dotprod.fut}
287+
\lstinputlisting[firstline=5]{src/dotprod.fut}
288288

289289
In Futhark, the notation for an array of element type $t$ is
290290
\texttt{[]$t$}. The program declares a function called \texttt{main}
@@ -796,7 +796,7 @@ \subsection{Filtering}
796796
But what are the corresponding indices? We can solve this using a
797797
combination of \texttt{zip}, \texttt{filter}, and \texttt{unzip}:
798798

799-
\lstinputlisting[firstline=2]{src/indices_of_nonzero.fut}
799+
\lstinputlisting[firstline=7]{src/indices_of_nonzero.fut}
800800

801801
Be aware that \texttt{filter} is a somewhat expensive SOAC,
802802
corresponding roughly to a \texttt{scan} plus a \texttt{map}.
@@ -1148,7 +1148,7 @@ \section{Benchmarking}
11481148

11491149
Consider an implementation of dot product:
11501150

1151-
\inplisting{src/dotprod.fut}
1151+
\lstinputlisting[firstline=5]{src/dotprod.fut}
11521152

11531153
We previously mentioned that, for small data sets, sequential
11541154
execution is likely to be much faster than parallel execution. But

src/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
*.exe
44
*.out
55
*-opencl
6-
*-c
6+
*-c
7+
*.bin

src/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ FUTHARKOPENCL ?= futhark-opencl
44
#FUTFILES=$(wildcard *.fut)
55

66
SRCFILES=radix_sort sgm_scan reduce_contract find_idx streak sgm_streak rsort_idx maxidx
7-
SRCFILES_INPUT=dotprod multable primes rsort
7+
SRCFILES_INPUT=multable primes rsort
88

99
RESFILES=$(SRCFILES:%=%.res) $(SRCFILES_INPUT:%=%_inp.res)
1010
RESOPENCLFILES=$(SRCFILES:%=%.resopencl)

src/dotprod.fut

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
1+
-- ==
2+
-- input { [1,2,3] [4,5,6] }
3+
-- output { 32 }
4+
15
fun main (x: []int) (y: []int): int =
26
reduce (+) 0 (map (*) x y)

src/dotprod.inp

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/dotprod_inp.ok

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/indices_of_nonzero.fut

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
-- ==
2+
-- input { [0,5,2,0,1] }
3+
-- output { [1,2,4] }
4+
5+
fun main(xs: [n]int): []int = indices_of_nonzero xs
6+
17
fun indices_of_nonzero(xs: [n]int): []int =
28
let xs_and_is = zip xs (iota n)
39
let xs_and_is' = filter (fn (x,_) => x != 0) xs_and_is

0 commit comments

Comments
 (0)