-- GENERATED by C->Haskell Compiler, version 0.28.6 Switcheroo, 25 November 2017 (Haskell)
-- Edit the ORIGNAL .chs file instead!


{-# LINE 1 "src/Foreign/CUDA/Runtime/Device.chs" #-}
{-# LANGUAGE BangPatterns             #-}
{-# LANGUAGE CPP                      #-}
{-# LANGUAGE EmptyDataDecls           #-}
{-# LANGUAGE ForeignFunctionInterface #-}
{-# LANGUAGE RecordWildCards          #-}
{-# LANGUAGE TemplateHaskell          #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# LANGUAGE EmptyCase                #-}
--------------------------------------------------------------------------------
-- |
-- Module    : Foreign.CUDA.Runtime.Device
-- Copyright : [2009..2018] Trevor L. McDonell
-- License   : BSD
--
-- Device management routines
--
--------------------------------------------------------------------------------

module Foreign.CUDA.Runtime.Device (

  -- * Device Management
  Device, DeviceFlag(..), DeviceProperties(..), Compute(..), ComputeMode(..),
  choose, get, count, props, set, setFlags, setOrder, reset, sync,

  -- * Peer Access
  PeerFlag,
  accessible, add, remove,

  -- * Cache Configuration
  Limit(..),
  getLimit, setLimit

) where
import qualified Foreign.C.Types as C2HSImp
import qualified Foreign.ForeignPtr as C2HSImp
import qualified Foreign.Ptr as C2HSImp
import qualified Foreign.Storable as C2HSImp





{-# LINE 38 "src/Foreign/CUDA/Runtime/Device.chs" #-}


-- Friends
import Foreign.CUDA.Analysis.Device
import Foreign.CUDA.Runtime.Error
import Foreign.CUDA.Internal.C2HS

-- System
import Control.Applicative
import Foreign
import Foreign.C
import Prelude

--------------------------------------------------------------------------------
-- Data Types
--------------------------------------------------------------------------------

-- |
-- A device identifier
--
type Device = Int


{-# LINE 76 "src/Foreign/CUDA/Runtime/Device.chs" #-}


-- |
-- Device execution flags
--
data DeviceFlag = ScheduleAuto
                | ScheduleSpin
                | ScheduleYield
                | BlockingSync
                | MapHost
                | LMemResizeToMax
  deriving (Eq,Show,Bounded)
instance Enum DeviceFlag where
  succ ScheduleAuto = ScheduleSpin
  succ ScheduleSpin = ScheduleYield
  succ ScheduleYield = BlockingSync
  succ BlockingSync = MapHost
  succ MapHost = LMemResizeToMax
  succ LMemResizeToMax = error "DeviceFlag.succ: LMemResizeToMax has no successor"

  pred ScheduleSpin = ScheduleAuto
  pred ScheduleYield = ScheduleSpin
  pred BlockingSync = ScheduleYield
  pred MapHost = BlockingSync
  pred LMemResizeToMax = MapHost
  pred ScheduleAuto = error "DeviceFlag.pred: ScheduleAuto has no predecessor"

  enumFromTo from to = go from
    where
      end = fromEnum to
      go v = case compare (fromEnum v) end of
                 LT -> v : go (succ v)
                 EQ -> [v]
                 GT -> []

  enumFrom from = enumFromTo from LMemResizeToMax

  fromEnum ScheduleAuto = 0
  fromEnum ScheduleSpin = 1
  fromEnum ScheduleYield = 2
  fromEnum BlockingSync = 4
  fromEnum MapHost = 8
  fromEnum LMemResizeToMax = 16

  toEnum 0 = ScheduleAuto
  toEnum 1 = ScheduleSpin
  toEnum 2 = ScheduleYield
  toEnum 4 = BlockingSync
  toEnum 8 = MapHost
  toEnum 16 = LMemResizeToMax
  toEnum unmatched = error ("DeviceFlag.toEnum: Cannot match " ++ show unmatched)

{-# LINE 82 "src/Foreign/CUDA/Runtime/Device.chs" #-}



instance Storable DeviceProperties where
  sizeOf _    = 712
{-# LINE 86 "src/Foreign/CUDA/Runtime/Device.chs" #-}

  alignment _ = alignment (undefined :: Ptr ())

  poke _ _    = error "no instance for Foreign.Storable.poke DeviceProperties"
  peek p      = do
    deviceName                    <- peekCString =<< (\ptr -> do {return $ ptr `C2HSImp.plusPtr` 0 :: IO (C2HSImp.Ptr C2HSImp.CChar)}) p
    computeCapability             <- Compute <$> (fromIntegral <$> (\ptr -> do {C2HSImp.peekByteOff ptr 360 :: IO C2HSImp.CInt}) p)
                                             <*> (fromIntegral <$> (\ptr -> do {C2HSImp.peekByteOff ptr 364 :: IO C2HSImp.CInt}) p)
    totalGlobalMem                <- cIntConv <$> (\ptr -> do {C2HSImp.peekByteOff ptr 288 :: IO C2HSImp.CULong}) p
    sharedMemPerBlock             <- cIntConv <$> (\ptr -> do {C2HSImp.peekByteOff ptr 296 :: IO C2HSImp.CULong}) p
    regsPerBlock                  <- cIntConv <$> (\ptr -> do {C2HSImp.peekByteOff ptr 304 :: IO C2HSImp.CInt}) p
    warpSize                      <- cIntConv <$> (\ptr -> do {C2HSImp.peekByteOff ptr 308 :: IO C2HSImp.CInt}) p
    memPitch                      <- cIntConv <$> (\ptr -> do {C2HSImp.peekByteOff ptr 312 :: IO C2HSImp.CULong}) p
    maxThreadsPerBlock            <- cIntConv <$> (\ptr -> do {C2HSImp.peekByteOff ptr 320 :: IO C2HSImp.CInt}) p
    clockRate                     <- cIntConv <$> (\ptr -> do {C2HSImp.peekByteOff ptr 348 :: IO C2HSImp.CInt}) p
    totalConstMem                 <- cIntConv <$> (\ptr -> do {C2HSImp.peekByteOff ptr 352 :: IO C2HSImp.CULong}) p
    textureAlignment              <- cIntConv <$> (\ptr -> do {C2HSImp.peekByteOff ptr 368 :: IO C2HSImp.CULong}) p
    deviceOverlap                 <- cToBool  <$> (\ptr -> do {C2HSImp.peekByteOff ptr 384 :: IO C2HSImp.CInt}) p
    multiProcessorCount           <- cIntConv <$> (\ptr -> do {C2HSImp.peekByteOff ptr 388 :: IO C2HSImp.CInt}) p
    kernelExecTimeoutEnabled      <- cToBool  <$> (\ptr -> do {C2HSImp.peekByteOff ptr 392 :: IO C2HSImp.CInt}) p
    integrated                    <- cToBool  <$> (\ptr -> do {C2HSImp.peekByteOff ptr 396 :: IO C2HSImp.CInt}) p
    canMapHostMemory              <- cToBool  <$> (\ptr -> do {C2HSImp.peekByteOff ptr 400 :: IO C2HSImp.CInt}) p
    computeMode                   <- cToEnum  <$> (\ptr -> do {C2HSImp.peekByteOff ptr 404 :: IO C2HSImp.CInt}) p
    concurrentKernels             <- cToBool  <$> (\ptr -> do {C2HSImp.peekByteOff ptr 576 :: IO C2HSImp.CInt}) p
    maxTextureDim1D               <- cIntConv <$> (\ptr -> do {C2HSImp.peekByteOff ptr 408 :: IO C2HSImp.CInt}) p
    eccEnabled                    <- cToBool  <$> (\ptr -> do {C2HSImp.peekByteOff ptr 580 :: IO C2HSImp.CInt}) p
    asyncEngineCount              <- cIntConv <$> (\ptr -> do {C2HSImp.peekByteOff ptr 600 :: IO C2HSImp.CInt}) p
    cacheMemL2                    <- cIntConv <$> (\ptr -> do {C2HSImp.peekByteOff ptr 616 :: IO C2HSImp.CInt}) p
    maxThreadsPerMultiProcessor   <- cIntConv <$> (\ptr -> do {C2HSImp.peekByteOff ptr 620 :: IO C2HSImp.CInt}) p
    memBusWidth                   <- cIntConv <$> (\ptr -> do {C2HSImp.peekByteOff ptr 612 :: IO C2HSImp.CInt}) p
    memClockRate                  <- cIntConv <$> (\ptr -> do {C2HSImp.peekByteOff ptr 608 :: IO C2HSImp.CInt}) p
    pciInfo                       <- PCI <$> (cIntConv <$> (\ptr -> do {C2HSImp.peekByteOff ptr 584 :: IO C2HSImp.CInt}) p)
                                         <*> (cIntConv <$> (\ptr -> do {C2HSImp.peekByteOff ptr 588 :: IO C2HSImp.CInt}) p)
                                         <*> (cIntConv <$> (\ptr -> do {C2HSImp.peekByteOff ptr 592 :: IO C2HSImp.CInt}) p)
    tccDriverEnabled              <- cToBool <$> (\ptr -> do {C2HSImp.peekByteOff ptr 596 :: IO C2HSImp.CInt}) p
    unifiedAddressing             <- cToBool <$> (\ptr -> do {C2HSImp.peekByteOff ptr 604 :: IO C2HSImp.CInt}) p
    [t1,t2,t3]                    <- peekArrayWith cIntConv 3 =<< (\ptr -> do {return $ ptr `C2HSImp.plusPtr` 324 :: IO (C2HSImp.Ptr C2HSImp.CInt)}) p
    [g1,g2,g3]                    <- peekArrayWith cIntConv 3 =<< (\ptr -> do {return $ ptr `C2HSImp.plusPtr` 336 :: IO (C2HSImp.Ptr C2HSImp.CInt)}) p
    let maxBlockSize = (t1,t2,t3)
        maxGridSize  = (g1,g2,g3)
    [u21,u22]                     <- peekArrayWith cIntConv 2 =<< (\ptr -> do {return $ ptr `C2HSImp.plusPtr` 420 :: IO (C2HSImp.Ptr C2HSImp.CInt)}) p
    [u31,u32,u33]                 <- peekArrayWith cIntConv 3 =<< (\ptr -> do {return $ ptr `C2HSImp.plusPtr` 456 :: IO (C2HSImp.Ptr C2HSImp.CInt)}) p
    let maxTextureDim2D = (u21,u22)
        maxTextureDim3D = (u31,u32,u33)
    streamPriorities              <- cToBool  <$> (\ptr -> do {C2HSImp.peekByteOff ptr 624 :: IO C2HSImp.CInt}) p
    globalL1Cache                 <- cToBool  <$> (\ptr -> do {C2HSImp.peekByteOff ptr 628 :: IO C2HSImp.CInt}) p
    localL1Cache                  <- cToBool  <$> (\ptr -> do {C2HSImp.peekByteOff ptr 632 :: IO C2HSImp.CInt}) p
    managedMemory                 <- cToBool  <$> (\ptr -> do {C2HSImp.peekByteOff ptr 652 :: IO C2HSImp.CInt}) p
    multiGPUBoard                 <- cToBool  <$> (\ptr -> do {C2HSImp.peekByteOff ptr 656 :: IO C2HSImp.CInt}) p
    multiGPUBoardGroupID          <- cIntConv <$> (\ptr -> do {C2HSImp.peekByteOff ptr 660 :: IO C2HSImp.CInt}) p
    preemption                    <- cToBool  <$> (\ptr -> do {C2HSImp.peekByteOff ptr 680 :: IO C2HSImp.CInt}) p
    singleToDoublePerfRatio       <- cIntConv <$> (\ptr -> do {C2HSImp.peekByteOff ptr 668 :: IO C2HSImp.CInt}) p
    cooperativeLaunch             <- cToBool <$> (\ptr -> do {C2HSImp.peekByteOff ptr 688 :: IO C2HSImp.CInt}) p
    cooperativeLaunchMultiDevice  <- cToBool <$> (\ptr -> do {C2HSImp.peekByteOff ptr 692 :: IO C2HSImp.CInt}) p

    return DeviceProperties{..}


--------------------------------------------------------------------------------
-- Device Management
--------------------------------------------------------------------------------

-- |
-- Select the compute device which best matches the given criteria
--
{-# INLINEABLE choose #-}
choose :: DeviceProperties -> IO Device
choose !dev = resultIfOk =<< cudaChooseDevice dev

{-# INLINE cudaChooseDevice #-}
cudaChooseDevice :: (DeviceProperties) -> IO ((Status), (Int))
cudaChooseDevice a2 =
  alloca $ \a1' ->
  withDevProp a2 $ \a2' ->
  cudaChooseDevice'_ a1' a2' >>= \res ->
  let {res' = cToEnum res} in
  peekIntConv  a1'>>= \a1'' ->
  return (res', a1'')

{-# LINE 183 "src/Foreign/CUDA/Runtime/Device.chs" #-}

  where
      withDevProp = with


-- |
-- Returns which device is currently being used
--
{-# INLINEABLE get #-}
get :: IO Device
get = resultIfOk =<< cudaGetDevice

{-# INLINE cudaGetDevice #-}
cudaGetDevice :: IO ((Status), (Int))
cudaGetDevice =
  alloca $ \a1' ->
  cudaGetDevice'_ a1' >>= \res ->
  let {res' = cToEnum res} in
  peekIntConv  a1'>>= \a1'' ->
  return (res', a1'')

{-# LINE 197 "src/Foreign/CUDA/Runtime/Device.chs" #-}



-- |
-- Returns the number of devices available for execution, with compute
-- capability >= 1.0
--
{-# INLINEABLE count #-}
count :: IO Int
count = resultIfOk =<< cudaGetDeviceCount

{-# INLINE cudaGetDeviceCount #-}
cudaGetDeviceCount :: IO ((Status), (Int))
cudaGetDeviceCount =
  alloca $ \a1' ->
  cudaGetDeviceCount'_ a1' >>= \res ->
  let {res' = cToEnum res} in
  peekIntConv  a1'>>= \a1'' ->
  return (res', a1'')

{-# LINE 210 "src/Foreign/CUDA/Runtime/Device.chs" #-}



-- |
-- Return information about the selected compute device
--
{-# INLINEABLE props #-}
props :: Device -> IO DeviceProperties
props !n = resultIfOk =<< cudaGetDeviceProperties n

{-# INLINE cudaGetDeviceProperties #-}
cudaGetDeviceProperties :: (Int) -> IO ((Status), (DeviceProperties))
cudaGetDeviceProperties a2 =
  alloca $ \a1' ->
  let {a2' = fromIntegral a2} in
  cudaGetDeviceProperties'_ a1' a2' >>= \res ->
  let {res' = cToEnum res} in
  peek  a1'>>= \a1'' ->
  return (res', a1'')

{-# LINE 223 "src/Foreign/CUDA/Runtime/Device.chs" #-}



-- |
-- Set device to be used for GPU execution
--
{-# INLINEABLE set #-}
set :: Device -> IO ()
set !n = nothingIfOk =<< cudaSetDevice n

{-# INLINE cudaSetDevice #-}
cudaSetDevice :: (Int) -> IO ((Status))
cudaSetDevice a1 =
  let {a1' = fromIntegral a1} in
  cudaSetDevice'_ a1' >>= \res ->
  let {res' = cToEnum res} in
  return (res')

{-# LINE 235 "src/Foreign/CUDA/Runtime/Device.chs" #-}



-- |
-- Set flags to be used for device executions
--
{-# INLINEABLE setFlags #-}
setFlags :: [DeviceFlag] -> IO ()
setFlags !f = nothingIfOk =<< cudaSetDeviceFlags (combineBitMasks f)

{-# INLINE cudaSetDeviceFlags #-}
cudaSetDeviceFlags :: (Int) -> IO ((Status))
cudaSetDeviceFlags a1 =
  let {a1' = fromIntegral a1} in
  cudaSetDeviceFlags'_ a1' >>= \res ->
  let {res' = cToEnum res} in
  return (res')

{-# LINE 247 "src/Foreign/CUDA/Runtime/Device.chs" #-}



-- |
-- Set list of devices for CUDA execution in priority order
--
{-# INLINEABLE setOrder #-}
setOrder :: [Device] -> IO ()
setOrder !l = nothingIfOk =<< cudaSetValidDevices l (length l)

{-# INLINE cudaSetValidDevices #-}
cudaSetValidDevices :: ([Int]) -> (Int) -> IO ((Status))
cudaSetValidDevices a1 a2 =
  withArrayIntConv a1 $ \a1' ->
  let {a2' = fromIntegral a2} in
  cudaSetValidDevices'_ a1' a2' >>= \res ->
  let {res' = cToEnum res} in
  return (res')

{-# LINE 260 "src/Foreign/CUDA/Runtime/Device.chs" #-}

  where
      withArrayIntConv = withArray . map cIntConv

-- |
-- Block until the device has completed all preceding requested tasks. Returns
-- an error if one of the tasks fails.
--
{-# INLINEABLE sync #-}
sync :: IO ()
{-# INLINE cudaDeviceSynchronize #-}
sync = nothingIfOk =<< cudaDeviceSynchronize
cudaDeviceSynchronize :: IO ((Status))
cudaDeviceSynchronize =
  cudaDeviceSynchronize'_ >>= \res ->
  let {res' = cToEnum res} in
  return (res')

{-# LINE 278 "src/Foreign/CUDA/Runtime/Device.chs" #-}


-- |
-- Explicitly destroys and cleans up all runtime resources associated with the
-- current device in the current process. Any subsequent API call will
-- reinitialise the device.
--
-- Note that this function will reset the device immediately. It is the caller’s
-- responsibility to ensure that the device is not being accessed by any other
-- host threads from the process when this function is called.
--
{-# INLINEABLE reset #-}
reset :: IO ()
{-# INLINE cudaDeviceReset #-}
reset = nothingIfOk =<< cudaDeviceReset
cudaDeviceReset :: IO ((Status))
cudaDeviceReset =
  cudaDeviceReset'_ >>= \res ->
  let {res' = cToEnum res} in
  return (res')

{-# LINE 299 "src/Foreign/CUDA/Runtime/Device.chs" #-}



--------------------------------------------------------------------------------
-- Peer Access
--------------------------------------------------------------------------------

-- |
-- Possible option values for direct peer memory access
--
data PeerFlag
instance Enum PeerFlag where
  toEnum   x = error ("PeerFlag.toEnum: Cannot match " ++ show x)
  fromEnum x = case x of {}

-- |
-- Queries if the first device can directly access the memory of the second. If
-- direct access is possible, it can then be enabled with 'add'. Requires
-- cuda-4.0.
--
{-# INLINEABLE accessible #-}
accessible :: Device -> Device -> IO Bool
accessible !dev !peer = resultIfOk =<< cudaDeviceCanAccessPeer dev peer

{-# INLINE cudaDeviceCanAccessPeer #-}
cudaDeviceCanAccessPeer :: (Device) -> (Device) -> IO ((Status), (Bool))
cudaDeviceCanAccessPeer a2 a3 =
  alloca $ \a1' ->
  let {a2' = cIntConv a2} in
  let {a3' = cIntConv a3} in
  cudaDeviceCanAccessPeer'_ a1' a2' a3' >>= \res ->
  let {res' = cToEnum res} in
  peekBool  a1'>>= \a1'' ->
  return (res', a1'')

{-# LINE 333 "src/Foreign/CUDA/Runtime/Device.chs" #-}


-- |
-- If the devices of both the current and supplied contexts support unified
-- addressing, then enable allocations in the supplied context to be accessible
-- by the current context. Requires cuda-4.0.
--
{-# INLINEABLE add #-}
add :: Device -> [PeerFlag] -> IO ()
add !dev !flags = nothingIfOk =<< cudaDeviceEnablePeerAccess dev flags

{-# INLINE cudaDeviceEnablePeerAccess #-}
cudaDeviceEnablePeerAccess :: (Device) -> ([PeerFlag]) -> IO ((Status))
cudaDeviceEnablePeerAccess a1 a2 =
  let {a1' = cIntConv a1} in
  let {a2' = combineBitMasks a2} in
  cudaDeviceEnablePeerAccess'_ a1' a2' >>= \res ->
  let {res' = cToEnum res} in
  return (res')

{-# LINE 351 "src/Foreign/CUDA/Runtime/Device.chs" #-}



-- |
-- Disable direct memory access from the current context to the supplied
-- context. Requires cuda-4.0.
--
{-# INLINEABLE remove #-}
remove :: Device -> IO ()
remove !dev = nothingIfOk =<< cudaDeviceDisablePeerAccess dev

{-# INLINE cudaDeviceDisablePeerAccess #-}
cudaDeviceDisablePeerAccess :: (Device) -> IO ((Status))
cudaDeviceDisablePeerAccess a1 =
  let {a1' = cIntConv a1} in
  cudaDeviceDisablePeerAccess'_ a1' >>= \res ->
  let {res' = cToEnum res} in
  return (res')

{-# LINE 368 "src/Foreign/CUDA/Runtime/Device.chs" #-}



--------------------------------------------------------------------------------
-- Cache Configuration
--------------------------------------------------------------------------------

-- |
-- Device limit flags
--
data Limit = Stacksize
           | Printffifosize
           | Mallocheapsize
           | Devruntimesyncdepth
           | Devruntimependinglaunchcount
           | Maxl2fetchgranularity
  deriving (Eq,Show)
instance Enum Limit where
  succ Stacksize = Printffifosize
  succ Printffifosize = Mallocheapsize
  succ Mallocheapsize = Devruntimesyncdepth
  succ Devruntimesyncdepth = Devruntimependinglaunchcount
  succ Devruntimependinglaunchcount = Maxl2fetchgranularity
  succ Maxl2fetchgranularity = error "Limit.succ: Maxl2fetchgranularity has no successor"

  pred Printffifosize = Stacksize
  pred Mallocheapsize = Printffifosize
  pred Devruntimesyncdepth = Mallocheapsize
  pred Devruntimependinglaunchcount = Devruntimesyncdepth
  pred Maxl2fetchgranularity = Devruntimependinglaunchcount
  pred Stacksize = error "Limit.pred: Stacksize has no predecessor"

  enumFromTo from to = go from
    where
      end = fromEnum to
      go v = case compare (fromEnum v) end of
                 LT -> v : go (succ v)
                 EQ -> [v]
                 GT -> []

  enumFrom from = enumFromTo from Maxl2fetchgranularity

  fromEnum Stacksize = 0
  fromEnum Printffifosize = 1
  fromEnum Mallocheapsize = 2
  fromEnum Devruntimesyncdepth = 3
  fromEnum Devruntimependinglaunchcount = 4
  fromEnum Maxl2fetchgranularity = 5

  toEnum 0 = Stacksize
  toEnum 1 = Printffifosize
  toEnum 2 = Mallocheapsize
  toEnum 3 = Devruntimesyncdepth
  toEnum 4 = Devruntimependinglaunchcount
  toEnum 5 = Maxl2fetchgranularity
  toEnum unmatched = error ("Limit.toEnum: Cannot match " ++ show unmatched)

{-# LINE 384 "src/Foreign/CUDA/Runtime/Device.chs" #-}



-- |
-- Query compute 2.0 call stack limits. Requires cuda-3.1.
--
{-# INLINEABLE getLimit #-}
getLimit :: Limit -> IO Int
getLimit !l = resultIfOk =<< cudaDeviceGetLimit l

{-# INLINE cudaDeviceGetLimit #-}
cudaDeviceGetLimit :: (Limit) -> IO ((Status), (Int))
cudaDeviceGetLimit a2 =
  alloca $ \a1' ->
  let {a2' = cFromEnum a2} in
  cudaDeviceGetLimit'_ a1' a2' >>= \res ->
  let {res' = cToEnum res} in
  peekIntConv  a1'>>= \a1'' ->
  return (res', a1'')

{-# LINE 408 "src/Foreign/CUDA/Runtime/Device.chs" #-}



-- |
-- Set compute 2.0 call stack limits. Requires cuda-3.1.
--
{-# INLINEABLE setLimit #-}
setLimit :: Limit -> Int -> IO ()
setLimit !l !n = nothingIfOk =<< cudaDeviceSetLimit l n

{-# INLINE cudaDeviceSetLimit #-}
cudaDeviceSetLimit :: (Limit) -> (Int) -> IO ((Status))
cudaDeviceSetLimit a1 a2 =
  let {a1' = cFromEnum a1} in
  let {a2' = cIntConv a2} in
  cudaDeviceSetLimit'_ a1' a2' >>= \res ->
  let {res' = cToEnum res} in
  return (res')

{-# LINE 432 "src/Foreign/CUDA/Runtime/Device.chs" #-}



foreign import ccall unsafe "Foreign/CUDA/Runtime/Device.chs.h cudaChooseDevice"
  cudaChooseDevice'_ :: ((C2HSImp.Ptr C2HSImp.CInt) -> ((C2HSImp.Ptr (DeviceProperties)) -> (IO C2HSImp.CInt)))

foreign import ccall unsafe "Foreign/CUDA/Runtime/Device.chs.h cudaGetDevice"
  cudaGetDevice'_ :: ((C2HSImp.Ptr C2HSImp.CInt) -> (IO C2HSImp.CInt))

foreign import ccall unsafe "Foreign/CUDA/Runtime/Device.chs.h cudaGetDeviceCount"
  cudaGetDeviceCount'_ :: ((C2HSImp.Ptr C2HSImp.CInt) -> (IO C2HSImp.CInt))

foreign import ccall unsafe "Foreign/CUDA/Runtime/Device.chs.h cudaGetDeviceProperties"
  cudaGetDeviceProperties'_ :: ((C2HSImp.Ptr (DeviceProperties)) -> (C2HSImp.CInt -> (IO C2HSImp.CInt)))

foreign import ccall unsafe "Foreign/CUDA/Runtime/Device.chs.h cudaSetDevice"
  cudaSetDevice'_ :: (C2HSImp.CInt -> (IO C2HSImp.CInt))

foreign import ccall unsafe "Foreign/CUDA/Runtime/Device.chs.h cudaSetDeviceFlags"
  cudaSetDeviceFlags'_ :: (C2HSImp.CUInt -> (IO C2HSImp.CInt))

foreign import ccall unsafe "Foreign/CUDA/Runtime/Device.chs.h cudaSetValidDevices"
  cudaSetValidDevices'_ :: ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CInt -> (IO C2HSImp.CInt)))

foreign import ccall safe "Foreign/CUDA/Runtime/Device.chs.h cudaDeviceSynchronize"
  cudaDeviceSynchronize'_ :: (IO C2HSImp.CInt)

foreign import ccall unsafe "Foreign/CUDA/Runtime/Device.chs.h cudaDeviceReset"
  cudaDeviceReset'_ :: (IO C2HSImp.CInt)

foreign import ccall unsafe "Foreign/CUDA/Runtime/Device.chs.h cudaDeviceCanAccessPeer"
  cudaDeviceCanAccessPeer'_ :: ((C2HSImp.Ptr C2HSImp.CInt) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (IO C2HSImp.CInt))))

foreign import ccall unsafe "Foreign/CUDA/Runtime/Device.chs.h cudaDeviceEnablePeerAccess"
  cudaDeviceEnablePeerAccess'_ :: (C2HSImp.CInt -> (C2HSImp.CUInt -> (IO C2HSImp.CInt)))

foreign import ccall unsafe "Foreign/CUDA/Runtime/Device.chs.h cudaDeviceDisablePeerAccess"
  cudaDeviceDisablePeerAccess'_ :: (C2HSImp.CInt -> (IO C2HSImp.CInt))

foreign import ccall unsafe "Foreign/CUDA/Runtime/Device.chs.h cudaDeviceGetLimit"
  cudaDeviceGetLimit'_ :: ((C2HSImp.Ptr C2HSImp.CULong) -> (C2HSImp.CInt -> (IO C2HSImp.CInt)))

foreign import ccall unsafe "Foreign/CUDA/Runtime/Device.chs.h cudaDeviceSetLimit"
  cudaDeviceSetLimit'_ :: (C2HSImp.CInt -> (C2HSImp.CULong -> (IO C2HSImp.CInt)))