NAME
perl_nvcc - a wrapper for nVidia's nvcc
DESCRIPTION
This script is designed to take command-line arguments that would have gone to gcc, and it repackages them for nvcc (which actually invoked g++). Hopefully, it is a drop-in replacement for gcc in modules like Inline::C or Module::Build.
TESTING AND DEBUGGING
Ideally this script would have all of its main functionality defined in a (testable) library. For this first iteration, however, it is simply a script. In order to test the script, you need to set environment variables, which control the behavior of the script. Most of these variables will result in extra printouts from the compiler, but one of them, PERL_NVCC_DRY_RUN, will prevent the script from actually invoking the compiler. This is useful for testing to get the results of the script without actually invoking the heavy lifting.
Note that this is used at present for the testing framework, but there is no guarantee that they will be present in the future. Consider the use of these environment variables to be temporary.
Setting these environment variables to a true value (non-empty string) will give you the following results:
- PERL_NVCC_VERBOSE
-
Gives verbose messages during processing.
- PERL_NVCC_MATCHING
-
Gives a printout of all of the options that match nvcc's list of known options, as well as filenames that are passed to the compiler.
- PERL_NVCC_NON_MATCHING
-
Gives a printout of all of the options that do not match nvcc's list of known options. Note that filenames are not options, so they will not be included in this list.
- PERL_NVCC_MODE
-
Gives a printout of the mode, which is either linking or compiling.
- PERL_NVCC_DRY_RUN
-
Sets the script to only print out results, but not actually invoke the compiler. This is mostly in place for testing purposes.
- PERL_NVCC_C_AS_CU
-
Sets whether or not the script should process .c source files as .cu files. nvcc's behavior depends on the filename's ending (can't set it with a flag, as far as I can tell), so filenames with CUDA code must have a .cu ending. However, Inline::C (and pretty much any utility that creates XS extensions for Perl) uses a .c file extension. To make this work as a drop-in replacement for gcc in Inline::C, this needs to send .cu files to nvcc whenever it encounters .c files.
The way this is actually implemented, perl_nvcc first tries to create a symbolic link to the .c file with the .cu extension; it then tries a hard link; it last tries a direct copy. If none of these work, perl_nvcc croaks. In particular, you will encounter trouble if you try to compile a .c file using perl_nvcc and you have an identically named .cu file.
Note that perl_nvcc will only do this with files ending in a .c extension; it will have no effect on the linking stage since, by that point, all the files have been compiled to object files and have a different file extension.
perl_nvcc's response to this variable is a bit different from the others. If you want a printout of the renaming, set it to a true value, in which case you will get the renaming whether it actually happens or not (due to setting of dry-run mode). If for some reason you don't want the renaming but you do want to compile the source, set this exlicitly to a false value, such as zero. If the environment variable is not defined, perl_nvcc will perform the renaming silently.