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

2 次查看(过去 30 天)
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

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Graphics Objects 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by