Параллельные алгоритмы

Листинг №3

Процедуры рабочей задачи

PROCEDURE Worker;  
VAR  
   X: CGA_LoRes_X;  
   Y: CGA_Y;  
   Count, N: Integer;  
   Complete: Boolean;  
   Gap, X_Coord, Y_Coord,  
   AC, BC, Sq, A2, B2, A, B: ShortReal;  
BEGIN  
   WHILE TRUE DO BEGIN     { Endless loop }  
      { Wait here till packet arrives }  
      N := Net_Receive (C, Complete);        
      { Unpack some of the parameters }  
      X_Coord := C.Details.X_Coord;  
      Y_Coord := C.Details.Y_Coord;  
      Gap := C.Details.Gap;  
      { Top-left and bottom-right corners specified which part to do }  
      N := 1;  
      FOR Y := C.T.Tly TO C.T.Bry DO BEGIN  
         BC := Y_Coord - Y*Gap;  
         FOR X := C.T.Tlx TO C.T.Brx DO BEGIN  
            AC := X*Gap + X_Coord;  
            A := AC; B := BC; Sq := 0; Count := 0;  
            { Do calculation until > 2 away, or count reaches 256 }  
            A2 := A*A; B2 := B*B;  
            WHILE (Sq < 4) AND (Count < 256) DO BEGIN  
               B := 2*A*B + BC;  
               A := A2 - B2 + AC;  
               A2 := A*A; B2 := B*B;  
               Sq := A2 + B2;  
               Count := Count + 1;  
            END;  
            { Store 0 means 1; stored 255 means 256 }  
            R.Counts[N] := Count - 1;  
            N := N + 1  
         END              
      END;  
      { Send top-left and bottom-right coordinates back to MANDELM  
        as well, to identify the data...                           }  
      R.T := C.T;  
      Net_Send (Size(Tile)+N, R, True)  
END   { of endless loop } 
END;  

возврат


Наш канал на Youtube

1999 1 2 3 4 5 6 7 8 9 10 11 12
2000 1 2 3 4 5 6 7 8 9 10 11 12
2001 1 2 3 4 5 6 7 8 9 10 11 12
2002 1 2 3 4 5 6 7 8 9 10 11 12
2003 1 2 3 4 5 6 7 8 9 10 11 12
2004 1 2 3 4 5 6 7 8 9 10 11 12
2005 1 2 3 4 5 6 7 8 9 10 11 12
2006 1 2 3 4 5 6 7 8 9 10 11 12
2007 1 2 3 4 5 6 7 8 9 10 11 12
2008 1 2 3 4 5 6 7 8 9 10 11 12
2009 1 2 3 4 5 6 7 8 9 10 11 12
2010 1 2 3 4 5 6 7 8 9 10 11 12
2011 1 2 3 4 5 6 7 8 9 10 11 12
2012 1 2 3 4 5 6 7 8 9 10 11 12
2013 1 2 3 4 5 6 7 8 9 10 11 12
Популярные статьи
КомпьютерПресс использует