Skip to content

Commit

Permalink
Merge branch 'release/0.11.0.1' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
tmcdonell committed Aug 15, 2023
2 parents 3d83232 + 646835c commit 48dc102
Show file tree
Hide file tree
Showing 11 changed files with 76 additions and 20 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ dist/
/stack.yaml
/.stack-work
/stack.yaml.lock
dist-newstyle
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ package _DOES NOT_ follow the PVP, or indeed any sensible version scheme,
because NVIDIA are A-OK introducing breaking changes in minor updates.


## [0.11.0.1] - 2023-08-15
### Fixed
* Build fixes for GHC 9.2 .. 9.6

## [0.11.0.0] - 2021-07-05
### Added
* Add support for CUDA-11.[0..4]
Expand Down Expand Up @@ -163,7 +167,8 @@ because NVIDIA are A-OK introducing breaking changes in minor updates.
### Added
* Add functions from CUDA-6.5


[next]: https://github.com/tmcdonell/cuda/compare/v0.11.0.1...HEAD
[0.11.0.1]: https://github.com/tmcdonell/cuda/compare/v0.11.0.0...v0.11.0.1
[0.11.0.0]: https://github.com/tmcdonell/cuda/compare/v0.10.2.0...v0.11.0.0
[0.10.2.0]: https://github.com/tmcdonell/cuda/compare/v0.10.1.0...v0.10.2.0
[0.10.1.0]: https://github.com/tmcdonell/cuda/compare/v0.10.0.0...v0.10.1.0
Expand Down
6 changes: 6 additions & 0 deletions Setup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ import Distribution.PackageDescription.Parsec
#else
import Distribution.PackageDescription.Parse
#endif
#if MIN_VERSION_Cabal(3,8,0)
import Distribution.Simple.PackageDescription
#endif

