Changeset 60 for sources/src/gen_code.h


Ignore:
Timestamp:
Feb 14, 2017, 11:30:19 AM (7 years ago)
Author:
meunier
Message:
  • Intégration des modifications de Clément, qui a intégré la version parallélisée de systemcass faite par Manuel.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • sources/src/gen_code.h

    r59 r60  
    2121#include "process_dependency.h"
    2222
     23#ifdef _OPENMP
     24#include <omp.h>
     25#endif
     26
    2327//-------------------------------------------------------------------
    2428#ifdef __GNUC__
     
    4044      method_process_list_t   &transition_list,
    4145      method_process_list_t   &moore_list,
    42       strong_component_list_t &mealy_list);
     46      strong_component_list_t *mealy_list);
    4347
    4448extern void  gen_scheduling_code_for_static_func(
     
    5559      method_process_list_t   &transition_list,
    5660      method_process_list_t   &moore_list,
    57       strong_component_list_t &strongcomponents);
     61      strong_component_list_t *strongcomponents);
    5862
    5963/* function when any dynamic link is impossible */
     
    8185inline void internal_sc_cycle2() {
    8286#ifdef DUMP_STAGE
    83     std::cerr << "begin of cycle #" << sc_simulation_time () << "\n";
    84 #endif
    85     func_simulate_1_cycle(); 
    86     ++nb_cycles;
     87#pragma omp master
     88    {
     89        std::cerr << "begin of cycle #" << sc_simulation_time() << "\n";
     90    }
     91#endif
     92
     93        func_simulate_1_cycle();
     94
     95        ++nb_cycles;
    8796#ifdef DUMP_STAGE
    88     std::cerr << "end of cycle\n";
     97#pragma omp master
     98    {
     99        std::cerr << "end of cycle\n";
     100    }
    89101#endif
    90102}
    91103
    92 
    93104inline void internal_sc_cycle1(int number_of_cycles) { 
    94     //while ((! have_to_stop) && (number_of_cycles != 0)) {
    95     while (!((have_to_stop) || (number_of_cycles == 0))) {
    96         trace_all(false);
    97         internal_sc_cycle2();
    98         trace_all(true);
    99         number_of_cycles = (number_of_cycles < 0) ? number_of_cycles : number_of_cycles - 1;
     105    extern unsigned long long busy_wait_f0, busy_wait_f1, busy_wait_up, busy_wait_ml;
     106    extern unsigned long long last_wait_f0, last_wait_f1, last_wait_up, last_wait_ml;
     107    extern unsigned int nb_func[2];
     108#pragma omp threadprivate (busy_wait_f0, busy_wait_f1, busy_wait_up, busy_wait_ml, nb_func)
     109#pragma omp threadprivate (last_wait_f0, last_wait_f1, last_wait_up, last_wait_ml)
     110    extern unsigned int expected_globaltime;
     111    extern volatile unsigned int globaltime;
     112#pragma omp shared (globaltime)
     113#pragma omp threadprivate (expected_globaltime)
     114
     115    extern unsigned int num_omp_threads;
     116
     117
     118#pragma omp parallel
     119    {
     120//        int cyclecount = number_of_cycles;
     121        busy_wait_f0 = busy_wait_f1 = busy_wait_up = busy_wait_ml = total_assig = 0;
     122        last_wait_f0 = last_wait_f1 = last_wait_up = last_wait_ml = 0;
     123
     124        expected_globaltime = 0;
     125#pragma omp master
     126        {
     127            globaltime = 0;
     128#ifdef _OPENMP
     129            num_omp_threads = omp_get_num_threads();
     130#else
     131            num_omp_threads = 1;
     132#endif
     133        }
     134
     135#pragma omp barrier
     136        // while (!((have_to_stop) | (cyclecount == 0))) {
     137        while (!((have_to_stop) || (number_of_cycles == 0))) {
     138#pragma omp master
     139            {
     140                trace_all(false);
     141            }
     142            internal_sc_cycle2();
     143#pragma omp master
     144            {
     145                trace_all(true);
     146            }
     147            // cyclecount = (number_of_cycles < 0) ? number_of_cycles : cyclecount - 1;
     148            number_of_cycles = (number_of_cycles < 0) ? number_of_cycles : number_of_cycles - 1;
     149        }
     150#pragma omp barrier
     151#if 0
     152#ifdef _OPENMP
     153#pragma omp critical
     154        {
     155            std::cerr << "Thread " << omp_get_thread_num() << " busy_wait " <<
     156                busy_wait_f0 << " " << busy_wait_up << " " <<
     157                busy_wait_f1 << " " << busy_wait_ml << std::endl;
     158        }
     159#pragma omp critical
     160        {
     161            std::cerr << "Thread " << omp_get_thread_num() << " last_wait " <<
     162                last_wait_f0 << " " << last_wait_up << " " <<
     163                last_wait_f1 << " " << last_wait_ml << std::endl;
     164        }
     165#pragma omp critical
     166        {
     167            std::cerr << "Thread " << omp_get_thread_num() << " nfuncs "
     168                << nb_func[0] << " " << nb_func[1] << " total_assig " <<
     169                total_assig << std::endl;
     170        }
     171#endif
     172#endif
    100173    }
    101174}
     
    117190
    118191    if (is_posted_write()) {
    119         // update posted value to external signals
     192        // update posted value to external signals             
     193#pragma omp parallel
    120194        update();
    121195        func_combinationals();
     
    126200    // don't need to do func_combinationals since 'unstable' flag is now false
    127201    if (is_posted_write()) {
     202#pragma omp parallel
    128203        update();
    129204        func_combinationals();
Note: See TracChangeset for help on using the changeset viewer.