time - Matlab parfor taking longer than normal for -
i have matlab code using parfor reduce amount of time taken for image processing tasks. basically,it taking 2 images , after doing mathematical calculations, produces scalar qunatity called eucdist. this, 1 image kept fixed , image generated fortran code taking around 20 seconds that. below outline of code:
matlabpool open gray1 = some_image(8192,200); dep = 0.04:0.01:0.40; % parameter 1 vel = 1.47:0.01:1.72; % parameter 2 dist = zeros(length(dep),length(vel)); tic parfor = 1:length(dep) ans = zeros(1,length(vel)); j = 1:length(vel) % updating input.txt file fname = sprintf('input_%.2d%s',i,'.txt'); fid=fopen(fname,'w'); fprintf(fid,'%-5.2f\n%-5.2f\n%.2d',dep(i),vel(j),i); fclose(fid); % running fortran code generate .dat file (note have compiled code outside these loops) system(['./editcrfl ' fname]); % calling image_gen script incorporating above .dat file system('image_gen'); system(sprintf('image_gen %d',i)); gray2 = some_image(8192,200); % doing mathematical calculations , getting value 'eucdist' - - - - - - - - - - - - - - ans(j) = eucdist; end dist(i,:) = ans; fclose('all'); end fprintf('total time taken: %f\n',toc); matlabpool close there 2 major problems facing above code.
first, dist matrix not able store eucdist generated. ideally dist matrix should of size 37 x 26 37 x 1 , values zeros in that. though have checked 37 x 26 values getting calculated don't know why not getting stored in dist.
second, total time taken when using parfor somewhere around 9.5 hours whereas normal for taking 5.5 hours.
can please me rid of above 2 problems?
in advance.
Comments
Post a Comment