Hey folks -

I have succeeded in transferring data from Perl to my video card, calling a
kernel to operate on that data, and transferring the data back to Perl.
Herein I describe how I got it working. Comments, suggestions, advice for
moving forward, and general enthusiasm would be greatly appreciated.

The first question I asked myself was this: Could I simply use Inline::C and
specify nvcc as my compiler? Answer: No. ExtUtils::MakeMaker sends a whole
boatload of compiler flags to gcc that makes nvcc choke. However, there is a
way to send special compiler flags to the compiler backend, using the
-Xcompiler=flag1,flag2,... option for nvcc.

Thence came the next question: Could I use a perl script for Inline::C's
compiler and linker? Answer: Yes. So, I wrote a little perl script that
takes all of the command-line options and checks if they are valid nvcc
options or flags. If so, it passes them along to nvcc unmodified, and if not
it collects them and packages them into a -Xcompiler=... or -Xlinker=...
argument. It then calls nvcc with the revised set of flags and options.

And after a bit of fiddling, it actually worked. I've posted my code on
github at this address: https://github.com/run4flat/perl_nvcc

My plans are to create CPAN distributions ExtUtils::nvcc (which would
install perl_nvcc) and Inline::CUDA (which would be derived from Inline::C).
If I still have energy, I may work with Module::Build to include some sort
of CUDA support. Eventually, I'd like to start working on the CUDA-Perl
bindings, which I'll take elsewhere, probably to the PDL list. Does these
sound like a good ideas? Is anybody else interested?

David

Reply via email to