how to deploy an external function (say filter) on GPU variable in row wise ?
4 ビュー (過去 30 日間)
古いコメントを表示
Hello friends,
I have a matrix A of size 2000 X200000. I want to perform row wise operations on the matrix A using external functions (ex: exfun()). So far i am calling each row in a parfor loop and execute the function. After executing the each row output is saved in a matrix. (pasted few lines of code for ease of understanding). But it is very time consuming process, I would like to use GPU to speed up the row-wise operations. So could you please provide any suggestions or a code to use gpu for my job ? Thanks in Advance
A %MAtrix size of 2000X200000
parfor i =1:1:size(A,2)
row_data=A(i,:);
output(i,:)=exfun(row_data);
end
2 件のコメント
Edric Ellis
2021 年 11 月 24 日
Whether you can use the GPU to help here depends entirely on whether the operations in exfun are supported on the GPU. See https://www.mathworks.com/help/parallel-computing/run-matlab-functions-on-a-gpu.html for more.
I would also suggest that iterating over rows of a matrix is generally less efficient than iterating over columns. That's because MATLAB stores matrices in "column major" order - picking out a single column is a simpler operation. (Of course, far better to have exfun operate on the whole matrix, or even chunks of matrix). So, you might be better off transposing A before you start. Depending on the computational time needed by exfun, this might or might not be significant.
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で GPU Computing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!