Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > VMS_impls > VMS__MC_shared_impl
comparison VMS.c @ 47:72373405c816
Adding TSC normalization -- still in progress, not working
| author | Me |
|---|---|
| date | Sat, 16 Oct 2010 04:11:15 -0700 |
| parents | cf3e9238aeb0 |
| children | 054006c26b92 |
comparison
equal
deleted
inserted
replaced
| 18:aa82127c7e20 | 19:a02b366f0cd7 |
|---|---|
| 77 } | 77 } |
| 78 | 78 |
| 79 void | 79 void |
| 80 create_masterEnv() | 80 create_masterEnv() |
| 81 { MasterEnv *masterEnv; | 81 { MasterEnv *masterEnv; |
| 82 SRSWQueueStruc **readyToAnimateQs; | 82 VMSQueueStruc **readyToAnimateQs; |
| 83 int coreIdx; | 83 int coreIdx; |
| 84 VirtProcr **masterVPs; | 84 VirtProcr **masterVPs; |
| 85 SchedSlot ***allSchedSlots; //ptr to array of ptrs | 85 SchedSlot ***allSchedSlots; //ptr to array of ptrs |
| 86 | 86 |
| 87 //Make the master env, which holds everything else | 87 //Make the master env, which holds everything else |
| 91 // before the first core loop starts up. -- not sure how yet.. | 91 // before the first core loop starts up. -- not sure how yet.. |
| 92 // masterEnv->coreLoopStartPt = ; | 92 // masterEnv->coreLoopStartPt = ; |
| 93 // masterEnv->coreLoopEndPt = ; | 93 // masterEnv->coreLoopEndPt = ; |
| 94 | 94 |
| 95 //Make a readyToAnimateQ for each core loop | 95 //Make a readyToAnimateQ for each core loop |
| 96 readyToAnimateQs = malloc( NUM_CORES * sizeof(SRSWQueueStruc *) ); | 96 readyToAnimateQs = malloc( NUM_CORES * sizeof(VMSQueueStruc *) ); |
| 97 masterVPs = malloc( NUM_CORES * sizeof(VirtProcr *) ); | 97 masterVPs = malloc( NUM_CORES * sizeof(VirtProcr *) ); |
| 98 | 98 |
| 99 //One array for each core, 3 in array, core's masterVP scheds all | 99 //One array for each core, 3 in array, core's masterVP scheds all |
| 100 allSchedSlots = malloc( NUM_CORES * sizeof(SchedSlot *) ); | 100 allSchedSlots = malloc( NUM_CORES * sizeof(SchedSlot *) ); |
| 101 | 101 |
| 194 void | 194 void |
| 195 create_the_coreLoop_OS_threads() | 195 create_the_coreLoop_OS_threads() |
| 196 { | 196 { |
| 197 //======================================================================== | 197 //======================================================================== |
| 198 // Create the Threads | 198 // Create the Threads |
| 199 int coreIdx, retCode; | 199 int coreIdx, retCode, i; |
| 200 | |
| 201 //create the arrays used to measure TSC offsets between cores | |
| 202 pongNums = malloc( NUM_CORES * sizeof( int ) ); | |
| 203 pingTimes = malloc( NUM_CORES * NUM_TSC_ROUND_TRIPS * sizeof( TSCount ) ); | |
| 204 pongTimes = malloc( NUM_CORES * NUM_TSC_ROUND_TRIPS * sizeof( TSCount ) ); | |
| 205 | |
| 206 for( coreIdx = 0; coreIdx < NUM_CORES; coreIdx++ ) | |
| 207 { | |
| 208 pongNums[ coreIdx ] = 0; | |
| 209 for( i = 0; i < NUM_TSC_ROUND_TRIPS; i++ ) | |
| 210 { | |
| 211 pingTimes[ coreIdx * NUM_TSC_ROUND_TRIPS + i ] = (TSCount) 0; | |
| 212 pingTimes[ coreIdx * NUM_TSC_ROUND_TRIPS + i ] = (TSCount) 0; | |
| 213 } | |
| 214 } | |
| 200 | 215 |
| 201 //Need the threads to be created suspended, and wait for a signal | 216 //Need the threads to be created suspended, and wait for a signal |
| 202 // before proceeding -- gives time after creating to initialize other | 217 // before proceeding -- gives time after creating to initialize other |
| 203 // stuff before the coreLoops set off. | 218 // stuff before the coreLoops set off. |
| 204 _VMSMasterEnv->setupComplete = 0; | 219 _VMSMasterEnv->setupComplete = 0; |
| 228 //=========================================================================== | 243 //=========================================================================== |
| 229 TSCount startCount, endCount; | 244 TSCount startCount, endCount; |
| 230 unsigned long long count = 0, freq = 0; | 245 unsigned long long count = 0, freq = 0; |
| 231 double runTime; | 246 double runTime; |
| 232 | 247 |
| 233 startCount = getTSCount(); | 248 startCount = getTSC(); |
| 234 | 249 |
| 235 //tell the core loop threads that setup is complete | 250 //tell the core loop threads that setup is complete |
| 236 //get lock, to lock out any threads still starting up -- they'll see | 251 //get lock, to lock out any threads still starting up -- they'll see |
| 237 // that setupComplete is true before entering while loop, and so never | 252 // that setupComplete is true before entering while loop, and so never |
| 238 // wait on the condition | 253 // wait on the condition |
| 251 //NOTE: do not clean up VMS env here -- semantic layer has to have | 266 //NOTE: do not clean up VMS env here -- semantic layer has to have |
| 252 // a chance to clean up its environment first, then do a call to free | 267 // a chance to clean up its environment first, then do a call to free |
| 253 // the Master env and rest of VMS locations | 268 // the Master env and rest of VMS locations |
| 254 | 269 |
| 255 | 270 |
| 256 endCount = getTSCount(); | 271 endCount = getTSC(); |
| 257 count = endCount - startCount; | 272 count = endCount - startCount; |
| 258 | 273 |
| 259 runTime = (double)count / (double)TSCOUNT_FREQ; | 274 runTime = (double)count / (double)TSCOUNT_FREQ; |
| 260 | 275 |
| 261 printf("\n Time startup to shutdown: %f\n", runTime); fflush( stdin ); | 276 printf("\n Time startup to shutdown: %f\n", runTime); fflush( stdin ); |
| 301 //fnPtr takes two params -- void *initData & void *animProcr | 316 //fnPtr takes two params -- void *initData & void *animProcr |
| 302 //alloc stack locations, make stackPtr be the highest addr minus room | 317 //alloc stack locations, make stackPtr be the highest addr minus room |
| 303 // for 2 params + return addr. Return addr (NULL) is in loc pointed to | 318 // for 2 params + return addr. Return addr (NULL) is in loc pointed to |
| 304 // by stackPtr, initData at stackPtr + 4 bytes, animatingPr just above | 319 // by stackPtr, initData at stackPtr + 4 bytes, animatingPr just above |
| 305 stackLocs = malloc( VIRT_PROCR_STACK_SIZE ); | 320 stackLocs = malloc( VIRT_PROCR_STACK_SIZE ); |
| 306 if(stackLocs == 0) | 321 if(stackLocs == 0) {perror("error: malloc stack"); exit(1);} |
| 307 {perror("malloc stack"); exit(1);} | |
| 308 newPr->startOfStack = stackLocs; | 322 newPr->startOfStack = stackLocs; |
| 309 stackPtr = ( (char *)stackLocs + VIRT_PROCR_STACK_SIZE - 0x10 ); | 323 stackPtr = ( (char *)stackLocs + VIRT_PROCR_STACK_SIZE - 0x10 ); |
| 310 //setup __cdecl on stack -- coreloop will switch to stackPtr before jmp | 324 //setup __cdecl on stack -- coreloop will switch to stackPtr before jmp |
| 311 *( (int *)stackPtr + 2 ) = (int) newPr; //rightmost param -- 32bit pointer | 325 *( (int *)stackPtr + 2 ) = (int) newPr; //rightmost param -- 32bit pointer |
| 312 *( (int *)stackPtr + 1 ) = (int) initialData; //next param to left | 326 *( (int *)stackPtr + 1 ) = (int) initialData; //next param to left |
| 650 * locations that might be left over. | 664 * locations that might be left over. |
| 651 */ | 665 */ |
| 652 void | 666 void |
| 653 VMS__cleanup_after_shutdown() | 667 VMS__cleanup_after_shutdown() |
| 654 { | 668 { |
| 655 SRSWQueueStruc **readyToAnimateQs; | 669 VMSQueueStruc **readyToAnimateQs; |
| 656 int coreIdx; | 670 int coreIdx; |
| 657 VirtProcr **masterVPs; | 671 VirtProcr **masterVPs; |
| 658 SchedSlot ***allSchedSlots; //ptr to array of ptrs | 672 SchedSlot ***allSchedSlots; //ptr to array of ptrs |
| 659 | 673 |
| 660 readyToAnimateQs = _VMSMasterEnv->readyToAnimateQs; | 674 readyToAnimateQs = _VMSMasterEnv->readyToAnimateQs; |
| 678 } | 692 } |
| 679 | 693 |
| 680 | 694 |
| 681 //=========================================================================== | 695 //=========================================================================== |
| 682 | 696 |
| 683 inline TSCount getTSCount() | 697 inline TSCount getTSC() |
| 684 { unsigned int low, high; | 698 { unsigned int low, high; |
| 685 TSCount out; | 699 TSCount out; |
| 686 | 700 |
| 687 saveTimeStampCountInto( low, high ); | 701 saveTimeStampCountInto( low, high ); |
| 688 out = high; | 702 out = high; |
