Changes between Version 58 and Version 59 of Next-GenOpenMPTransformation
- Timestamp:
- 11/12/19 13:20:57 (7 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Next-GenOpenMPTransformation
v58 v59 611 611 612 612 Basically, 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. 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. \\ 614 The 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''' 614 624 615 625 {{{ … … 632 642 633 643 // critical block with unspecified name 644 $read_and_write_set_update(team); 634 645 $yield(); 635 $check_data_race(team);636 646 $omp_helper_semaphore_p(critical_, 0); 637 647 $omp_helper_semaphore_v(critical_, 1); 648 $check_data_race(team); 649 638 650 translate(BLOCK_A) 651 652 $read_and_write_set_update(team); 653 $yield(); 639 654 $omp_helper_semaphore_v(critical_, 0); 655 $check_data_race(team); 640 656 641 657 // critical block with specified name 658 659 $read_and_write_set_update(team); 642 660 $yield(); 643 $check_data_race(team);644 661 $omp_helper_semaphore_p(critical_x, 0); 645 662 $omp_helper_semaphore_v(critical_x, 1); 663 $check_data_race(team); 664 646 665 translate(BLOCK_X); 666 667 $read_and_write_set_update(team); 668 $yield(); 647 669 $omp_helper_semaphore_v(critical_x, 0); 670 $check_data_race(team); 648 671 }}} 649 672 … … 692 715 int i_next = i + I_INCR; 693 716 ... 717 $read_and_write_set_update(team); 694 718 $yield(); 695 $check_data_race(team);696 719 // wait until hs0->val is i 697 720 $omp_helper_semaphore_p(ordered_0, i); 721 $check_data_race(team); 722 698 723 translate(BLOCK); 724 725 $read_and_write_set_update(team); 726 $yield(); 699 727 // set hs0->val as i_next 700 728 $omp_helper_semaphore_v(ordered_0, i_next); 729 $check_data_race(team); 701 730 ... 702 731 } … … 704 733 }}} 705 734 706 ==== Case 1: ordered for-loop with a collapse clause ==== 735 ==== Case 2: ordered for-loop with a collapse clause ==== 736 The 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''' 707 749 708 750 {{{ … … 731 773 int k_next = k + K_INCR; 732 774 775 $read_and_write_set_update(team); 733 776 $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); 734 780 $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);738 781 739 782 translate(BLOCK); 740 783 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' 743 788 else { 744 $omp_helper_semaphore_v(ordered_2, K_INIT); // reset 745 746 if (j_next < J_COND) // hitbound747 $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' 748 793 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' 752 797 } 753 798 } 799 $check_data_race(team); 754 800 } 755 801 ..
