[commit: ghc] wip/simd: Add support for -mavx512* flags. (03e33c9)

git at git.haskell.org git at git.haskell.org
Mon Sep 23 06:12:52 CEST 2013


Repository : ssh://git@git.haskell.org/ghc

On branch  : wip/simd
Link       : http://ghc.haskell.org/trac/ghc/changeset/03e33c92f4f3b95bad4efa3c9754a681de43610b/ghc

>---------------------------------------------------------------

commit 03e33c92f4f3b95bad4efa3c9754a681de43610b
Author: Geoffrey Mainland <gmainlan at microsoft.com>
Date:   Sun Sep 15 16:24:04 2013 -0400

    Add support for -mavx512* flags.


>---------------------------------------------------------------

03e33c92f4f3b95bad4efa3c9754a681de43610b
 compiler/main/DriverPipeline.hs |   19 +++++++++++++++----
 compiler/main/DynFlags.hs       |   32 ++++++++++++++++++++++++++++++--
 2 files changed, 45 insertions(+), 6 deletions(-)

diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs
index 76f6186..63f203a 100644
--- a/compiler/main/DriverPipeline.hs
+++ b/compiler/main/DriverPipeline.hs
@@ -1382,6 +1382,7 @@ runPhase (RealPhase LlvmLlc) input_fn dflags
                 ++ map SysTools.Option abiOpts
                 ++ map SysTools.Option sseOpts
                 ++ map SysTools.Option avxOpts
+                ++ map SysTools.Option avx512Opts
                 ++ map SysTools.Option stackAlignOpts)
 
     return (RealPhase next_phase, output_fn)
@@ -1415,9 +1416,15 @@ runPhase (RealPhase LlvmLlc) input_fn dflags
                 | isSse2Enabled dflags   = ["-mattr=+sse2"]
                 | otherwise              = []
 
-        avxOpts | isAvx2Enabled dflags   = ["-mattr=+avx2"]
-                | isAvxEnabled dflags    = ["-mattr=+avx"]
-                | otherwise              = []
+        avxOpts | isAvx512fEnabled dflags = ["-mattr=+avx512f"]
+                | isAvx2Enabled dflags    = ["-mattr=+avx2"]
+                | isAvxEnabled dflags     = ["-mattr=+avx"]
+                | otherwise               = []
+
+        avx512Opts =
+          [ "-mattr=+avx512cd" | isAvx512cdEnabled dflags ] ++
+          [ "-mattr=+avx512er" | isAvx512erEnabled dflags ] ++
+          [ "-mattr=+avx512pf" | isAvx512pfEnabled dflags ]
 
         stackAlignOpts =
             case platformArch (targetPlatform dflags) of
@@ -2035,7 +2042,11 @@ doCpp dflags raw input_fn output_fn = do
 
     let avx_defs =
           [ "-D__AVX__=1"  | isAvxEnabled  dflags ] ++
-          [ "-D__AVX2__=1" | isAvx2Enabled dflags ]
+          [ "-D__AVX2__=1" | isAvx2Enabled dflags ] ++
+          [ "-D__AVX512CD__=1" | isAvx512cdEnabled dflags ] ++
+          [ "-D__AVX512ER__=1" | isAvx512erEnabled dflags ] ++
+          [ "-D__AVX512F__=1"  | isAvx512fEnabled  dflags ] ++
+          [ "-D__AVX512PF__=1" | isAvx512pfEnabled dflags ]
 
     backend_defs <- getBackendDefs dflags
 
diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs
index cf6db24..74241ba 100644
--- a/compiler/main/DynFlags.hs
+++ b/compiler/main/DynFlags.hs
@@ -133,6 +133,10 @@ module DynFlags (
         isSse4_2Enabled,
         isAvxEnabled,
         isAvx2Enabled,
+        isAvx512cdEnabled,
+        isAvx512erEnabled,
+        isAvx512fEnabled,
+        isAvx512pfEnabled,
 
         -- * Linker information
         LinkerInfo(..),
@@ -774,6 +778,10 @@ data DynFlags = DynFlags {
   sseVersion            :: Maybe (Int, Int),  -- (major, minor)
   avx                   :: Bool,
   avx2                  :: Bool,
+  avx512cd              :: Bool, -- Enable AVX-512 Conflict Detection Instructions.
+  avx512er              :: Bool, -- Enable AVX-512 Exponential and Reciprocal Instructions.
+  avx512f               :: Bool, -- Enable AVX-512 instructions.
+  avx512pf              :: Bool, -- Enable AVX-512 PreFetch Instructions.
 
   -- | Run-time linker information (what options we need, etc.)
   rtldFlags             :: IORef (Maybe LinkerInfo)
@@ -1407,6 +1415,10 @@ defaultDynFlags mySettings =
         sseVersion = Nothing,
         avx = False,
         avx2 = False,
+        avx512cd = False,
+        avx512er = False,
+        avx512f = False,
+        avx512pf = False,
         rtldFlags = panic "defaultDynFlags: no rtldFlags"
       }
 
@@ -2313,6 +2325,10 @@ dynamic_flags = [
   , Flag "msse"         (versionSuffix (\maj min d -> d{ sseVersion = Just (maj, min) }))
   , Flag "mavx"         (noArg (\d -> d{ avx = True }))
   , Flag "mavx2"        (noArg (\d -> d{ avx2 = True }))
+  , Flag "mavx512cd"    (noArg (\d -> d{ avx512cd = True }))
+  , Flag "mavx512er"    (noArg (\d -> d{ avx512er = True }))
+  , Flag "mavx512f"     (noArg (\d -> d{ avx512f = True }))
+  , Flag "mavx512pf"    (noArg (\d -> d{ avx512pf = True }))
 
      ------ Warning opts -------------------------------------------------
   , Flag "W"      (NoArg (mapM_ setWarningFlag minusWOpts))
@@ -3614,10 +3630,22 @@ isSse4_2Enabled :: DynFlags -> Bool
 isSse4_2Enabled dflags = sseVersion dflags >= Just (4,2)
 
 isAvxEnabled :: DynFlags -> Bool
-isAvxEnabled dflags = avx dflags || avx2 dflags
+isAvxEnabled dflags = avx dflags || avx2 dflags || avx512f dflags
 
 isAvx2Enabled :: DynFlags -> Bool
-isAvx2Enabled dflags = avx2 dflags
+isAvx2Enabled dflags = avx2 dflags || avx512f dflags
+
+isAvx512cdEnabled :: DynFlags -> Bool
+isAvx512cdEnabled dflags = avx512cd dflags
+
+isAvx512erEnabled :: DynFlags -> Bool
+isAvx512erEnabled dflags = avx512er dflags
+
+isAvx512fEnabled :: DynFlags -> Bool
+isAvx512fEnabled dflags = avx512f dflags
+
+isAvx512pfEnabled :: DynFlags -> Bool
+isAvx512pfEnabled dflags = avx512pf dflags
 
 -- -----------------------------------------------------------------------------
 -- Linker information




More information about the ghc-commits mailing list