/usr/share/doc/libghc-monad-par-doc/examples/stream/fft_pipeline.hs is in libghc-monad-par-doc 0.1.0.3-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | {-# OPTIONS_GHC -fwarn-unused-imports #-}
module Main(main) where
import Control.Monad.Par
import Control.Monad.Par.Stream as S
import Control.Exception
import Data.Complex
import GHC.Conc as Conc
import Debug.Trace
import Math.FFT (dft)
type Elt = Complex Double
fft_kern :: Window Elt -> Window Elt
fft_kern arr = dft arr
-- -- TEMP, evaluate one element to make sure the fft really gets called:
-- -- trace ("One elt sample: "++ show (arr!10)) $
-- case arr2 ! 10 of _ -> arr2
-- where arr2 = dft arr
--------------------------------------------------------------------------------
-- Main script
-- target = maxBound
target = 10 * 1000 * 1000
bufsize = 1024
main = do
putStrLn$ "numCapabilities: "++ show numCapabilities
putStrLn$ " Frequency in measurable ticks: "++ commaint one_second ++ "\n"
putStrLn$ "Performing FFT of "++ commaint target ++" numbers windowed into buffers of size "++ show bufsize ++"\n"
results <- evaluate $ runParAsync$ do
strm1 <- countupWin bufsize target :: Par (WStream Elt)
print_$ "\n Next, applying FFT filter... "
strm2 <- streamMap fft_kern strm1
-- Make a pipeline of 10 stages:
-- strm2 <- foldl (\ s _ -> streamMap kern0) strm1 [1..10]
print_$ "\n Stream graph constructed, returning from Par computation... "
return strm2
measureRate results
putStrLn$ "End of stream reached. All done."
print_ msg = trace msg $ return ()
-- work pop 1 peek N push 1
-- float->float filter
-- firFilter n coefs =
-- {
-- float sum = 0;
-- for (int i = 0; i < N; i++)
-- sum += peek(i) * COEFF[N-1-i];
-- pop();
-- push(sum);
-- }
-- }
{-
Notes:
-}
|