LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

GPU programming support

Please see Manooch's post above. We still do not have any plans for native CVI support of GPU programming. Please express your interest by creating a post on the LabWindows/CVI Idea Exchange.

National Instruments
0 Kudos
Message 11 of 16
(1,202 Views)

There is a nice example how should GPU support be implemented by NI.

 

http://www.accelereyes.com/arrayfire/c/index.htm

 

Imagine this packaged into a Labwindows CVI library an use as any other lib. would be really good and useful.

Accelereyes has CUDA C/C++ and openCL version, so if restriction with CUDA are the issue, OpenCL could more hardware independent approach.

 

Regardless, this would put labwindows into a new market, with millions of possible new customers.

 

/lajos

0 Kudos
Message 12 of 16
(1,123 Views)

I imagine that doubling the price of CVI (looking at the web site you have linked) might not make everyone happy... And since you have suggested it already in the Idea Exchange NI will be aware of it 😉

0 Kudos
Message 13 of 16
(1,120 Views)

The price is $285, thhy just cut it. The CVI libraries do cost more.

0 Kudos
Message 14 of 16
(1,111 Views)

(Re-posting with readable formatting)

I have been able to implement CUDA code in LabWindows. I used this answer as a reference:
http://stackoverflow.com/questions/9363827/building-gpl-c-program-with-cuda-module

 

Basically the idea is quite simple.

 

Step one: Write an intermediate C source file and header that "wrap" the CUDA code you wish to call in plain vanilla C code, as in the example I linked. You will call these C functions in LabWindows to execute the CUDA code. For example, I this is the prototype for the wrapper function I wrote for CUDA malloc functions:

int TOMCUFFT_cudaMalloc(void** allocatedMemory, size_t numberOfBytes);

 

TOMCUFFT_cudaMalloc() can be called from within LabWindows. The body of the function simply calls cudaMalloc for numberOfBytes of memory, and stores the resulting address in the pointer allocatedMemory.

 

Step two: Generate C object code from your CUDA files. This involves compiling it with the nVidia CUDA compiler (nvcc) to object code. This generates (in Windows) a file with the extension ".o". Object code is compiled binary code which has not yet been linked into an executable. LabWindows is capable of linking in external binary files to your project in the process of creating the final ".exe" executable. If you are using an IDE such as Visual Studio configured to compile CUDA code, you can compile it to a static library (".lib" file in Windows), though I can't think of any reason why this would more desirable than an object file.

 

IMPORTANT! Make sure to compile the object code / library with C style linkage! Do this by adjusting the settings of the IDE you are working with CUDA in, or by wrapping the entire C source file with:
extern "C" { }
Otherwise, LabWindows's linker will not be able to link these files in, as LabWindows only seems to have support for C linkage, and not C++ linkage.

 

Step three: Add files to LabWindows project. Now you have a static library of functions with C-style calling conventions with already compiled CUDA code in them. The header file lets you use these functions in LabWindows. Add your header file and the object code / static library to the LabWindows project. Finally, because static libraries do not actually contain all of their dependencies, you have to add in some of the CUDA libraries provided by nVidia. The default dependency is "cudart.lib". There are two copies (32 and 64 bit) of this file, so make sure you get the right one.

 

LabWindows should now be able to compile the rest of your project, and during linking it will link in cudart.lib and your object / library file. Good luck!

0 Kudos
Message 15 of 16
(1,065 Views)

The implementation I made and tested uses the CUDA library "cufft", which is designed to perform a batch Fourier transform without the coder having to make decisions about block/grid sizes, optimization, etc etc.  I am attaching:

 

- The CUDA source file, which I compiled to a static library in Visual Studio 10, configured to compile .cu files with nvcc to object files (default CUDA configuration), and for the project to take that and produce a ".lib" instead of ".exe".

 

- The header file used to "wrap" the CUDA object code, and to add in a few definitions which are present in "cufft.lib".  I did not wish to add "cufft.lib" directly to my LabWindows project, however, there's something in there the linker doesn't like, so I just re-defined them in the header file (such as the data type "cufftComplex").

 

- The static library, which you can try adding to your own LabWindows project if you want to perform batch Fourier transforms on the GPU without having to do anything else.

 

(I had to add a ".txt" extension to get the forum to accept the files, just remove it again)

0 Kudos
Message 16 of 16
(1,062 Views)