-2

I'm doing image processing in a cluster, but failed to optimal performance, I have a function that replicate the edges and another to apply the filter or mask, but when the time of execution of MATLAB SPMD used the program are not meeting each while increasing worker as time increases.

enter code here
      p1=parpool('local',4);
      addAttachedFiles(p1,{'Max_Duplicado_pixel.m',
      'funcion_Aplicacion_mascaras.m'});
      tic
      spmd
      d1=codistributor1d(2);
      c = codistributed(imA, d1);  
      som=funcion_Aplicacion_mascaras(
      Max_Duplicado_pixel(getLocalPart(c),sombrero),sombrero);     
      salida=gcat(som);
       end
      imshow(salida{1});
       end
       delete(gcp);   

enter code here

this is the function to apply mascara

enter code here
     x=ceil(R1/2):R-floor(R1/2); 
     y=ceil(R1/2):C-floor(R1/2); 
     for b=-floor(R1/2):floor(R1/2)
         for a=-floor(R1/2):floor(R1/2)
             salida(x,y)=salida(x,y)+single(imagen(x+b,y+a))
            *sombrero(b+ceil(R1/2),a+ceil(R1/2));        
         end

     end
     temp=salida(ceil(R1/2):R-floor(R1/2),ceil(R1/2):C-floor(R1/2));
     image_procesada=uint8(temp);
John Slegers
  • 45,213
  • 22
  • 199
  • 169

1 Answers1

0

From what I understand, you are just doing something like spmd,x=somefunction(),end without ever using labindex. This won't accelerate your computation, each worker will do exactly the same stuff, evaluating x=somefunction(). With 5 workers the function will be evaluated 5 times. Take a look at parfor, it's typically the easiest concept to write parallel code.

Daniel
  • 36,610
  • 3
  • 36
  • 69
  • also try this labindex and with labSend and labReceive – Eduardo Alejandro Feb 17 '16 at 02:35
  • Based on the description you gave I have no Idea what your code is supposed to do. From what I see I can only tell all workers are doing the same stuff. Maybe update your question and include a description of your code and how you want the workers to split the task. – Daniel Feb 17 '16 at 02:46
  • I have understood that an independent parfor is not to use this data to apply the mask spmd – Eduardo Alejandro Feb 17 '16 at 03:13
  • I do not understand you comment. – Daniel Feb 17 '16 at 03:13
  • do not know much English, I have understood that the 'parfor' is for data not dependent , Well what I want to do; I have a cluster and I want to perform distributed processing with images no sé mucho inglés, Tengo entendido que la 'parfor'_ es para datos no dependientes, Bueno lo que quiero hacer; Tengo un cluster y Quiero realizar un procesamiento distribuido con imágenes – Eduardo Alejandro Feb 17 '16 at 03:41
  • @EduardoAlejandro: To distribute a task among multiple workers, independent tasks are required. If you can not identify them, the parallel computing toolbox is not the right choice. – Daniel Feb 17 '16 at 03:54