packages feed

cuda 0.7.5.3 → 0.8.0.0

raw patch · 43 files changed

+602/−127 lines, 43 filesdep +filepathsetup-changed

Dependencies added: filepath

Files

CHANGELOG.markdown view
@@ -1,56 +1,70 @@-0.7.5.3--  * Bug fix in occupancy calculator--0.7.5.2+# Change Log -  * Bug fixes: #43, #45, #47+Notable changes to the project will be documented in this file. -0.7.5.1+The format is based on [Keep a Changelog](http://keepachangelog.com/). -  * Re-enable support for Cabal-1.22+## [0.8.0.0] - 2017-08-24+### Changed+  * Tested with CUDA toolkit 8.0 -  * Bug fixes: #40, #44+### Added+  * Add operations for unified addressing in the device API+  * Add `write` and `wait` operations for streams in the device API+  * (internals) The paths this module was configured against are exposed by the+    module `Foreign.CUDA.Paths`. -0.7.5.0+## [0.7.5.3] - 2017-03-23+### Fixed+  * Bug fix in occupancy calculator -  * Add support for CUDA-7.5+## [0.7.5.2] - 2017-01-06+### Fixed+  * [#43]: Build fails with library profiling+  * [#45]: On Windows, the Cabal installer is looking in the wrong place+  * [#47]: Windows install fix -0.7.1.0+## [0.7.5.1] - 2016-10-21+### Fixed+  * Re-enable support for Cabal-1.22+  * [#40]: Unknown CUDA device compute capability 6.1+  * [#44]: Compilation fails for CUDA-8 [was: ghc 7.10.3 fail to install] -  * mallocHostForeignPtr+## [0.7.5.0] - 2016-10-07+### Changed+  * Tested with CUDA toolkit 7.5 +### Added+  * Add functions from CUDA-7.5   * Add profiler control functions--0.7.0.0+  * Add function `mallocHostForeignPtr` +## [0.7.0.0] - 2015-11-30+### Changed   * Add support for operations from CUDA-7.0-   * Add support for online linking-   * Add support for inter-process communication-   * Bug fixes, extra documentation, improve library coverage.-   * Mac OS X no longer requires the DYLD_LIBRARY_PATH environment variable in     order to compile or run programs that use this package. -0.6.7.0--  * Add support for building on Windows (thanks to mwu-tow)--0.6.6.2+## [0.6.7.0] - 2015-09-12+### Added+  * Add support for building on Windows (thanks to @mwu-tow) +## [0.6.6.2] - 2015-04-04+### Fixed   * Build fix -0.6.6.1-+## [0.6.6.1] - 2015-04-04 [YANKED]+### Fixed   * Build fixes for ghc-7.6 and ghc-7.10 -0.6.6.0--  * Drop support for CUDA 3.0 and older.+## [0.6.6.0] - 2015-03-10+### Added+  * Add compute-capability data for 3.7, 5.2 devices. +### Changed   * Combine the definition of the 'Event' and 'Stream' data types. As of     CUDA-3.1 these data structures are equivalent, and can be safely shared     between runtime and driver API calls and libraries.@@ -59,13 +73,38 @@     allows them to be safely called from Haskell threads without blocking the     entire HEC. -  * Add compute-capability data for 3.7, 5.2 devices.--0.6.5.1+### Removed+  * Drop support for CUDA 3.0 and older. +## [0.6.5.1] - 2014-12-02+### Fixed   * Build fix for Mac OS X 10.10 (Yosemite) -0.6.5.0+## [0.6.5.0] - 2014-09-03+### Changed+  * Tested with CUDA toolkit 6.5 -  * Add support for the CUDA-6.5 release+### Added+  * Add functions from CUDA-6.5+++[unreleased]: https://github.com/tmcdonell/cuda/compare/0.8.0.0...HEAD+[0.8.0.0]:    https://github.com/tmcdonell/cuda/compare/0.7.5.3...0.8.0.0+[0.7.5.3]:    https://github.com/tmcdonell/cuda/compare/0.7.5.2...0.7.5.3+[0.7.5.2]:    https://github.com/tmcdonell/cuda/compare/0.7.5.1...0.7.5.2+[0.7.5.1]:    https://github.com/tmcdonell/cuda/compare/0.7.5.0...0.7.5.1+[0.7.5.0]:    https://github.com/tmcdonell/cuda/compare/0.7.0.0...0.7.5.0+[0.7.0.0]:    https://github.com/tmcdonell/cuda/compare/0.6.7.0...0.7.0.0+[0.6.7.0]:    https://github.com/tmcdonell/cuda/compare/0.6.6.2...0.6.7.0+[0.6.6.2]:    https://github.com/tmcdonell/cuda/compare/0.6.6.1...0.6.6.2+[0.6.6.1]:    https://github.com/tmcdonell/cuda/compare/0.6.6.0...0.6.6.1+[0.6.6.0]:    https://github.com/tmcdonell/cuda/compare/0.6.5.1...0.6.6.0+[0.6.5.1]:    https://github.com/tmcdonell/cuda/compare/0.6.5.0...0.6.5.1+[0.6.5.0]:    https://github.com/tmcdonell/cuda/compare/0.6.0.1...0.6.5.0++[#40]:        https://github.com/tmcdonell/cuda/issues/40+[#43]:        https://github.com/tmcdonell/cuda/issues/43+[#44]:        https://github.com/tmcdonell/cuda/issues/44+[#45]:        https://github.com/tmcdonell/cuda/issues/45+[#47]:        https://github.com/tmcdonell/cuda/pull/47 
README.markdown view
@@ -2,6 +2,7 @@ ============================  [![Build status](https://travis-ci.org/tmcdonell/cuda.svg?branch=master)](https://travis-ci.org/tmcdonell/cuda)+[![Hackage](https://img.shields.io/hackage/v/cuda.svg)](https://hackage.haskell.org/package/cuda)  The CUDA library provides a direct, general purpose C-like SPMD programming model for NVIDIA graphics cards (G8x series onwards). This is a collection of
Setup.hs view
@@ -116,13 +116,15 @@ libraryBuildInfo :: Bool -> FilePath -> Platform -> Version -> IO HookedBuildInfo libraryBuildInfo profile installPath platform@(Platform arch os) ghcVersion = do   let-      libraryPaths      = [cudaLibraryPath platform installPath]-      includePaths      = [cudaIncludePath platform installPath]+      libraryPath       = cudaLibraryPath platform installPath+      includePath       = cudaIncludePath platform installPath        -- options for GHC-      extraLibDirs'     = libraryPaths-      ccOptions'        = map ("-I"++) includePaths-      ldOptions'        = map ("-L"++) libraryPaths+      extraLibDirs'     = [ libraryPath ]+      ccOptions'        = [ "-DCUDA_INSTALL_PATH=\"" ++ installPath ++ "\""+                          , "-DCUDA_LIBRARY_PATH=\"" ++ libraryPath ++ "\""+                          , "-I" ++ includePath ]+      ldOptions'        = [ "-L" ++ libraryPath ]       ghcOptions        = map ("-optc"++) ccOptions'                        ++ map ("-optl"++) ldOptions'                        ++ if os /= Windows && not profile@@ -423,7 +425,7 @@       info verbosity $ printf "checking for %s" desc       found <- validateIOLocation verbosity platform path       if found-        then Just `fmap` path+        then fmap Just $ canonicalizePath =<< path         else go xs  
cuda.cabal view
@@ -1,5 +1,5 @@ Name:                   cuda-Version:                0.7.5.3+Version:                0.8.0.0 Synopsis:               FFI binding to the CUDA interface for programming NVIDIA GPUs Description:     The CUDA library provides a direct, general purpose C-like SPMD programming@@ -28,7 +28,8 @@     .     * "Foreign.CUDA.Runtime"     .-    This release tested with versions 6.0, 6.5, 7.0, and 7.5 of the CUDA toolkit.+    See the <https://travis-ci.org/tmcdonell/cuda travis-ci.org> build matrix+    for tested CUDA library versions.     .     [/NOTES:/]     .@@ -56,7 +57,7 @@  License:                BSD3 License-file:           LICENSE-Copyright:              Copyright (c) [2009..2016]. Trevor L. McDonell <tmcdonell@cse.unsw.edu.au>+Copyright:              Copyright (c) [2009..2017]. Trevor L. McDonell <tmcdonell@cse.unsw.edu.au> Author:                 Trevor L. McDonell <tmcdonell@cse.unsw.edu.au> Maintainer:             Trevor L. McDonell <tmcdonell@cse.unsw.edu.au> Homepage:               https://github.com/tmcdonell/cuda@@ -83,46 +84,56 @@  Library   hs-source-dirs:       src-  Exposed-Modules:      Foreign.CUDA-                        Foreign.CUDA.Ptr-                        Foreign.CUDA.Types-                        Foreign.CUDA.Analysis-                        Foreign.CUDA.Analysis.Device-                        Foreign.CUDA.Analysis.Occupancy-                        Foreign.CUDA.Runtime-                        Foreign.CUDA.Runtime.Device-                        Foreign.CUDA.Runtime.Error-                        Foreign.CUDA.Runtime.Event-                        Foreign.CUDA.Runtime.Exec-                        Foreign.CUDA.Runtime.Marshal-                        Foreign.CUDA.Runtime.Stream-                        Foreign.CUDA.Runtime.Texture-                        Foreign.CUDA.Runtime.Utils-                        Foreign.CUDA.Driver-                        Foreign.CUDA.Driver.Context-                        Foreign.CUDA.Driver.Context.Base-                        Foreign.CUDA.Driver.Context.Config-                        Foreign.CUDA.Driver.Context.Peer-                        Foreign.CUDA.Driver.Context.Primary-                        Foreign.CUDA.Driver.Device-                        Foreign.CUDA.Driver.Error-                        Foreign.CUDA.Driver.Event-                        Foreign.CUDA.Driver.Exec-                        Foreign.CUDA.Driver.IPC.Event-                        Foreign.CUDA.Driver.IPC.Marshal-                        Foreign.CUDA.Driver.Marshal-                        Foreign.CUDA.Driver.Module-                        Foreign.CUDA.Driver.Module.Base-                        Foreign.CUDA.Driver.Module.Link-                        Foreign.CUDA.Driver.Module.Query-                        Foreign.CUDA.Driver.Profiler-                        Foreign.CUDA.Driver.Stream-                        Foreign.CUDA.Driver.Texture-                        Foreign.CUDA.Driver.Utils+  Exposed-Modules:+      Foreign.CUDA+      Foreign.CUDA.Path+      Foreign.CUDA.Ptr+      Foreign.CUDA.Types -  Other-modules:        Foreign.CUDA.Internal.C2HS-                        Text.Show.Describe+      -- Kernel and device analysis+      Foreign.CUDA.Analysis+      Foreign.CUDA.Analysis.Device+      Foreign.CUDA.Analysis.Occupancy +      -- Driver API+      Foreign.CUDA.Driver+      Foreign.CUDA.Driver.Context+      Foreign.CUDA.Driver.Context.Base+      Foreign.CUDA.Driver.Context.Config+      Foreign.CUDA.Driver.Context.Peer+      Foreign.CUDA.Driver.Context.Primary+      Foreign.CUDA.Driver.Device+      Foreign.CUDA.Driver.Error+      Foreign.CUDA.Driver.Event+      Foreign.CUDA.Driver.Exec+      Foreign.CUDA.Driver.IPC.Event+      Foreign.CUDA.Driver.IPC.Marshal+      Foreign.CUDA.Driver.Marshal+      Foreign.CUDA.Driver.Module+      Foreign.CUDA.Driver.Module.Base+      Foreign.CUDA.Driver.Module.Link+      Foreign.CUDA.Driver.Module.Query+      Foreign.CUDA.Driver.Profiler+      Foreign.CUDA.Driver.Stream+      Foreign.CUDA.Driver.Texture+      Foreign.CUDA.Driver.Unified+      Foreign.CUDA.Driver.Utils++      -- Runtime API+      Foreign.CUDA.Runtime+      Foreign.CUDA.Runtime.Device+      Foreign.CUDA.Runtime.Error+      Foreign.CUDA.Runtime.Event+      Foreign.CUDA.Runtime.Exec+      Foreign.CUDA.Runtime.Marshal+      Foreign.CUDA.Runtime.Stream+      Foreign.CUDA.Runtime.Texture+      Foreign.CUDA.Runtime.Utils++  Other-modules:+      Foreign.CUDA.Internal.C2HS+      Text.Show.Describe+   Include-dirs:         .   C-sources:            cbits/stubs.c                         cbits/init.c@@ -131,17 +142,21 @@   Build-depends:       base              >= 4 && < 5     , bytestring+    , filepath          >= 1.0     , template-haskell    default-language:     Haskell98   Extensions:-  ghc-options:          -Wall-                        -O2-                        -funbox-strict-fields-                        -fwarn-tabs-                        -fno-warn-unused-imports+  ghc-options:+      -Wall+      -O2+      -funbox-strict-fields+      -fwarn-tabs+      -fno-warn-unused-imports -  ghc-prof-options:     -fprof-auto -fprof-cafs+  ghc-prof-options:+      -fprof-auto+      -fprof-cafs    if impl(ghc == 8.0.1)     cpp-options:        -DCUDA_PRELOAD@@ -159,10 +174,14 @@   default-language:     Haskell98  +source-repository head+    type:               git+    location:           https://github.com/tmcdonell/cuda+ source-repository this     type:               git     location:           https://github.com/tmcdonell/cuda-    tag:                0.7.5.3+    tag:                0.8.0.0  -- vim: nospell 
src/Foreign/CUDA.hs view
@@ -1,7 +1,7 @@ -------------------------------------------------------------------------------- -- | -- Module    : Foreign.CUDA--- Copyright : [2009..2014] Trevor L. McDonell+-- Copyright : [2009..2017] Trevor L. McDonell -- License   : BSD -- -- Top level bindings. By default, expose the C-for-CUDA runtime API bindings,
src/Foreign/CUDA/Analysis.hs view
@@ -1,7 +1,7 @@ -------------------------------------------------------------------------------- -- | -- Module    : Foreign.CUDA.Analysis--- Copyright : [2009..2014] Trevor L. McDonell+-- Copyright : [2009..2017] Trevor L. McDonell -- License   : BSD -- -- Meta-module exporting CUDA analysis routines
src/Foreign/CUDA/Analysis/Device.chs view
@@ -1,7 +1,7 @@ -------------------------------------------------------------------------------- -- | -- Module    : Foreign.CUDA.Analysis.Device--- Copyright : [2009..2014] Trevor L. McDonell+-- Copyright : [2009..2017] Trevor L. McDonell -- License   : BSD -- -- Common device functions
src/Foreign/CUDA/Analysis/Occupancy.hs view
@@ -2,7 +2,7 @@ -------------------------------------------------------------------------------- -- | -- Module    : Foreign.CUDA.Analysis.Occupancy--- Copyright : [2009..2014] Trevor L. McDonell+-- Copyright : [2009..2017] Trevor L. McDonell -- License   : BSD -- -- Occupancy calculations for CUDA kernels
src/Foreign/CUDA/Driver.hs view
@@ -1,7 +1,7 @@ -------------------------------------------------------------------------------- -- | -- Module    : Foreign.CUDA.Driver--- Copyright : [2009..2015] Trevor L. McDonell+-- Copyright : [2009..2017] Trevor L. McDonell -- License   : BSD -- -- This module defines an interface to the CUDA driver API. The Driver API@@ -223,6 +223,7 @@   module Foreign.CUDA.Driver.Exec,   module Foreign.CUDA.Driver.Marshal,   module Foreign.CUDA.Driver.Module,+  module Foreign.CUDA.Driver.Unified,   module Foreign.CUDA.Driver.Utils  ) where@@ -234,5 +235,6 @@ import Foreign.CUDA.Driver.Exec import Foreign.CUDA.Driver.Marshal      hiding ( useDeviceHandle, peekDeviceHandle ) import Foreign.CUDA.Driver.Module+import Foreign.CUDA.Driver.Unified import Foreign.CUDA.Driver.Utils 
src/Foreign/CUDA/Driver/Context.hs view
@@ -1,7 +1,7 @@ -------------------------------------------------------------------------------- -- | -- Module    : Foreign.CUDA.Driver.Context--- Copyright : [2009..2015] Trevor L. McDonell+-- Copyright : [2009..2017] Trevor L. McDonell -- License   : BSD -- -- Context management for low-level driver interface
src/Foreign/CUDA/Driver/Context/Base.chs view
@@ -9,7 +9,7 @@ -------------------------------------------------------------------------------- -- | -- Module    : Foreign.CUDA.Driver.Context.Base--- Copyright : [2009..2015] Trevor L. McDonell+-- Copyright : [2009..2017] Trevor L. McDonell -- License   : BSD -- -- Context management for the low-level driver interface
src/Foreign/CUDA/Driver/Context/Config.chs view
@@ -9,7 +9,7 @@ -------------------------------------------------------------------------------- -- | -- Module    : Foreign.CUDA.Driver.Context.Config--- Copyright : [2009..2015] Trevor L. McDonell+-- Copyright : [2009..2017] Trevor L. McDonell -- License   : BSD -- -- Context configuration for the low-level driver interface
src/Foreign/CUDA/Driver/Context/Peer.chs view
@@ -9,7 +9,7 @@ -------------------------------------------------------------------------------- -- | -- Module    : Foreign.CUDA.Driver.Context.Peer--- Copyright : [2009..2015] Trevor L. McDonell+-- Copyright : [2009..2017] Trevor L. McDonell -- License   : BSD -- -- Direct peer context access functions for the low-level driver interface.
src/Foreign/CUDA/Driver/Context/Primary.chs view
@@ -5,7 +5,7 @@ -------------------------------------------------------------------------------- -- | -- Module    : Foreign.CUDA.Driver.Context.Primary--- Copyright : [2009..2014] Trevor L. McDonell+-- Copyright : [2009..2017] Trevor L. McDonell -- License   : BSD -- -- Primary context management for low-level driver interface. The primary
src/Foreign/CUDA/Driver/Device.chs view
@@ -8,7 +8,7 @@ -------------------------------------------------------------------------------- -- | -- Module    : Foreign.CUDA.Driver.Device--- Copyright : [2009..2014] Trevor L. McDonell+-- Copyright : [2009..2017] Trevor L. McDonell -- License   : BSD -- -- Device management for low-level driver interface
src/Foreign/CUDA/Driver/Error.chs view
@@ -4,7 +4,7 @@ -------------------------------------------------------------------------------- -- | -- Module    : Foreign.CUDA.Driver.Error--- Copyright : [2009..2014] Trevor L. McDonell+-- Copyright : [2009..2017] Trevor L. McDonell -- License   : BSD -- -- Error handling
src/Foreign/CUDA/Driver/Event.chs view
@@ -6,7 +6,7 @@ -------------------------------------------------------------------------------- -- | -- Module    : Foreign.CUDA.Driver.Event--- Copyright : [2009..2014] Trevor L. McDonell+-- Copyright : [2009..2017] Trevor L. McDonell -- License   : BSD -- -- Event management for low-level driver interface
src/Foreign/CUDA/Driver/Exec.chs view
@@ -7,7 +7,7 @@ -------------------------------------------------------------------------------- -- | -- Module    : Foreign.CUDA.Driver.Exec--- Copyright : [2009..2014] Trevor L. McDonell+-- Copyright : [2009..2017] Trevor L. McDonell -- License   : BSD -- -- Kernel execution control for low-level driver interface
src/Foreign/CUDA/Driver/IPC/Event.chs view
@@ -5,7 +5,7 @@ -------------------------------------------------------------------------------- -- | -- Module    : Foreign.CUDA.Driver.IPC.Event--- Copyright : [2009..2015] Trevor L. McDonell+-- Copyright : [2009..2017] Trevor L. McDonell -- License   : BSD -- -- IPC event management for low-level driver interface.
src/Foreign/CUDA/Driver/IPC/Marshal.chs view
@@ -6,7 +6,7 @@ -------------------------------------------------------------------------------- -- | -- Module    : Foreign.CUDA.Driver.IPC.Marshal--- Copyright : [2009..2015] Trevor L. McDonell+-- Copyright : [2009..2017] Trevor L. McDonell -- License   : BSD -- -- IPC memory management for low-level driver interface.
src/Foreign/CUDA/Driver/Marshal.chs view
@@ -7,7 +7,7 @@ -------------------------------------------------------------------------------- -- | -- Module    : Foreign.CUDA.Driver.Marshal--- Copyright : [2009..2014] Trevor L. McDonell+-- Copyright : [2009..2017] Trevor L. McDonell -- License   : BSD -- -- Memory management for low-level driver interface@@ -27,6 +27,7 @@   -- * Unified Memory Allocation   AttachFlag(..),   mallocManagedArray,+  prefetchArrayAsync,    -- * Marshalling   peekArray, peekArrayAsync, peekArray2D, peekArray2DAsync, peekListArray,@@ -52,6 +53,7 @@  -- Friends import Foreign.CUDA.Ptr+import Foreign.CUDA.Driver.Device import Foreign.CUDA.Driver.Error import Foreign.CUDA.Driver.Stream                       ( Stream(..), defaultStream ) import Foreign.CUDA.Driver.Context.Base                 ( Context(..) )@@ -327,6 +329,35 @@   , combineBitMasks `[AttachFlag]'                  } -> `Status' cToEnum #}   where     alloca' !f = F.alloca $ \ !p -> poke p nullPtr >> f (castPtr p)+#endif+++-- | Pre-fetches the given number of elements to the specified destination+-- device. If the specified device is Nothing, the data is pre-fetched to host+-- memory. The pointer must refer to a memory range allocated with+-- 'mallocManagedArray'.+--+-- <http://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__UNIFIED.html#group__CUDA__UNIFIED_1gfe94f8b7fb56291ebcea44261aa4cb84>+--+-- Requires CUDA-8.0.+--+prefetchArrayAsync :: Storable a => DevicePtr a -> Int -> Maybe Device -> Maybe Stream -> IO ()+#if CUDA_VERSION < 8000+prefetchArrayAsync _   _ _    _   = requireSDK 'prefetchArrayAsync 8.0+#else+prefetchArrayAsync ptr n mdev mst = go undefined ptr+  where+    go :: Storable a' => a' -> DevicePtr a' -> IO ()+    go x _ = nothingIfOk =<< cuMemPrefetchAsync ptr (n * sizeOf x) (maybe (-1) useDevice mdev) (fromMaybe defaultStream mst)++{-# INLINE cuMemPrefetchAsync #-}+{# fun unsafe cuMemPrefetchAsync+  { useDeviceHandle `DevicePtr a'+  ,                 `Int'+  ,                 `CInt'+  , useStream       `Stream'+  }+  -> `Status' cToEnum #} #endif  
src/Foreign/CUDA/Driver/Module.hs view
@@ -1,7 +1,7 @@ -------------------------------------------------------------------------------- -- | -- Module    : Foreign.CUDA.Driver.Module--- Copyright : [2009..2014] Trevor L. McDonell+-- Copyright : [2009..2017] Trevor L. McDonell -- License   : BSD -- -- Module management for low-level driver interface
src/Foreign/CUDA/Driver/Module/Base.chs view
@@ -7,7 +7,7 @@ -------------------------------------------------------------------------------- -- | -- Module    : Foreign.CUDA.Driver.Module.Base--- Copyright : [2009..2014] Trevor L. McDonell+-- Copyright : [2009..2017] Trevor L. McDonell -- License   : BSD -- -- Module loading for low-level driver interface
src/Foreign/CUDA/Driver/Module/Link.chs view
@@ -6,7 +6,7 @@ -------------------------------------------------------------------------------- -- | -- Module    : Foreign.CUDA.Driver.Module.Link--- Copyright : [2009..2014] Trevor L. McDonell+-- Copyright : [2009..2017] Trevor L. McDonell -- License   : BSD -- -- Module linking for low-level driver interface
src/Foreign/CUDA/Driver/Module/Query.chs view
@@ -3,7 +3,7 @@ -------------------------------------------------------------------------------- -- | -- Module    : Foreign.CUDA.Driver.Module.Query--- Copyright : [2009..2014] Trevor L. McDonell+-- Copyright : [2009..2017] Trevor L. McDonell -- License   : BSD -- -- Querying module attributes for low-level driver interface
src/Foreign/CUDA/Driver/Profiler.chs view
@@ -2,7 +2,7 @@ -------------------------------------------------------------------------------- -- | -- Module    : Foreign.CUDA.Driver.Profiler--- Copyright : [2009..2014] Trevor L. McDonell+-- Copyright : [2009..2017] Trevor L. McDonell -- License   : BSD -- -- Profiler control for low-level driver interface
src/Foreign/CUDA/Driver/Stream.chs view
@@ -5,7 +5,7 @@ -------------------------------------------------------------------------------- -- | -- Module    : Foreign.CUDA.Driver.Stream--- Copyright : [2009..2014] Trevor L. McDonell+-- Copyright : [2009..2017] Trevor L. McDonell -- License   : BSD -- -- Stream management for low-level driver interface@@ -15,8 +15,9 @@ module Foreign.CUDA.Driver.Stream (    -- * Stream Management-  Stream(..), StreamFlag,+  Stream(..), StreamFlag, StreamWriteFlag(..), StreamWaitFlag(..),   create, createWithPriority, destroy, finished, block, getPriority,+  write, wait,    defaultStream, @@ -68,7 +69,7 @@ -- be queried using 'Foreign.CUDA.Driver.Context.Config.getStreamPriorityRange'. -- If the specified priority is outside the supported numerical range, it -- will automatically be clamped to the highest or lowest number in the--- range.+-- range -- -- Requires CUDA-5.5. --@@ -163,5 +164,73 @@   , alloca-   `StreamPriority' peekIntConv*   }   -> `Status' cToEnum #}+#endif+++#if CUDA_VERSION < 8000+data StreamWriteFlag+data StreamWaitFlag+#else+{# enum CUstreamWriteValue_flags as StreamWriteFlag+  { underscoreToCase }+  with prefix="CU_STREAM" deriving (Eq, Show, Bounded) #}++{# enum CUstreamWaitValue_flags as StreamWaitFlag+  { underscoreToCase }+  with prefix="CU_STREAM" deriving (Eq, Show, Bounded) #}+#endif+++-- | Write a value to memory, (presumably) after all preceding work in the+-- stream has completed. Unless the option 'WriteValueNoMemoryBarrier' is+-- supplied, the write is preceded by a system-wide memory fence.+--+-- <http://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__EVENT.html#group__CUDA__EVENT_1g091455366d56dc2f1f69726aafa369b0>+--+-- Requires CUDA-8.0.+--+{-# INLINEABLE write #-}+write :: DevicePtr Int32 -> Int32 -> Stream -> [StreamWriteFlag] -> IO ()+#if CUDA_VERSION < 8000+write _   _   _      _     = requireSDK 'write 8.0+#else+write ptr val stream flags = nothingIfOk =<< cuStreamWriteValue32 stream ptr val flags++{-# INLINE cuStreamWriteValue32 #-}+{# fun unsafe cuStreamWriteValue32+  { useStream       `Stream'+  , useDeviceHandle `DevicePtr Int32'+  ,                 `Int32'+  , combineBitMasks `[StreamWriteFlag]'+  }+  -> `Status' cToEnum #}+  where+    useDeviceHandle = fromIntegral . ptrToIntPtr . useDevicePtr+#endif+++-- | Wait on a memory location. Work ordered after the operation will block+-- until the given condition on the memory is satisfied.+--+-- <http://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__EVENT.html#group__CUDA__EVENT_1g629856339de7bc6606047385addbb398>+--+-- Requires CUDA-8.0.+--+{-# INLINEABLE wait #-}+wait :: DevicePtr Int32 -> Int32 -> Stream -> [StreamWaitFlag] -> IO ()+#if CUDA_VERSION < 8000+wait _   _   _      _     = requireSDK 'wait 8.0+#else+wait ptr val stream flags = nothingIfOk =<< cuStreamWaitValue32 stream ptr val flags++{-# INLINE cuStreamWaitValue32 #-}+{# fun unsafe cuStreamWaitValue32+  { useStream       `Stream'+  , useDeviceHandle `DevicePtr Int32'+  ,                 `Int32'+  , combineBitMasks `[StreamWaitFlag]'+  } -> `Status' cToEnum #}+  where+    useDeviceHandle = fromIntegral . ptrToIntPtr . useDevicePtr #endif 
src/Foreign/CUDA/Driver/Texture.chs view
@@ -4,7 +4,7 @@ -------------------------------------------------------------------------------- -- | -- Module    : Foreign.CUDA.Driver.Texture--- Copyright : [2009..2014] Trevor L. McDonell+-- Copyright : [2009..2017] Trevor L. McDonell -- License   : BSD -- -- Texture management for low-level driver interface
+ src/Foreign/CUDA/Driver/Unified.chs view
@@ -0,0 +1,271 @@+{-# LANGUAGE BangPatterns             #-}+{-# LANGUAGE CPP                      #-}+{-# LANGUAGE EmptyDataDecls           #-}+{-# LANGUAGE ForeignFunctionInterface #-}+{-# LANGUAGE ScopedTypeVariables      #-}+{-# LANGUAGE TemplateHaskell          #-}+{-# OPTIONS_HADDOCK prune #-}+--------------------------------------------------------------------------------+-- |+-- Module    : Foreign.CUDA.Driver.Unified+-- Copyright : [2017] Trevor L. McDonell+-- License   : BSD+--+-- Unified addressing functions for the low-level driver interface+--+-- [/Overview/]+--+-- CUDA devices can share a unified address space with the host. For these+-- devices, there is no distinction between a device pointer and a host+-- pointer---the same pointer value may be used to access memory from the host+-- program and from a kernel running on the device (with exceptions enumerated+-- below).+--+-- [/Support/]+--+-- Whether or not a device supports unified addressing may be queried by calling+-- 'Foreign.CUDA.Driver.Device.attribute' with the+-- 'Foreign.CUDA.Driver.Device.UnifiedAddressing' attribute.+--+-- Unified addressing is automatically enabled in 64-bit processes on devices+-- with compute capability at leas 2.0.+--+-- [/Looking up information about pointers/]+--+-- It is possible to look up information about the memory which backs a pointer;+-- that is, whether the memory resides on the host or the device (and in+-- particular, which device).+--+-- [/Automatic mapping of host memory/]+--+-- All host memory allocated in all contexts using+-- 'Foreign.CUDA.Driver.Marshal.mallocHostArray' or+-- 'Foreign.CUDA.Driver.Marshal.mallocHostForeignPtr' is always directly+-- accessible from all contexts on all devices which support unified addressing.+-- This is the case whether or not the flags+-- 'Foreign.CUDA.Driver.Marshal.Portable' or+-- 'Foreign.CUDA.Driver.Marshal.DeviceMapped' are specified.+--+-- The pointer value through which allocated host memory may be accessed in+-- kernels on all devices which support unified addressing is the same as the+-- pointer value as on the host; that is, it is not necessary to call+-- 'Foreign.CUDA.Driver.Marshal.getDevicePtr' for these allocations.+--+-- Note that this is not the case for memory allocated using the+-- 'Foreign.CUDA.Driver.Marshal.WriteCombined' option; see below.+--+-- [/Automatic registration of peer memory/]+--+-- Upon enabling direct access from a context which supports unified addressing+-- to another peer context which supports unified addressing using+-- 'Foreign.CUDA.Driver.Context.Peer.add', all memory allocated in the peer+-- context will immediately be accessible by the current context. The device+-- pointer values are the same on both contexts.+--+-- [/Exceptions (disjoint addressing/]+--+-- Not all memory may be accessed on devices through the same pointer value+-- as they are accessed with on the host. These exceptions are host arrays+-- registered with 'Foreign.CUDA.Driver.Marshal.registerArray', and those+-- allocated with the flag 'Foreign.CUDA.Driver.Marshal.WriteCombined'. In these+-- cases, the host and device arrays have distinct addresses (pointer values).+-- However, the device address is guaranteed to not overlap with any valid host+-- pointer range and is guaranteed to have the same value across all contexts+-- which support unified addressing.+--+-- The value of the device pointer may be queried with+-- 'Foreign.CUDA.Driver.Marshal.getDevicePtr' from any context supporting+-- unified addressing.+--+--------------------------------------------------------------------------------++module Foreign.CUDA.Driver.Unified (++  -- ** Querying pointer attributes+  PointerAttributes(..), MemoryType(..),+  getAttributes,++  -- ** Setting pointer attributes+  Advice(..),+  setSyncMemops,+  advise,++) where++#include "cbits/stubs.h"+{# context lib="cuda" #}++-- Friends+import Foreign.CUDA.Driver.Context+import Foreign.CUDA.Driver.Device+import Foreign.CUDA.Driver.Error+import Foreign.CUDA.Driver.Marshal+import Foreign.CUDA.Internal.C2HS+import Foreign.CUDA.Types++-- System+import Control.Applicative+import Control.Monad+import Data.Maybe+import Foreign+import Foreign.C+import Foreign.Storable+import Prelude+++#if CUDA_VERSION < 7000+data PointerAttributes a+data MemoryType+#else+-- | Information about a pointer+--+data PointerAttributes a = PointerAttributes+  { ptrContext    :: {-# UNPACK #-} !Context+  , ptrDevice     :: {-# UNPACK #-} !(DevicePtr a)+  , ptrHost       :: {-# UNPACK #-} !(HostPtr a)+  , ptrBufferID   :: {-# UNPACK #-} !CULLong+  , ptrMemoryType :: !MemoryType+  , ptrSyncMemops :: !Bool+  , ptrIsManaged  :: !Bool+  }+  deriving Show++{# enum CUmemorytype as MemoryType+  { underscoreToCase+  , DEVICE  as DeviceMemory+  , HOST    as HostMemory+  , ARRAY   as ArrayMemory+  , UNIFIED as UnifiedMemory }+  with prefix="CU_MEMORYTYPE" deriving (Eq, Show, Bounded) #}++{# enum CUpointer_attribute as PointerAttribute+  { underscoreToCase }+  with prefix="CU_POINTER" deriving (Eq, Show, Bounded) #}+#endif++#if CUDA_VERSION < 8000+data Advice+#else+{# enum CUmem_advise as Advice+  { underscoreToCase }+  with prefix="CU_MEM_ADVISE" deriving (Eq, Show, Bounded) #}+#endif+++-- Return information about a pointer.+--+-- <http://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__UNIFIED.html#group__CUDA__UNIFIED_1g0c28ed0aff848042bc0533110e45820c>+--+-- Requires CUDA-7.0.+--+{-# INLINEABLE getAttributes #-}+getAttributes :: Ptr a -> IO (PointerAttributes a)+#if CUDA_VERSION < 7000+getAttributes _   = requireSDK 'getAttributes 7.0+#else+getAttributes ptr =+  alloca $ \p_ctx  ->+  alloca $ \p_dptr ->+  alloca $ \p_hptr ->+  alloca $ \(p_bid :: Ptr CULLong) ->+  alloca $ \(p_mt  :: Ptr CUInt)   ->+  alloca $ \(p_sm  :: Ptr CInt)    ->+  alloca $ \(p_im  :: Ptr CInt)    -> do+    let n       = length as+        (as,ps) = unzip [ (AttributeContext,       castPtr p_ctx)+                        , (AttributeDevicePointer, castPtr p_dptr)+                        , (AttributeHostPointer,   castPtr p_hptr)+                        , (AttributeBufferId,      castPtr p_bid)+                        , (AttributeMemoryType,    castPtr p_mt)+                        , (AttributeSyncMemops,    castPtr p_sm)+                        , (AttributeIsManaged,     castPtr p_im)+                        ]+    --+    nothingIfOk =<< cuPointerGetAttributes n as ps ptr+    PointerAttributes+      <$> liftM Context (peek p_ctx)+      <*> liftM DevicePtr (peek p_dptr)+      <*> liftM HostPtr   (peek p_hptr)+      <*> peek p_bid+      <*> liftM cToEnum (peek p_mt)+      <*> liftM cToBool (peek p_sm)+      <*> liftM cToBool (peek p_im)++{-# INLINE cuPointerGetAttributes #-}+{# fun unsafe cuPointerGetAttributes+  {            `Int'+  , withAttrs* `[PointerAttribute]'+  , withArray* `[Ptr ()]'+  , useHandle  `Ptr a'+  }+  -> `Status' cToEnum #}+  where+    withAttrs as = withArray (map cFromEnum as)+    useHandle    = fromIntegral . ptrToIntPtr+#endif+++-- Set whether or not the given memory region is guaranteed to always+-- synchronise memory operations that are synchronous. If there are some+-- previously initiated synchronous memory operations that are pending when this+-- attribute is set, the function does not return until those memory operations+-- are complete. See+-- <http://docs.nvidia.com/cuda/cuda-driver-api/api-sync-behavior.html API+-- synchronisation behaviour> for more information on cases where synchronous+-- memory operations can exhibit asynchronous behaviour.+--+-- <http://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__UNIFIED.html#group__CUDA__UNIFIED_1g89f7ad29a657e574fdea2624b74d138e>+--+-- Requires CUDA-7.0.+--+{-# INLINE setSyncMemops #-}+setSyncMemops :: Ptr a -> Bool -> IO ()+#if CUDA_VERSION < 7000+setSyncMemops _   _   = requireSDK 'setSyncMemops 7.0+#else+setSyncMemops ptr val = nothingIfOk =<< cuPointerSetAttribute val AttributeSyncMemops ptr++{-# INLINE cuPointerSetAttribute #-}+{# fun unsafe cuPointerSetAttribute+  { withBool'* `Bool'+  , cFromEnum  `PointerAttribute'+  , useHandle  `Ptr a'+  }+  -> `Status' cToEnum #}+  where+    withBool' :: Bool -> (Ptr () -> IO b) -> IO b+    withBool' v k = with (fromBool v :: CUInt) (k . castPtr)++    useHandle = fromIntegral . ptrToIntPtr+#endif+++-- | Advise about the usage of a given range of memory. If the supplied device+-- is Nothing, then the preferred location is taken to mean the CPU.+--+-- <http://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__UNIFIED.html#group__CUDA__UNIFIED_1g27608c857a9254789c13f3e3b72029e2>+--+-- Requires CUDA-8.0.+--+{-# INLINEABLE advise #-}+advise :: Storable a => Ptr a -> Int -> Advice -> Maybe Device -> IO ()+#if CUDA_VERSION < 8000+advise _   _ _ _    = requireSDK 'advise 8.0+#else+advise ptr n a mdev = go undefined ptr+  where+    go :: Storable a' => a' -> Ptr a' -> IO ()+    go x _ = nothingIfOk =<< cuMemAdvise ptr (n * sizeOf x) a (maybe (-1) useDevice mdev)++{-# INLINE cuMemAdvise #-}+{# fun unsafe cuMemAdvise+  { useHandle `Ptr a'+  ,           `Int'+  , cFromEnum `Advice'+  ,           `CInt'+  }+  -> `Status' cToEnum #}+  where+    useHandle = fromIntegral . ptrToIntPtr+#endif+
src/Foreign/CUDA/Driver/Utils.chs view
@@ -2,7 +2,7 @@ -------------------------------------------------------------------------------- -- | -- Module    : Foreign.CUDA.Driver.Utils--- Copyright : [2009..2014] Trevor L. McDonell+-- Copyright : [2009..2017] Trevor L. McDonell -- License   : BSD -- -- Utility functions
+ src/Foreign/CUDA/Path.chs view
@@ -0,0 +1,41 @@+{-# LANGUAGE CPP #-}+--------------------------------------------------------------------------------+-- |+-- Module    : Foreign.CUDA.Path+-- Copyright : [2017] Trevor L. McDonell+-- License   : BSD+--+--------------------------------------------------------------------------------++module Foreign.CUDA.Path (++  cudaInstallPath,+  cudaBinPath, cudaLibraryPath, cudaIncludePath,++) where++import System.FilePath++-- | The base path to the CUDA toolkit installation that this package was+-- compiled against.+--+cudaInstallPath :: FilePath+cudaInstallPath = {#const CUDA_INSTALL_PATH#}++-- | The path where the CUDA toolkit executables, such as @nvcc@ and @ptxas@,+-- can be found.+--+cudaBinPath :: FilePath+cudaBinPath = cudaInstallPath </> "bin"++-- | The path where the CUDA libraries this package was linked against are+-- located+--+cudaLibraryPath :: FilePath+cudaLibraryPath = {#const CUDA_LIBRARY_PATH#}++-- | The path where the CUDA headers this package was built against are located+--+cudaIncludePath :: FilePath+cudaIncludePath = cudaInstallPath </> "include"+
src/Foreign/CUDA/Ptr.hs view
@@ -2,7 +2,7 @@ -------------------------------------------------------------------------------- -- | -- Module    : Foreign.CUDA.Ptr--- Copyright : [2009..2014] Trevor L. McDonell+-- Copyright : [2009..2017] Trevor L. McDonell -- License   : BSD -- -- Data pointers on the host and device. These can be shared freely between the
src/Foreign/CUDA/Runtime.hs view
@@ -1,7 +1,7 @@ -------------------------------------------------------------------------------- -- | -- Module    : Foreign.CUDA.Runtime--- Copyright : [2009..2014] Trevor L. McDonell+-- Copyright : [2009..2017] Trevor L. McDonell -- License   : BSD -- -- Top level bindings to the C-for-CUDA runtime API
src/Foreign/CUDA/Runtime/Device.chs view
@@ -10,7 +10,7 @@ -------------------------------------------------------------------------------- -- | -- Module    : Foreign.CUDA.Runtime.Device--- Copyright : [2009..2014] Trevor L. McDonell+-- Copyright : [2009..2017] Trevor L. McDonell -- License   : BSD -- -- Device management routines
src/Foreign/CUDA/Runtime/Error.chs view
@@ -4,7 +4,7 @@ -------------------------------------------------------------------------------- -- | -- Module    : Foreign.CUDA.Runtime.Error--- Copyright : [2009..2014] Trevor L. McDonell+-- Copyright : [2009..2017] Trevor L. McDonell -- License   : BSD -- -- Error handling functions
src/Foreign/CUDA/Runtime/Event.chs view
@@ -6,7 +6,7 @@ -------------------------------------------------------------------------------- -- | -- Module    : Foreign.CUDA.Driver.Event--- Copyright : [2009..2014] Trevor L. McDonell+-- Copyright : [2009..2017] Trevor L. McDonell -- License   : BSD -- -- Event management for C-for-CUDA runtime environment
src/Foreign/CUDA/Runtime/Exec.chs view
@@ -6,7 +6,7 @@ -------------------------------------------------------------------------------- -- | -- Module    : Foreign.CUDA.Runtime.Exec--- Copyright : [2009..2014] Trevor L. McDonell+-- Copyright : [2009..2017] Trevor L. McDonell -- License   : BSD -- -- Kernel execution control for C-for-CUDA runtime interface
src/Foreign/CUDA/Runtime/Marshal.chs view
@@ -5,7 +5,7 @@ -------------------------------------------------------------------------------- -- | -- Module    : Foreign.CUDA.Runtime.Marshal--- Copyright : [2009..2014] Trevor L. McDonell+-- Copyright : [2009..2017] Trevor L. McDonell -- License   : BSD -- -- Memory management for CUDA devices
src/Foreign/CUDA/Runtime/Stream.chs view
@@ -3,7 +3,7 @@ -------------------------------------------------------------------------------- -- | -- Module    : Foreign.CUDA.Runtime.Stream--- Copyright : [2009..2014] Trevor L. McDonell+-- Copyright : [2009..2017] Trevor L. McDonell -- License   : BSD -- -- Stream management routines
src/Foreign/CUDA/Runtime/Texture.chs view
@@ -3,7 +3,7 @@ -------------------------------------------------------------------------------- -- | -- Module    : Foreign.CUDA.Runtime.Texture--- Copyright : [2009..2014] Trevor L. McDonell+-- Copyright : [2009..2017] Trevor L. McDonell -- License   : BSD -- -- Texture references
src/Foreign/CUDA/Runtime/Utils.chs view
@@ -2,7 +2,7 @@ -------------------------------------------------------------------------------- -- | -- Module    : Foreign.CUDA.Runtime.Utils--- Copyright : [2009..2014] Trevor L. McDonell+-- Copyright : [2009..2017] Trevor L. McDonell -- License   : BSD -- -- Utility functions
src/Foreign/CUDA/Types.chs view
@@ -7,7 +7,7 @@ -------------------------------------------------------------------------------- -- | -- Module    : Foreign.CUDA.Types--- Copyright : [2009..2014] Trevor L. McDonell+-- Copyright : [2009..2017] Trevor L. McDonell -- License   : BSD -- -- Data types that are equivalent and can be shared freely between the CUDA
src/Text/Show/Describe.hs view
@@ -1,7 +1,7 @@ -------------------------------------------------------------------------------- -- | -- Module    : Text.Show.Describe--- Copyright : [2016] Trevor L. McDonell+-- Copyright : [2016..2017] Trevor L. McDonell -- License   : BSD -- --------------------------------------------------------------------------------