Ignore:
Timestamp:
Oct 23, 2019, 12:53:07 PM (5 years ago)
Author:
bouyer
Message:

Various performance improvements for the parallel systemcass: cache-aligned
data structures, write only when needed, disable some unneeded barriers.

Fix bug in the non-openmp case: a pointer was not initialized

various style updates

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sources/src/schedulers.cc

    r63 r65  
    6161namespace sc_core {
    6262
     63//
    6364// sort_functions splits and sorts instances_list into three functions lists :
    64 method_process_list_t * transition_func_list;
    65 method_process_list_t * moore_func_list;
    66 #ifdef _OPENMP
    67 #pragma omp threadprivate(transition_func_list, moore_func_list)
     65method_process_list_t *transition_func_list;
     66method_process_list_t *moore_func_list;
     67#ifdef _OPENMP
     68#pragma omp threadprivate (transition_func_list, moore_func_list)
    6869#endif
    6970method_process_list_t combinational_func_list;
     71
    7072/* ***************************** */
    7173/* Dumping functions (for debug) */
     
    8486/*  functions   */
    8587/****************/
    86 
    87 
    8888
    8989static bool sort_by_module_ptr (const method_process_t * a1, const method_process_t * a2) {
     
    133133            if ((*m)->omp_threadnum == omp_get_thread_num())
    134134#endif
    135             {
    136                 if ((*m)->is_transition()) {
    137                     transition_func_list->push_back(*m);
    138                 }
    139                 else if ((*m)->is_genmoore()) {
    140                     moore_func_list->push_back(*m);
    141                 }
    142             }
    143         }
    144         // Sort transition functions by method pointer (1) and by module pointer (2)
    145         std::sort(transition_func_list->begin(), transition_func_list->end(), sort_by_fct_ptr);
    146         // Sort generation functions by method pointer (1) and by module pointer (2)
    147         std::sort(moore_func_list->begin(), moore_func_list->end(), sort_by_fct_ptr);
    148     }
    149 
    150     for (m = method_process_list.begin(); m != method_process_list.end(); ++m) {
    151         if ((*m)->is_combinational()) {
    152             combinational_func_list.push_back(*m);
    153         }
    154     }
     135            {
     136                if ((*m)->is_transition ())
     137                    transition_func_list->push_back(*m);
     138                else if ((*m)->is_genmoore ())
     139                    moore_func_list->push_back(*m);
     140            }
     141        }
     142#if 1
     143        // Sort transition functions by method pointer (1) and by module pointer (2)
     144        std::sort (transition_func_list->begin(), transition_func_list->end(), sort_by_fct_ptr);
     145        // Sort generation functions by method pointer (1) and by module pointer (2)
     146        std::sort (moore_func_list->begin(), moore_func_list->end(), sort_by_fct_ptr);
     147#endif
     148#if 0
     149        std::sort (transition_func_list->begin(), transition_func_list->end(), only_sort_by_module_ptr);
     150        std::sort (moore_func_list->begin(), moore_func_list->end(), only_sort_by_module_ptr);
     151#endif
     152  }
     153
     154  for (m = method_process_list.begin(); m != method_process_list.end(); ++m) {
     155    if ((*m)->is_combinational()) combinational_func_list.push_back(*m);
     156  }
    155157}
    156158
     
    225227}
    226228
    227 
    228 string get_scheduling(int scheduling_method) {
    229     string base_name;
    230     /* marque les fonctions comme fonction de mealy ou non */
    231     if (dump_funclist_info) {
    232         cerr << "method process list : " << method_process_list << "\n";
    233     }
    234 
    235     sort_functions();
     229string
     230get_scheduling (int scheduling_method)
     231{
     232  string base_name;
     233  /* marque les fonctions comme fonction de mealy ou non */
     234  if (dump_funclist_info)
     235    cerr << "method process list : " << method_process_list << "\n";
     236  sort_functions ();
    236237#ifdef _OPENMP
    237238#pragma omp parallel
     
    243244            cerr << "Thread " << omp_get_thread_num() << "\n";
    244245#endif
    245             cerr << "  Transition functions : " << *transition_func_list << "\n";
    246             cerr << "  Moore generation functions : " << *moore_func_list << "\n";
     246    cerr << "  Transition functions : " << *transition_func_list << "\n";
     247    cerr << "  Moore generation functions : " << *moore_func_list << "\n";
    247248#ifdef _OPENMP
    248249#pragma omp master
    249250#endif
    250             {
    251                 if (!combinational_func_list.empty()) {
    252                     cerr << "Mealy generation functions : " << combinational_func_list << "\n";
    253                 }
    254             }
    255         }
    256 
    257     /* Schedule */
    258         switch (scheduling_method) {
    259             case BUCHMANN_SCHEDULING :
    260             {
    261                 // Generate the scheduled code, compile and link.
    262                 // Buchmann's thesis explains this scheduling method.
    263                 // Uses port dependancies like Dr. Mouchard.
    264                 ProcessDependencyList * process_list = BuchmannScheduling();
    265                 if (dynamic_link_of_scheduling_code) {
    266                     base_name = gen_scheduling_code_for_dynamic_link(*transition_func_list, *moore_func_list, *process_list);
    267                 }
    268                 else {
    269                     gen_scheduling_code_for_static_func(*transition_func_list, *moore_func_list, *process_list);
    270                 }
    271                 break;
    272             }
    273 
    274             case MOUCHARD_SCHEDULING :
    275             {
    276                 // Generate the scheduled code, compile and link.
    277                 // Mouchard's thesis explains this scheduling method.
    278                 // Uses port dependancies like Dr. Mouchard.
    279                 // CAUTION : unlike FastSysC, this scheduling is totally static
    280                 // and does not use an event-driven scheduler.
    281                 ProcessDependencyList * process_list = MouchardScheduling();
    282                 if (dynamic_link_of_scheduling_code) {
    283                     base_name = gen_scheduling_code_for_dynamic_link(*transition_func_list, *moore_func_list, *process_list);
    284                 }
    285                 else {
    286                     gen_scheduling_code_for_static_func (*transition_func_list, *moore_func_list, *process_list);
    287                 }
    288                 break;
    289             }
    290 
    291             case CASS_SCHEDULING :
    292             {
    293                 // Generate the scheduled code, compile and link
    294                 // Hommais's thesis explains this scheduling method (like CASS strategy)
    295                 // Doesn't use port dependancies
    296                 strong_component_list_t * strong_list = NULL;
     251    {
     252      if (!combinational_func_list.empty()) {
     253            cerr << "Mealy generation functions : " <<
     254                combinational_func_list << "\n";
     255      }
     256    }
     257  }
     258
     259  /* Schedule */
     260  switch (scheduling_method) {
     261  case BUCHMANN_SCHEDULING : {
     262    // Generate the scheduled code, compile and link.
     263    // Buchmann's thesis explains this scheduling method.
     264    // Uses port dependancies like Dr. Mouchard.
     265    ProcessDependencyList* process_list = BuchmannScheduling ();
     266  if (dynamic_link_of_scheduling_code)
     267    base_name = gen_scheduling_code_for_dynamic_link (*transition_func_list, *moore_func_list,*process_list);
     268  else
     269    gen_scheduling_code_for_static_func (*transition_func_list, *moore_func_list, *process_list);
     270    break;
     271  }
     272  case MOUCHARD_SCHEDULING : {
     273    // Generate the scheduled code, compile and link.
     274    // Mouchard's thesis explains this scheduling method.
     275    // Uses port dependancies like Dr. Mouchard.
     276    // CAUTION : unlike FastSysC, this scheduling is totally static
     277    // and does not use an event-driven scheduler.
     278    ProcessDependencyList* process_list = MouchardScheduling ();
     279  if (dynamic_link_of_scheduling_code)
     280    base_name = gen_scheduling_code_for_dynamic_link(*transition_func_list, *moore_func_list,*process_list);
     281  else
     282    gen_scheduling_code_for_static_func (*transition_func_list, *moore_func_list, *process_list);
     283    break;
     284  }
     285  case CASS_SCHEDULING : {
     286    // Generate the scheduled code, compile and link
     287    // Hommais's thesis explains this scheduling method (like CASS strategy)
     288    // Doesn't use port dependancies
     289    strong_component_list_t *strong_list = NULL;
    297290#ifdef _OPENMP
    298291#pragma omp master
    299292#endif
    300                 {
    301                     Graph * g = makegraph (&combinational_func_list);
    302                     if (dump_all_graph && g) {
    303                         graph2dot("module_graph", *g);
    304                     }
    305                     strong_list = strong_component(g);
    306                 }
    307                 if (dynamic_link_of_scheduling_code) {
    308                     base_name = gen_scheduling_code_for_dynamic_link(*transition_func_list, *moore_func_list, strong_list);
    309                 }
    310                 else {
    311                     gen_scheduling_code_for_quasistatic_func (*transition_func_list, *moore_func_list, strong_list);
    312                 }
    313                 // free the void_lists in strong_list
    314                 //for ( strong_component_list_t::iterator i = strong_list->begin(); i < strong_list->end(); i++) {
    315                 //    delete *i;
    316                 //}
     293    {
     294    Graph *g = makegraph (&combinational_func_list);
     295    if (dump_all_graph && g)
     296      graph2dot("module_graph", *g);
     297    strong_list = strong_component (g);
     298    }
     299  if (dynamic_link_of_scheduling_code)
     300    base_name = gen_scheduling_code_for_dynamic_link(*transition_func_list, *moore_func_list,strong_list);
     301  else
     302    gen_scheduling_code_for_quasistatic_func (*transition_func_list, *moore_func_list, strong_list);
    317303#ifdef _OPENMP
    318304#pragma omp master
    319305#endif
    320                 {
    321                     delete strong_list;
    322                 }
    323                 break;
    324             }
    325             default :
    326                 cerr << "Error : Unable to schedule SystemC process."
    327                     "Please select a scheduling method.\n";
    328                 exit (35);
    329         }
    330     }
    331     return base_name;
     306  {
     307    delete strong_list;
     308  }
     309  break;
     310  }
     311  default :
     312    cerr << "Error : Unable to schedule SystemC process."
     313            "Please select a scheduling method.\n";
     314    exit (35);
     315  }
     316  }
     317  return base_name;
    332318}
    333319
Note: See TracChangeset for help on using the changeset viewer.