gpt4 book ai didi

haskell - 没有并行化的 Repa

转载 作者:行者123 更新时间:2023-12-02 15:32:28 25 4
gpt4 key购买 nike

我真的很喜欢 Repa 的界面,即使它的并发能力如何。我实际上需要 repa 的数组是连续的,因为我的数组相对较小,并且它们的并行化是无用的,甚至是有害的。

但是,我确实在程序中使用了并行化,因此我将其编译为 -threaded 并使用 +RTS -Nx 运行。这使得修复能够并行化。有没有办法关闭repa的并发功能?

嗯,在写这篇文章时,我明白我不太可能需要 DIM1 以外的任何东西,所以也许我应该切换到 Vector。但无论如何,这个问题的答案还是有用的。

并行运行时我收到的警告消息是

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.

我的代码中实际上没有force

最佳答案

使用 http://code.ouroborus.net/repa/repa-head 中的 Repa 3 开发版本。它有一个“force”版本(如何称为computeS),它将按顺序评估数组。

Repa 不会自动对小数组上的操作进行排序。使用 (map f xs) 时,运行时间取决于 'f' 正在执行的操作以及 'xs' 的大小。 Repa 不会尝试计算出“f”正在做什么(这会很困难),因此它不知道计算的成本有多大。

关于haskell - 没有并行化的 Repa,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8652363/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com