GPU Computing

cancel
Showing results for 
Search instead for 
Did you mean: 

how to smu in gpu?

hi, plese qustion

example)

I want 1D Array sum in GPU. I don't no method. How to method ?

In case, CUDA VI's in addition GPU SUM DLL ?

plese, answer

0 Kudos
Message 1 of 6
(10,952 Views)

You have a few options for array summation. The two I mention here involve writing C code using CUDA calls.

NOTE: The LabVIEW GPU Computing module is designed to help integrate existing external C/C++ functions written using the CUDA SDK into a LabVIEW application. It is not capable of deploying G code to the GPU for execution.

  1. Pass the two SGL arrays to a C function the invokes a GPU kernel which sums the array elements. You can find examples of how to do this in the Black-Scholes example (.\LVCUDA\examples\BlackScholes). The type of GPU kernel code would be similiar (but much simpler) than those found in GPU_BlackScholes.cu (e.g. GPU_BlackSholes_Stage1 or GPU_BlackScholes_Stage2). The CUDA SDK may also come with a code example where two arrays are added.
  2. Use the CUBLAS library (function : cublasSaxpy - stands for Single precision a*x plus y for a scalar a and vectors x & y) to do the summation. The SGEMV example in LVCUDA is an example of how you call a CUBLAS function from LV.

If you are not familiar with C code, option #2 is more straightforward as much of the code can be copied and function calls and parameters replaced with those for the SAXPY.

I know the VI you attached is just a sample, but I have some observations worth noting:

  • You only allocate the GPU buffer during the first iteration which is good for efficiency - no need to reallocate when the sample size remains the same. However, the samples can change from iteration to iteration (i.e. the control is inside the loop) so you would want to free the previous reference and allocate it again if the size increased. You don't have to resize the buffer if the sample size gets smaller unless GPU resources are scarce.
  • The operation on the two arrays will have to be much more complex or the arrays must be signficantly larger for you to see a performance improvement using a GPU.
0 Kudos
Message 2 of 6
(5,042 Views)

thank you, answer MathGuy

Explane error code 15 , LV_cublasSgemv.vi-> cuda test_01.vi in a library function call node

How error eliminate solution?

What private  method for LV_cublasSgemv.vi each variable ??

What ldA, xInc, yInc, n, m, a, b ?

I don't no ideas.

Please, detail explane Help!!

thank you

0 Kudos
Message 3 of 6
(5,042 Views)

Error codes can be tricky because calls using CUBLAS can involve both CUDA and CUBLAS functions. Each have their own set of error codes which can be found in their header files (see the include directory where you CUDA is installed).

Information on CUDA or CUBLAS functions and their errors is documented in the header files where the functions are declared as well as the programming guides. You can find those online at www.nvidia.com/cuda.

If I were debugging this, I'd start with CUBLAS error codes - error code 15 is an internal error.

The LabVIEW interface to CUDA (LVCUDA) remaps error codes to different regions. The offsets are defined in the different header files for error codes (file name has the form *_errors.h). These are in the include directory under LVCUDA. The first error code segment starts at 10000 so I don't the error your getting is not handled expliciy by the LV interface functions.

To learn more about BLAS functions, visit www.netlib.org/blas. That's the definitive site on the subject. If you are not familiar with these functions, they can be very confusing at first because the parameter names are cryptic.

Good luck!

0 Kudos
Message 4 of 6
(5,042 Views)

I recalled your post regarding the error code 15 from SGEMV. There was a bug in the wrapper function that may have caused your problem. You can find a related post on the issue here:

http://decibel.ni.com/content/message/18831#18831

I hope this helps.

0 Kudos
Message 5 of 6
(5,042 Views)

Hi, have you solve the problem. I am also trying adopting GPU in Labview, however, it doesn't work for me. I tried to copy the example, but I don't know why i could not get the sum of the two array out.

Hope you can hel me.

0 Kudos
Message 6 of 6
(5,042 Views)