小编Ali*_*abi的帖子

Data.Vector.Unboxed.Mutable.MVector的索引真的很慢吗?

我有一个应用程序花费大约80%的时间使用Kahan求和算法计算大型列表(10 ^ 7)的高维向量(dim = 100)的质心.我已经尽力优化求和,但它仍然比同等的C实现慢20倍.分析表明罪犯是unsafeReadunsafeWrite来自的功能Data.Vector.Unboxed.Mutable.我的问题是:这些功能真的很慢还是我误解了性能分析统计数据?

这是两个实现.使用llvm后端使用ghc-7.0.3编译Haskell.C one用llvm-gcc编译.

哈斯克尔的卡汉总结:

{-# LANGUAGE BangPatterns #-}
module Test where

import Control.Monad ( mapM_ )
import Data.Vector.Unboxed ( Vector, Unbox )
import Data.Vector.Unboxed.Mutable ( MVector )
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import Data.Word ( Word )
import Data.Bits ( shiftL, shiftR, xor )

prng :: Word -> Word
prng w = w' where
    !w1 = w  `xor` (w  `shiftL` 13)
    !w2 = …
Run Code Online (Sandbox Code Playgroud)

floating-point performance profiling haskell vector

15
推荐指数
1
解决办法
1505
查看次数

标签 统计

floating-point ×1

haskell ×1

performance ×1

profiling ×1

vector ×1