# multi-dimensional gpu array multiplication

1 visualizzazione (ultimi 30 giorni)
Qiu Xu il 26 Ott 2021
Commentato: Walter Roberson il 26 Ott 2021
Hi,
I am performing the following two GPU calculations:
(1) The first problem
m=100;
n=100;
p=1024;
A=gpuArray(rand(m,n,p)); % 3D matrix
B=gpuArray(rand(m,n,p)); % 3D matrix
C=gpuArray(rand(m,n)+i*rand(m,n)); % 2D matrix with element being complex numbers
D=gpuArray(zeros(p,p));
for j=1:p
for k=1:p
D(j,k)=sum(sum(A(:,:,j).*C.*B(:,:,k)));
end
end
(2) The second problem
m=1024;
n=2048;
p=1024;
a0=2;
a1=3;
u=gpuArray(rand(m,n)+i*rand(m,n)); % 2D complex matrix
v=gpuArray(rand(m,n)+i*rand(m,n)); % 2D complex matrix
B=gpuArray(rand(60,60,m)); % 3D matrix
c=0;
d=0;
for j=1:n
usum=0;
vsum=0;
for k=1:m
usum=usum+u(k,j)*B(:,:,k);
vsum=vsum+v(k,j)*B(:,:,k);
end
c=c+a0*usum.*conj(vsum);
d=d+a1*abs(vsum).^2;
end
In above two problems, the two for-loops are very slowly, are there some good methods to aviod the two for-loops on GPU calculations?
Thanks a lots.
##### 1 CommentoMostra -1 commenti meno recentiNascondi -1 commenti meno recenti
Walter Roberson il 26 Ott 2021
pagemtimes() is supported on GPU; perhaps that would help.

Accedi per commentare.

### Categorie

Scopri di più su GPU Computing in Help Center e File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by