[Haskell-cafe] optimising for vector units

MR K P SCHUPKE k.schupke at imperial.ac.uk
Mon Jul 26 08:52:02 EDT 2004

>Correct me if I'm wrong but I thought that there was some overhead to
>making FFI (even safe/unsafe)

You are not wrong... so it would only be worth it if you could
execute a whole bunch of C at the same time. But it is possible...

Consider: Use a monad to sequence vector operations on the Vector class.
The monad instead of directly executing vector instructions compiles
a syntax tree, or a list of instructions. This list of instructions
is passed to the C code, which sequences the primitive vector ops
into a block of code, and returns a function pointer via the FFI.

You just call the whole block with the right parameters. 

This is probably getting to be more work than integrating stuff into
GHC though. It is also doing stuff dynamically that could be done
statically at compile time.

If GCC is providing vector abstractions then it would seem a lot
less work for GHC to incorporate 'vector' types directly...

Anyone like to comment more specifically on what would be involved
in plumbing a new datatype into GHC that handles vectors? Assuming
we wanted an interface like:

myFn :: Vector Word8 Four -> Vector Word8 Four.

Also vector is not a good name, as with vectors:

	"a * b" would be the cross-product, but with
	SIMD we get 4 scalar multiplies...


More information about the Haskell-Cafe mailing list