Ignore:
Timestamp:
Feb 14, 2017, 11:30:19 AM (8 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/schedulers.cc

    r59 r60  
    4949#include "graph_signals.h" // makegraph
    5050
     51#ifdef _OPENMP
     52#include <omp.h>
     53#endif
     54
    5155#ifdef HAVE_CONFIG_H
    5256#include "config.h"
     
    5761namespace sc_core {
    5862
     63// sort_functions splits and sorts instances_list into three functions lists :
     64method_process_list_t * transition_func_list;
     65method_process_list_t * moore_func_list;
     66#pragma omp threadprivate(transition_func_list, moore_func_list)
     67method_process_list_t combinational_func_list;
    5968/* ***************************** */
    6069/* Dumping functions (for debug) */
     
    7483/****************/
    7584
    76 // sort_functions splits and sorts instances_list into three functions lists :
    77 method_process_list_t transition_func_list;
    78 method_process_list_t moore_func_list;
    79 method_process_list_t combinational_func_list;
    8085
    8186
     
    115120void sort_functions() {
    116121    method_process_list_t::const_iterator m;
     122#pragma omp parallel
     123#pragma omp critical
     124    {
     125        transition_func_list = new method_process_list_t;
     126        moore_func_list = new method_process_list_t;
     127        for (m = method_process_list.begin(); m != method_process_list.end(); ++m) {
     128#ifdef _OPENMP
     129            if ((*m)->omp_threadnum == omp_get_thread_num())
     130#endif
     131            {
     132                if ((*m)->is_transition()) {
     133                    transition_func_list->push_back(*m);
     134                }
     135                else if ((*m)->is_genmoore()) {
     136                    moore_func_list->push_back(*m);
     137                }
     138            }
     139        }
     140        // Sort transition functions by method pointer (1) and by module pointer (2)
     141        std::sort(transition_func_list->begin(), transition_func_list->end(), sort_by_fct_ptr);
     142        // Sort generation functions by method pointer (1) and by module pointer (2)
     143        std::sort(moore_func_list->begin(), moore_func_list->end(), sort_by_fct_ptr);
     144    }
     145
    117146    for (m = method_process_list.begin(); m != method_process_list.end(); ++m) {
    118147        if ((*m)->is_combinational()) {
    119148            combinational_func_list.push_back(*m);
    120149        }
    121         else if ((*m)->is_transition ()) {
    122             transition_func_list.push_back(*m);
    123         }
    124         else if ((*m)->is_genmoore ()) {
    125             moore_func_list.push_back(*m);
    126         }
    127     }
    128     // Sort transition functions by method pointer (1) and by module pointer (2)
    129     std::sort (transition_func_list.begin(), transition_func_list.end(), sort_by_fct_ptr);
    130     // Sort generation functions by method pointer (1) and by module pointer (2)
    131     std::sort (moore_func_list.begin(), moore_func_list.end(), sort_by_fct_ptr);
     150    }
    132151}
    133152
     
    203222
    204223string get_scheduling(int scheduling_method) {
     224    string base_name;
    205225    /* marque les fonctions comme fonction de mealy ou non */
    206226    if (dump_funclist_info) {
     
    209229
    210230    sort_functions();
    211     if (dump_funclist_info) {
    212         cerr << "Transition functions : " << transition_func_list << "\n";
    213         cerr << "Moore generation functions : " << moore_func_list << "\n";
    214         cerr << "Mealy generation functions : " << combinational_func_list << "\n";
    215     }
     231#pragma omp parallel
     232#pragma omp critical
     233    {
     234        if (dump_funclist_info) {
     235#ifdef _OPENMP
     236            cerr << "Thread " << omp_get_thread_num() << "\n";
     237#endif
     238            cerr << "  Transition functions : " << *transition_func_list << "\n";
     239            cerr << "  Moore generation functions : " << *moore_func_list << "\n";
     240#pragma omp master
     241            {
     242                if (!combinational_func_list.empty()) {
     243                    cerr << "Mealy generation functions : " << combinational_func_list << "\n";
     244                }
     245            }
     246        }
    216247
    217248    /* Schedule */
    218     string base_name;
    219249    switch (scheduling_method) {
    220250        case BUCHMANN_SCHEDULING :
     
    225255            ProcessDependencyList * process_list = BuchmannScheduling();
    226256            if (dynamic_link_of_scheduling_code) {
    227                 base_name = gen_scheduling_code_for_dynamic_link(transition_func_list, moore_func_list, *process_list);
     257                base_name = gen_scheduling_code_for_dynamic_link(*transition_func_list, *moore_func_list, *process_list);
    228258            }
    229259            else {
    230                 gen_scheduling_code_for_static_func(transition_func_list, moore_func_list, *process_list);
     260                gen_scheduling_code_for_static_func(*transition_func_list, *moore_func_list, *process_list);
    231261            }
    232262            break;
     
    242272            ProcessDependencyList * process_list = MouchardScheduling();
    243273            if (dynamic_link_of_scheduling_code) {
    244                 base_name = gen_scheduling_code_for_dynamic_link(transition_func_list, moore_func_list, *process_list);
     274                base_name = gen_scheduling_code_for_dynamic_link(*transition_func_list, *moore_func_list, *process_list);
    245275            }
    246276            else {
    247                 gen_scheduling_code_for_static_func (transition_func_list, moore_func_list, *process_list);
     277                gen_scheduling_code_for_static_func (*transition_func_list, *moore_func_list, *process_list);
    248278            }
    249279            break;
     
    255285            // Hommais's thesis explains this scheduling method (like CASS strategy)
    256286            // Doesn't use port dependancies
    257             Graph * g = makegraph (&combinational_func_list);
    258             if (dump_all_graph && g) {
    259                 graph2dot("module_graph", *g);
    260             }
    261             strong_component_list_t * strong_list = strong_component(g);
     287            strong_component_list_t * strong_list = NULL;
     288#pragma omp master
     289            {
     290                Graph * g = makegraph (&combinational_func_list);
     291                if (dump_all_graph && g) {
     292                    graph2dot("module_graph", *g);
     293                }
     294                strong_list = strong_component(g);
     295            }
    262296            if (dynamic_link_of_scheduling_code) {
    263                 base_name = gen_scheduling_code_for_dynamic_link(transition_func_list, moore_func_list, *strong_list);
     297                base_name = gen_scheduling_code_for_dynamic_link(*transition_func_list, *moore_func_list, strong_list);
    264298            }
    265299            else {
    266                 gen_scheduling_code_for_quasistatic_func (transition_func_list, moore_func_list, *strong_list);
     300                gen_scheduling_code_for_quasistatic_func (*transition_func_list, *moore_func_list, strong_list);
    267301            }
    268302            break;
     
    272306                    "Please select a scheduling method.\n";
    273307            exit (35);
     308    }
    274309    }
    275310    return base_name;
Note: See TracChangeset for help on using the changeset viewer.