GPU Array fun inside for loop - slower execution

I have a function that I know executes correctly on the GPU using arrayfun. I also know that the execution is very quick ~0.1 seconds. I essentially itterate over the function with slightly different inputs lets say 100 times. What does make sense is that if i were to copy and past the command line and execute it as 100 lines of code instead of a for loop it is much slower
for i = 1:100
out = arrayfun(@fun(a),gpuArray)
end
can anyone explain what i am seeing?

2 件のコメント

Walter Roberson
Walter Roberson 2020 年 2 月 9 日
@fun(a) is not valid syntax
You have to be careful with gpu timing. gputimeit is recommended.
Joss Knight
Joss Knight 2020 年 2 月 9 日
I think you're going to have to post your actual code because it's hard to work out exactly what you mean. If your function is an anonymous function, for instance, then it's easy to explain the difference.

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

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeGPU Computing についてさらに検索

タグ

質問済み:

2020 年 2 月 9 日

コメント済み:

2020 年 2 月 9 日

Community Treasure Hunt

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

Start Hunting!

Translated by