GPU performance with short vectors
古いコメントを表示
Hello - I see GPU computation underperforming when used for vector manipulation with short lengths.
>> a = rand(1000000, 100,'gpuArray');
>> b= gather(a);
>> tic; for i=1:100 ; eval('q = zeros(1000000,1);for i = 1:100; q = b(:,i)+q;end') ; end;doc
Elapsed time is 45.489811 seconds.
>>tic; for i=1:100 ; eval('qq = zeros(1000000,1);for i = 1:100; q = a(:,i)+q;end') ; end;toc
Elapsed time is 0.875140 seconds.
same when done for short vectors see GPU computation under performing:
>> a = rand(200, 100,'gpuArray');
>>b= gather(a);
>> tic; for i=1:100 ; eval('q = zeros(200,1);for i = 1:100; q = b(:,i)+q;end') ; end;doc
Elapsed time is 0.021727 seconds.
>>tic; for i=1:100 ; eval('qq = zeros(200,1);for i = 1:100; q = a(:,i)+q;end') ; end;toc
Elapsed time is 0.833865 seconds.
Any insight will be appreciated.
Thank you.
採用された回答
その他の回答 (1 件)
Walter Roberson
2016 年 3 月 30 日
0 投票
Do not use eval() for this. use timeit()
3 件のコメント
Edric Ellis
2016 年 3 月 30 日
... and for GPU timings, use gputimeit.
Walter Roberson
2016 年 3 月 30 日
Good point.
MatlabNinja
2016 年 3 月 30 日
カテゴリ
ヘルプ センター および File Exchange で GPU Computing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!