comparison VMS.c @ 173:bfaebdf60df3

coreLoop: All written variables are now on local stack or in seperate cache line
author Merten Sach <msach@mailbox.tu-berlin.de>
date Tue, 20 Dec 2011 15:39:30 +0100
parents d1dd9e6ee72c
children c3f458403cd6
comparison
equal deleted inserted replaced
82:c3f33b1970fd 83:09904d22c4aa
98 VirtProcr **masterVPs; 98 VirtProcr **masterVPs;
99 SchedSlot ***allSchedSlots; //ptr to array of ptrs 99 SchedSlot ***allSchedSlots; //ptr to array of ptrs
100 100
101 101
102 //Make the master env, which holds everything else 102 //Make the master env, which holds everything else
103 _VMSMasterEnv = malloc( sizeof(MasterEnv) ); 103 posix_memalign((void*)&_VMSMasterEnv, CACHELINE_SIZE, sizeof(MasterEnv) );
104 memset( _VMSMasterEnv, 0, sizeof(MasterEnv) ); 104 memset( _VMSMasterEnv, 0, sizeof(MasterEnv) );
105 105
106 //Very first thing put into the master env is the free-list, seeded 106 //Very first thing put into the master env is the free-list, seeded
107 // with a massive initial chunk of memory. 107 // with a massive initial chunk of memory.
108 //After this, all other mallocs are VMS__malloc. 108 //After this, all other mallocs are VMS__malloc.
141 141
142 //Q: should give masterVP core-specific info as its init data? 142 //Q: should give masterVP core-specific info as its init data?
143 masterVPs[ coreIdx ] = VMS__create_procr( (VirtProcrFnPtr)&masterLoop, (void*)masterEnv ); 143 masterVPs[ coreIdx ] = VMS__create_procr( (VirtProcrFnPtr)&masterLoop, (void*)masterEnv );
144 masterVPs[ coreIdx ]->coreAnimatedBy = coreIdx; 144 masterVPs[ coreIdx ]->coreAnimatedBy = coreIdx;
145 allSchedSlots[ coreIdx ] = create_sched_slots(); //makes for one core 145 allSchedSlots[ coreIdx ] = create_sched_slots(); //makes for one core
146 _VMSMasterEnv->numMasterInARow[ coreIdx ] = 0; 146 //_VMSMasterEnv->numMasterInARow[ coreIdx ] = 0; //moved to coreLoops stack, reason: avoid false sharing
147 _VMSMasterEnv->workStealingGates[ coreIdx ] = NULL; 147 _VMSMasterEnv->workStealingGates[ coreIdx ] = NULL;
148 } 148 }
149 _VMSMasterEnv->readyToAnimateQs = readyToAnimateQs; 149 _VMSMasterEnv->readyToAnimateQs = readyToAnimateQs;
150 _VMSMasterEnv->masterVPs = masterVPs; 150 _VMSMasterEnv->masterVPs = masterVPs;
151 _VMSMasterEnv->masterLock = UNLOCKED; 151 _VMSMasterEnv->masterLockUnion.masterLock = UNLOCKED;
152 _VMSMasterEnv->allSchedSlots = allSchedSlots; 152 _VMSMasterEnv->allSchedSlots = allSchedSlots;
153 _VMSMasterEnv->workStealingLock = UNLOCKED; 153 _VMSMasterEnv->workStealingLock = UNLOCKED;
154 154
155 155
156 //Aug 19, 2010: no longer need to place initial masterVP into queue 156 //Aug 19, 2010: no longer need to place initial masterVP into queue
286 inline VirtProcr * 286 inline VirtProcr *
287 VMS__create_procr( VirtProcrFnPtr fnPtr, void *initialData ) 287 VMS__create_procr( VirtProcrFnPtr fnPtr, void *initialData )
288 { VirtProcr *newPr; 288 { VirtProcr *newPr;
289 void *stackLocs; 289 void *stackLocs;
290 290
291 newPr = VMS__malloc( sizeof(VirtProcr) ); 291 posix_memalign((void*)&newPr, CACHELINE_SIZE, sizeof(VirtProcr) ); //align to cacheline
292 stackLocs = VMS__malloc( VIRT_PROCR_STACK_SIZE ); 292 posix_memalign(&stackLocs, CACHELINE_SIZE, VIRT_PROCR_STACK_SIZE ); //align to cacheline
293 if( stackLocs == 0 ) 293 if( stackLocs == 0 )
294 { perror("VMS__malloc stack"); exit(1); } 294 { perror("VMS__malloc stack"); exit(1); }
295 295
296 return create_procr_helper( newPr, fnPtr, initialData, stackLocs ); 296 return create_procr_helper( newPr, fnPtr, initialData, stackLocs );
297 } 297 }
588 // been alloc'd with VMS__malloc, or freed by the level above animPr. 588 // been alloc'd with VMS__malloc, or freed by the level above animPr.
589 //So, all that's left to free here is the stack and the VirtProcr struc 589 //So, all that's left to free here is the stack and the VirtProcr struc
590 // itself 590 // itself
591 //Note, should not stack-allocate initial data -- no guarantee, in 591 //Note, should not stack-allocate initial data -- no guarantee, in
592 // general that creating processor will outlive ones it creates. 592 // general that creating processor will outlive ones it creates.
593 VMS__free( animatingPr->startOfStack ); 593 //VMS__free( animatingPr->startOfStack );
594 VMS__free( animatingPr ); 594 //VMS__free( animatingPr );
595 } 595 }
596 596
597 597
598 //TODO: look at architecting cleanest separation between request handler 598 //TODO: look at architecting cleanest separation between request handler
599 // and master loop, for dissipate, create, shutdown, and other non-semantic 599 // and master loop, for dissipate, create, shutdown, and other non-semantic