problems with Parallel Computing Toolbox
I would like to reduce the processing time of a 25e6x1 signal. for this I have thought about parallelizing processes, so that the 25e6 of samples are processed in smaller blocks. I have been researching and I have several options, however I am new with the PCT (Parallel Computing Toolbox) tool and I am having certain problems. First I thought about using a parfor loop but since my code contains not allowed functions like save or eval, I do not consider this option as valid. I have also tried to use pmode so that it divides the array into blocks and performs the processing of each block in the different labs. This option does not work the way I expected, it only runs one of the labs.
function obtener_RDM_individuales_v2(parametros, directorio_guardar)
carpeta_guardar = fullfile(directorio_guardar, 'RDM antenas ECA'); mkdir(carpeta_guardar);
% Parametros necesarios: PRI_start = parametros.pris(1); PRI_stop = parametros.pris(end); Tobs = parametros.Tobs; num_antenas = parametros.nantenas; fc = parametros.AB_adq; Nspb = parametros.Nspb; tH1 = parametros.tH1; fdmax = parametros.fdmax; Tc = parametros.Tc; K = parametros.K; Nrange=length(tH1);
for ind = 1:num_antenas
folder_RD_antena = [carpeta_guardar,filesep, 'Antena ' num2str(ind)];
mkdir(folder_RD_antena);
end
for n_PRI=PRI_start:PRI_stop
[ch_0,ch_1,ch_2,ch_3]=IdeparMex_v2;
pmode start 5
%---------------------------------------------------
% when I try to copy the variables I get another error% pmode client2lab Tobs 1:numlabs % pmode client2lab fc 1:numlabs % pmode client2lab n_PRI 1:numlabs % pmode client2lab k 1:numlabs % pmode client2lab Nspb 1:numlabs % pmode client2lab fdmax 1:numlabs % pmode client2lab tH1 1:numlabs % pmode client2lab Tc 1:numlabs % pmode client2lab carpeta_guardar 1:numlabs
% for ind = 1:num_antenas
% va=genvarname(['ch_',num2str(ind)]);
% y=eval(va);
% pmode client2lab y 1:numlabs
% end
%---------------------------------------------------
for bpri=drange(1:numlabs)
cicle=num2str(((bpri-1)+(n_PRI*5)));
jump=round(((bpri-1)*Tobs+1/fc)*fc-1)+1996;
jump1=round(((bpri-1+1)*Tobs+1/fc)*fc-1)+1995; S_ref=zeros(1,round(Tobs*fc));
S_ref=double(ch_0(jump:jump1-3).');…
folder_RD_antena = [carpeta_guardar, filesep, 'Antena ' num2str(ind)];
salvar_RD = fullfile(folder_RD_antena,['RD_BATCHES' '_' 'PRI_' num2str(cicle)]);
save(salvar_RD,'RD_batches','freqB');
clear ssurv_fil salvar_RD RD_batches folder_RD_antena freqB S_surv
end
end
pmode exit
end
clear sref_fil S_refend
Finally I tried to create a function with the code I want to parallelize and make use of spmd and distributed arrays as shown in the code.
function antenas_for(parametros_fun, channels, PRI, carpeta_guardar_a)
%...parameters
cha_0=channels.ch0; cha_1=channels.ch1; cha_2=channels.ch2; cha_3=channels.ch3;
cicle=num2str(PRI);
S_ref=zeros(round(Tobs*fc),1,'distributed');
S_ref=double(cha_0).';…
save(salvar_RD,'RD_batches','freqB');
clear ssurv_fil salvar_RD RD_batches folder_RD_antena freqB S_surv
end
end
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function obtener_RDM_individuales_modificado1(parametros, directorio_medidas, medida, directorio_guardar)
…
for n_PRI=PRI_start:PRI_stop
[ch_0,ch_1,ch_2,ch_3]=IdeparMex_v2;
canales.ch0=codistributed(ch_0(1996:25001997-3)); canales.ch1=codistributed(ch_1(1996:25001997-3)); canales.ch2=codistributed(ch_2(1996:25001997-3)); canales.ch3=codistributed(ch_3(1996:25001997-3));
spmd
antenas_for(parametros, canales, n_PRI, carpeta_guardar);
end
end
clear sref_fil S_ref
endAfter run matlab I have obtained the following error. I am possibly misusing the distributed arrays but I do not know how to fix it.
Warning: The number of workers must be the same when loading a codistributed array as it was when the array was saved. This array was saved with numlabs equal to 1, but numlabs is now 10.
> In codistributed.loadobj (line 14)
In parallel.internal.pool.deserialize (line 29)
In parallel.internal.pool.deserializeFunction (line 17)
In spmdlang.remoteBlockExecution>iDeserializeInputs (line 178)
In spmdlang.remoteBlockExecution>iPrelude (line 119)
In spmdlang.remoteBlockExecution (line 36)
Warning: The number of workers must be the same when loading a codistributed array as it was when the array was saved. This array was saved with numlabs equal to 1, but numlabs is now 10.
> In codistributed.loadobj (line 14)
In parallel.internal.pool.deserialize (line 29)
In parallel.internal.pool.deserializeFunction (line 17)
In spmdlang.remoteBlockExecution>iDeserializeInputs (line 178)
In spmdlang.remoteBlockExecution>iPrelude (line 119)
In spmdlang.remoteBlockExecution (line 36)
Error using obtener_RDM_individuales_modificado1 (line 50)
Error detected on worker 3.Error in procesado_una_antena (line 73)
obtener_RDM_individuales_modificado1(parametros_gen, directorio_medidas, medida, directorio_guardar);
Caused by:
Error using codistributor1d (line 498)
Distribution partition must be a length NUMLABS row-vector of non-negative integer-valued numeric values.
I need to reduce the processing times since they are critical times for my system. After a time analysis of the code I discovered that the function that consumes the most time is xcorr. Any help on how to reduce processing time or the use of PCT tool is very helpful.
Regards,
Anabel
0 Kommentare
Antworten (0)
Siehe auch
Kategorien
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!