summaryrefslogtreecommitdiff
path: root/compiler/vectorise/Vectorise/Utils.hs
diff options
context:
space:
mode:
authorManuel M T Chakravarty <chak@cse.unsw.edu.au>2012-12-05 15:28:19 +1100
committerManuel M T Chakravarty <chak@cse.unsw.edu.au>2012-12-05 15:28:19 +1100
commitb77da25ef0d95e776a43779bbb4843eb01d33552 (patch)
tree4aeb4d158a5e66d033bca83f2a804b2ce394b5ad /compiler/vectorise/Vectorise/Utils.hs
parent2a7217e3fa39410ac61e17f5c8e2ce3976bec1a9 (diff)
downloadhaskell-b77da25ef0d95e776a43779bbb4843eb01d33552.tar.gz
Rewrote vectorisation avoidance (based on the HS paper)
* Vectorisation avoidance is now the default * Types and values from unvectorised modules are permitted in scalar code * Simplified the VECTORISE pragmas (see http://hackage.haskell.org/trac/ghc/wiki/DataParallel/VectPragma for the spec) * Vectorisation information is now included in the annotated Core AST
Diffstat (limited to 'compiler/vectorise/Vectorise/Utils.hs')
-rw-r--r--compiler/vectorise/Vectorise/Utils.hs27
1 files changed, 18 insertions, 9 deletions
diff --git a/compiler/vectorise/Vectorise/Utils.hs b/compiler/vectorise/Vectorise/Utils.hs
index c5f1cb7cb1..fafce7a67d 100644
--- a/compiler/vectorise/Vectorise/Utils.hs
+++ b/compiler/vectorise/Vectorise/Utils.hs
@@ -17,7 +17,7 @@ module Vectorise.Utils (
combinePD, liftPD,
-- * Scalars
- zipScalars, scalarClosure,
+ isScalar, zipScalars, scalarClosure,
-- * Naming
newLocalVar
@@ -137,20 +137,29 @@ liftPD x
-- Scalars --------------------------------------------------------------------
+isScalar :: Type -> VM Bool
+isScalar ty
+ = do
+ { scalar <- builtin scalarClass
+ ; existsInst scalar [ty]
+ }
+
zipScalars :: [Type] -> Type -> VM CoreExpr
zipScalars arg_tys res_ty
- = do
- scalar <- builtin scalarClass
- (dfuns, _) <- mapAndUnzipM (\ty -> lookupInst scalar [ty]) ty_args
- zipf <- builtin (scalarZip $ length arg_tys)
- return $ Var zipf `mkTyApps` ty_args `mkApps` map Var dfuns
+ = do
+ { scalar <- builtin scalarClass
+ ; (dfuns, _) <- mapAndUnzipM (\ty -> lookupInst scalar [ty]) ty_args
+ ; zipf <- builtin (scalarZip $ length arg_tys)
+ ; return $ Var zipf `mkTyApps` ty_args `mkApps` map Var dfuns
+ }
where
ty_args = arg_tys ++ [res_ty]
scalarClosure :: [Type] -> Type -> CoreExpr -> CoreExpr -> VM CoreExpr
scalarClosure arg_tys res_ty scalar_fun array_fun
= do
- ctr <- builtin (closureCtrFun $ length arg_tys)
- pas <- mapM paDictOfType (init arg_tys)
- return $ Var ctr `mkTyApps` (arg_tys ++ [res_ty])
+ { ctr <- builtin (closureCtrFun $ length arg_tys)
+ ; pas <- mapM paDictOfType (init arg_tys)
+ ; return $ Var ctr `mkTyApps` (arg_tys ++ [res_ty])
`mkApps` (pas ++ [scalar_fun, array_fun])
+ }