Changeset 65 for sources/src/gen_code.h
- Timestamp:
- Oct 23, 2019, 12:53:07 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sources/src/gen_code.h
r63 r65 42 42 /* generate a scheduling code */ 43 43 extern void gen_scheduling_code_for_quasistatic_func( 44 method_process_list_t &transition_list, 45 method_process_list_t &moore_list, 46 strong_component_list_t *mealy_list); 47 44 method_process_list_t &transition_list, 45 method_process_list_t &moore_list, 46 strong_component_list_t *mealy_list); 48 47 extern void gen_scheduling_code_for_static_func( 49 method_process_list_t &transition_list, 50 method_process_list_t &moore_list, 51 ProcessDependencyList &mealy_list); 48 method_process_list_t &transition_list, 49 method_process_list_t &moore_list, 50 ProcessDependencyList &mealy_list); 51 extern char *gen_scheduling_code_for_dynamic_link( 52 method_process_list_t &transition_list, 53 method_process_list_t &moore_list, 54 ProcessDependencyList &mealy_list); 55 extern char *gen_scheduling_code_for_dynamic_link( 56 method_process_list_t &transition_list, 57 method_process_list_t &moore_list, 58 strong_component_list_t *strongcomponents); 52 59 53 60 extern char * gen_scheduling_code_for_dynamic_link( … … 87 94 #pragma omp master 88 95 { 89 std::cerr << "begin of cycle #" << sc_simulation_time() << "\n";90 } 91 #endif 92 93 func_simulate_1_cycle ();96 std::cerr << "begin of cycle #" << sc_simulation_time () << "\n"; 97 } 98 #endif 99 100 func_simulate_1_cycle (); 94 101 95 102 ++nb_cycles; … … 97 104 #pragma omp master 98 105 { 99 106 std::cerr << "end of cycle\n"; 100 107 } 101 108 #endif 102 109 } 103 110 104 inline void internal_sc_cycle1(int number_of_cycles) { 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 extern unsigned int expected_globaltime; 109 extern volatile unsigned int globaltime; 111 inline void 112 internal_sc_cycle1 (int number_of_cycles) 113 { 114 115 extern unsigned long long busy_wait_f0, busy_wait_f1, busy_wait_up, busy_wait_ml; 116 extern unsigned long long last_wait_f0, last_wait_f1, last_wait_up, last_wait_ml; 117 extern unsigned int nb_func[2]; 110 118 #ifdef _OPENMP 111 119 #pragma omp threadprivate (busy_wait_f0, busy_wait_f1, busy_wait_up, busy_wait_ml, nb_func) 112 120 #pragma omp threadprivate (last_wait_f0, last_wait_f1, last_wait_up, last_wait_ml) 121 #endif 122 extern unsigned int expected_globaltime; 123 extern volatile unsigned int globaltime; 124 #ifdef _OPENMP 113 125 #pragma omp threadprivate (expected_globaltime) 114 126 #pragma omp shared (globaltime) 115 127 #endif 116 extern unsigned int num_omp_threads; 128 129 extern unsigned int num_omp_threads; 117 130 118 131 … … 120 133 #pragma omp parallel 121 134 #endif 122 123 124 125 126 127 128 #ifdef _OPENMP 129 #pragma omp master 130 #endif 131 132 133 #ifdef _OPENMP 134 135 { 136 int cyclecount = number_of_cycles; 137 busy_wait_f0 = busy_wait_f1 = busy_wait_up = busy_wait_ml = total_assig = 0; 138 last_wait_f0 = last_wait_f1 = last_wait_up = last_wait_ml = 0; 139 140 expected_globaltime = 0; 141 #ifdef _OPENMP 142 #pragma omp master 143 #endif 144 { 145 globaltime = 0; 146 #ifdef _OPENMP 147 num_omp_threads = omp_get_num_threads(); 135 148 #else 136 137 #endif 138 149 num_omp_threads = 1; 150 #endif 151 } 139 152 140 153 #ifdef _OPENMP 141 154 #pragma omp barrier 142 155 #endif 143 while (!(have_to_stop || cyclecount == 0)) { 144 //while (!(have_to_stop || number_of_cycles == 0)) { 145 #ifdef _OPENMP 146 #pragma omp master 147 #endif 148 { 149 trace_all(false); 150 } 151 internal_sc_cycle2(); 152 #ifdef _OPENMP 153 #pragma omp master 154 #endif 155 { 156 trace_all(true); 157 } 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 } 156 while (!((have_to_stop) | (cyclecount == 0))) { 157 #ifdef _OPENMP 158 #pragma omp master 159 #endif 160 { 161 trace_all (false); 162 } 163 internal_sc_cycle2 (); 164 #ifdef _OPENMP 165 #pragma omp master 166 #endif 167 { 168 trace_all (true); 169 } 170 cyclecount = (number_of_cycles<0)?number_of_cycles:cyclecount-1; 171 } 161 172 #ifdef _OPENMP 162 173 #pragma omp barrier 163 #endif164 #if 0165 #ifdef _OPENMP166 174 #pragma omp critical 167 168 169 170 171 175 { 176 std::cerr << "Thread " << omp_get_thread_num() << " busy_wait " << 177 busy_wait_f0 << " " << busy_wait_up << " " << 178 busy_wait_f1 << " " << busy_wait_ml << std::endl; 179 } 172 180 #pragma omp critical 173 174 175 176 177 181 { 182 std::cerr << "Thread " << omp_get_thread_num() << " last_wait " << 183 last_wait_f0 << " " << last_wait_up << " " << 184 last_wait_f1 << " " << last_wait_ml << std::endl; 185 } 178 186 #pragma omp critical 179 { 180 std::cerr << "Thread " << omp_get_thread_num() << " nfuncs " 181 << nb_func[0] << " " << nb_func[1] << " total_assig " << 182 total_assig << std::endl; 183 } 184 #endif 185 #endif 186 } 187 { 188 std::cerr << "Thread " << omp_get_thread_num() << " nfuncs " 189 << nb_func[0] << " " << nb_func[1] << " total_assig " << 190 total_assig << std::endl; 191 } 192 #endif // _OPENMP 193 } 187 194 } 188 195 … … 206 213 #ifdef _OPENMP 207 214 #pragma omp parallel 208 #endif 209 update();210 func_combinationals();211 212 213 internal_sc_cycle1((int)duration);214 215 216 if (is_posted_write()) {215 #endif // _OPENMP 216 update (); 217 func_combinationals (); 218 } 219 220 internal_sc_cycle1 ((int)duration); 221 222 // don't need to do func_combinationals since 'unstable' flag is now false 223 if (is_posted_write ()) { 217 224 #ifdef _OPENMP 218 225 #pragma omp parallel 219 #endif 220 update();221 func_combinationals();222 226 #endif // _OPENMP 227 update (); 228 func_combinationals (); 229 } 223 230 } 224 231
Note: See TracChangeset
for help on using the changeset viewer.