#3557: CPU Vector instructions in GHC.Prim
---------------------------------+------------------------------------------
Reporter: guest | Owner: vivian
Type: feature request | Status: new
Priority: normal | Milestone: _|_
Component: Compiler (NCG) | Version: 6.11
Keywords: | Testcase:
Blockedby: | Difficulty: Unknown
Os: Unknown/Multiple | Blocking:
Architecture: Unknown/Multiple | Failure: None/Unknown
---------------------------------+------------------------------------------
Comment(by guest):
Replying to [comment:5 vivian]:
> Okay, this might take a while. First set of questions:
>
> I'm thinking of making a module `GHC.Prim.SSE` that contains the new
ops.
>
> 1) SSE instructions are CPU specific, so we need a way to check whether
the CPU supports the various SSE extensions (SSE, SSE2, SSE3, SSE4,...).
(assembler instruction CPUID).
I like the way LLVM solves this problem. If we adapt it, implementation of
vector instructions is also easy for the LLVM backend.
LLVM is divided into a high level interface and a low level interface.
The high level interface provides virtual vectors of every possible
length. Early versions did only provide power of two vector sizes. The
implementation of the vector instructions tries to make as much as
possible use of vector units by dividing virtual vectors into physical CPU
vectors. If there is no CPU vector unit at all, the chunk size is 1.
The low level interface provides access to the actual CPU instructions via
intrinsics. You may use these functions to optimize your program. However
for portable code you must always provide an alternative implementation
using the high level interface. I have written such automatical switches
for LLVM:
http://hackage.haskell.org/packages/archive/llvm-extra/0.1/doc/html/LLVM-
Extra-Extension.html
http://hackage.haskell.org/packages/archive/llvm-extra/0.1/doc/html/LLVM-
Extra-Extension-X86.html
I would like to see the same for GHC: Define a primitive arbitrary length
vector type in, say, Data.CPUVector. The vector size might be encoded with
a type, just as in the llvm package. Additionally write GHC.Prim.X86.SSE
modules for the CPU specific instructions.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/3557#comment:7>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs