As an alternative to accelerate , I am trying to invoke CUDA code via Haskell FFI.
Here is a simple program that does not compile:
cuda_code.cu:
void cuda_init() {
cudaFree (0);
cudaThreadSynchronize ();
}
Test.hs:
foreign import ccall unsafe "cuda_init" cuda_init :: IO ()
main = cuda_init
Compiled with
$> nvcc -c -o cuda_code.o cuda_code.cu
$> ghc Test cuda_code.o
and got some binding errors (undefined reference to cudaFree, etc.). This is not surprising, and the obvious solution for me is to communicate with NVCC using -pgml nvcc. (This worked when I used Intel CILK + in my C code: I just changed the linker to ICC, and it worked out just fine.)
Be that as it may, using NVCC to associate the results with a binding error:
ghc Test -pgml nvcc cuda_code.o
[1 of 1] Compiling Main ( Test.hs, Test.o )
Linking Test ...
nvcc fatal : Unknown option 'u'
Performance
strace -v -f -e execve ghc Test -pgml nvcc cuda_code.o
(is there an easier way?) I found that ghccalls nvccwith
nvcc ... -L ~ / ghc ... -L ... -l ... -l ... -u ghczmprim_GHC ... -u ghc ...
, -u gcc (, -, icc) undefined, - nvcc .
, GHC. , GHC CUDA?
-------- -----------------
- , GCC ( ), gcc, CUDA. - , , , , !