Commit 5db93d2e authored by niteria's avatar niteria
Browse files

Make vectInfoParallelVars a DVarSet

We dump it in the interface file, so we need to do it in a
deterministic order. I haven't seen any problems with this
during my testing, but that's probably because it's unused.

Test Plan: ./validate

Reviewers: simonmar, austin, bgamari

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D2313

GHC Trac Issues: #4012
parent 3b698e89
......@@ -327,7 +327,7 @@ mkIface_ hsc_env maybe_old_fingerprint
{ ifaceVectInfoVar = [Var.varName v | (v, _ ) <- varEnvElts vVar]
, ifaceVectInfoTyCon = [tyConName t | (t, t_v) <- nameEnvElts vTyCon, t /= t_v]
, ifaceVectInfoTyConReuse = [tyConName t | (t, t_v) <- nameEnvElts vTyCon, t == t_v]
, ifaceVectInfoParallelVars = [Var.varName v | v <- varSetElems vParallelVars]
, ifaceVectInfoParallelVars = [Var.varName v | v <- dVarSetElems vParallelVars]
, ifaceVectInfoParallelTyCons = nameSetElemsStable vParallelTyCons
}
......
......@@ -779,7 +779,7 @@ tcIfaceVectInfo mod typeEnv (IfaceVectInfo
{ vectInfoVar = mkVarEnv vVars `extendVarEnvList` concat vScSels
, vectInfoTyCon = mkNameEnv vTyCons
, vectInfoDataCon = mkNameEnv (concat vDataCons)
, vectInfoParallelVars = mkVarSet vParallelVars
, vectInfoParallelVars = mkDVarSet vParallelVars
, vectInfoParallelTyCons = parallelTyConsSet
}
}
......
......@@ -2642,7 +2642,7 @@ data VectInfo
{ vectInfoVar :: VarEnv (Var , Var ) -- ^ @(f, f_v)@ keyed on @f@
, vectInfoTyCon :: NameEnv (TyCon , TyCon) -- ^ @(T, T_v)@ keyed on @T@
, vectInfoDataCon :: NameEnv (DataCon, DataCon) -- ^ @(C, C_v)@ keyed on @C@
, vectInfoParallelVars :: VarSet -- ^ set of parallel variables
, vectInfoParallelVars :: DVarSet -- ^ set of parallel variables
, vectInfoParallelTyCons :: NameSet -- ^ set of parallel type constructors
}
......@@ -2673,14 +2673,14 @@ data IfaceVectInfo
noVectInfo :: VectInfo
noVectInfo
= VectInfo emptyVarEnv emptyNameEnv emptyNameEnv emptyVarSet emptyNameSet
= VectInfo emptyVarEnv emptyNameEnv emptyNameEnv emptyDVarSet emptyNameSet
plusVectInfo :: VectInfo -> VectInfo -> VectInfo
plusVectInfo vi1 vi2 =
VectInfo (vectInfoVar vi1 `plusVarEnv` vectInfoVar vi2)
(vectInfoTyCon vi1 `plusNameEnv` vectInfoTyCon vi2)
(vectInfoDataCon vi1 `plusNameEnv` vectInfoDataCon vi2)
(vectInfoParallelVars vi1 `unionVarSet` vectInfoParallelVars vi2)
(vectInfoParallelVars vi1 `unionDVarSet` vectInfoParallelVars vi2)
(vectInfoParallelTyCons vi1 `unionNameSet` vectInfoParallelTyCons vi2)
concatVectInfo :: [VectInfo] -> VectInfo
......
......@@ -493,11 +493,12 @@ tidyVectInfo (_, var_env) info@(VectInfo { vectInfoVar = vars
, isDataConWorkId var || not (isImplicitId var)
]
tidy_parallelVars = mkVarSet [ tidy_var
| var <- varSetElems parallelVars
, let tidy_var = lookup_var var
, isExternalId tidy_var && isExportedId tidy_var
]
tidy_parallelVars = mkDVarSet
[ tidy_var
| var <- dVarSetElems parallelVars
, let tidy_var = lookup_var var
, isExternalId tidy_var && isExportedId tidy_var
]
lookup_var var = lookupWithDefaultVarEnv var_env var var
......
......@@ -30,6 +30,7 @@ import NameSet
import Name
import NameEnv
import FastString
import UniqDFM
import Data.Maybe
......@@ -86,7 +87,7 @@ data GlobalEnv
-- ^Mapping from global variables to their vectorised versions — aka the /vectorisation
-- map/.
, global_parallel_vars :: VarSet
, global_parallel_vars :: DVarSet
-- ^The domain of 'global_vars'.
--
-- This information is not redundant as it is impossible to extract the domain from a
......@@ -208,8 +209,8 @@ modVectInfo env mg_ids mg_tyCons vectDecls info
{ vectInfoVar = mk_env ids (global_vars env)
, vectInfoTyCon = mk_env tyCons (global_tycons env)
, vectInfoDataCon = mk_env dataCons (global_datacons env)
, vectInfoParallelVars = (global_parallel_vars env `minusVarSet` vectInfoParallelVars info)
`intersectVarSet` (mkVarSet ids)
, vectInfoParallelVars = (global_parallel_vars env `minusDVarSet` vectInfoParallelVars info)
`udfmIntersectUFM` (mkVarSet ids)
, vectInfoParallelTyCons = global_parallel_tycons env `minusNameSet` vectInfoParallelTyCons info
}
where
......
......@@ -1039,13 +1039,13 @@ vectAvoidInfo :: VarSet -> CoreExprWithFVs -> VM CoreExprWithVectInfo
vectAvoidInfo pvs ce@(_, AnnVar v)
= do
{ gpvs <- globalParallelVars
; vi <- if v `elemVarSet` pvs || v `elemVarSet` gpvs
; vi <- if v `elemVarSet` pvs || v `elemDVarSet` gpvs
then return VIParr
else vectAvoidInfoTypeOf ce
; viTrace ce vi []
; when (vi == VIParr) $
traceVt " reason:" $ if v `elemVarSet` pvs then text "local" else
if v `elemVarSet` gpvs then text "global" else text "parallel type"
if v `elemDVarSet` gpvs then text "global" else text "parallel type"
; return ((fvs, vi), AnnVar v)
}
......
......@@ -185,7 +185,7 @@ dumpVar dflags var
addGlobalParallelVar :: Var -> VM ()
addGlobalParallelVar var
= do { traceVt "addGlobalParallelVar" (ppr var)
; updGEnv $ \env -> env{global_parallel_vars = extendVarSet (global_parallel_vars env) var}
; updGEnv $ \env -> env{global_parallel_vars = extendDVarSet (global_parallel_vars env) var}
}
-- |Mark the given type constructor as parallel — i.e., its values might embed parallel arrays.
......
......@@ -135,7 +135,7 @@ lookupVectDecl var
-- |Get the set of global parallel variables.
--
globalParallelVars :: VM VarSet
globalParallelVars :: VM DVarSet
globalParallelVars = readGEnv global_parallel_vars
-- |Get the set of all parallel type constructors (those that may embed parallelism) including both
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment