Permalink
Browse files

Rework alignment specification types

Mainly for readability purposes. Once again, thanks to Gábor Lehel on
`Haskell Cafe`_.

.. _Haskell Cafe: http://www.haskell.org/pipermail/haskell-cafe/2012-July/102195.html
  • Loading branch information...
1 parent 5a32729 commit aedf25460b410e04a3d103befea59ebcb3903fdc @NicolasT committed Jul 8, 2012
Showing with 11 additions and 13 deletions.
  1. +2 −3 src/Data/Vector/SIMD/Algorithms.hs
  2. +9 −10 src/Data/Vector/SIMD/Mutable.hs
@@ -42,9 +42,8 @@ foreign import ccall unsafe "_vector_simd_xor_sse42" _c_xor_sse42
:: Ptr a -> Ptr a -> Ptr a -> CSize -> IO ()
unsafeXorSSE42 :: (Storable a,
- SV.AlignedToAtLeast SV.A16 o1, SV.Alignment o1,
- SV.AlignedToAtLeast SV.A16 o2, SV.Alignment o2,
- SV.AlignedToAtLeast SV.A16 o3, SV.Alignment o3) =>
+ SV.AlignedToAtLeast SV.A16 (o1, o2, o3),
+ SV.Alignment o1, SV.Alignment o2, SV.Alignment o3) =>
SV.Vector o1 a -> SV.Vector o2 a -> SV.Vector o3 a
unsafeXorSSE42 !a !b = unsafePerformIO $ do
let l = SV.length a
@@ -79,16 +79,15 @@ type A32 = Twice A16
instance Alignment A1 where
alignment _ = 1
-instance Alignment A2 where
- alignment _ = 2
-instance Alignment A4 where
- alignment _ = 4
-instance Alignment A8 where
- alignment _ = 8
-instance Alignment A16 where
- alignment _ = 16
-instance Alignment A32 where
- alignment _ = 32
+instance Alignment a => Alignment (Twice a) where
+ alignment _ = 2 * alignment (undefined :: a)
+
+instance (AlignedToAtLeast n a, AlignedToAtLeast n b) =>
+ AlignedToAtLeast n (a, b)
+instance (AlignedToAtLeast n a, AlignedToAtLeast n b, AlignedToAtLeast n c) =>
+ AlignedToAtLeast n (a, b, c)
+instance (AlignedToAtLeast n a, AlignedToAtLeast n b, AlignedToAtLeast n c, AlignedToAtLeast n d) =>
+ AlignedToAtLeast n (a, b, c, d)
instance (Storable a, Alignment o) => G.MVector (MVector o) a where
basicLength (MVector n _) = n

0 comments on commit aedf254

Please sign in to comment.