Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int proc , bit ;
- // Length of binary representation for the process IDs.
- int process_bits = log2(p) ;
- int partner;
- // Communicate with all the corresponding processes.
- for ( proc = 0 ; proc < process_bits ; proc ++ )
- {
- // For every bit in the current phase of the sorting procedure :
- for ( j = proc ; j >=0 ; j-- )
- {
- // Get the next process we will communicate by toggling
- // bit
- partner = processID ^ ( 1 << j ) ;
- if ( ( ( processID >> (j+1) ) & 1 ) == ( ( processID >> j ) & 1 ) )
- {
- CompareLow( array , N , partner);
- }
- else
- {
- CompareHigh( array , N , partner );
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement