Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > VMS_impls > VMS__MC_shared_impl
changeset 287:15ee3fe10e3d Dev_ML
Fixed issue with meta tasks -- in slot slave, have to replace previous
Also fixed give taskID, and added SS give num cores
added "replace or insert into collection" so that prev meta task is replaced
| author | Sean Halle <seanhalle@yahoo.com> |
|---|---|
| date | Thu, 05 Sep 2013 17:38:19 -0700 |
| parents | 2fc69e6c14ea |
| children | c7142d15fc40 |
| files | AnimationMaster.c HW_Dependent_Primitives/PR__MetaInfo.c PR.c PR__PI.h PR__SS.c PR__int.c PR__int.h PR__structs.h PR_req_handlers.c Services_Offered_by_PR/Debugging/DEBUG__macros.h Services_Offered_by_PR/Measurement_and_Stats/MEAS__Counter_Recording.c Services_Offered_by_PR/Services_Language/PRServ.c Services_Offered_by_PR/Services_Language/PRServ.h Services_Offered_by_PR/Services_Language/PRServ_PluginFns.c Services_Offered_by_PR/Services_Language/PRServ_Request_Handlers.c Services_Offered_by_PR/Services_Language/PRServ_SS.c |
| diffstat | 16 files changed, 105 insertions(+), 107 deletions(-) [+] |
line diff
1.1 --- a/AnimationMaster.c Fri Mar 08 05:34:21 2013 -0800 1.2 +++ b/AnimationMaster.c Thu Sep 05 17:38:19 2013 -0700 1.3 @@ -10,7 +10,6 @@ 1.4 #include <stddef.h> 1.5 1.6 #include "PR.h" 1.7 -#include "VSs_impl/VSs.h" 1.8 1.9 //========================= Local Declarations ======================== 1.10 inline PRProcess * 1.11 @@ -74,7 +73,7 @@ 1.12 if( slot->workIsDone ) 1.13 { slot->workIsDone = FALSE; 1.14 slot->needsWorkAssigned = TRUE; 1.15 -printf("top handle request: %d | reqType: %d\n", slot->coreSlotIsOn, (int32)req->reqType );fflush(stdin); 1.16 +//printf("top handle request: %d | reqType: %d\n", slot->coreSlotIsOn, (int32)req->reqType );fflush(stdin); 1.17 1.18 //An Idle VP has no request to handle, so skip to assign.. 1.19 if( slot->slaveAssignedToSlot->typeOfVP != IdleVP &&
2.1 --- a/HW_Dependent_Primitives/PR__MetaInfo.c Fri Mar 08 05:34:21 2013 -0800 2.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 2.3 @@ -1,26 +0,0 @@ 2.4 -#include <unistd.h> 2.5 -#include <fcntl.h> 2.6 -#include <linux/types.h> 2.7 -#include <linux/perf_event.h> 2.8 -#include <errno.h> 2.9 -#include <sys/syscall.h> 2.10 -#include <linux/prctl.h> 2.11 - 2.12 -#include "../PR.h" 2.13 - 2.14 -void PR_SS__set_meta_info() 2.15 - { 2.16 - garbage__delete; 2.17 - 2.18 - _PRTopEnv->metaInfo = PR_int__malloc( sizeof(PRSysMetaInfo) ); 2.19 - //Meta info gets set by calls from the language during its init, 2.20 - // and info registered by calls from inside the application 2.21 - _PRTopEnv->metaInfo->assignerInfo; 2.22 - 2.23 - //-------------------------- 2.24 - //Application 2.25 - j += sprintf(buffer+j, "#\n# >> Application <<\n"); 2.26 - j += sprintf(buffer+j, "# Name: %s\n", _PRTopEnv->metaInfo->appInfo); 2.27 - j += sprintf(buffer+j, "# Data Set:\n%s\n",_PRTopEnv->metaInfo->inputSet); 2.28 - 2.29 - } 2.30 \ No newline at end of file
3.1 --- a/PR.c Fri Mar 08 05:34:21 2013 -0800 3.2 +++ b/PR.c Thu Sep 05 17:38:19 2013 -0700 3.3 @@ -327,5 +327,4 @@ 3.4 PR_SS__cleanup_at_end_of_shutdown(); 3.5 } 3.6 3.7 - 3.8 - 3.9 +//====================================================
4.1 --- a/PR__PI.h Fri Mar 08 05:34:21 2013 -0800 4.2 +++ b/PR__PI.h Thu Sep 05 17:38:19 2013 -0700 4.3 @@ -7,7 +7,7 @@ 4.4 */ 4.5 4.6 #ifndef _PR__PI_H 4.7 -#define _PR__PI_H 4.8 +#define _PR__PI_H 4.9 #define _GNU_SOURCE 4.10 4.11 4.12 @@ -39,6 +39,10 @@ 4.13 #define \ 4.14 PR_PI__create_slaveVP PR_int__create_slaveVP_helper 4.15 4.16 + 4.17 +#define \ 4.18 +PR_PI__give_num_cores PR_SS__give_num_cores 4.19 + 4.20 //============== 4.21 //=== Lang Data 4.22 //= 4.23 @@ -129,6 +133,9 @@ 4.24 void 4.25 PR_SS__create_the_coreCtlr_OS_threads(); 4.26 4.27 +int 4.28 +PR_SS__give_num_cores(); 4.29 + 4.30 //=================== 4.31 void * 4.32 PR_SS__create_lang_env( int32 size, SlaveVP *slave, int32 magicNum );
5.1 --- a/PR__SS.c Fri Mar 08 05:34:21 2013 -0800 5.2 +++ b/PR__SS.c Thu Sep 05 17:38:19 2013 -0700 5.3 @@ -227,6 +227,15 @@ 5.4 } 5.5 } 5.6 5.7 +/*This is intended to be called from lang plugin dynamic lib, and call 5.8 + * into proto-runtime dynamic lib -- so, the call in the lang code 5.9 + * will get different answers depending upon which PR impl it connects 5.10 + * to. 5.11 + */ 5.12 +int 5.13 +PR_SS__give_num_cores() 5.14 + { return NUM_CORES; 5.15 + } 5.16 5.17 //====================== 5.18 //===
6.1 --- a/PR__int.c Fri Mar 08 05:34:21 2013 -0800 6.2 +++ b/PR__int.c Thu Sep 05 17:38:19 2013 -0700 6.3 @@ -310,7 +310,7 @@ 6.4 void * 6.5 PR_int__give_lang_env( PRLangEnv *protoLangEnv ) 6.6 { 6.7 - return (void *) &(protoLangEnv[1]); 6.8 + return (void *) &(protoLangEnv[1]); 6.9 } 6.10 inline 6.11 PRLangEnv * 6.12 @@ -567,18 +567,22 @@ 6.13 6.14 inline 6.15 void 6.16 -PR_int__insert_meta_task_into_slave( PRMetaTask *task, SlaveVP *slave ) 6.17 +PR_int__insert_meta_task_into_slave( PRMetaTask *metaTask, SlaveVP *slave ) 6.18 { 6.19 - task->slaveAssignedTo = slave; 6.20 - PR_int__insert_elem_into_collection( (PRCollElem *)task, 6.21 - (PRCollElem **)slave->metaTasks, task->langMagicNumber ); 6.22 + metaTask->slaveAssignedTo = slave; 6.23 + //at most one meta-task from a given language can be in slave, 6.24 + // so use a form that replaces old meta task if one already there 6.25 + PR_int__replace_or_insert_elem_into_collection( (PRCollElem *)metaTask, 6.26 + (PRCollElem **)slave->metaTasks, metaTask->langMagicNumber ); 6.27 } 6.28 inline 6.29 void 6.30 PR_int__insert_lang_meta_task_into_slave( void *langMetaTask, SlaveVP *slave ) 6.31 { PRMetaTask *metaTask = &(((PRMetaTask*)langMetaTask)[-1]); 6.32 metaTask->slaveAssignedTo = slave; 6.33 - PR_int__insert_elem_into_collection( (PRCollElem *)metaTask, 6.34 + //at most one meta-task from a given language can be in slave, 6.35 + // so use a form that replaces old meta task if one already there 6.36 + PR_int__replace_or_insert_elem_into_collection( (PRCollElem *)metaTask, 6.37 (PRCollElem **)slave->metaTasks, metaTask->langMagicNumber ); 6.38 } 6.39 6.40 @@ -615,7 +619,7 @@ 6.41 6.42 metaTasks = (PRCollElem **)slave->metaTasks; 6.43 retMetaTask = PR_int__lookup_elem_in_collection( magicNum, metaTasks ); 6.44 - if( retMetaTask != NULL ) 6.45 + if( retMetaTask != NULL ) 6.46 return PR_int__give_lang_meta_task_of_prolog(retMetaTask); //skip over prolog 6.47 else 6.48 { protoLangEnv = PR_int__give_proto_lang_env_for_slave( slave, magicNum ); 6.49 @@ -745,6 +749,40 @@ 6.50 } 6.51 6.52 inline 6.53 +void 6.54 +PR_int__replace_or_insert_elem_into_collection( PRCollElem *elem, 6.55 + PRCollElem **coll, 6.56 + int32 hash ) 6.57 + { int32 idx, numIdxsInColl; 6.58 + PRCollElem *test, **prevPtrLoc; 6.59 + 6.60 + numIdxsInColl = ((int32 *)coll)[-1]; //prolog holds number of idexes in array 6.61 + 6.62 + //figure out where to link in 6.63 + idx = hash & (numIdxsInColl - 1); //mask off, leaving lowest bits 6.64 + test = coll[idx]; 6.65 + if( test == NULL ) 6.66 + { //insert 6.67 + coll[idx] = elem; 6.68 + return; 6.69 + } 6.70 + //see if any elements match 6.71 + prevPtrLoc = &(coll[idx]); 6.72 + while( test->hash != hash ) 6.73 + { prevPtrLoc = &(test->chained); 6.74 + test = test->chained; 6.75 + if( test == NULL ) 6.76 + { //got to end of chain, not there, so add elem to end 6.77 + *prevPtrLoc = elem; 6.78 + return; 6.79 + } 6.80 + } 6.81 + //found a match -- replace it 6.82 + elem->chained = test->chained; 6.83 + *prevPtrLoc = elem; 6.84 + } 6.85 + 6.86 +inline 6.87 void * 6.88 PR_int__lookup_elem_in_collection( int32 hash, PRCollElem **coll ) 6.89 { int32 idx, numIdxsInColl; 6.90 @@ -832,6 +870,7 @@ 6.91 /*Later, improve this -- for now, just exits the application after printing 6.92 * the error message. 6.93 */ 6.94 + 6.95 void 6.96 PR_int__throw_exception( char *msgStr, SlaveVP *reqstSlv, PRExcp *excpData ) 6.97 {
7.1 --- a/PR__int.h Fri Mar 08 05:34:21 2013 -0800 7.2 +++ b/PR__int.h Thu Sep 05 17:38:19 2013 -0700 7.3 @@ -7,7 +7,7 @@ 7.4 */ 7.5 7.6 #ifndef _PR_INT_H 7.7 -#define _PR_INT_H 7.8 +#define _PR_INT_H 7.9 #define _GNU_SOURCE 7.10 7.11 7.12 @@ -195,6 +195,12 @@ 7.13 PR_int__insert_elem_into_collection( PRCollElem *elem, PRCollElem **coll, int32 hash ); 7.14 7.15 inline 7.16 +void 7.17 +PR_int__replace_or_insert_elem_into_collection( PRCollElem *elem, 7.18 + PRCollElem **coll, 7.19 + int32 hash ); 7.20 + 7.21 +inline 7.22 void * 7.23 PR_int__lookup_elem_in_collection( int32 hash, PRCollElem **coll ); 7.24 7.25 @@ -216,6 +222,21 @@ 7.26 void 7.27 PR_int__error( char *msgStr ); 7.28 7.29 +/*Some macro magic -- the __FILE__ turns into a string, and the 7.30 + * preprocessor merges the quotes. But the __LINE__ turns into an int, 7.31 + * so have to use the # operator to turn it into a string.. but the 7.32 + * # operator doesn't expand what comes after, so have to do an extra 7.33 + * level so that pre-processor first expands __LINE__ into number then 7.34 + * hands to the # operator, which turns into string (then it merges 7.35 + * quotes) 7.36 + */ 7.37 +#define PR__throw_simple_exception( throwingVP ) \ 7.38 + do{ PR_int__throw_exception( __FILE__ ", " STR(__LINE__), throwingVP, NULL ); \ 7.39 + } while(0) 7.40 + 7.41 +#define STR( s ) #s 7.42 + 7.43 + 7.44 void 7.45 PR_int__throw_exception( char *msgStr, SlaveVP *reqstSlv, PRExcp *excpData ); 7.46
8.1 --- a/PR__structs.h Fri Mar 08 05:34:21 2013 -0800 8.2 +++ b/PR__structs.h Thu Sep 05 17:38:19 2013 -0700 8.3 @@ -222,7 +222,7 @@ 8.4 PRProcess *processSlaveIsIn; 8.5 enum VPtype typeOfVP; //Slave vs Master vs Shutdown.. 8.6 int32 slaveNum; //each slave given it's seq in creation 8.7 - int32 *ID; //App defines meaning of each int in array 8.8 + int32 *ID; //App defines meaning of each int in array 8.9 int32 coreAnimatedBy; 8.10 int32 numTimesAssignedToASlot; //Each assign is for one work-unit, so is an ID 8.11 //note, a scheduling decision is uniquely identified by the triple:
9.1 --- a/PR_req_handlers.c Fri Mar 08 05:34:21 2013 -0800 9.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 9.3 @@ -1,57 +0,0 @@ 9.4 -/* 9.5 - * Copyright 2010 OpenSourceStewardshipFoundation 9.6 - * 9.7 - * Licensed under BSD 9.8 - */ 9.9 - 9.10 -#include <stdio.h> 9.11 -#include <stdlib.h> 9.12 -#include <string.h> 9.13 -#include <malloc.h> 9.14 -#include <inttypes.h> 9.15 -#include <sys/time.h> 9.16 - 9.17 -#include "PR.h" 9.18 - 9.19 - 9.20 -/* MEANING OF WL PI SS int 9.21 - * These indicate which places the function is safe to use. They stand for: 9.22 - * WL: Wrapper Library 9.23 - * PI: Plugin 9.24 - * SS: Startup and Shutdown 9.25 - * int: internal to the PR implementation 9.26 - */ 9.27 - 9.28 - 9.29 -/* 9.30 - */ 9.31 -void inline 9.32 -handleMakeProbe( PRSemReq *semReq, void *semEnv, ResumeSlvFnPtr resumeFn ) 9.33 - { IntervalProbe *newProbe; 9.34 - 9.35 - newProbe = PR_int__malloc( sizeof(IntervalProbe) ); 9.36 - newProbe->nameStr = PR_int__strDup( semReq->nameStr ); 9.37 - newProbe->hist = NULL; 9.38 - newProbe->schedChoiceWasRecorded = FALSE; 9.39 - 9.40 - //This runs in masterVP, so no race-condition worries 9.41 - newProbe->probeID = 9.42 - addToDynArray( newProbe, _PRMasterEnv->dynIntervalProbesInfo ); 9.43 - 9.44 - semReq->requestingSlv->dataRetFromReq = newProbe; 9.45 - 9.46 - //This in inside PR, while resume_slaveVP fn is inside language, so pass 9.47 - // pointer from lang to here, then call it. 9.48 - (*resumeFn)( semReq->requestingSlv, semEnv ); 9.49 - } 9.50 - 9.51 -void inline 9.52 -handleThrowException( PRSemReq *semReq, void *semEnv, ResumeSlvFnPtr resumeFn ) 9.53 - { 9.54 - PR_int__throw_exception( semReq->msgStr, semReq->requestingSlv, semReq->exceptionData ); 9.55 - 9.56 - (*resumeFn)( semReq->requestingSlv, semEnv ); 9.57 - } 9.58 - 9.59 - 9.60 -
10.1 --- a/Services_Offered_by_PR/Debugging/DEBUG__macros.h Fri Mar 08 05:34:21 2013 -0800 10.2 +++ b/Services_Offered_by_PR/Debugging/DEBUG__macros.h Thu Sep 05 17:38:19 2013 -0700 10.3 @@ -13,10 +13,10 @@ 10.4 /* 10.5 */ 10.6 #ifdef DEBUG__TURN_ON_DEBUG_PRINT 10.7 - #define DEBUG__printf( bool, msg) \ 10.8 + #define DEBUG__printf( bool, ...) \ 10.9 do{\ 10.10 if(bool)\ 10.11 - { printf(msg);\ 10.12 + { printf( __VA_ARGS__ );\ 10.13 printf(" | function: %s\n", __FUNCTION__);\ 10.14 fflush(stdin);\ 10.15 }\
11.1 --- a/Services_Offered_by_PR/Measurement_and_Stats/MEAS__Counter_Recording.c Fri Mar 08 05:34:21 2013 -0800 11.2 +++ b/Services_Offered_by_PR/Measurement_and_Stats/MEAS__Counter_Recording.c Thu Sep 05 17:38:19 2013 -0700 11.3 @@ -3,7 +3,7 @@ 11.4 * author: Nina Engelhardt 11.5 */ 11.6 11.7 -#include "PR_MEAS__Counter_Recording.h" 11.8 +#include "MEAS__Counter_Recording.h" 11.9 #include "PR_impl/PR.h" 11.10 //#include "../PRServ.h" 11.11
12.1 --- a/Services_Offered_by_PR/Services_Language/PRServ.c Fri Mar 08 05:34:21 2013 -0800 12.2 +++ b/Services_Offered_by_PR/Services_Language/PRServ.c Thu Sep 05 17:38:19 2013 -0700 12.3 @@ -99,11 +99,18 @@ 12.4 inline 12.5 int32 * 12.6 PRServ__give_self_taskID( SlaveVP *animSlv ) 12.7 + { void *metaTask; 12.8 + metaTask = PR_WL__give_lang_meta_task_from_slave( animSlv, PRServ_MAGIC_NUMBER ); 12.9 + return PR__give_ID_from_lang_meta_task( metaTask ); 12.10 + } 12.11 + 12.12 +inline 12.13 +int32 * 12.14 +PRServ__give_slave_ID( SlaveVP *animSlv ) 12.15 { 12.16 return PR__give_ID_from_slave( animSlv, PRServ_MAGIC_NUMBER ); 12.17 } 12.18 12.19 - 12.20 /* 12.21 *This function returns information about the version of PR, the language 12.22 * the program is being run in, its version, and information on the
13.1 --- a/Services_Offered_by_PR/Services_Language/PRServ.h Fri Mar 08 05:34:21 2013 -0800 13.2 +++ b/Services_Offered_by_PR/Services_Language/PRServ.h Thu Sep 05 17:38:19 2013 -0700 13.3 @@ -92,7 +92,7 @@ 13.4 13.5 typedef struct 13.6 { 13.7 - PrivQueueStruc *slavesReadyToResumeQ; //Shared (slaves not pinned) 13.8 + PrivQueueStruc *slaveReadyQ; //Shared (slaves not pinned) 13.9 PrivQueueStruc *taskReadyQ; //will never be used in seed langlet 13.10 13.11 int32 primitiveStartTime;
14.1 --- a/Services_Offered_by_PR/Services_Language/PRServ_PluginFns.c Fri Mar 08 05:34:21 2013 -0800 14.2 +++ b/Services_Offered_by_PR/Services_Language/PRServ_PluginFns.c Thu Sep 05 17:38:19 2013 -0700 14.3 @@ -52,7 +52,7 @@ 14.4 langEnv = (PRServLangEnv *)_langEnv; 14.5 14.6 //Check for suspended slaves that are ready to resume 14.7 - returnSlv = readPrivQ( langEnv->slavesReadyToResumeQ ); 14.8 + returnSlv = readPrivQ( langEnv->slaveReadyQ ); 14.9 if( returnSlv != NULL ) //Yes, have a slave, so return it. 14.10 { returnSlv->coreAnimatedBy = coreNum; 14.11 14.12 @@ -117,7 +117,7 @@ 14.13 } 14.14 #endif 14.15 /* PR handles work available in lang env and in process.. 14.16 - if( isEmptyPrivQ(langEnv->slavesReadyToResumeQ) && 14.17 + if( isEmptyPrivQ(langEnv->slaveReadyQ) && 14.18 isEmptyPrivQ(langEnv->taskReadyQ) ) 14.19 PR_int__clear_work_in_lang_env(langEnv); 14.20 */
15.1 --- a/Services_Offered_by_PR/Services_Language/PRServ_Request_Handlers.c Fri Mar 08 05:34:21 2013 -0800 15.2 +++ b/Services_Offered_by_PR/Services_Language/PRServ_Request_Handlers.c Thu Sep 05 17:38:19 2013 -0700 15.3 @@ -291,7 +291,7 @@ 15.4 { PRServLangEnv *langEnv = (PRServLangEnv *)_langEnv; 15.5 15.6 //both suspended tasks and suspended explicit slaves resumed with this 15.7 - writePrivQ( slave, langEnv->slavesReadyToResumeQ ); 15.8 + writePrivQ( slave, langEnv->slaveReadyQ ); 15.9 //PR handles this.. PR_int__set_work_in_lang_env(langEnv); 15.10 15.11 #ifdef HOLISTIC__TURN_ON_PERF_COUNTERS
16.1 --- a/Services_Offered_by_PR/Services_Language/PRServ_SS.c Fri Mar 08 05:34:21 2013 -0800 16.2 +++ b/Services_Offered_by_PR/Services_Language/PRServ_SS.c Thu Sep 05 17:38:19 2013 -0700 16.3 @@ -31,7 +31,7 @@ 16.4 16.5 16.6 //create the ready queues 16.7 - langEnv->slavesReadyToResumeQ = makePRQ(); 16.8 + langEnv->slaveReadyQ = makePRQ(); 16.9 langEnv->taskReadyQ = makePRQ(); 16.10 16.11 //register the langlet's handlers with PR 16.12 @@ -206,7 +206,7 @@ 16.13 SlaveVP *slave; 16.14 16.15 //dissipate any slaves still in the readyQ, because this is last lang 16.16 - queue = langEnv->slavesReadyToResumeQ; 16.17 + queue = langEnv->slaveReadyQ; 16.18 slave = readPrivQ( queue ); 16.19 while( slave != NULL ) 16.20 {
