Skip to content

Commit

Permalink
update for new rts flag handling
Browse files Browse the repository at this point in the history
  • Loading branch information
tmcdonell committed Oct 20, 2017
1 parent 0592152 commit d4e3764
Show file tree
Hide file tree
Showing 13 changed files with 73 additions and 177 deletions.
4 changes: 0 additions & 4 deletions .ghci
@@ -1,9 +1,5 @@
:set -DUNIX
:set -DACCELERATE_DEBUG
:set -DACCELERATE_BOUNDS_CHECKS
:set -DACCELERATE_INTERNAL_CHECKS
:set -iaccelerate-llvm
:set -iaccelerate-llvm-native
:set -iaccelerate-llvm-ptx
:set -iaccelerate-llvm-multidev
:set -optP-include -optPutils/cabal_macros.h
Expand Up @@ -87,8 +87,8 @@ compile acc aenv = do
--
obj <- liftIO . unsafeInterleaveIO $ do
exists <- doesFileExist cacheFile
recomp <- Debug.queryFlag Debug.force_recomp
if exists && not (fromMaybe False recomp)
recomp <- if Debug.debuggingIsEnabled then Debug.getFlag Debug.force_recomp else return False
if exists && not recomp
then do
Debug.traceIO Debug.dump_cc (printf "cc: found cached object code %016x" uid)
B.readFile cacheFile
Expand Down
Expand Up @@ -590,44 +590,42 @@ readLoadSymbolTable p@Peek{..} obj = do

readDynamicSymbolTable :: Peek -> ByteString -> Get ()
readDynamicSymbolTable Peek{..} _obj = do
#ifdef ACCELERATE_DEBUG
ilocalsym <- getWord32
nlocalsym <- getWord32
iextdefsym <- getWord32
nextdefsym <- getWord32
iundefsym <- getWord32
nundefsym <- getWord32
skip 4 -- tocoff
ntoc <- getWord32
skip 4 -- modtaboff
nmodtab <- getWord32
skip 12 -- extrefsymoff, nextrefsyms, indirectsymoff,
nindirectsyms <- getWord32
skip 16 -- extreloff, nextrel, locreloff, nlocrel,
message "LC_DYSYMTAB:"
--
if nlocalsym > 0
then message (printf " %d local symbols at index %d" nlocalsym ilocalsym)
else message (printf " No local symbols")
if nextdefsym > 0
then message (printf " %d external symbols at index %d" nextdefsym iextdefsym)
else message (printf " No external symbols")
if nundefsym > 0
then message (printf " %d undefined symbols at index %d" nundefsym iundefsym)
else message (printf " No undefined symbols")
if ntoc > 0
then message (printf " %d table of contents entries" ntoc)
else message (printf " No table of contents")
if nmodtab > 0
then message (printf " %d module table entries" nmodtab)
else message (printf " No module table")
if nindirectsyms > 0
then message (printf " %d indirect symbols" nindirectsyms)
else message (printf " No indirect symbols")
#else
skip ({#sizeof dysymtab_command#} - 8)
#endif
return ()
if not Debug.debuggingIsEnabled
then skip ({#sizeof dysymtab_command#} - 8)
else do
ilocalsym <- getWord32
nlocalsym <- getWord32
iextdefsym <- getWord32
nextdefsym <- getWord32
iundefsym <- getWord32
nundefsym <- getWord32
skip 4 -- tocoff
ntoc <- getWord32
skip 4 -- modtaboff
nmodtab <- getWord32
skip 12 -- extrefsymoff, nextrefsyms, indirectsymoff,
nindirectsyms <- getWord32
skip 16 -- extreloff, nextrel, locreloff, nlocrel,
message "LC_DYSYMTAB:"
--
if nlocalsym > 0
then message (printf " %d local symbols at index %d" nlocalsym ilocalsym)
else message (printf " No local symbols")
if nextdefsym > 0
then message (printf " %d external symbols at index %d" nextdefsym iextdefsym)
else message (printf " No external symbols")
if nundefsym > 0
then message (printf " %d undefined symbols at index %d" nundefsym iundefsym)
else message (printf " No undefined symbols")
if ntoc > 0
then message (printf " %d table of contents entries" ntoc)
else message (printf " No table of contents")
if nmodtab > 0
then message (printf " %d module table entries" nmodtab)
else message (printf " No module table")
if nindirectsyms > 0
then message (printf " %d indirect symbols" nindirectsyms)
else message (printf " No indirect symbols")

loadSymbol :: Peek -> ByteString -> Get Symbol
loadSymbol Peek{..} strtab = do
Expand Down
40 changes: 2 additions & 38 deletions accelerate-llvm-native/accelerate-llvm-native.cabal
Expand Up @@ -75,29 +75,6 @@ extra-source-files:
README.md


-- Configuration flags
-- -------------------

Flag debug
Default: False
Description:
Enable debug tracing message flags. Note that 'debug' must be enabled in the
base 'accelerate' package as well. See the 'accelerate' package for usage
and available options.

Flag bounds-checks
Default: True
Description: Enable bounds checking

Flag unsafe-checks
Default: False
Description: Enable bounds checking in unsafe operations

Flag internal-checks
Default: False
Description: Enable internal consistency checks


-- Build configuration
-- -------------------

Expand Down Expand Up @@ -151,15 +128,14 @@ Library

build-depends:
base >= 4.7 && < 4.11
, accelerate == 1.1.*
, accelerate-llvm == 1.1.*
, accelerate == 1.2.*
, accelerate-llvm == 1.2.*
, bytestring >= 0.10.4
, Cabal >= 2.0
, cereal >= 0.4
, containers >= 0.5 && < 0.6
, directory >= 1.0
, dlist >= 0.6
, fclabels >= 2.0
, filepath >= 1.0
, ghc
, hashable >= 1.0
Expand All @@ -179,18 +155,6 @@ Library
if impl(ghc >= 8.0)
ghc-options: -Wmissed-specialisations

if flag(debug)
cpp-options: -DACCELERATE_DEBUG

if flag(bounds-checks)
cpp-options: -DACCELERATE_BOUNDS_CHECKS

if flag(unsafe-checks)
cpp-options: -DACCELERATE_UNSAFE_CHECKS

if flag(internal-checks)
cpp-options: -DACCELERATE_INTERNAL_CHECKS

if os(darwin)
other-modules:
Data.Array.Accelerate.LLVM.Native.Link.MachO
Expand Down
20 changes: 9 additions & 11 deletions accelerate-llvm-ptx/Data/Array/Accelerate/LLVM/PTX/Compile.hs
Expand Up @@ -31,9 +31,7 @@ import qualified LLVM.PassManager as LLVM
import qualified LLVM.Target as LLVM
import qualified LLVM.Internal.Module as LLVM.Internal
import qualified LLVM.Internal.FFI.LLVMCTypes as LLVM.Internal.FFI
#ifdef ACCELERATE_INTERNAL_CHECKS
import qualified LLVM.Analysis as LLVM
#endif

-- accelerate
import Data.Array.Accelerate.Error ( internalError )
Expand Down Expand Up @@ -121,8 +119,8 @@ compile acc aenv = do
--
cubin <- liftIO . unsafeInterleaveIO $ do
exists <- doesFileExist cacheFile
recomp <- Debug.queryFlag Debug.force_recomp
if exists && not (fromMaybe False recomp)
recomp <- if Debug.debuggingIsEnabled then Debug.getFlag Debug.force_recomp else return False
if exists && not recomp
then do
Debug.traceIO Debug.dump_cc (printf "cc: found cached object code %016x" uid)
B.readFile cacheFile
Expand Down Expand Up @@ -156,8 +154,8 @@ compilePTX dev ctx ast = do
--
compileCUBIN :: CUDA.DeviceProperties -> FilePath -> ByteString -> IO ByteString
compileCUBIN dev sass ptx = do
_verbose <- Debug.queryFlag Debug.verbose
_debug <- Debug.queryFlag Debug.debug_cc
_verbose <- if Debug.debuggingIsEnabled then Debug.getFlag Debug.verbose else return False
_debug <- if Debug.debuggingIsEnabled then Debug.getFlag Debug.debug else return False
--
let verboseFlag = if _verbose then [ "-v" ] else []
debugFlag = if _debug then [ "-g", "-lineinfo" ] else []
Expand Down Expand Up @@ -236,7 +234,7 @@ ignoreSIGPIPE =
--
compileModuleNVVM :: CUDA.DeviceProperties -> String -> [(String, ByteString)] -> LLVM.Module -> IO ByteString
compileModuleNVVM dev name libdevice mdl = do
_debug <- Debug.queryFlag Debug.debug_cc
_debug <- if Debug.debuggingIsEnabled then Debug.getFlag Debug.debug else return False
--
let arch = CUDA.computeCapability dev
verbose = if _debug then [ NVVM.GenerateDebugInfo ] else []
Expand Down Expand Up @@ -280,14 +278,14 @@ compileModuleNVPTX :: CUDA.DeviceProperties -> LLVM.Module -> IO ByteString
compileModuleNVPTX dev mdl =
withPTXTargetMachine dev $ \nvptx -> do

when Debug.internalChecksAreEnabled $ LLVM.verify mdl

-- Run the standard optimisation pass
--
let pss = LLVM.defaultCuratedPassSetSpec { LLVM.optLevel = Just 3 }
LLVM.withPassManager pss $ \pm -> do
#ifdef ACCELERATE_INTERNAL_CHECKS
LLVM.verify mdl
#endif
b1 <- LLVM.runPassManager pm mdl

b1 <- LLVM.runPassManager pm mdl

-- debug printout
Debug.when Debug.dump_cc $ do
Expand Down
14 changes: 4 additions & 10 deletions accelerate-llvm-ptx/Data/Array/Accelerate/LLVM/PTX/Debug.hs
@@ -1,5 +1,3 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE TypeOperators #-}
-- |
-- Module : Data.Array.Accelerate.LLVM.PTX.Debug
-- Copyright : [2014..2017] Trevor L. McDonell
Expand All @@ -24,7 +22,6 @@ import Foreign.CUDA.Driver.Stream ( Stream )
import qualified Foreign.CUDA.Driver.Event as Event

import Control.Concurrent
import Data.Label
import Data.Time.Clock
import System.CPUTime
import Text.Printf
Expand All @@ -36,14 +33,14 @@ import GHC.Float
-- to format the output string given elapsed GPU and CPU time respectively
--
timed
:: (Flags :-> Bool)
:: Flag
-> (Double -> Double -> Double -> String)
-> Maybe Stream
-> IO ()
-> IO ()
{-# INLINE timed #-}
timed f msg =
monitorProcTime (queryFlag f) (\t1 t2 t3 -> traceIO f (msg t1 t2 t3))
monitorProcTime (getFlag f) (\t1 t2 t3 -> traceIO f (msg t1 t2 t3))

monitorProcTime
:: IO Bool
Expand All @@ -52,9 +49,8 @@ monitorProcTime
-> IO ()
-> IO ()
{-# INLINE monitorProcTime #-}
#if ACCELERATE_DEBUG
monitorProcTime enabled display stream action = do
yes <- enabled
yes <- if debuggingIsEnabled then enabled else return False
if yes
then do
gpuBegin <- Event.create []
Expand Down Expand Up @@ -87,9 +83,7 @@ monitorProcTime enabled display stream action = do

else
action
#else
monitorProcTime _ _ _ action = action
#endif


{-# INLINE elapsed #-}
elapsed :: Double -> Double -> Double -> String
Expand Down
Expand Up @@ -584,7 +584,7 @@ launch Kernel{..} stream n args =
-- Debugging/monitoring support
query = if Debug.monitoringIsEnabled
then return True
else Debug.queryFlag Debug.dump_exec
else Debug.getFlag Debug.dump_exec

fst3 (x,_,_) = x
msg wall cpu gpu = do
Expand Down
38 changes: 2 additions & 36 deletions accelerate-llvm-ptx/accelerate-llvm-ptx.cabal
Expand Up @@ -83,26 +83,6 @@ Flag nvvm
Default: False
Description: Use the NVVM library to generate optimised PTX

Flag debug
Default: False
Description:
Enable debug tracing message flags. Note that 'debug' must be enabled in the
base 'accelerate' package as well. See the 'accelerate' package for usage
and available options.

Flag bounds-checks
Default: True
Description: Enable bounds checking

Flag unsafe-checks
Default: False
Description: Enable bounds checking in unsafe operations

Flag internal-checks
Default: False
Description: Enable internal consistency checks


-- Build configuration
-- -------------------

Expand Down Expand Up @@ -160,15 +140,14 @@ Library

build-depends:
base >= 4.7 && < 4.11
, accelerate == 1.1.*
, accelerate-llvm == 1.1.*
, accelerate == 1.2.*
, accelerate-llvm == 1.2.*
, bytestring >= 0.10.4
, containers >= 0.5 && <0.6
, cuda >= 0.8
, deepseq >= 1.3
, directory >= 1.0
, dlist >= 0.6
, fclabels >= 2.0
, file-embed >= 0.0.8
, filepath >= 1.0
, hashable >= 1.2
Expand All @@ -193,19 +172,6 @@ Library
if flag(nvvm)
cpp-options: -DACCELERATE_USE_NVVM

if flag(debug)
cpp-options: -DACCELERATE_DEBUG

if flag(bounds-checks)
cpp-options: -DACCELERATE_BOUNDS_CHECKS

if flag(unsafe-checks)
cpp-options: -DACCELERATE_UNSAFE_CHECKS

if flag(internal-checks)
cpp-options: -DACCELERATE_INTERNAL_CHECKS


source-repository head
type: git
location: https://github.com/AccelerateHS/accelerate-llvm.git
Expand Down
Expand Up @@ -72,7 +72,7 @@ cacheOfUID
=> UID
-> LLVM arch FilePath
cacheOfUID uid = do
dbg <- liftIO $ queryFlag debug_cc
dbg <- liftIO $ if debuggingIsEnabled then getFlag debug else return False
appdir <- liftIO $ getAppUserDataDirectory "accelerate"
template <- targetCacheTemplate
let
Expand Down

0 comments on commit d4e3764

Please sign in to comment.