# HG changeset patch # User SeanHalle # Date 1289480285 28800 # Node ID b98f0f8da7d92f16cda16a83a4d8f23b426a8103 # Parent 2845dca6a28b208a0ee4d3c511bf8f3d3d1f4e86 Made seed pr creation re-used create procr helper diff -r 2845dca6a28b -r b98f0f8da7d9 VCilk_PluginFns.c --- a/VCilk_PluginFns.c Mon Nov 08 03:58:41 2010 -0800 +++ b/VCilk_PluginFns.c Thu Nov 11 04:58:05 2010 -0800 @@ -202,65 +202,80 @@ //============================== VMS requests =============================== - -/* +/*Re-use this in the entry-point fn */ -void inline -handleSpawn( VMSReqst *req, VirtProcr *requestingPr, VCilkSemEnv *semEnv ) - { VCilkSemReq *semReq; - VirtProcr *newPr; - VCilkSemData *semanticData; - - semReq = VMS__take_sem_reqst_from(req); +inline VirtProcr * +VCilk__create_procr_helper( VirtProcrFnPtr fnPtr, void *initData, + VCilkSemEnv *semEnv, int32 coreToScheduleOnto ) + { VirtProcr *newPr; + VCilkSemData semData; //This is running in master, so use internal version - newPr = VMS__create_procr( semReq->fnPtr, semReq->initData ); + newPr = VMS__create_procr( fnPtr, initData ); - semanticData = VMS__malloc( sizeof(VCilkSemData) ); + semData = VMS__malloc( sizeof(VCilkSemData) ); - semanticData->numLiveChildren = 0; - semanticData->parentPr = NULL; - semanticData->syncPending = FALSE; + semData->numLiveChildren = 0; + semData->parentPr = NULL; + semData->syncPending = FALSE; + + semData->highestTransEntered = -1; + semData->lastTransEntered = NULL; - semanticData->highestTransEntered = -1; - semanticData->lastTransEntered = NULL; - - newPr->semanticData = semanticData; + newPr->semanticData = semData; /* add newly created to the list of live children of requester. * In newly created, add pointer to VP requesting, as the parentVP */ - ((VCilkSemData *)(requestingPr->semanticData))->numLiveChildren +=1; - ((VCilkSemData *)(newPr->semanticData))->parentPr = requestingPr; + ((VCilkSemData *)(newPr->semanticData))->numLiveChildren +=1; + ((VCilkSemData *)(newPr->semanticData))->parentPr = newPr; semEnv->numVirtPr += 1; - //Assign new processor to a core & transition it to ready + //=================== Assign new processor to a core ===================== #ifdef SEQUENTIAL newPr->coreAnimatedBy = 0; #else - int32 - coreToSpawnOnto = semReq->coreToSpawnOnto; - if(coreToSpawnOnto < 0 || coreToSpawnOnto >= NUM_CORES ) + if(coreToScheduleOnto < 0 || coreToScheduleOnto >= NUM_CORES ) { //out-of-range, so round-robin assignment newPr->coreAnimatedBy = semEnv->nextCoreToGetNewPr; + if( semEnv->nextCoreToGetNewPr >= NUM_CORES - 1 ) semEnv->nextCoreToGetNewPr = 0; else semEnv->nextCoreToGetNewPr += 1; } else //core num in-range, so use it - { newPr->coreAnimatedBy = coreToSpawnOnto; + { newPr->coreAnimatedBy = coreToScheduleOnto; } #endif + //======================================================================== + + return newPr; + } + + +void inline +handleSpawn( VMSReqst *req, VirtProcr *requestingPr, VCilkSemEnv *semEnv ) + { VCilkSemReq *semReq; + VirtProcr *newPr; + + semReq = VMS__take_sem_reqst_from( req ); + + newPr = VCilk__create_procr_helper( semReq->fnPtr, semReq->initData, semEnv, + semReq->coreToSpawnOnto ); + + //For VPThread, caller needs ptr to created processor returned to it + requestingPr->dataRetFromReq = newPr; resume_procr( newPr, semEnv ); resume_procr( requestingPr, semEnv ); } + /*get parentVP & remove dissipator from parent's live children. *If this was last live child, check "sync pending" flag *-- if set, then resume the parentVP. diff -r 2845dca6a28b -r b98f0f8da7d9 VCilk_lib.c --- a/VCilk_lib.c Mon Nov 08 03:58:41 2010 -0800 +++ b/VCilk_lib.c Thu Nov 11 04:58:05 2010 -0800 @@ -103,24 +103,8 @@ //VCilk starts with one processor, which is put into initial environ, // and which then calls create() to create more, thereby expanding work - //Note, have to use external version of VMS__create_procr because - // internal version uses VMS__malloc, which hasn't been set up by here - seedPr = VMS__create_procr( fnPtr, initData ); - VCilkSemData * - semanticData = VMS__malloc( sizeof(VCilkSemData) ); - - semanticData->numLiveChildren = 0; - semanticData->parentPr = NULL; - semanticData->syncPending = FALSE; - - semanticData->highestTransEntered = -1; - semanticData->lastTransEntered = NULL; - - seedPr->semanticData = semanticData; - seedPr->coreAnimatedBy = semEnv->nextCoreToGetNewPr++; - - writePrivQ( seedPr, semEnv->readyVPQs[seedPr->coreAnimatedBy] ); - semEnv->numVirtPr = 1; + seedPr = VCilk__create_procr_helper( fnPtr, initData, semEnv, -1 ); + resume_procr( seedPr ); #ifdef SEQUENTIAL VMS__start_the_work_then_wait_until_done_Seq(); //debug sequential exe