What?! CUDA::Minimal... works?

I wrote CUDA::Minimal back in late 2010/early 2011 and used it in some of my research before defending my Ph. D. dissertation in May of 2011. At my postdoc I didn't use parallel anything, so CUDA::Minimal languished. When I picked it back up, it didn't even compile on a modern version of Perl. It was disheartening, to say the least.

But now, once again, it works (as long as you're not using Perl v5.16)!!!

I was spurred to work on this based on some bug feedback that seemed to suggest a solution. This moring I fired up my machine with the CUDA-capable hardward and---thinking I already had the development headers I needed---tried to install ExtUtils::nvcc, a toolchain module needed by CUDA::Minimal. That didn't work, because I didnt' have the drivers installed. As of this afternoon, ExtUtils::nvcc will tell you that. :-)

I then spent an hour or so re-installing everything so I could run CUDA again on my Debian box. That's the thing about CUDA development: it takes some up-front cost to get it going. But once it's going, it's pretty fun. At any rate, you can see why I delayed work on this in the past.

I next turned my attention to CUDA::Minimal. The bug that showed up last I checked prevented the project from compiling, so I was a little confused when it compiled without errors on v5.18. It didn't pass the whole test suite, but it compiled fine. And... it seemed to pass a nontrivial part of the test suite, too!

After cleaning up the tests little bit, spent the rest of the day tracking down an alignment mismatch. I will spare you the details. The important part is that, using perlbrew, I have confirmed that I can run CUDA::Minimal on Linux for Perls v5.12, 5.14, and 5.18, both threaded and non-threaded! I haven't tested blead yet.

Back in February, when the compilation failed on the freshest non-bleed version of Perl, I threw my hands up in disgust and put the project aside again. I am so glad that it was just a temporary issue, and now I hope to start using git-bisect to figure out what is special about Perl v51.6, and if there is a hack I can employ on my end to make it Just Work.

I am deeply indebted to rafl and bulk88, and their help on irc.perl.org#xs for helping me isolate the alignment problem. #xs was recently resuscitated by the efforts of alh, and I am very glad to have had the help!

3 Comments

hello David Mertens
will you the running environment be the virtual machine?

I did it in the vmware rh5.5 virtual machine.

I tried to install ExtUtils::nvcc, that didn't work, because I didnt' have the drivers installed. But I can not find the Nvida driver in vmware.

Could you tell me which driver can I use in vmware in order to install the ExtUtils::nvcc?

thank you very much!

ch

And here's this - with Perl 5.22, GCC 5.3.0, CUDA 7.5 anno domini 2016:

dev@sol.petamem.com:/data/soft/perl-CUDA-Minimal
# ./Build test
t/00_load.t ............... ok   
t/Index-Manipulation.t .... ok   
t/Memory.t ................ ok   
t/Transfer.t .............. ok     
t/z_PDL.t ................. ok     
t/z_kernel_invocations.t .. ok    
All tests successful.
Files=6, Tests=76,  1 wallclock secs ( 0.02 usr  0.01 sys +  0.21 cusr  0.74 csys =  0.98 CPU)
Result: PASS

You have to do some hacking

/opt/cuda/host_config.h
to remain silent about gcc 5.3.0

ExtUtils::nvcc::Backend
to inject forced inlines to nvcc
push @nvcc_args, '-D_FORCE_INLINES=1';
as I wasn't able to do it on CLI

PDL build
https://sourceforge.net/p/pdl/bugs/407/

and finally hack 3 tests in t/z_kernel_invocations.t to match against "illegal memory access" instead of "unspecified".


cheers!

Leave a comment

About David Mertens

user-pic This is my blog about numerical computing with Perl.