フィルターのクリア

Code optimization with GPU

2 ビュー (過去 30 日間)
POHL Michel
POHL Michel 2021 年 1 月 16 日
コメント済み: Joss Knight 2021 年 1 月 16 日
Hi everyone, I have the following line of codes which I would like to parallelize on the GPU :
U = zeros(q, M, q, 'gpuArray');
for j=1:q
U(j,:,j) = my_line_vector;
end
Is there any way to suppress the loop?
Thes are the lines of code that run the slowest in my program.
Thank you in advance
Michel

採用された回答

Joss Knight
Joss Knight 2021 年 1 月 16 日
編集済み: Joss Knight 2021 年 1 月 16 日
I = reshape(gpuArray.eye(q),q,1,q);
U = I.*my_line_vector;
  4 件のコメント
POHL Michel
POHL Michel 2021 年 1 月 16 日
Thank you, it works!
I did not know that the element wise product worked with matrices with different size.
Joss Knight
Joss Knight 2021 年 1 月 16 日

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGPU Computing in MATLAB についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by