Can I use GPU instead of CPU to run parfor-loop?

5 ビュー (過去 30 日間)
Chang seok Ma
Chang seok Ma 2022 年 5 月 19 日
コメント済み: Jan 2022 年 5 月 19 日
Hello,
I am trying to figure out how GPU works when it comes to parallelization.
Below is the part of the code that I am working on.
I usually rely on CPU parallelization. My CPU has 36 cores and as far as I understand, each worker is assigned with each outerloop (in this case 1 to Na is assigned to each worker)
And I was told about this GPU parallelization and Matlab supports GPU tasks. I read some documents but couldn't get how can it work so fast.
If I understand this correctly, a single GPU has more cores than CPU in usual. So I was wondering if GPU parallelization works in the same way by using spmd (each core of GPU is assigned with each loop).
parfor i_a = 1:Na
for i_d = 1:Nd
for i_y = 1:Ny
for i_t = 1:Nt
[adj_sol, adjval] = fminsearchbnd(@(x) ...
adjvalue_model1(x,i_a,i_d,i_y,i_t,Utility,A,D,Y,T,R,delta,fixed,Interpol_1,Na,Nd), ...
[x0(i_a,i_d,i_y,i_t); x1(i_a,i_d,i_y,i_t)],...
[A(1); D(1)],[A(end); D(end)],options);
end
end
end
end
Any help will be very much appreciated.
Thank you.
  1 件のコメント
Jan
Jan 2022 年 5 月 19 日
Although the GPU has much more cores, they are very simple compared to a CPU. The addition, elementwise multiplication or trigonometric functions run faster on a GPU using a large number of processing units. But you cannot run fminsearchbnd in a GPU core.

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

回答 (1 件)

Raymond Norris
Raymond Norris 2022 年 5 月 19 日
GPU threads aren't divided up by workers. Conversely, one worker controls a GPU at a time.

Community Treasure Hunt

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

Start Hunting!

Translated by