Skip to content

Instantly share code, notes, and snippets.

@tmcdonell
Created July 4, 2016 01:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tmcdonell/ee7c5183633a3687dafd15023f15a914 to your computer and use it in GitHub Desktop.
Save tmcdonell/ee7c5183633a3687dafd15023f15a914 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include "cuwrap.h"
/* C driver to test invocation of wrapped cuInit */
int main(int argc, char **argv)
{
int r;
printf("Running main.\n");
r = cuwrap(0);
printf("Main completed, result %d\n", r);
}
{-# LANGUAGE ScopedTypeVariables, ForeignFunctionInterface #-}
module Main where
import Foreign.C.Types
-- FFI interface for cuwrap interface function.
foreign import ccall unsafe "cuwrap.h cuwrap" cuwrap :: CInt -> IO CInt
main :: IO ()
main = do
putStrLn "Running Main"
i :: Int <- return . fromEnum =<< cuwrap 0
putStrLn $ "Main completed, result " ++ show i
#include <stdio.h>
#include <cuda.h>
/* Invoke cuInit, reporting arg and result. */
int cuwrap(int arg)
{
CUresult res = cuInit(arg);
printf("cuInit called: arg %d, result %d\n", arg, res);
return res;
}
/* Interface to cuInit allowing inspection of arg and result between C & Haskell */
int cuwrap(int arg);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment