Created
July 4, 2016 01:58
-
-
Save tmcdonell/ee7c5183633a3687dafd15023f15a914 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# 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 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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