# HG changeset patch # User Sean Halle # Date 1378427899 25200 # Node ID 15ee3fe10e3d4c6e58d8c48700c12ad0ac75547e # Parent 2fc69e6c14eac85925eaf0d2a7889f7e4b82e6f0 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 diff -r 2fc69e6c14ea -r 15ee3fe10e3d AnimationMaster.c --- a/AnimationMaster.c Fri Mar 08 05:34:21 2013 -0800 +++ b/AnimationMaster.c Thu Sep 05 17:38:19 2013 -0700 @@ -10,7 +10,6 @@ #include #include "PR.h" -#include "VSs_impl/VSs.h" //========================= Local Declarations ======================== inline PRProcess * @@ -74,7 +73,7 @@ if( slot->workIsDone ) { slot->workIsDone = FALSE; slot->needsWorkAssigned = TRUE; -printf("top handle request: %d | reqType: %d\n", slot->coreSlotIsOn, (int32)req->reqType );fflush(stdin); +//printf("top handle request: %d | reqType: %d\n", slot->coreSlotIsOn, (int32)req->reqType );fflush(stdin); //An Idle VP has no request to handle, so skip to assign.. if( slot->slaveAssignedToSlot->typeOfVP != IdleVP && diff -r 2fc69e6c14ea -r 15ee3fe10e3d HW_Dependent_Primitives/PR__MetaInfo.c --- a/HW_Dependent_Primitives/PR__MetaInfo.c Fri Mar 08 05:34:21 2013 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,26 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -#include "../PR.h" - -void PR_SS__set_meta_info() - { - garbage__delete; - - _PRTopEnv->metaInfo = PR_int__malloc( sizeof(PRSysMetaInfo) ); - //Meta info gets set by calls from the language during its init, - // and info registered by calls from inside the application - _PRTopEnv->metaInfo->assignerInfo; - - //-------------------------- - //Application - j += sprintf(buffer+j, "#\n# >> Application <<\n"); - j += sprintf(buffer+j, "# Name: %s\n", _PRTopEnv->metaInfo->appInfo); - j += sprintf(buffer+j, "# Data Set:\n%s\n",_PRTopEnv->metaInfo->inputSet); - - } \ No newline at end of file diff -r 2fc69e6c14ea -r 15ee3fe10e3d PR.c --- a/PR.c Fri Mar 08 05:34:21 2013 -0800 +++ b/PR.c Thu Sep 05 17:38:19 2013 -0700 @@ -327,5 +327,4 @@ PR_SS__cleanup_at_end_of_shutdown(); } - - +//==================================================== diff -r 2fc69e6c14ea -r 15ee3fe10e3d PR__PI.h --- a/PR__PI.h Fri Mar 08 05:34:21 2013 -0800 +++ b/PR__PI.h Thu Sep 05 17:38:19 2013 -0700 @@ -7,7 +7,7 @@ */ #ifndef _PR__PI_H -#define _PR__PI_H +#define _PR__PI_H #define _GNU_SOURCE @@ -39,6 +39,10 @@ #define \ PR_PI__create_slaveVP PR_int__create_slaveVP_helper + +#define \ +PR_PI__give_num_cores PR_SS__give_num_cores + //============== //=== Lang Data //= @@ -129,6 +133,9 @@ void PR_SS__create_the_coreCtlr_OS_threads(); +int +PR_SS__give_num_cores(); + //=================== void * PR_SS__create_lang_env( int32 size, SlaveVP *slave, int32 magicNum ); diff -r 2fc69e6c14ea -r 15ee3fe10e3d PR__SS.c --- a/PR__SS.c Fri Mar 08 05:34:21 2013 -0800 +++ b/PR__SS.c Thu Sep 05 17:38:19 2013 -0700 @@ -227,6 +227,15 @@ } } +/*This is intended to be called from lang plugin dynamic lib, and call + * into proto-runtime dynamic lib -- so, the call in the lang code + * will get different answers depending upon which PR impl it connects + * to. + */ +int +PR_SS__give_num_cores() + { return NUM_CORES; + } //====================== //=== diff -r 2fc69e6c14ea -r 15ee3fe10e3d PR__int.c --- a/PR__int.c Fri Mar 08 05:34:21 2013 -0800 +++ b/PR__int.c Thu Sep 05 17:38:19 2013 -0700 @@ -310,7 +310,7 @@ void * PR_int__give_lang_env( PRLangEnv *protoLangEnv ) { - return (void *) &(protoLangEnv[1]); + return (void *) &(protoLangEnv[1]); } inline PRLangEnv * @@ -567,18 +567,22 @@ inline void -PR_int__insert_meta_task_into_slave( PRMetaTask *task, SlaveVP *slave ) +PR_int__insert_meta_task_into_slave( PRMetaTask *metaTask, SlaveVP *slave ) { - task->slaveAssignedTo = slave; - PR_int__insert_elem_into_collection( (PRCollElem *)task, - (PRCollElem **)slave->metaTasks, task->langMagicNumber ); + metaTask->slaveAssignedTo = slave; + //at most one meta-task from a given language can be in slave, + // so use a form that replaces old meta task if one already there + PR_int__replace_or_insert_elem_into_collection( (PRCollElem *)metaTask, + (PRCollElem **)slave->metaTasks, metaTask->langMagicNumber ); } inline void PR_int__insert_lang_meta_task_into_slave( void *langMetaTask, SlaveVP *slave ) { PRMetaTask *metaTask = &(((PRMetaTask*)langMetaTask)[-1]); metaTask->slaveAssignedTo = slave; - PR_int__insert_elem_into_collection( (PRCollElem *)metaTask, + //at most one meta-task from a given language can be in slave, + // so use a form that replaces old meta task if one already there + PR_int__replace_or_insert_elem_into_collection( (PRCollElem *)metaTask, (PRCollElem **)slave->metaTasks, metaTask->langMagicNumber ); } @@ -615,7 +619,7 @@ metaTasks = (PRCollElem **)slave->metaTasks; retMetaTask = PR_int__lookup_elem_in_collection( magicNum, metaTasks ); - if( retMetaTask != NULL ) + if( retMetaTask != NULL ) return PR_int__give_lang_meta_task_of_prolog(retMetaTask); //skip over prolog else { protoLangEnv = PR_int__give_proto_lang_env_for_slave( slave, magicNum ); @@ -745,6 +749,40 @@ } inline +void +PR_int__replace_or_insert_elem_into_collection( PRCollElem *elem, + PRCollElem **coll, + int32 hash ) + { int32 idx, numIdxsInColl; + PRCollElem *test, **prevPtrLoc; + + numIdxsInColl = ((int32 *)coll)[-1]; //prolog holds number of idexes in array + + //figure out where to link in + idx = hash & (numIdxsInColl - 1); //mask off, leaving lowest bits + test = coll[idx]; + if( test == NULL ) + { //insert + coll[idx] = elem; + return; + } + //see if any elements match + prevPtrLoc = &(coll[idx]); + while( test->hash != hash ) + { prevPtrLoc = &(test->chained); + test = test->chained; + if( test == NULL ) + { //got to end of chain, not there, so add elem to end + *prevPtrLoc = elem; + return; + } + } + //found a match -- replace it + elem->chained = test->chained; + *prevPtrLoc = elem; + } + +inline void * PR_int__lookup_elem_in_collection( int32 hash, PRCollElem **coll ) { int32 idx, numIdxsInColl; @@ -832,6 +870,7 @@ /*Later, improve this -- for now, just exits the application after printing * the error message. */ + void PR_int__throw_exception( char *msgStr, SlaveVP *reqstSlv, PRExcp *excpData ) { diff -r 2fc69e6c14ea -r 15ee3fe10e3d PR__int.h --- a/PR__int.h Fri Mar 08 05:34:21 2013 -0800 +++ b/PR__int.h Thu Sep 05 17:38:19 2013 -0700 @@ -7,7 +7,7 @@ */ #ifndef _PR_INT_H -#define _PR_INT_H +#define _PR_INT_H #define _GNU_SOURCE @@ -195,6 +195,12 @@ PR_int__insert_elem_into_collection( PRCollElem *elem, PRCollElem **coll, int32 hash ); inline +void +PR_int__replace_or_insert_elem_into_collection( PRCollElem *elem, + PRCollElem **coll, + int32 hash ); + +inline void * PR_int__lookup_elem_in_collection( int32 hash, PRCollElem **coll ); @@ -216,6 +222,21 @@ void PR_int__error( char *msgStr ); +/*Some macro magic -- the __FILE__ turns into a string, and the + * preprocessor merges the quotes. But the __LINE__ turns into an int, + * so have to use the # operator to turn it into a string.. but the + * # operator doesn't expand what comes after, so have to do an extra + * level so that pre-processor first expands __LINE__ into number then + * hands to the # operator, which turns into string (then it merges + * quotes) + */ +#define PR__throw_simple_exception( throwingVP ) \ + do{ PR_int__throw_exception( __FILE__ ", " STR(__LINE__), throwingVP, NULL ); \ + } while(0) + +#define STR( s ) #s + + void PR_int__throw_exception( char *msgStr, SlaveVP *reqstSlv, PRExcp *excpData ); diff -r 2fc69e6c14ea -r 15ee3fe10e3d PR__structs.h --- a/PR__structs.h Fri Mar 08 05:34:21 2013 -0800 +++ b/PR__structs.h Thu Sep 05 17:38:19 2013 -0700 @@ -222,7 +222,7 @@ PRProcess *processSlaveIsIn; enum VPtype typeOfVP; //Slave vs Master vs Shutdown.. int32 slaveNum; //each slave given it's seq in creation - int32 *ID; //App defines meaning of each int in array + int32 *ID; //App defines meaning of each int in array int32 coreAnimatedBy; int32 numTimesAssignedToASlot; //Each assign is for one work-unit, so is an ID //note, a scheduling decision is uniquely identified by the triple: diff -r 2fc69e6c14ea -r 15ee3fe10e3d PR_req_handlers.c --- a/PR_req_handlers.c Fri Mar 08 05:34:21 2013 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,57 +0,0 @@ -/* - * Copyright 2010 OpenSourceStewardshipFoundation - * - * Licensed under BSD - */ - -#include -#include -#include -#include -#include -#include - -#include "PR.h" - - -/* MEANING OF WL PI SS int - * These indicate which places the function is safe to use. They stand for: - * WL: Wrapper Library - * PI: Plugin - * SS: Startup and Shutdown - * int: internal to the PR implementation - */ - - -/* - */ -void inline -handleMakeProbe( PRSemReq *semReq, void *semEnv, ResumeSlvFnPtr resumeFn ) - { IntervalProbe *newProbe; - - newProbe = PR_int__malloc( sizeof(IntervalProbe) ); - newProbe->nameStr = PR_int__strDup( semReq->nameStr ); - newProbe->hist = NULL; - newProbe->schedChoiceWasRecorded = FALSE; - - //This runs in masterVP, so no race-condition worries - newProbe->probeID = - addToDynArray( newProbe, _PRMasterEnv->dynIntervalProbesInfo ); - - semReq->requestingSlv->dataRetFromReq = newProbe; - - //This in inside PR, while resume_slaveVP fn is inside language, so pass - // pointer from lang to here, then call it. - (*resumeFn)( semReq->requestingSlv, semEnv ); - } - -void inline -handleThrowException( PRSemReq *semReq, void *semEnv, ResumeSlvFnPtr resumeFn ) - { - PR_int__throw_exception( semReq->msgStr, semReq->requestingSlv, semReq->exceptionData ); - - (*resumeFn)( semReq->requestingSlv, semEnv ); - } - - - diff -r 2fc69e6c14ea -r 15ee3fe10e3d Services_Offered_by_PR/Debugging/DEBUG__macros.h --- a/Services_Offered_by_PR/Debugging/DEBUG__macros.h Fri Mar 08 05:34:21 2013 -0800 +++ b/Services_Offered_by_PR/Debugging/DEBUG__macros.h Thu Sep 05 17:38:19 2013 -0700 @@ -13,10 +13,10 @@ /* */ #ifdef DEBUG__TURN_ON_DEBUG_PRINT - #define DEBUG__printf( bool, msg) \ + #define DEBUG__printf( bool, ...) \ do{\ if(bool)\ - { printf(msg);\ + { printf( __VA_ARGS__ );\ printf(" | function: %s\n", __FUNCTION__);\ fflush(stdin);\ }\ diff -r 2fc69e6c14ea -r 15ee3fe10e3d Services_Offered_by_PR/Measurement_and_Stats/MEAS__Counter_Recording.c --- a/Services_Offered_by_PR/Measurement_and_Stats/MEAS__Counter_Recording.c Fri Mar 08 05:34:21 2013 -0800 +++ b/Services_Offered_by_PR/Measurement_and_Stats/MEAS__Counter_Recording.c Thu Sep 05 17:38:19 2013 -0700 @@ -3,7 +3,7 @@ * author: Nina Engelhardt */ -#include "PR_MEAS__Counter_Recording.h" +#include "MEAS__Counter_Recording.h" #include "PR_impl/PR.h" //#include "../PRServ.h" diff -r 2fc69e6c14ea -r 15ee3fe10e3d Services_Offered_by_PR/Services_Language/PRServ.c --- a/Services_Offered_by_PR/Services_Language/PRServ.c Fri Mar 08 05:34:21 2013 -0800 +++ b/Services_Offered_by_PR/Services_Language/PRServ.c Thu Sep 05 17:38:19 2013 -0700 @@ -99,11 +99,18 @@ inline int32 * PRServ__give_self_taskID( SlaveVP *animSlv ) + { void *metaTask; + metaTask = PR_WL__give_lang_meta_task_from_slave( animSlv, PRServ_MAGIC_NUMBER ); + return PR__give_ID_from_lang_meta_task( metaTask ); + } + +inline +int32 * +PRServ__give_slave_ID( SlaveVP *animSlv ) { return PR__give_ID_from_slave( animSlv, PRServ_MAGIC_NUMBER ); } - /* *This function returns information about the version of PR, the language * the program is being run in, its version, and information on the diff -r 2fc69e6c14ea -r 15ee3fe10e3d Services_Offered_by_PR/Services_Language/PRServ.h --- a/Services_Offered_by_PR/Services_Language/PRServ.h Fri Mar 08 05:34:21 2013 -0800 +++ b/Services_Offered_by_PR/Services_Language/PRServ.h Thu Sep 05 17:38:19 2013 -0700 @@ -92,7 +92,7 @@ typedef struct { - PrivQueueStruc *slavesReadyToResumeQ; //Shared (slaves not pinned) + PrivQueueStruc *slaveReadyQ; //Shared (slaves not pinned) PrivQueueStruc *taskReadyQ; //will never be used in seed langlet int32 primitiveStartTime; diff -r 2fc69e6c14ea -r 15ee3fe10e3d Services_Offered_by_PR/Services_Language/PRServ_PluginFns.c --- a/Services_Offered_by_PR/Services_Language/PRServ_PluginFns.c Fri Mar 08 05:34:21 2013 -0800 +++ b/Services_Offered_by_PR/Services_Language/PRServ_PluginFns.c Thu Sep 05 17:38:19 2013 -0700 @@ -52,7 +52,7 @@ langEnv = (PRServLangEnv *)_langEnv; //Check for suspended slaves that are ready to resume - returnSlv = readPrivQ( langEnv->slavesReadyToResumeQ ); + returnSlv = readPrivQ( langEnv->slaveReadyQ ); if( returnSlv != NULL ) //Yes, have a slave, so return it. { returnSlv->coreAnimatedBy = coreNum; @@ -117,7 +117,7 @@ } #endif /* PR handles work available in lang env and in process.. - if( isEmptyPrivQ(langEnv->slavesReadyToResumeQ) && + if( isEmptyPrivQ(langEnv->slaveReadyQ) && isEmptyPrivQ(langEnv->taskReadyQ) ) PR_int__clear_work_in_lang_env(langEnv); */ diff -r 2fc69e6c14ea -r 15ee3fe10e3d Services_Offered_by_PR/Services_Language/PRServ_Request_Handlers.c --- a/Services_Offered_by_PR/Services_Language/PRServ_Request_Handlers.c Fri Mar 08 05:34:21 2013 -0800 +++ b/Services_Offered_by_PR/Services_Language/PRServ_Request_Handlers.c Thu Sep 05 17:38:19 2013 -0700 @@ -291,7 +291,7 @@ { PRServLangEnv *langEnv = (PRServLangEnv *)_langEnv; //both suspended tasks and suspended explicit slaves resumed with this - writePrivQ( slave, langEnv->slavesReadyToResumeQ ); + writePrivQ( slave, langEnv->slaveReadyQ ); //PR handles this.. PR_int__set_work_in_lang_env(langEnv); #ifdef HOLISTIC__TURN_ON_PERF_COUNTERS diff -r 2fc69e6c14ea -r 15ee3fe10e3d Services_Offered_by_PR/Services_Language/PRServ_SS.c --- a/Services_Offered_by_PR/Services_Language/PRServ_SS.c Fri Mar 08 05:34:21 2013 -0800 +++ b/Services_Offered_by_PR/Services_Language/PRServ_SS.c Thu Sep 05 17:38:19 2013 -0700 @@ -31,7 +31,7 @@ //create the ready queues - langEnv->slavesReadyToResumeQ = makePRQ(); + langEnv->slaveReadyQ = makePRQ(); langEnv->taskReadyQ = makePRQ(); //register the langlet's handlers with PR @@ -206,7 +206,7 @@ SlaveVP *slave; //dissipate any slaves still in the readyQ, because this is last lang - queue = langEnv->slavesReadyToResumeQ; + queue = langEnv->slaveReadyQ; slave = readPrivQ( queue ); while( slave != NULL ) {