Real GPU parallel computation ?

Dear all,
I want to improve my code by using parallel & GPU computation .
I currently use parfor and gpuArray, for example
x = gpuArray(rand(256,256)) ;
# all variable are in the type of gpuArray
parfor i=1:50000
m = 0:255;
list = (beta/2)* ((x(i) - m).^2) + (eta/2)*(m.^gamma) + ((zeta/2)*((m - Y(i))).^2) + (kappa/2)*((u(i) - m)).^2 ;
[~,Index] = min(list) ;
M(i) = Index;
end
I also try to increase the workers in a parallel pool from 4 to 24 works, but it will not change anything.
The computation time is always between 24s ~ 26s in my device (i7-6700, GTX 1060 6GB)
and the max utilization of CPU & GPU are 50 & 65, respectively.
I have some questions about that
  1. What is the max number of workers in a parallel pool in a 8-cores CPU?
  2. Is the workers from CPU or GPU?
  3. Is there any possible I can use the GPU thread directly to do any GPU parallel computation?
  4. Can I increase the GPU usage to accelerate my code?
I suppose my code is only use CPU parallelization and GPU computation instead of GPU parallel computation
Thank you for reading my question.

2 个评论

To get parallelism on a GPU you need to formulate your code to operate on large vectors and matrices instead of using loops (see Vectorization). MATLAB then takes care of spreading all that work over the GPU cores for you.
You do not explicitly write code to run on different GPU cores, not unless you want to write your own kernels in CUDA C++.
Thank your for your answer.
I'll try to vectorize my code, but right now I accelerate my code by using GPU Coder, the computation time is less than 0.1 second.

请先登录,再进行评论。

回答(0 个)

类别

帮助中心File Exchange 中查找有关 GPU Computing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by