for i=1:10
A(:,:,i)=rand(5,5);
[q1,r1]=qr(A(:,:,i));
end
I wanted cpu and gpu's to communicate with itself about the loop index. For iteration 1, cpu is working, gpu1 should also simultaneously work on iteration 2. gpu 2 should also simultaneously work on iteration 2. If gpu1 completes its task early, it should start iteration 3. When cpu is done with iteration 1, it should proceed with iteration 4 and so on. How should we implement this. The cpu, gpu1,gpu2 should only communiate about the loop index 'i' and not the A matrix. Once cpu or either of gpu's completes its iteration, it should parallely update the output array. How should this be implemented ?

댓글 수: 6

Naveen kumar Elumalai
Naveen kumar Elumalai 2019년 1월 14일
편집: Naveen kumar Elumalai 2019년 1월 14일
That question is talking about how each iteration can be run in asynchronous manner. Here, I needed a partial communication internally about the loop index but not A matrix. So this is a different question. No it's not a homework @walter roberson and @ocder. Yeah its a bit similar @madhan ravi.
Just curious, why do you want to split the job as such? Do you want GPU and CPU to be treated as indistinguishable processors? I foresee an issue where you must continuously exchange an array from a normal array to gpuArray, which can create a lot of overhead and slow things down.
Example of job tasks you want?
Task# CPU1 CPU2 GPU1 GPU2
1 X
2 X
3 X
4 X
5 X
6 X
7 X
8 X
9 X
10 X
11 X
Yeah, the above example you referred, is what I want. The conversion of normalArray to gpuArray does bring a lot of overhead. Thats why, I wanted a work around for executing above task.

댓글을 달려면 로그인하십시오.

 채택된 답변

Walter Roberson
Walter Roberson 2019년 1월 14일

1 개 추천

You cannot do that with parfor or spmd.
What you can perhaps do is use parfeval to submit tasks associated with various resources. Monitor task completion, and upon completion upon a resource, collect the results and start a new task on the same resource.

추가 답변 (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