Talk:Numeric Haskell: A Repa Tutorial
Things I've Learned So Far
If you specify a slice as such: (Z :. All :. 2), for example, you will get many pages of type incantation errors. In order to be a true wizard you must touch the 2 with a salve of type annotation as so: (Z :. All :. (2 :: Int)). This will satisfy the type demons that compile your code.
The reason is that GHC assumes literals like 2 are of type Integer, and Repa demands Ints.
I'll post more "oopsies" as I come across them.
--Danharaj 00:51, 24 April 2011 (UTC)
I have a bunch of simulation code that, every frame of simulation:
- Creates a few intermediate arrays.
- Creates a list of intermediate arrays then folds them immediately
- Adds and multiplies a few intermediate arrays with (*^) and (+^)
The thing is, unless I force at every intermediate step, the performance is so abysmal that the application loses responsiveness. With the forcing, it runs fast enough (need to optimize the code to make it run faster), but then...
I get this gem of a runtime warning (reported every frame)... sometimes!
Data.Array.Repa: Performing nested parallel computation sequentially.
You've probably called the 'force' function while another instance was already running. This can happen if the second version was suspended due to lazy evaluation. Use 'deepSeqArray' to ensure that each array is fully evaluated before you 'force' the next one.
--Danharaj 16:48, 24 April 2011 (UTC)
The solution is to use deepSeqArray at each intermediate step, as the warning suggests. It works. Forcing arrays is idiomatic of Repa I think. You use it to specify sharing. force is lazy, however, so you have to deepSeqArray in order to get everything working nicely.
--Danharaj 18:47, 24 April 2011 (UTC)