This project is read-only.

MAtrix multiplication

Apr 14, 2013 at 2:50 AM
I've just started to learn manageCuda and it's use. I've managed to get vectorAdd going in VB and am very impressed. I wanted to try matrix multiplication but I can't seem to get the declarations correct. Here is a bit of the VB code.
   '--Dimension a 10 x 10 host matrix
   Dim h_A(10, 10) As Single

    ' --Fill it was random values
    RandomInit(h_A, 10)

   '--Dimension the device array
    Dim d_A As CudaDeviceVariable(Of Single)

    d_A = h_A
The transfer has an error:

" value of 2 dimensional array of single cannot be converted to ManagedCuda.CudaDeviceVariable(Single)"

Can anybody help?

Apr 14, 2013 at 10:52 AM

managedCuda doesn't support more dimensional arrays (The ECMA-Standard allows some internal padding, but this is not accessible to us as users whereas Microsoft currently doesn't seem to use it). In order to get it run, just use plain / flattened arrays as in C/C++: One big 1D-Array and compute the indices directly your self.
Dim h_a(100) As Single

h_a(y * width + x) = XYZ
assuming that your indices start at 0.

On the other hand, you might want to use CudaPitchedDeviceVariable on device side: Adding some junk values to each array line assures that every line starts at an address good for memory controlers on your graphics card. (see CUDA Programming Guide page 19-20).