Multiple GPU usage in Parallel
6 次查看(过去 30 天)
显示 更早的评论
There just isn't a ton of information out there about using multiple gpus.
I apologize in advance for not posting exact code but only pseudocode. I've also kind of felt my way through the available matlab parallel structures to get the form that I want.
What I don't get is the performance I want. Here is what I'm doing.
Number_of_Things = 4;
parpool = 4
spmd(4) % Parallel region 1 allocate gpus. Yes, my box has 4 gpus.
gd = gpuDevice;
end
single processor stuff gets done relating to data initialization.
spmd(4) % Parallel region 2 Push the local data to the different gpus.
gpu_data = gpuArray(localdata(labindex))
end
spmd(4) % parallel region 3 do the work
process(gpu_data)
end
spmd(4) % parallel region 4 gather the data.
output(labindex) = gather(results)
end
Now please recognize the code that I've psuedocoded does what I want it to do.
I've put things in this form for timing purposes.
I've verified that I'm using 4 different gpus.
As I vary the Number_of_Things that the timing for regions 1,2 & 4 show an increase as number of things increases. I expect that for 1 and 4 and I accept that for #2 as there is a good bit of data being transferred.
What I don't understand is a linear increase in the time of region 3 as the number of things increases. If I pull out the references to gpus and just use standard processors my time goes large,but flat with respect to the number of things. I don't understand why my timing is not flat in the processing region and would appreciate thoughts. My only explanation is that transferring the commands in region 4 to the different gpus is causing interference and slowing thing down in a linear way.
A single thing takes 40 seconds to process. Each multiple thing adds 10 seconds.
8 个评论
Walter Roberson
2017-4-27
David Short:
When you are posting code, please use your cursor to select it, and then click on the "{} Code" button. That would format the code so that the Answers system knows it is code for presentation purposes.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Parallel for-Loops (parfor) 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!