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.
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;
anotherMatrixtoMultiply = diag( exp(Values).*col2(ix) );
cumulMatProduct = matrixToMultiply*anotherMatrixtoMultiply*cumulMatProduct;
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);
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)? Or even what is the best way to do this in parallel ? (even just with CPUs/Workers. Is matlabpool the best option ?