diff options
author | Abhiroop Sarkar <asiamgenius@gmail.com> | 2018-09-27 15:28:46 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2019-07-01 17:02:29 -0400 |
commit | ff823a08f897e770efda4e89c43618dc6e30bb65 (patch) | |
tree | f26a80bcb060c8439d2daf8cefc9cb367bb3b388 /testsuite/tests/codeGen/should_run/simd002.hs | |
parent | bd660edeb783a74e5ca3f1f82713b2aeedae19dc (diff) | |
download | haskell-wip/simd.tar.gz |
Add support for SIMD operations in the NCGwip/simd
This adds support for constructing vector types from Float#, Double# etc
and performing arithmetic operations on them
Cleaned-Up-By: Ben Gamari <ben@well-typed.com>
Diffstat (limited to 'testsuite/tests/codeGen/should_run/simd002.hs')
-rw-r--r-- | testsuite/tests/codeGen/should_run/simd002.hs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/testsuite/tests/codeGen/should_run/simd002.hs b/testsuite/tests/codeGen/should_run/simd002.hs new file mode 100644 index 0000000000..8c61546381 --- /dev/null +++ b/testsuite/tests/codeGen/should_run/simd002.hs @@ -0,0 +1,33 @@ +{-# OPTIONS_GHC -mavx #-} +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnboxedTuples #-} +-- !!! test arithmetic vector operations + +import GHC.Exts + +data FloatX4 = FX4# FloatX4# + +instance Show FloatX4 where + show (FX4# f) = case (unpackFloatX4# f) of + (# a, b, c, d #) -> show ((F# a), (F# b), (F# c), (F# d)) + +data DoubleX2 = DX2# DoubleX2# + +instance Show DoubleX2 where + show (DX2# d) = case (unpackDoubleX2# d) of + (# a, b #) -> show ((D# a), (D# b)) + + +main :: IO () +main = do + print (FX4# (plusFloatX4# (broadcastFloatX4# 1.3#) (broadcastFloatX4# 2.2#))) + print (FX4# (minusFloatX4# (broadcastFloatX4# 3.5#) (broadcastFloatX4# 2.2#))) + print (FX4# (timesFloatX4# (broadcastFloatX4# 2.4#) (broadcastFloatX4# 2.2#))) + print (FX4# (divideFloatX4# (broadcastFloatX4# 9.2#) (broadcastFloatX4# 4.0#))) + print (FX4# (negateFloatX4# (broadcastFloatX4# 3.5#))) + + print (DX2# (plusDoubleX2# (broadcastDoubleX2# 1.3##) (broadcastDoubleX2# 2.2##))) + print (DX2# (minusDoubleX2# (broadcastDoubleX2# 3.5##) (broadcastDoubleX2# 2.2##))) + print (DX2# (timesDoubleX2# (broadcastDoubleX2# 2.4##) (broadcastDoubleX2# 2.2##))) + print (DX2# (divideDoubleX2# (broadcastDoubleX2# 9.2##) (broadcastDoubleX2# 4.0##))) + print (DX2# (negateDoubleX2# (broadcastDoubleX2# 3.5##))) |