Changes between Version 25 and Version 26 of SIMDPlan


Ignore:
Timestamp:
Oct 21, 2011 6:06:59 PM (2 years ago)
Author:
pmonday
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • SIMDPlan

    v25 v26  
    160160        {Float operations that can take advantage of vectorization.} 
    161161------------------------------------------------------------------------ 
     162primtype FloatVec# a 
    162163 
    163164primop   FloatVectorAddOp   "plusFloatVec#"      Dyadic             
    164    Float# -> Float# -> Float# 
     165   FloatVec# -> FloatVec# -> FloatVec# 
    165166   with can_fail = True 
    166 }}} 
    167  
    168 Here is an example of the update to ./compiler/codeGen/CgPrimOp.hs 
     167 
     168primop   FloatVectorAddOp   "plusFloatVec#"      Dyadic             
     169   FloatVec# -> FloatVec# -> FloatVec# 
     170   with can_fail = True 
     171}}} 
     172 
     173Here is an example of the update to ./compiler/codeGen/CgPrimOp.hs that generates Machine Ops based on the new PrimOps. 
    169174{{{ 
    170175-- SIMD Float Ops 
    171176translateOp FloatVectorAddOp    = Just (MO_VF_Add W32 4) 
     177translateOp FloatVectorMultOp   = Just (MO_VF_Mult W32 4) 
     178}}} 
     179 
     180The new primtype also needs to be weaved through the code generation path, but it is slightly different then primops.  To complete the primtype definition, the following files need to be modified. 
     181 
     182./utils/genprimopcode/Main.hs needs to have an association added between the FloatVec# type added above and a Type that is used for representation elsewhere: 
     183{{{ 
     184ppType (TyApp "FloatVec#"   []) = "floatVecPrimTy" 
     185}}} 
     186 
     187By adding the floatVecPrimTy, several additional relationships and constructs need to be created as well. 
     188 
     189./compiler/prelude/TysPrim.lhs, wires the new type into Prelude: 
     190{{{ 
     191module TysPrim( 
     192.... 
     193-- Added 
     194        floatVecPrimTyCon,      floatVecPrimTy, 
     195... 
     196 
     197primTyCons  
     198  = [ addrPrimTyCon 
     199... 
     200-- Added 
     201    , floatVecPrimTyCon 
     202 
     203... 
     204floatVecPrimTyConName             = mkPrimTc (fsLit "FloatVec#") floatVecPrimTyConKey floatVecPrimTyCon 
     205 
     206... 
     207-- Add a new subsection for primitive types (others will be added here as well) 
     208%************************************************************************ 
     209%*                                                                      * 
     210\subsection[TysPrim-SIMDvectors]{The primitive SIMD vector types} 
     211%*                                                                      * 
     212%************************************************************************ 
     213 
     214\begin{code} 
     215floatVecPrimTyCon :: TyCon 
     216floatVecPrimTyCon                 = pcPrimTyCon  floatVecPrimTyConName         1 PtrRep 
     217 
     218floatVecPrimTy :: Type 
     219floatVecPrimTy              = mkTyConTy floatVecPrimTyCon 
     220\end{code} 
     221}}} 
     222 
     223./compiler/prelude/PrelNames.lhs gives keys for each of the primtypes 
     224{{{ 
     225\subsection[Uniques-prelude-TyCons] ... 
     226... 
     227floatVecPrimTyConKey    = mkPreludeTyConUnique 38 
     228}}} 
     229 
     230./compiler/ghci/ByteCodeGen.lhs 
     231{{{ 
     232}}} 
     233 
     234./compiler/ghci/RtClosureInspect.hs 
     235{{{ 
     236repPrim t = rep where  
     237... 
     238-- Added 
     239    | t == floatVecPrimTyCon  = "<floatvec>" 
    172240}}} 
    173241 
     
    175243{{{ 
    176244   | FloatVectorAddOp 
     245   | FloatVectorMultOp 
    177246}}} 
    178247 
     
    193262 
    194263{{{ 
     264          -- SIMD Vector Instruction in Native Revert to Simple Instructions 
    195265      MO_VF_Add w i | sse2      -> trivialFCode_sse2 w ADD  x y 
    196                     | otherwise -> trivialFCode_x87    GADD x y    
     266                  | otherwise -> trivialFCode_x87    GADD x y 
     267      MO_VF_Mul w i | sse2      -> trivialFCode_sse2 w MUL x y 
     268                  | otherwise -> trivialFCode_x87    GMUL x y    
    197269}}} 
    198270