Originally reported by David Duke.
While working with the Haskell Cuda library on OSX 10.11 I started getting a strange set of behaviours, and wondered if you had come anything similar? I recently updated both my GHC installation (to 8.0.1) and my CUDA toolkit (to 7.5). I therefore wanted to update Accelerate etc, but noted that your Cuda package was only noted up to 7.0. As I don't believe there are substantial changes from 7.0 -> 7.5 I thought it should still work (and I need to have the later CUDA for work not involving Haskell).
However I found that Haskell code that called the Cuda library was aborting, and tracked the failure down to the call to cuInit (made through "initialise" in your library) returning error code 2 (CUDA_DEVICE_OUT_OF_MEMORY). Its not clear why this should be happening, and to explore further I:
- created my own simple C wrapper function around cuInit, which displays the arg and result.
- wrote a C driver to call the wrapper; when executed cuInit is called and returns error code 0.
- wrote a Haskell driver to call the simple wrapper directly via FFI: now when the wrapper is executed cuInit returns error code 2.
Given the simplicity of the two programs, I'm scratching my head for possible causes: when called from C, the wrapper is showing the correct arg and result; when called from Haskell it shows the correct arg but the wrong result! Here are the compiler invocations and runtime results (programs are attached):
~> gcc -c -I /usr/local/cuda/include cuwrap.c
~> ghc callFromHs.hs cuwrap.o -L /usr/local/cuda/lib/ -lcuda
~> gcc -o callFromC callFromC.c cuwrap.o -L /usr/local/cuda/lib/ -lcuda
~> ./callFromC
Running main.
cuInit called: arg 0, result 0
Main completed, result 0
~> ./callFromHs
Running Main
cuInit called: arg 0, result 2
Main completed, result 2
I haven't had a chance to regress to ghc-7.10.3, and was also planning to try the code on linux once Cuda is reinstalled next week. Wondered if you had come across anything similar - or could check what happens on a different configuration?
Attachments: https://gist.github.com/tmcdonell/ee7c5183633a3687dafd15023f15a914