3

I have a custom function that takes in a m by 2 matrix (2 columns) and operates on it. It's quite a bit complicated function as it involves several matrix multiplications going sequentially through one of the column vectors (in a for loop) and depending on the corresponding value from the other column vector choose the matrix to multiply. More like a cumulative matrix product with elements on on column but conditional upon values in one of the column.

eg.,:

 col1 col2
 0   0.03
 0   0.04
 1   0.02
 0   0.1
 1   0.004

if values are 0, one matrix is chosen to multiply or if it's 1 a different one is chosen. Then a cumulative matrix product is taken. ie., Values = diag(Valuesmat); cumulMatProduct = ini;

  for ix = 1:length(col2)
      if col1(ix) == 0
          matrixToMultiply = matrix1;
      elsif col1(ix) == 1
          matrixToMultiply = matrix2;
      end

      anotherMatrixtoMultiply = diag( exp(Values).*col2(ix) );
      cumulMatProduct = matrixToMultiply*anotherMatrixtoMultiply*cumulMatProduct;

   end

  etc., 

Basically that's what the function does.

Now, I have a large number of such column data and so would like to know if I could use GPU computation with it. ( having access to Matlab r2013A with PCT & a TESLA s2050 )

I would like do something like:

    DataMatrix1 = [col1; col1; col1] ;
    DataMatrix2 = [col2; col2; col2];

    gpuDat1 = gpuArray(DataMatrix1);
    gpuDat2 = gpuArray(DataMatrix2);

    [resultVect] = myFuncCall(gpuDat1, gpuDat2, ValueMat,ini); 
     %(ValueMat & ini is not sliced & each processor will have its copy)

ie., slice the matrix as columns to each of the gpuProcessor & make each processor use myfunction to give me an output of the cumulativeMatrixProduct for those input columns of data. (more like independent, grained parallelization to cpu nodes/workers but on GPUs)

I don't think the element-wise operations such as arrayfun or bsxfun could be of help here. Will really appreciate suggestions and help. Thanks for your time.

1 Answer 1

0

If you had multi GPU you could use spmd or parfor.

You want a low level access to your GPU resources which you can have only using CUDA and Mex files.

The book Accelerating MATLAB with GPU Computing might be the right point to start.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.