 --
 -- Initialize device memory to a given value
 --
-memset                  :: DevicePtr -> Integer -> Int -> IO (Maybe String)
+memset                  :: DevicePtr -> Int -> Integer -> IO (Maybe String)
 memset ptr symbol bytes =  nothingIfOk `fmap` cudaMemset ptr bytes symbol
 
 {# fun unsafe cudaMemset

    (rv,ptr) <- cudaMalloc bytes
    case rv of
        Success -> doAutoRelease cudaFree_ >>= \fp ->
                   newDevicePtr fp ptr >>= (return.Right)
        _       -> return.Left $ getErrorString rv

{# fun unsafe cudaMalloc

    (rv,ptr,pitch) <- cudaMallocPitch width height
    case rv of
        Success -> doAutoRelease cudaFree_ >>= \fp ->
                   newDevicePtr fp ptr     >>= \dp -> return.Right $ (dp,pitch)
        _       -> return.Left $ getErrorString rv

{# fun unsafe cudaMallocPitch
    { alloca-  `Ptr ()'  peek*        ,
      alloca-  `Integer' peekIntConv* ,
      cIntConv `Integer'              ,
      cIntConv `Integer'              } -> `Status' cToEnum #}
