I do not understand why this program using repa:
import Data.Array.Repa
import Data.Array.Repa.Algorithms.Matrix
import Data.Functor.Identity
go = runIdentity $ do
let mat = fromListUnboxed (ix2 2 2) [1..4]
let ins = fromListUnboxed (ix2 2 1) [1, 1]
mmultP mat ins
is giving me the following warning:
Data.Array.Repa: Performing nested parallel computation sequentially.
You've probably called the 'compute' or 'copy' 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 'compute' the next one.
I have no nested computations, I didn't call compute
or copy
, and everything that I used to do the computation is inside the same monad. Is it something to do with lazy evaluation? If so, how do I make the parallel computation happen while using the Identity monad (to keep the overall computation pure) ?
For reference, replacing runIdentity
with runST
makes it work, although in either case the specific monad's functionality isn't being used at all.
mmultP
callscomputeP
, which callsunsafePerformIO
. I'm not very experienced with this, but might there be an incompatibility betweenunsafePerformIO
and theIdentity
monad (maybeIdentity
's behaviour with laziness) ? – Background