change code to use GPU
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi
I am trying to change a code that has double for loop to use GPU(single gpu right now).
But it seems fall in endless loop,because simple double for loop ends almost 300 sec but parfor and inner for loop does not end when elapsed 1000 sec over.
please find my error in my code below.
Thank you.
original code
ft_mcd = gpuArray(zeros(npulse,nrbin)); %19454x9098 array
parfor k = 1:npulse
R_real = gpuArray(R_ori + R_ori .* (1 - D_fa_rcmc(k,:)) ./ D_fa_rcmc(k,:)); % 1x9098 array
z = gpuArray(fft(temp_ft_rcd(k,:))); %1x9098 array
zp = gpuArray([z(1:half_len) zeros(1, zpadlen) z(half_len + 1:end)]); %1x72784 array
tf_sub = gpuArray(ifft(zp) * m); %1x72784 array
tf_sub2 = gpuArray([tf_sub tf_sub(1, end:-1:1)]); %1x145568 array
idx = gpuArray(round((R_real-R_ori)/ori_sam_dist*m)); %1x9098 array
temp_ft_mcd = gpuArray(zeros(1,nrbin));%1x9098 array
for rn=1:nrbin
temp_index = gpuArray(1 + m*(rn-1) + idx(rn));%number
temp_ft_mcd(1,rn) = tf_sub2(1, temp_index);%1x9098 array
end
ft_mcd(k,:) = temp_ft_mcd(k,:); %19454x9098 array
end
1 commentaire
Joss Knight
le 23 Juin 2022
I can't really tell what your question is, but your use of gpuArray is wrong. You don't wrap the result of an operation in gpuArray you move the input.
NO: z = gpuArray(fft(temp_ft_rcd(k,:)));
YES: temp_ft_rcd = gpuArray(temp_ft_rcd); z = fft(temp_ft_rcd(k,:));
Now z is a gpuArray so any operations on it will continue to take place on the GPU.
Réponses (0)
Voir également
Catégories
En savoir plus sur GPU Computing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!