- Timestamp:
- May 9, 2017, 1:56:38 PM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 6182039
- Parents:
- c10ee66 (diff), f408e1a (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- src
- Files:
-
- 2 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Common/utility.h
rc10ee66 r298581c 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Wed Dec 14 21:25:25 201613 // Update Count : 3 111 // Last Modified By : Andrew Beach 12 // Last Modified On : Fri May 5 11:03:00 2017 13 // Update Count : 32 14 14 // 15 15 … … 322 322 std::string filename; 323 323 324 CodeLocation() 324 /// Create a new unset CodeLocation. 325 CodeLocation() 325 326 : linenumber( -1 ) 326 327 , filename("") 327 328 {} 328 329 330 /// Create a new CodeLocation with the given values. 329 331 CodeLocation( const char* filename, int lineno ) 330 332 : linenumber( lineno ) 331 333 , filename(filename ? filename : "") 332 334 {} 335 336 bool isSet () const { 337 return -1 != linenumber; 338 } 339 340 bool isUnset () const { 341 return !isSet(); 342 } 343 344 void unset () { 345 linenumber = -1; 346 filename = ""; 347 } 348 349 // Use field access for set. 333 350 }; 334 351 335 352 inline std::string to_string( const CodeLocation& location ) { 336 return location. linenumber >= 0? location.filename + ":" + std::to_string(location.linenumber) + " " : "";353 return location.isSet() ? location.filename + ":" + std::to_string(location.linenumber) + " " : ""; 337 354 } 338 355 #endif // _UTILITY_H -
src/benchmark/csv-data.c
rc10ee66 r298581c 100 100 } 101 101 102 //----------------------------------------------------------------------------- 103 // single internal sched entry 104 mon_t mon1; 105 106 condition cond1a; 107 condition cond1b; 108 109 thread thrd1a { long long int * out; }; 110 thread thrd1b {}; 111 112 void ?{}( thrd1a * this, long long int * out ) { 113 this->out = out; 114 } 115 116 void side1A( mon_t * mutex a, long long int * out ) { 117 long long int StartTime, EndTime; 118 119 StartTime = Time(); 120 for( int i = 0;; i++ ) { 121 signal(&cond1a); 122 if( i > N ) break; 123 wait(&cond1b); 124 } 125 EndTime = Time(); 126 127 *out = ( EndTime - StartTime ) / N; 128 } 129 130 void side1B( mon_t * mutex a ) { 131 for( int i = 0;; i++ ) { 132 signal(&cond1b); 133 if( i > N ) break; 134 wait(&cond1a); 135 } 136 } 137 138 void main( thrd1a * this ) { side1A( &mon1, this->out ); } 139 void main( thrd1b * this ) { side1B( &mon1 ); } 140 141 long long int measure_1_sched_int() { 142 long long int t; 143 { 144 thrd1a a = { &t }; 145 thrd1b b; 146 } 147 return t; 148 } 149 150 //----------------------------------------------------------------------------- 151 // multi internal sched entry 152 mon_t mon2; 153 154 condition cond2a; 155 condition cond2b; 156 157 thread thrd2a { long long int * out; }; 158 thread thrd2b {}; 159 160 void ?{}( thrd2a * this, long long int * out ) { 161 this->out = out; 162 } 163 164 void side2A( mon_t * mutex a, mon_t * mutex b, long long int * out ) { 165 long long int StartTime, EndTime; 166 167 StartTime = Time(); 168 for( int i = 0;; i++ ) { 169 signal(&cond2a); 170 if( i > N ) break; 171 wait(&cond2b); 172 } 173 EndTime = Time(); 174 175 *out = ( EndTime - StartTime ) / N; 176 } 177 178 void side2B( mon_t * mutex a, mon_t * mutex b ) { 179 for( int i = 0;; i++ ) { 180 signal(&cond2b); 181 if( i > N ) break; 182 wait(&cond2a); 183 } 184 } 185 186 void main( thrd2a * this ) { side2A( &mon1, &mon2, this->out ); } 187 void main( thrd2b * this ) { side2B( &mon1, &mon2 ); } 188 189 long long int measure_2_sched_int() { 190 long long int t; 191 { 192 thrd2a a = { &t }; 193 thrd2b b; 194 } 195 return t; 196 } 197 198 //----------------------------------------------------------------------------- 199 // main loop 102 200 int main() 103 201 { … … 106 204 sout | measure_thread() | ','; 107 205 sout | measure_1_monitor_entry() | ','; 108 sout | measure_2_monitor_entry() | endl; 109 } 206 sout | measure_2_monitor_entry() | ','; 207 sout | measure_1_sched_int() | ','; 208 sout | measure_2_sched_int() | endl; 209 }
Note: See TracChangeset
for help on using the changeset viewer.