Hi Ben,
Thank you for your comments. More below...
On 17 April 2014 02:15, Ben Lippmeier <
be...@ouroborus.net> wrote:
> This is provided by the suspendedComputeP function in Data.Array.Repa.Eval, but pay attention to the warning in the comments.
>
> I would just write all the code that invokes compute{P,S} in the IO monad. It's a sledgehammer, but it works.
So my ongoing work is about writing a DSL for image processing, with
repa as a backend for parallel image processing. Consider the
following pseudo code:
a := readFile("lolcats.png")
b := convolve(a,Sobel)
c := blur(b)
d := darken(c)
writeFile("processed-meow.png",d)
There interpretation of this code is serial in that no Haskell
concurrency primitives are used to fork threads, meaning that any
parallelism comes from repa implementations of "convolve", "blur", and
"darken". What I'd like to do is take advantage of repa's delayed
array for these three functions, using computeP only in "writeFile".
That is:
readFile :: FIlePath -> IO (Array D DIM2 (Word8,Word8,Word8))
convolve, blur, darken :: Array D DIM2 (Word8,Word8,Word8) -> Array D
DIM2 (Word8,Word8,Word8)
writeFile :: FIlePath -> Array D DIM2 (Word8,Word8,Word8) -> IO (Array
U DIM2 (Word8,Word8,Word8))
My thinking is that delaying `computeP` to the very end i.e in the
`writeFile` call, then the would be no synchronisation between the
execution of convolve, blur and darken. So I'm happy to just have all
my code in the IO monad. My question has changed to: when using repa,
why not delay `computeP` calls to the very last function call over an
array?
Thanks,
--
Rob