How to pass data divided to two GPU for parallel calculations?

조회 수: 1 (최근 30일)
Mantas Vaitonis
Mantas Vaitonis 2019년 3월 27일
Hello,
I have a group of large *.mat files that are arrays of size Nx130. I would like to load this data and sent it to two GPUs (workers) divided like Nx1:75 to 1GPU and Nx76:130 to 2GPU. I need to do both calculations in parallel, thus I use spmd. Firstly, I would like to ask if this method in the code below is correct. If yes, then if this is the optimal one?
clear;
gpuDevice(1);
nGPUs = gpuDeviceCount(); %start pool of 2 GPUS
parpool('local', nGPUs );
labdata=load ('07_04.mat');%load data to workspace
lab1=labdata.c;
[~,zz]=size(lab1);
zz=zz/2;
zz = fix(zz)*2;
spmd
er=zz-zz/labindex+1;
er1=zz/2*labindex;
lab=lab1(:,er:er1); %creat array depending of worker (Nx1:75 or Nx76:130)
dydis=5050;
[z,~]=size(lab);
z=z/dydis;
z = fix(z);
[a,b]=parallel (lab,z);
end

답변 (0개)

카테고리

Help CenterFile Exchange에서 GPU Computing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by