-- GENERATED by C->Haskell Compiler, version 0.17.2 Crystal Seed, 24 Jan 2009 (Haskell)
-- Edit the ORIGNAL .chs file instead!


{-# LINE 1 "./Foreign/CUDA/Runtime/Utils.chs" #-}
{-# LANGUAGE ForeignFunctionInterface #-}
--------------------------------------------------------------------------------
-- |
-- Module    : Foreign.CUDA.Runtime.Utils
-- Copyright : (c) [2009..2012] Trevor L. McDonell
-- License   : BSD
--
-- Utility functions
--
--------------------------------------------------------------------------------

module Foreign.CUDA.Runtime.Utils (runtimeVersion, driverVersion)
  where



{-# LINE 16 "./Foreign/CUDA/Runtime/Utils.chs" #-}


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

-- System
import Foreign
import Foreign.C


-- |
-- Return the version number of the installed CUDA driver
--
{-# INLINEABLE runtimeVersion #-}
runtimeVersion :: IO Int
runtimeVersion =  resultIfOk =<< cudaRuntimeGetVersion

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

{-# LINE 36 "./Foreign/CUDA/Runtime/Utils.chs" #-}



-- |
-- Return the version number of the installed CUDA runtime
--
{-# INLINEABLE driverVersion #-}
driverVersion :: IO Int
driverVersion =  resultIfOk =<< cudaDriverGetVersion

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

{-# LINE 48 "./Foreign/CUDA/Runtime/Utils.chs" #-}



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

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