Changeset 62
- Timestamp:
- Feb 16, 2017, 3:46:11 PM (8 years ago)
- Location:
- sources
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
sources/configure.ac
r50 r62 38 38 39 39 MY_ARG_ENABLE(debug, [Enable debugging], [no]) 40 MY_ARG_ENABLE(use_omp, [Compile with OpenMP activated], [no]) 40 41 41 42 MY_ARG_ENABLE(default_runtime_compilation, [Compile scheduling code], [no]) 42 43 43 44 # Also set -DNDEBUG when not debugging, this disables assert()s 44 AS_IF([test "x$do_debug" = "xyes"], [CXXFLAGS="-g" 45 AS_IF([test "x$do_debug" = "xyes"], [CXXFLAGS="-g"], 45 46 [test "x$do_debug" != "xyes"], [CXXFLAGS="-O2 -DNDEBUG"]) 47 48 AS_IF([test "x$do_use_omp" = "xyes"], [CXXFLAGS+=" -DUSE_OPENMP"], 49 [test "x$do_use_omp" != "xyes"], [CXXFLAGS+=""]) 46 50 47 51 case $target_os in … … 90 94 91 95 # OpenMP 92 AC_OPENMP([C]) 93 AC_CHECK_LIB(dl, dlopen, , ) 94 AC_CHECK_LIB(gomp, omp_get_thread_num, , ) 96 AS_IF([test "x$do_use_omp" = "xyes"], 97 [AC_OPENMP([C]) 98 AC_CHECK_LIB(dl, dlopen, , ) 99 AC_CHECK_LIB(gomp, omp_get_thread_num, , )] 100 ) 95 101 96 102 AM_CONDITIONAL(BUILD_DOCS, -
sources/src/casc.h
r60 r62 21 21 22 22 #include <cstdio> 23 //#include <stdint.h>24 23 25 24 EXTERN char unstable; 26 EXTERN int32 * pending_write_vector_nb; 25 EXTERN int32_t * pending_write_vector_nb; 26 #ifdef USE_OPENMP 27 27 #pragma omp threadprivate (pending_write_vector_nb) 28 #endif 28 29 29 30 namespace sc_core { -
sources/src/dump_used_options.cc
r52 r62 89 89 "INIT_SIGNALS_TO_ZERO, " 90 90 #endif 91 #ifdef _OPENMP92 " _OPENMP, "91 #ifdef USE_OPENMP 92 "USE_OPENMP, " 93 93 #endif 94 94 "..."; -
sources/src/gen_code.cc
r61 r62 241 241 242 242 243 char * gen_scheduling_code_for_dynamic_link(method_process_list_t & 244 transition_func_list, 245 method_process_list_t & 246 moore_func_list, 247 strong_component_list_t * 248 strongcomponents) { 243 char * gen_scheduling_code_for_dynamic_link(method_process_list_t & transition_func_list, 244 method_process_list_t & moore_func_list, 245 strong_component_list_t * strongcomponents) { 249 246 if (dump_stage) { 250 247 cerr << "Generating C code for scheduling...\n"; … … 305 302 306 303 307 char * gen_scheduling_code_for_dynamic_link(method_process_list_t & 308 transition_func_list, 309 method_process_list_t & 310 moore_func_list, 311 ProcessDependencyList & 312 mealy_func_list) { 304 char * gen_scheduling_code_for_dynamic_link(method_process_list_t & transition_func_list, 305 method_process_list_t & moore_func_list, 306 ProcessDependencyList & mealy_func_list) { 313 307 if (dump_stage) { 314 308 cerr << "Generating C code for scheduling...\n"; … … 509 503 510 504 511 void gen_scheduling_code_for_static_func(method_process_list_t & 512 transition_func_list, 513 method_process_list_t & 514 moore_func_list, 515 ProcessDependencyList & 516 mealy_func_list) { 505 void gen_scheduling_code_for_static_func(method_process_list_t & transition_func_list, 506 method_process_list_t & moore_func_list, 507 ProcessDependencyList & mealy_func_list) { 517 508 if (dump_stage) { 518 509 cerr << "Generating scheduling...\n"; … … 546 537 int n = fc.func_number; 547 538 int i; 548 #pragma omp parallel for549 539 for (i = 0; i < n; ++i) { 550 540 #if 0 … … 578 568 unsigned int nb_func[2]; 579 569 static method_process_t **func_list[2]; 580 #pragma omp threadprivate (nb_func, func_list)581 570 static strong_component_list_t quasistatic_list; 582 571 583 572 unsigned long long busy_wait_f0, busy_wait_f1, busy_wait_up, busy_wait_ml; 584 573 unsigned long long last_wait_f0, last_wait_f1, last_wait_up, last_wait_ml; 574 #ifdef USE_OPENMP 575 #pragma omp threadprivate (nb_func, func_list) 585 576 #pragma omp threadprivate (busy_wait_f0, busy_wait_f1, busy_wait_up,busy_wait_ml) 586 577 #pragma omp threadprivate (last_wait_f0, last_wait_f1, last_wait_up,last_wait_ml) 578 #endif 587 579 588 580 static void Call(const method_process_t & m) { … … 621 613 unsigned int expected_globaltime = 0; 622 614 volatile unsigned int globaltime __attribute__ ((aligned (128))) = 0; 615 #ifdef USE_OPENMP 616 #pragma omp threadprivate (expected_globaltime) 623 617 #pragma omp shared (globaltime) 624 # pragma omp threadprivate (expected_globaltime)618 #endif 625 619 626 620 unsigned int num_omp_threads; … … 644 638 __asm volatile("lfence"); 645 639 } 646 647 640 #else 648 #pragma omp barrier 641 #ifdef USE_OPENMP 642 #pragma omp barrier 643 #endif 649 644 #endif 650 645 … … 664 659 } 665 660 #else 666 #pragma omp barrier 661 #ifdef USE_OPENMP 662 #pragma omp barrier 663 #endif 667 664 #endif 668 665 if (!quasistatic_list.empty()) { 666 #ifdef USE_OPENMP 669 667 #pragma omp master 668 #endif 670 669 { 671 670 quasistatic_mealy_generation(); … … 682 681 } 683 682 #else 684 #pragma omp barrier 685 #endif 686 } 687 688 } 689 690 691 void gen_scheduling_code_for_quasistatic_func(method_process_list_t & 692 transition_func_list, 693 method_process_list_t & 694 moore_func_list, 695 strong_component_list_t * 696 mealy_func_list) { 683 #ifdef USE_OPENMP 684 #pragma omp barrier 685 #endif 686 #endif 687 } 688 } 689 690 691 void gen_scheduling_code_for_quasistatic_func(method_process_list_t & transition_func_list, 692 method_process_list_t & moore_func_list, 693 strong_component_list_t * mealy_func_list) { 697 694 if (dump_stage) { 698 695 cerr << "Generating quasi static scheduling...\n"; -
sources/src/gen_code.h
r61 r62 106 106 extern unsigned long long last_wait_f0, last_wait_f1, last_wait_up, last_wait_ml; 107 107 extern unsigned int nb_func[2]; 108 extern unsigned int expected_globaltime; 109 extern volatile unsigned int globaltime; 110 #ifdef USE_OPENMP 108 111 #pragma omp threadprivate (busy_wait_f0, busy_wait_f1, busy_wait_up, busy_wait_ml, nb_func) 109 112 #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; 113 #pragma omp threadprivate (expected_globaltime) 112 114 #pragma omp shared (globaltime) 113 #pragma omp threadprivate (expected_globaltime) 114 115 #endif 115 116 extern unsigned int num_omp_threads; 116 117 117 118 119 #ifdef USE_OPENMP 118 120 #pragma omp parallel 121 #endif 119 122 { 120 //int cyclecount = number_of_cycles;123 int cyclecount = number_of_cycles; 121 124 busy_wait_f0 = busy_wait_f1 = busy_wait_up = busy_wait_ml = total_assig = 0; 122 125 last_wait_f0 = last_wait_f1 = last_wait_up = last_wait_ml = 0; 123 126 124 127 expected_globaltime = 0; 125 #pragma omp master 128 #ifdef USE_OPENMP 129 #pragma omp master 130 #endif 126 131 { 127 132 globaltime = 0; 128 #ifdef _OPENMP133 #ifdef USE_OPENMP 129 134 num_omp_threads = omp_get_num_threads(); 130 135 #else … … 133 138 } 134 139 140 #ifdef USE_OPENMP 135 141 #pragma omp barrier 136 // while (!((have_to_stop) | (cyclecount == 0))) { 137 while (!((have_to_stop) || (number_of_cycles == 0))) { 138 #pragma omp master 142 #endif 143 while (!(have_to_stop || cyclecount == 0)) { 144 //while (!(have_to_stop || number_of_cycles == 0)) { 145 #ifdef USE_OPENMP 146 #pragma omp master 147 #endif 139 148 { 140 149 trace_all(false); 141 150 } 142 151 internal_sc_cycle2(); 143 #pragma omp master 152 #ifdef USE_OPENMP 153 #pragma omp master 154 #endif 144 155 { 145 156 trace_all(true); 146 157 } 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 } 158 cyclecount = (number_of_cycles < 0) ? number_of_cycles : cyclecount - 1; 159 // number_of_cycles = (number_of_cycles < 0) ? number_of_cycles : number_of_cycles - 1; 160 } 161 #ifdef USE_OPENMP 150 162 #pragma omp barrier 163 #endif 151 164 #if 0 152 #ifdef _OPENMP165 #ifdef USE_OPENMP 153 166 #pragma omp critical 154 167 { … … 191 204 if (is_posted_write()) { 192 205 // update posted value to external signals 206 #ifdef USE_OPENMP 193 207 #pragma omp parallel 208 #endif 194 209 update(); 195 210 func_combinationals(); … … 200 215 // don't need to do func_combinationals since 'unstable' flag is now false 201 216 if (is_posted_write()) { 217 #ifdef USE_OPENMP 202 218 #pragma omp parallel 219 #endif 203 220 update(); 204 221 func_combinationals(); -
sources/src/global_functions.cc
r60 r62 248 248 assert(pending_write_vector_capacity != 0); 249 249 250 #ifdef _OPENMP251 #define LINE_SIZE 128L250 #ifdef USE_OPENMP 251 #define LINE_SIZE 128L 252 252 int malloc_size = (sizeof (pending_write_t) * (pending_write_vector_capacity + 1) + (LINE_SIZE - 1)) & ~(LINE_SIZE - 1); 253 253 assert((sizeof(pending_write_t) * (pending_write_vector_capacity + 1)) <= malloc_size && "bad allocation size"); 254 254 255 #pragma omp parallel255 #pragma omp parallel 256 256 { 257 257 posix_memalign((void **) &pending_write_vector, LINE_SIZE, malloc_size); … … 263 263 #else 264 264 pending_write_vector = (pending_write_vector_t) malloc(sizeof(pending_write_t) * pending_write_vector_capacity); 265 pending_write_vector_nb = (int32_t *) malloc(sizeof(int32_t)); 266 *pending_write_vector_nb = 0; 265 267 #endif 266 268 -
sources/src/sc_main.cc
r61 r62 90 90 bool use_port_dependency = false; 91 91 92 #ifdef _OPENMP92 #ifdef USE_OPENMP 93 93 bool use_openmp = true; 94 94 #else -
sources/src/sc_module.cc
r61 r62 131 131 module = &mod; 132 132 dont_initialize = false; 133 #ifdef _OPENMP133 #ifdef USE_OPENMP 134 134 omp_threadnum = omp_get_thread_num(); 135 135 #endif -
sources/src/sc_object.cc
r59 r62 106 106 const char * sc_gen_unique_name(const char * basename_) { 107 107 string s; 108 gen_name(basename_, s);108 gen_name(basename_, s); 109 109 const char * ret = strdup(s.c_str()); 110 110 sc_core::allocated_names.push_back(ret); -
sources/src/sc_port.cc
r60 r62 53 53 extern char unstable; 54 54 char unstable = 0; // not in sc_core namespace because dynamic link support C linkage only 55 int32 * pending_write_vector_nb = 0;55 int32_t * pending_write_vector_nb = 0; 56 56 unsigned long long int total_assig = 0; 57 #ifdef USE_OPENMP 57 58 #pragma omp threadprivate (pending_write_vector_nb, total_assig) 59 #endif 58 60 } 59 61 … … 65 67 const char * const sc_signal_base::kind_string = "sc_signal"; 66 68 67 unsigned int pending_write_vector_capacity = 512;69 unsigned int pending_write_vector_capacity; 68 70 pending_write_vector_t pending_write_vector = NULL; 71 #ifdef USE_OPENMP 69 72 #pragma omp threadprivate (pending_write_vector) 73 #endif 70 74 extern equi_list_t equi_list; 71 75 … … 215 219 void update() { 216 220 #if defined(DUMP_STAGE) 217 218 #endif 219 220 221 221 cerr << "Updating... "; 222 #endif 223 // stl vectors are too slow 224 // memcopy is not better 225 // signal table sorting doesn't give any better performance 222 226 #if defined(DUMP_STAGE) 223 224 225 #endif 226 227 227 cerr << "(" << *pending_write_vector_nb 228 << " internal pending writings) "; 229 #endif 230 unsigned int i; 231 for (i = 0; i < *pending_write_vector_nb; ++i) { 228 232 #define iter (sc_core::pending_write_vector[i]) 229 233 #ifdef CONFIG_DEBUG 230 231 232 233 234 if (iter.pointer == NULL) { 235 cerr << "Internal error : trying to apply a posted write from an unassigned signal/port\n"; 236 exit (8); 237 } 234 238 #endif 235 239 #ifdef DUMP_SIGNAL_STATS 236 237 238 239 240 #endif 241 240 if (*(iter.pointer) == iter.value) { 241 unnecessary++; 242 } 243 counter[iter.pointer]++; 244 #endif 245 *(iter.pointer) = iter.value; 242 246 #undef iter 243 247 } 244 248 #ifdef DUMP_SIGNAL_STATS 245 246 #endif 247 248 249 total_assig += *pending_write_vector_nb; 250 #endif 251 total_assig += *pending_write_vector_nb; 252 *pending_write_vector_nb = 0; 249 253 250 254 #if defined(DUMP_STAGE) 251 252 #endif 253 255 cerr << "done.\n"; 256 #endif 257 } 254 258 255 259 } // end of extern "C" -
sources/src/sc_port_ext.h
r60 r62 295 295 std::cerr << "write " << value_ << " on in/out port (writing into a signal) '" << name() << "'\n"; 296 296 #endif 297 T *p = (T*)get_pointer();298 if (*p != value_) {299 297 T * p = (T *) get_pointer(); 298 if (*p != value_) { 299 *p = value_; 300 300 #ifndef USE_PORT_DEPENDENCY 301 if (unstable == 0) 302 unstable = 1; 303 #endif 304 } 301 if (unstable == 0) { 302 unstable = 1; 303 } 304 #endif 305 } 305 306 } 306 307 -
sources/src/sc_signal.h
r60 r62 70 70 extern "C" int32_t * pending_write_vector_nb; 71 71 extern "C" unsigned long long int total_assig; 72 #ifdef USE_OPENMP 72 73 #pragma omp threadprivate(pending_write_vector_nb, total_assig) 74 #endif 73 75 extern unsigned int pending_write_vector_capacity; 74 75 76 extern pending_write_vector_t pending_write_vector; 77 #ifdef USE_OPENMP 76 78 #pragma omp threadprivate(pending_write_vector) 79 #endif 77 80 78 81 template < typename T > … … 282 285 #else 283 286 memset(&val, 0, sizeof(val)); 287 memset(&new_val, 0, sizeof(new_val)); 284 288 #endif 285 289 } -
sources/src/sc_time.cc
r60 r62 55 55 56 56 uint64 nb_cycles = 0; 57 #ifdef USE_OPENMP 57 58 #pragma omp threadprivate(nb_cycles) 59 #endif 58 60 59 61 const sc_time SC_ZERO_TIME(0, SC_NS); -
sources/src/sc_time.h
r60 r62 15 15 16 16 #include <string> 17 //#include <stdint.h>18 17 19 18 #include "sc_nbdefs.h" … … 43 42 44 43 extern uint64 nb_cycles; 44 #ifdef USE_OPENMP 45 45 #pragma omp threadprivate(nb_cycles) 46 #endif 46 47 47 48 inline double sc_simulation_time() { -
sources/src/sc_ver.cc
r52 r62 78 78 "\n" 79 79 " Last change : " __DATE__ "\n" 80 #ifdef USE_OPENMP 81 " Compiled with OpenMP enabled\n" 82 #endif 80 83 "\n"; 81 84 -
sources/src/schedulers.cc
r61 r62 64 64 method_process_list_t * transition_func_list; 65 65 method_process_list_t * moore_func_list; 66 #ifdef USE_OPENMP 66 67 #pragma omp threadprivate(transition_func_list, moore_func_list) 68 #endif 67 69 method_process_list_t combinational_func_list; 68 70 /* ***************************** */ … … 120 122 void sort_functions() { 121 123 method_process_list_t::const_iterator m; 124 #ifdef USE_OPENMP 122 125 #pragma omp parallel 123 126 #pragma omp critical 127 #endif 124 128 { 125 129 transition_func_list = new method_process_list_t; 126 130 moore_func_list = new method_process_list_t; 127 131 for (m = method_process_list.begin(); m != method_process_list.end(); ++m) { 128 #ifdef _OPENMP132 #ifdef USE_OPENMP 129 133 if ((*m)->omp_threadnum == omp_get_thread_num()) 130 134 #endif … … 189 193 exit (24092004); 190 194 } 195 delete s; 191 196 return sig_graph; 192 197 } … … 229 234 230 235 sort_functions(); 236 #ifdef USE_OPENMP 231 237 #pragma omp parallel 232 238 #pragma omp critical 239 #endif 233 240 { 234 241 if (dump_funclist_info) { 235 #ifdef _OPENMP242 #ifdef USE_OPENMP 236 243 cerr << "Thread " << omp_get_thread_num() << "\n"; 237 244 #endif 238 245 cerr << " Transition functions : " << *transition_func_list << "\n"; 239 246 cerr << " Moore generation functions : " << *moore_func_list << "\n"; 247 #ifdef USE_OPENMP 240 248 #pragma omp master 249 #endif 241 250 { 242 251 if (!combinational_func_list.empty()) { … … 247 256 248 257 /* Schedule */ 249 switch (scheduling_method) { 250 case BUCHMANN_SCHEDULING : 251 { 252 // Generate the scheduled code, compile and link. 253 // Buchmann's thesis explains this scheduling method. 254 // Uses port dependancies like Dr. Mouchard. 255 ProcessDependencyList * process_list = BuchmannScheduling(); 256 if (dynamic_link_of_scheduling_code) { 257 base_name = gen_scheduling_code_for_dynamic_link(*transition_func_list, *moore_func_list, *process_list); 258 } 259 else { 260 gen_scheduling_code_for_static_func(*transition_func_list, *moore_func_list, *process_list); 261 } 262 break; 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; 297 #ifdef USE_OPENMP 298 #pragma omp master 299 #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 //} 317 #ifdef USE_OPENMP 318 #pragma omp master 319 #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); 263 329 } 264 265 case MOUCHARD_SCHEDULING :266 {267 // Generate the scheduled code, compile and link.268 // Mouchard's thesis explains this scheduling method.269 // Uses port dependancies like Dr. Mouchard.270 // CAUTION : unlike FastSysC, this scheduling is totally static271 // and does not use an event-driven scheduler.272 ProcessDependencyList * process_list = MouchardScheduling();273 if (dynamic_link_of_scheduling_code) {274 base_name = gen_scheduling_code_for_dynamic_link(*transition_func_list, *moore_func_list, *process_list);275 }276 else {277 gen_scheduling_code_for_static_func (*transition_func_list, *moore_func_list, *process_list);278 }279 break;280 }281 282 case CASS_SCHEDULING :283 {284 // Generate the scheduled code, compile and link285 // Hommais's thesis explains this scheduling method (like CASS strategy)286 // Doesn't use port dependancies287 strong_component_list_t * strong_list = NULL;288 #pragma omp master289 {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 }296 if (dynamic_link_of_scheduling_code) {297 base_name = gen_scheduling_code_for_dynamic_link(*transition_func_list, *moore_func_list, strong_list);298 }299 else {300 gen_scheduling_code_for_quasistatic_func (*transition_func_list, *moore_func_list, strong_list);301 }302 break;303 }304 default :305 cerr << "Error : Unable to schedule SystemC process."306 "Please select a scheduling method.\n";307 exit (35);308 }309 330 } 310 331 return base_name;
Note: See TracChangeset
for help on using the changeset viewer.