import Control.Exception
import Control.Monad
Expand Down Expand Up @@ -637,6 +640,9 @@ ppC2hs bi lbi
#endif
= PreProcessor {
platformIndependent = False,
#if MIN_VERSION_Cabal(3,8,0)
ppOrdering = unsorted,
#endif
runPreProcessor = \(inBaseDir, inRelativeFile)
(outBaseDir, outRelativeFile) verbosity ->
runDbProgram verbosity c2hsProgram (withPrograms lbi) . filter (not . null) $
Expand Down
2 changes: 1 addition & 1 deletion cuda.cabal
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cabal-version: 1.24

Name: cuda
Version: 0.11.0.0
Version: 0.11.0.1
Synopsis: FFI binding to the CUDA interface for programming NVIDIA GPUs
Description:
The CUDA library provides a direct, general purpose C-like SPMD programming
Expand Down
14 changes: 12 additions & 2 deletions src/Foreign/CUDA/Driver/Marshal.chs
Original file line number Diff line number Diff line change
Expand Up @@ -1166,12 +1166,22 @@ type DeviceHandle = {# type CUdeviceptr #}
peekDeviceHandle :: Ptr DeviceHandle -> IO (DevicePtr a)
peekDeviceHandle !p = do
CULLong (W64# w#) <- peek p
return $! DevicePtr (Ptr (int2Addr# (word2Int# w#)))
return $! DevicePtr (Ptr (int2Addr# (word2Int# (word64ToWord# w#))))

-- Use a device pointer as an opaque handle type
--
{-# INLINE useDeviceHandle #-}
useDeviceHandle :: DevicePtr a -> DeviceHandle
useDeviceHandle (DevicePtr (Ptr addr#)) =
CULLong (W64# (int2Word# (addr2Int# addr#)))
CULLong (W64# (wordToWord64# (int2Word# (addr2Int# addr#))))

#if __GLASGOW_HASKELL__ < 904
{-# INLINE word64ToWord# #-}
word64ToWord# :: Word# -> Word#
word64ToWord# x = x

{-# INLINE wordToWord64# #-}
wordToWord64# :: Word# -> Word#
wordToWord64# x = x
#endif

23 changes: 15 additions & 8 deletions src/Foreign/CUDA/Driver/Module/Query.chs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE ForeignFunctionInterface #-}
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE UnboxedTuples #-}
Expand Down Expand Up @@ -135,14 +136,14 @@ resultIfFound kind name (!status,!result) =
{-# INLINE useAsCString #-}
useAsCString :: ShortByteString -> (CString -> IO a) -> IO a
useAsCString (BI.SBS ba#) action = IO $ \s0 ->
case sizeofByteArray# ba# of { n# ->
case newPinnedByteArray# (n# +# 1#) s0 of { (# s1, mba# #) ->
case byteArrayContents# (unsafeCoerce# mba#) of { addr# ->
case copyByteArrayToAddr# ba# 0# addr# n# s1 of { s2 ->
case writeWord8OffAddr# addr# n# 0## s2 of { s3 ->
case action (Ptr addr#) of { IO action' ->
case action' s3 of { (# s4, r #) ->
case touch# mba# s4 of { s5 ->
case sizeofByteArray# ba# of { n# ->
case newPinnedByteArray# (n# +# 1#) s0 of { (# s1, mba# #) ->
case byteArrayContents# (unsafeCoerce# mba#) of { addr# ->
case copyByteArrayToAddr# ba# 0# addr# n# s1 of { s2 ->
case writeWord8OffAddr# addr# n# (wordToWord8# 0##) s2 of { s3 ->
case action (Ptr addr#) of { IO action' ->
case action' s3 of { (# s4, r #) ->
case touch# mba# s4 of { s5 ->
(# s5, r #)
}}}}}}}}

Expand All @@ -151,3 +152,9 @@ useAsCString (BI.SBS ba#) action = IO $ \s0 ->
unpack :: ShortByteString -> [Char]
unpack = P.map BI.w2c . BS.unpack

#if __GLASGOW_HASKELL__ < 902
{-# INLINE wordToWord8# #-}
wordToWord8# :: Word# -> Word#
wordToWord8# x = x
#endif

9 changes: 8 additions & 1 deletion src/Foreign/CUDA/Driver/Stream.chs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE EmptyDataDecls #-}
{-# LANGUAGE ForeignFunctionInterface #-}
{-# LANGUAGE MagicHash #-}
Expand Down Expand Up @@ -474,5 +475,11 @@ defaultStreamPerThread = Stream (Ptr (int2Addr# 0x2#))
{-# INLINE useDeviceHandle #-}
useDeviceHandle :: DevicePtr a -> {# type CUdeviceptr #}
useDeviceHandle (DevicePtr (Ptr addr#)) =
CULLong (W64# (int2Word# (addr2Int# addr#)))
CULLong (W64# (wordToWord64# (int2Word# (addr2Int# addr#))))

#if __GLASGOW_HASKELL__ < 904
{-# INLINE wordToWord64# #-}
wordToWord64# :: Word# -> Word#
wordToWord64# x = x
#endif

28 changes: 24 additions & 4 deletions src/Foreign/CUDA/Internal/C2HS.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE MagicHash #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
-- C->Haskell Compiler: Marshalling library
Expand Down Expand Up @@ -200,12 +201,12 @@ cIntConv = fromIntegral
-- fromIntegral entirely (in particular, without relying on orphan instances).
--
{-# RULES
"fromIntegral/Int->CInt" fromIntegral = \(I# i#) -> CInt (I32# (narrow32Int# i#)) ;
"fromIntegral/Int->CLLong" fromIntegral = \(I# i#) -> CLLong (I64# i#) ;
"fromIntegral/Int->CInt" fromIntegral = \(I# i#) -> CInt (I32# (intToInt32# i#)) ;
"fromIntegral/Int->CLLong" fromIntegral = \(I# i#) -> CLLong (I64# (intToInt64# i#)) ;
#-}
{-# RULES
"fromIntegral/Int->CUInt" fromIntegral = \(I# i#) -> CUInt (W32# (narrow32Word# (int2Word# i#))) ;
"fromIntegral/Int->CULLong" fromIntegral = \(I# i#) -> CULLong (W64# (int2Word# i#)) ;
"fromIntegral/Int->CUInt" fromIntegral = \(I# i#) -> CUInt (W32# (wordToWord32# (int2Word# i#))) ;
"fromIntegral/Int->CULLong" fromIntegral = \(I# i#) -> CULLong (W64# (wordToWord64# (int2Word# i#))) ;
#-}

-- The C 'long' type might be 32- or 64-bits wide
Expand Down Expand Up @@ -255,3 +256,22 @@ cToEnum = toEnum . cIntConv
cFromEnum :: (Enum e, Integral i) => e -> i
cFromEnum = cIntConv . fromEnum

#if __GLASGOW_HASKELL__ < 902
{-# INLINE intToInt32# #-}
intToInt32# :: Int# -> Int#
intToInt32# = narrow32Int#

{-# INLINE wordToWord32# #-}
wordToWord32# :: Word# -> Word#
wordToWord32# = narrow32Word#
#endif
#if __GLASGOW_HASKELL__ < 904
{-# INLINE intToInt64# #-}
intToInt64# :: Int# -> Int#
intToInt64# x = x

{-# INLINE wordToWord64# #-}
wordToWord64# :: Word# -> Word#
wordToWord64# x = x
#endif

2 changes: 1 addition & 1 deletion stack-8.10.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# For advanced use and comprehensive documentation of the format, please see:
# https://docs.haskellstack.org/en/stable/yaml_configuration/

resolver: lts-18.0
resolver: lts-18.28

packages:
- .
Expand Down
2 changes: 1 addition & 1 deletion stack-8.6.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# For more information, see: https://github.com/commercialhaskell/stack/blob/release/doc/yaml_configuration.md
# vim: nospell

resolver: lts-13.19
resolver: lts-14.27

packages:
- .
Expand Down
2 changes: 1 addition & 1 deletion stack-9.0.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# For advanced use and comprehensive documentation of the format, please see:
# https://docs.haskellstack.org/en/stable/yaml_configuration/

resolver: nightly-2021-07-02
resolver: lts-19.33

packages:
- .
Expand Down

0 comments on commit 48dc102

Please sign in to comment.