Quick actions

cmd+k|ctrl+k

Navigation

Languages

SIMD in Haskell

Snippet info

Language

Haskell

Visibility

public

Author

rightfold

Created

2016-07-17T15:03:21Z

Updated

2016-07-17T15:23:55Z

{-# 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