我不明白为什么这个程序使用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
给我以下警告:
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.
我没有嵌套计算,我没有调用compute
or copy
,并且我用来进行计算的所有内容都在同一个 monad 中。这与惰性评估有关吗?如果是这样,我如何在使用 Identity monad 时进行并行计算(以保持整体计算纯粹)?
作为参考,替换runIdentity
为runST
使其工作,尽管在任何一种情况下都没有使用特定的 monad 的功能。