Filter löschen
Filter löschen

getting execution time more than serial, procedure to optimise the following code using either spmd or using parfor loop

2 Ansichten (letzte 30 Tage)
Hi, Following code uses structure array , i have parallelised the code as follows but execution time is more compared to serial. if (nargin<3 isempty(bandList)) bandList=10:11; end
% making sure band numbers are not repeated.
opBandList=unique(bandList);
% Removing any band other than 10 and 11
opBandList=[any(opBandList==10)*10 any(opBandList==11)*11];
% checking if the requested bandNumber is loaded.
bandIsLoaded=cellfun(@(x) ~isempty(x),Data.Band);
bandIsLoaded=bandIsLoaded(opBandList);
if (all(~bandIsLoaded))
error('None of the requested bands are loaded')
elseif (any(~bandIsLoaded))
disp('The following Bands are not loaded:')
disp(opBandList(~bandIsLoaded))
disp('These bands are ignored.')
end
opBandList=opBandList(bandIsLoaded);
output.SatBT_bandList=opBandList;
output.SatBT=cell(numel(opBandList));
parpool('local',4);
spmd
for i=1:numel(opBandList)
output=struct();
m=Data.MetaData.L1_METADATA_FILE.RADIOMETRIC_RESCALING.(['RADIANCE_MULT_BAND_' num2str(opBandList(i))]);
b=Data.MetaData.L1_METADATA_FILE.RADIOMETRIC_RESCALING.(['RADIANCE_ADD_BAND_' num2str(opBandList(i))]);
K1=Data.MetaData.L1_METADATA_FILE.TIRS_THERMAL_CONSTANTS.(['K1_CONSTANT_BAND_' num2str(opBandList(i))]);
K2=Data.MetaData.L1_METADATA_FILE.TIRS_THERMAL_CONSTANTS.(['K2_CONSTANT_BAND_' num2str(opBandList(i))]);
tmpOutput=m*double(Data.Band{opBandList(i)})+b;
tmpOutput=K2./ log(K1./tmpOutput +1.0 );
tmpOutput(Data.Band{opBandList(i)}==0)=NaN;
output.SatBT{i}=tmpOutput;
end

Antworten (0)

Kategorien

Mehr zu Graphics Objects finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by