Concurrent write to gpuArray
15 ビュー (過去 30 日間)
古いコメントを表示
Is there a way for multiple threads of an arrayfun or other structure to write to the same gpuArray matrix, if I do not care about the order of writes (it is a array of falses and i only ever write trues) and will not read the array by gather until all threads are finished? Doing this by local output and reduction will consume too much memory.
Application: a monochrome 2d rasterizer that processes multiple polygons onto the frame buffer simultaneously
0 件のコメント
回答 (2 件)
Matt J
2015 年 8 月 8 日
編集済み: Matt J
2015 年 8 月 8 日
Even if there's a way, I think it will be very slow. GPUs are not designed to share large data across threads. However, one strategy might be to use gpuArray.arrayfun to prepare a table of the values to be written and their matrix coordinates (I,J,S). Then later, on the CPU, do
A_new=A_old+sparse(I,J,S)
Or, use accumarray instead of sparse(), if the resulting matrix is not sparse. Each GPU thread could compute a single triplet I(k),J(k), S(k) effectively assuming these computations are small, parallel, and don't share large data
Joss Knight
2015 年 9 月 2 日
In short, no, not in MATLAB code. arrayfun has to write one value per thread to a separate output address. Write a CUDAKernel or MEX function in C++.
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!