Advertisement
Guest User

Partner Allocation

a guest
Dec 22nd, 2014
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.74 KB | None | 0 0
  1. int proc , bit ;
  2.     // Length of binary representation for the process IDs.
  3.     int process_bits = log2(p) ;
  4.    
  5.     int partner;
  6.  
  7.  
  8.     // Communicate with all the corresponding processes.
  9.     for ( proc = 0 ; proc < process_bits ; proc ++ )
  10.     {
  11.       // For every bit in the current phase of the sorting procedure :
  12.       for ( j = proc ; j >=0 ; j-- )
  13.       {
  14.         // Get the next process we will communicate by toggling
  15.         // bit
  16.         partner = processID ^ ( 1 << j )  ;
  17.  
  18.         if ( (  ( processID >> (j+1) ) & 1 ) == ( ( processID >> j  ) & 1  ) )
  19.         {
  20.           CompareLow( array , N , partner);
  21.         }
  22.         else
  23.         {
  24.           CompareHigh( array , N , partner );
  25.         }
  26.       }
  27.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement