Changeset 60 for sources/src/gen_code.cc
- Timestamp:
- Feb 14, 2017, 11:30:19 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sources/src/gen_code.cc
r59 r60 49 49 #include <iostream> 50 50 #include <fstream> 51 #ifdef _OPENMP 52 #include <omp.h> 53 #endif 51 54 52 55 #include "internal.h" … … 58 61 #ifdef HAVE_CONFIG_H 59 62 #include "config.h" 60 #endif61 62 #ifdef _OPENMP63 #include <omp.h>64 63 #endif 65 64 … … 246 245 method_process_list_t & 247 246 moore_func_list, 248 strong_component_list_t &247 strong_component_list_t * 249 248 strongcomponents) { 250 249 if (dump_stage) { … … 277 276 gen_transition(o, transition_func_list); 278 277 gen_moore(o, moore_func_list); 279 gen_mealy(o, strongcomponents); 278 if (strongcomponents != NULL) { 279 gen_mealy (o, *strongcomponents); 280 } 280 281 281 282 o << " \n}\n"; … … 575 576 */ 576 577 577 static method_process_list_t func_list[2]; 578 unsigned int nb_func[2]; 579 static method_process_t **func_list[2]; 580 #pragma omp threadprivate (nb_func, func_list) 578 581 static strong_component_list_t quasistatic_list; 582 583 unsigned long long busy_wait_f0, busy_wait_f1, busy_wait_up, busy_wait_ml; 584 unsigned long long last_wait_f0, last_wait_f1, last_wait_up, last_wait_ml; 585 #pragma omp threadprivate (busy_wait_f0, busy_wait_f1, busy_wait_up,busy_wait_ml) 586 #pragma omp threadprivate (last_wait_f0, last_wait_f1, last_wait_up,last_wait_ml) 579 587 580 588 static void Call(const method_process_t & m) { … … 611 619 } 612 620 621 unsigned int expected_globaltime = 0; 622 volatile unsigned int globaltime __attribute__ ((aligned (128))) = 0; 623 #pragma omp shared (globaltime) 624 #pragma omp threadprivate (expected_globaltime) 625 626 unsigned int num_omp_threads; 613 627 614 628 void quasistatic_simulate_1_cycle(void) { 615 method_process_list_t::iterator mm; 616 for (mm = func_list[0].begin(); mm != func_list[0].end(); ++mm) { 617 method_process_t & m = **mm; 618 Call(m); 619 } 629 int i; 630 631 for (i = 0; i < nb_func[0]; ++i) { 632 Call(*(func_list[0][i])); 633 } 634 #define USE_BUSY_WAIT 1 620 635 update(); 621 for (mm = func_list[1].begin(); mm != func_list[1].end(); ++mm) { 622 method_process_t & m = **mm; 623 Call(m); 624 } 625 quasistatic_mealy_generation(); 636 #if USE_BUSY_WAIT 637 expected_globaltime += num_omp_threads; 638 if (__sync_add_and_fetch(&globaltime, 1) == expected_globaltime) { 639 last_wait_up++; 640 } 641 __asm volatile("mfence"); 642 while (globaltime < expected_globaltime) { 643 busy_wait_up++; 644 __asm volatile("lfence"); 645 } 646 647 #else 648 #pragma omp barrier 649 #endif 650 651 for (i = 0; i < nb_func[1]; ++i) { 652 Call(*(func_list[1][i])); 653 } 654 655 #if USE_BUSY_WAIT 656 expected_globaltime += num_omp_threads; 657 if (__sync_add_and_fetch(&globaltime, 1) == expected_globaltime) { 658 last_wait_f1++; 659 } 660 __asm volatile("mfence"); 661 while (globaltime < expected_globaltime) { 662 busy_wait_f1++; 663 __asm volatile("lfence"); 664 } 665 #else 666 #pragma omp barrier 667 #endif 668 if (!quasistatic_list.empty()) { 669 #pragma omp master 670 { 671 quasistatic_mealy_generation(); 672 } 673 #if USE_BUSY_WAIT 674 expected_globaltime += num_omp_threads; 675 if (__sync_add_and_fetch(&globaltime, 1) == expected_globaltime) { 676 last_wait_ml++; 677 } 678 __asm volatile("mfence"); 679 while (globaltime < expected_globaltime) { 680 busy_wait_ml++; 681 __asm volatile("lfence"); 682 } 683 #else 684 #pragma omp barrier 685 #endif 686 } 687 626 688 } 627 689 … … 631 693 method_process_list_t & 632 694 moore_func_list, 633 strong_component_list_t &695 strong_component_list_t * 634 696 mealy_func_list) { 635 697 if (dump_stage) { … … 637 699 } 638 700 639 func_list[0] = transition_func_list; 640 func_list[1] = moore_func_list; 641 quasistatic_list = mealy_func_list; 701 nb_func[0] = transition_func_list.size(); 702 nb_func[1] = moore_func_list.size(); 703 704 func_list[0] = (method_process_t**) malloc(sizeof (method_process_t*) * nb_func[0]); 705 func_list[1] = (method_process_t**) malloc(sizeof (method_process_t*) * nb_func[1]); 706 707 unsigned int i; 708 for (i = 0; i < nb_func[0]; ++i) { 709 func_list[0][i] = (transition_func_list[i]); 710 } 711 712 for (i = 0; i < nb_func[1]; ++i) { 713 func_list[1][i] = (moore_func_list[i]); 714 } 715 716 if (mealy_func_list != NULL) { 717 quasistatic_list = *mealy_func_list; 718 } 642 719 643 720 if (dump_stage) {
Note: See TracChangeset
for help on using the changeset viewer.