从Haskell生成向量代码? [英] Generate vector code from Haskell?

查看:165
本文介绍了从Haskell生成向量代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能让GHC为各代SSE生成SIMD码?



例如。得到这样的程序

  import Data.Array.Vector 
main = print。 sumU $(enumFromToFracU 1 10000000 :: UArr Double)

我可以看到生成的代码(编译为64位x86)以标量模式(C和asm后端)使用SSE指令。所以添加,而不是addpd。对于我使用矢量指令的程序类型,对于性能很重要。有没有一种简单的方法让像我这样的新手能够让GHC使用SSE来SIMD化代码?

是的,它是可能的,通过C后端,但它是试错。
我使用的标志:

  gcc -O2 -funbox-strict-fields -fvia-C -optc-O3 -march = native -optc-msse4 

然后希望GCC通过uvector代码发现GHC产生的紧密循环,并意识到SIMD潜力。


Is it possible to get GHC to produce SIMD code for the various SSE generations?

Eg. got a program like this

import Data.Array.Vector
main = print . sumU $ (enumFromToFracU 1 10000000 :: UArr Double)

I can see the generated code (compiled for 64 bit x86) use SSE instructions in scalar mode (both C and asm backends). So addsd rather than addpd. For the types of programs I work on the use of vector instructions is important for performance. Is there an easy way for a newbie such as myself to get GHC to SIMDize the code using SSE?

解决方案

Yes, it is possible, via the C backend, but it is trial and error. The flags I use:

 gcc -O2 -funbox-strict-fields -fvia-C -optc-O3 -march=native -optc-msse4

Then hope GCC spots the tight loop GHC generates via the uvector code, and realises there is SIMD potential.

这篇关于从Haskell生成向量代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