Changes between Version 58 and Version 59 of Next-GenOpenMPTransformation


Ignore:
Timestamp:
11/12/19 13:20:57 (7 years ago)
Author:
wuwenhao
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Next-GenOpenMPTransformation

    v58 v59  
    611611
    612612Basically, use a lock for each critical name, plus one for the "no name".  All threads must obtain lock to enter the critical section, then release it.
    613 I.e., if there are critical sections name a, b, and c, there should be global root-scope variables of boolean type named `_critical_noname`, `_critical_a`, etc.
     613i.e., if there are critical sections name a, b, and c, there should be global root-scope variables of boolean type named `_critical_noname`, `_critical_a`, etc. \\
     614The translation pattern is:
     615* '''update R/W sets''' for the caller thread that calls `$read_and_write_set_update(team)`
     616* '''wait''' for other threads until they finish updating their R/W sets, by calling `$yield()`
     617* '''acquire the lock''', which bonds to this `critical` region.
     618* '''check data-race''' by calling `$check_data_race(team)` at each synchronizing point.
     619* '''explore''' the  translated `critical` region.
     620* '''update R/W sets'''
     621* '''wait''' for other threads
     622* '''release the lock'''
     623* '''check data-race'''
    614624
    615625{{{
     
    632642
    633643// critical block with unspecified name
     644  $read_and_write_set_update(team);
    634645  $yield();
    635   $check_data_race(team);
    636646  $omp_helper_semaphore_p(critical_, 0);
    637647  $omp_helper_semaphore_v(critical_, 1);
     648  $check_data_race(team);
     649
    638650  translate(BLOCK_A)
     651
     652  $read_and_write_set_update(team);
     653  $yield();
    639654  $omp_helper_semaphore_v(critical_, 0);
     655  $check_data_race(team);
    640656
    641657// critical block with specified name
     658
     659  $read_and_write_set_update(team);
    642660  $yield();
    643   $check_data_race(team);
    644661  $omp_helper_semaphore_p(critical_x, 0);
    645662  $omp_helper_semaphore_v(critical_x, 1);
     663  $check_data_race(team);
     664
    646665  translate(BLOCK_X);
     666
     667  $read_and_write_set_update(team);
     668  $yield();
    647669  $omp_helper_semaphore_v(critical_x, 0);
     670  $check_data_race(team);
    648671}}}
    649672
     
    692715    int i_next = i + I_INCR;
    693716    ...
     717    $read_and_write_set_update(team);
    694718    $yield();
    695     $check_data_race(team);
    696719    // wait until hs0->val is i
    697720    $omp_helper_semaphore_p(ordered_0, i);
     721    $check_data_race(team);
     722
    698723    translate(BLOCK);
     724
     725    $read_and_write_set_update(team);
     726    $yield();
    699727    // set hs0->val as i_next
    700728    $omp_helper_semaphore_v(ordered_0, i_next);
     729    $check_data_race(team);
    701730    ...
    702731  }
     
    704733}}}
    705734
    706 ==== Case 1: ordered for-loop with a collapse clause ====
     735==== Case 2: ordered for-loop with a collapse clause ====
     736The transformation pattern is:
     737* '''record next iteration value''' for all loop variables in the entry of the loop body.
     738* '''update R/W sets''' for the current thread.
     739* '''wait for other threads''' finishing R/W set updates.
     740* '''semaphore P operations''' from the outer-most to the inner-most loop variable.
     741  (This operation waits for a "signal" send when its sequentially previous iteration is completed.)
     742* '''check data-race''' at any synchronizing point.
     743* '''explore''' the translated `ordered` region
     744* '''update R/W sets'''
     745* '''wait for others'''
     746* '''semaphore V operations''' from the inner-most to the outer-most loop variable;
     747  (This operation issues a "signal" to enable the execution of its sequentially next iteration.)
     748* '''check data-race'''
    707749
    708750{{{
     
    731773    int k_next = k + K_INCR;
    732774
     775    $read_and_write_set_update(team);
    733776    $yield();
     777    $omp_helper_semaphore_p(ordered_0, i);
     778    $omp_helper_semaphore_p(ordered_1, j);
     779    $omp_helper_semaphore_p(ordered_2, k);
    734780    $check_data_race(team);
    735     $omp_helper_semaphore_p(ordered_0, i);
    736     $omp_helper_semaphore_p(ordered_1, j);
    737     $omp_helper_semaphore_p(ordered_2, k);
    738781
    739782    translate(BLOCK);
    740783
    741     if (k_next < K_COND) // hit bound
    742       $omp_helper_semaphore_v(ordered_2, k_next); // incr
     784    $read_and_write_set_update(team);
     785    $yield();
     786    if (k_next < K_COND) // 'k' deos NOT hit its bound
     787      $omp_helper_semaphore_v(ordered_2, k_next); // incr 'k'
    743788    else {
    744       $omp_helper_semaphore_v(ordered_2, K_INIT); // reset
    745 
    746       if (j_next < J_COND) // hit bound
    747         $omp_helper_semaphore_v(ordered_1, j_next); // incr
     789      $omp_helper_semaphore_v(ordered_2, K_INIT); // reset 'k'
     790
     791      if (j_next < J_COND) // 'j' deos NOT hit its bound
     792        $omp_helper_semaphore_v(ordered_1, j_next); // incr 'j'
    748793      else {
    749         $omp_helper_semaphore_v(ordered_1, J_INIT); // reset
    750 
    751         $omp_helper_semaphore_v(ordered_0, i_next); // incr
     794        $omp_helper_semaphore_v(ordered_1, J_INIT); // reset 'j'
     795
     796        $omp_helper_semaphore_v(ordered_0, i_next); // incr 'i'
    752797      }
    753798    }
     799    $check_data_race(team);
    754800  }
    755801  ..