Skip to content

Commit

Permalink
Merge branch 'master' of github.com:AccelerateHS/accelerate
Browse files Browse the repository at this point in the history
  • Loading branch information
tmcdonell committed Nov 19, 2021
2 parents 7b8a141 + 20cd262 commit 2fbefef
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/.ghci
/dist/
/dist-newstyle/
/accelerate-examples/dist
/accelerate-buildbot/dist
/accelerate-cuda/dist/
Expand All @@ -8,6 +9,7 @@
/accelerate-cuda/cubits/accelerate_cuda_shape.h
/accelerate-io/dist/
/.stack-work
/cabal.project.local*
/stack.yaml
/stack.yaml.lock
.DS_Store
Expand Down
43 changes: 42 additions & 1 deletion accelerate.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ extra-source-files:
CHANGELOG.md
cbits/*.c
cbits/*.h
-- These are referenced directly using the FFI
cbits/tracy/*.h
cbits/tracy/*.hpp
cbits/tracy/*.cpp
Expand All @@ -146,6 +147,46 @@ extra-source-files:
cbits/tracy/client/*.h
cbits/tracy/client/*.hpp
cbits/tracy/client/*.cpp
-- These are used to build Tracy's client tools in Setup.hs
cbits/tracy/capture/build/unix/Makefile
cbits/tracy/capture/build/unix/*.mk
cbits/tracy/profiler/build/unix/Makefile
cbits/tracy/profiler/build/unix/*.mk
cbits/tracy/common/*.mk
-- The Makefiles fetch the source files from these Visual Studio project
-- files
cbits/tracy/capture/build/win32/capture.vcxproj
cbits/tracy/capture/build/win32/capture.vcxproj.filters
cbits/tracy/profiler/build/win32/Tracy.vcxproj
cbits/tracy/profiler/build/win32/Tracy.vcxproj.filters
-- Used by the Tracy's client tools
cbits/tracy/capture/src/*.cpp
cbits/tracy/imgui/*.h
cbits/tracy/imgui/*.cpp
cbits/tracy/imgui/misc/freetype/*.h
cbits/tracy/imgui/misc/freetype/*.cpp
cbits/tracy/libbacktrace/*.h
cbits/tracy/libbacktrace/*.hpp
cbits/tracy/libbacktrace/*.cpp
cbits/tracy/nfd/*.h
cbits/tracy/nfd/*.c
cbits/tracy/profiler/src/*.h
cbits/tracy/profiler/src/*.hpp
cbits/tracy/profiler/src/*.cpp
cbits/tracy/profiler/libs/gl3w/GL/*.h
cbits/tracy/profiler/libs/gl3w/GL/*.c
cbits/tracy/server/*.h
cbits/tracy/server/*.hpp
cbits/tracy/server/*.cpp
cbits/tracy/zstd/*.h
cbits/tracy/zstd/common/*.h
cbits/tracy/zstd/common/*.c
cbits/tracy/zstd/compress/*.h
cbits/tracy/zstd/compress/*.c
cbits/tracy/zstd/decompress/*.h
cbits/tracy/zstd/decompress/*.c
cbits/tracy/zstd/dictBuilder/*.h
cbits/tracy/zstd/dictBuilder/*.c

extra-doc-files:
images/*.png
Expand Down Expand Up @@ -587,7 +628,7 @@ test-suite doctest
default-language: Haskell2010
hs-source-dirs: test/doctest
main-is: Main.hs
other-modules: Build_doctests
autogen-modules: Build_doctests

build-depends:
base >= 4.10
Expand Down
7 changes: 3 additions & 4 deletions src/Data/Array/Accelerate/AST/Idx.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE ViewPatterns #-}
{-# OPTIONS_HADDOCK hide #-}
Expand Down Expand Up @@ -76,12 +75,12 @@ newtype Idx env t = UnsafeIdxConstructor { unsafeRunIdx :: Int }

{-# COMPLETE ZeroIdx, SuccIdx #-}

pattern ZeroIdx :: forall env envt t. () => (envt ~ (env, t)) => Idx envt t
pattern ZeroIdx <- (\x -> (idxToInt x, unsafeCoerce @(envt :~: envt) @(envt :~: (env, t)) Refl) -> (0, Refl))
pattern ZeroIdx :: forall envt t. () => forall env. (envt ~ (env, t)) => Idx envt t
pattern ZeroIdx <- (\x -> (idxToInt x, unsafeCoerce Refl) -> (0, Refl :: envt :~: (env, t)))
where
ZeroIdx = UnsafeIdxConstructor 0

pattern SuccIdx :: () => (envs ~ (env, s)) => Idx env t -> Idx envs t
pattern SuccIdx :: forall envs t. () => forall s env. (envs ~ (env, s)) => Idx env t -> Idx envs t
pattern SuccIdx idx <- (unSucc -> Just (idx, Refl))
where
SuccIdx (UnsafeIdxConstructor i) = UnsafeIdxConstructor (i+1)
Expand Down
18 changes: 17 additions & 1 deletion src/Data/Array/Accelerate/Debug/Internal/Clock.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE ForeignFunctionInterface #-}
{-# LANGUAGE TemplateHaskell #-}
{-# OPTIONS_GHC -fobject-code #-}
Expand All @@ -16,12 +17,27 @@ module Data.Array.Accelerate.Debug.Internal.Clock

import Language.Haskell.TH.Syntax

-- FIXME: HLS requires stubs because it does not process the
-- 'addForeignFilePath' calls when evaluating Template Haskell
--
-- https://github.com/haskell/haskell-language-server/issues/365
#ifndef __GHCIDE__

foreign import ccall unsafe "clock_gettime_monotonic_seconds" getMonotonicTime :: IO Double
foreign import ccall unsafe "clock_gettime_elapsed_seconds" getProgramTime :: IO Double

#else

getMonotonicTime :: IO Double
getMonotonicTime = undefined

getProgramTime :: IO Double
getProgramTime = undefined

#endif

-- SEE: [linking to .c files]
--
runQ $ do
addForeignFilePath LangC "cbits/clock.c"
return []

31 changes: 31 additions & 0 deletions src/Data/Array/Accelerate/Debug/Internal/Profile.hs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,12 @@ emit_remote_gc = void $ Atomic.add __num_remote_gcs 1
-- Monitoring variables
-- --------------------

-- FIXME: HLS requires stubs because it does not process the
-- 'addForeignFilePath' calls when evaluating Template Haskell
--
-- https://github.com/haskell/haskell-language-server/issues/365
#ifndef __GHCIDE__

foreign import ccall "&__total_bytes_allocated_local" __total_bytes_allocated_local :: Atomic -- bytes allocated in the local (CPU) memory space
foreign import ccall "&__total_bytes_allocated_remote" __total_bytes_allocated_remote :: Atomic -- bytes allocated in the remote memory space (if it is separate, e.g. GPU)
foreign import ccall "&__total_bytes_copied_to_remote" __total_bytes_copied_to_remote :: Atomic -- bytes copied to the remote memory space
Expand All @@ -152,6 +158,31 @@ foreign import ccall "&__total_bytes_evicted_from_remote" __total_bytes_evicted_
foreign import ccall "&__num_remote_gcs" __num_remote_gcs :: Atomic -- number of times the remote memory space was forcibly garbage collected
foreign import ccall "&__num_evictions" __num_evictions :: Atomic -- number of LRU eviction events

#else

__total_bytes_allocated_local :: Atomic
__total_bytes_allocated_local = undefined

__total_bytes_allocated_remote :: Atomic
__total_bytes_allocated_remote = undefined

__total_bytes_copied_to_remote :: Atomic
__total_bytes_copied_to_remote = undefined

__total_bytes_copied_from_remote :: Atomic
__total_bytes_copied_from_remote = undefined

__total_bytes_evicted_from_remote :: Atomic
__total_bytes_evicted_from_remote = undefined

__num_remote_gcs :: Atomic
__num_remote_gcs = undefined

__num_evictions :: Atomic
__num_evictions = undefined

#endif

-- SEE: [linking to .c files]
--
runQ $ do
Expand Down
8 changes: 6 additions & 2 deletions src/Data/Array/Accelerate/Debug/Internal/Tracy.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,18 @@ import Foreign.C.String
import Foreign.C.Types
import Foreign.Ptr

#ifdef ACCELERATE_DEBUG
#if defined(ACCELERATE_DEBUG) && !defined(__GHCIDE__)
import Language.Haskell.TH.Syntax
#endif

type Zone = Word64
type SrcLoc = Word64

#ifdef ACCELERATE_DEBUG
-- FIXME: HLS requires stubs because it does not process the
-- 'addForeignFilePath' calls when evaluating Template Haskell
--
-- https://github.com/haskell/haskell-language-server/issues/365
#if defined(ACCELERATE_DEBUG) && !defined(__GHCIDE__)

foreign import ccall unsafe "___tracy_init_thread" init_thread :: IO ()
foreign import ccall unsafe "___tracy_set_thread_name" set_thread_name :: CString -> IO ()
Expand Down

0 comments on commit 2fbefef

Please sign in to comment.