SIMD in Haskell
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE UnboxedTuples #-}
module Main where
import Control.Concurrent (forkOS)
import Control.Monad (forM_)
import GHC.Prim (packInt64X4#, plusInt64X4#, unpackInt64X4#)
import GHC.Types (Int(I#))
main :: IO ()
main = do
forM_ [1 .. 4] $ \_ -> forkOS $ do
let xs = packInt64X4# (# 1#, 2#, 3#, 4# #)
let ys = packInt64X4# (# 2#, 3#, 4#, 5# #)
let zs = xs `plusInt64X4#` ys
let (# a, b, c, d #) = unpackInt64X4# zs
print (I# a, I# b, I# c, I# d)
return ()
INFO