# HG changeset patch # User Sean Halle # Date 1380039330 25200 # Node ID 6c0691c4f2a6c050ac88873c3cf57aa503b5e61c # Parent d460a47ed2d6b02df6741933a7ebdbf65244ea06 Added prdsl and PRServ wrapper libraries diff -r d460a47ed2d6 -r 6c0691c4f2a6 PR__PI.h --- a/PR__PI.h Thu Aug 08 02:39:56 2013 -0700 +++ b/PR__PI.h Tue Sep 24 09:15:30 2013 -0700 @@ -46,8 +46,9 @@ #define \ PR_SS__give_lang_data_from_slave PR_int__give_lang_data_from_slave -int32 -PR_PI__give_num_cores(); +#define \ +PR_PI__give_num_cores PR_SS__give_num_cores + //============ //=== Lang Env @@ -130,6 +131,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 d460a47ed2d6 -r 6c0691c4f2a6 PR__int.h --- a/PR__int.h Thu Aug 08 02:39:56 2013 -0700 +++ b/PR__int.h Tue Sep 24 09:15:30 2013 -0700 @@ -197,6 +197,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 ); @@ -221,6 +227,20 @@ void PR_int__throw_exception( char *msgStr, SlaveVP *reqstSlv, PRExcp *excpData ); +/*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 + char * PR_int__strDup( char *str ); diff -r d460a47ed2d6 -r 6c0691c4f2a6 PR__structs__common.h --- a/PR__structs__common.h Thu Aug 08 02:39:56 2013 -0700 +++ b/PR__structs__common.h Tue Sep 24 09:15:30 2013 -0700 @@ -80,7 +80,7 @@ PRLangEnv **langEnvs; //used as a hash table PRLangEnv **protoLangEnvsList; //for fast linear scan of envs - int32 numLangEnvs; //for fast linear scan of envs + int32 numLangEnvs; //for fast linear scan of envs SlaveVP *seedSlv; @@ -89,6 +89,7 @@ SlaveAssigner overrideAssigner; + int32 numConsecutiveTasks; //These are used to coord with an OS thread waiting for process to end @@ -146,7 +147,7 @@ int32 langMagicNumber; SlaveVP *requestingSlave; - BirthFnPtr topLevelFn; + BirthFnPtr birthFn; void *initData; int32 *ID; @@ -243,6 +244,8 @@ PRLangData **langDatas; //Lang saves lang-specific things in slave here PRMetaTask **metaTasks; +// PRGhostInfo *ghostInfo; + //=========== MEASUREMENT STUFF ========== MEAS__Insert_Meas_Fields_into_Slave; float64 createPtInSecs; //time VP created, in seconds @@ -305,7 +308,7 @@ int32 *ID; //is standard PR ID PRProcess *processTaskIsIn; SlaveVP *slaveAssignedTo; //not valid until task animated - BirthFnPtr topLevelFn; //This is the Fn executes as the task + BirthFnPtr birthFn; //This is the Fn executes as the task void *initData; //The data taken by the function LangMetaTaskFreer freer; bool32 goAheadAndFree; diff -r d460a47ed2d6 -r 6c0691c4f2a6 Services_offered_by_PR/MEAS__Counter_Recording.h --- a/Services_offered_by_PR/MEAS__Counter_Recording.h Thu Aug 08 02:39:56 2013 -0700 +++ b/Services_offered_by_PR/MEAS__Counter_Recording.h Tue Sep 24 09:15:30 2013 -0700 @@ -8,7 +8,8 @@ #ifndef MEAS__COUNTER_RECORDING_H #define MEAS__COUNTER_RECORDING_H -#include "PR__common_includes/PR__common_structs.h" + +#include typedef struct { diff -r d460a47ed2d6 -r 6c0691c4f2a6 langlets/PRServ__wrapper_library.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langlets/PRServ__wrapper_library.h Tue Sep 24 09:15:30 2013 -0700 @@ -0,0 +1,171 @@ +/* + * Copyright 2009-2013 OpenSourceResearchInstitute.org + * Licensed under GNU General Public License version 2 + * + * Author: seanhalle@yahoo.com + * + */ + +#ifndef _PRServ_wrapper_library_H +#define _PRServ_wrapper_library_H + +#include + + +//=========================================================================== +typedef void (*PtrToAtomicFn ) ( void * ); //executed atomically in master + +typedef struct _DKUPiece DKUPiece; +typedef struct _DKUInstance DKUInstance; + +typedef void (*DKUKernel ) ( void *, SlaveVP * ); //used as task birth Fn +typedef void (*DKUSerialKernel ) ( void *, SlaveVP * ); //used as task birth Fn +typedef void (*DKUDivider ) ( DKUPiece * ); +typedef void (*DKUUndivider ) ( DKUPiece * ); + +typedef DKUPiece * (*DKURootPieceMaker) ( void *, DKUInstance * ); + +struct _DKUInstance + { + DKURootPieceMaker rootPieceMaker; + DKUKernel kernel; + DKUSerialKernel serialKernel; + DKUDivider divider; + DKUUndivider undivider; + }; + +struct _DKUPiece + { + void *payload; + DKUPiece *parent; + DKUPiece **children; + int32 numChildren; + int32 numUnfinishedChildren; + DKUInstance *dkuInstance; //to get kernel and undivider + void *undividerInfo; //divider communicates to undivider + SlaveVP *waitingVP; + bool32 wasRecursivelyDivided; + }; + + + + + + + + +/*WARNING: assembly hard-codes position of endInstrAddr as first field + */ +typedef struct + { + void *endInstrAddr; + int32 hasBeenStarted; + int32 hasFinished; + PrivQueueStruc *waitQ; + } +PRServSingleton; + + +//=========================================================================== + +int32 +PRServ__giveMinWorkUnitCycles( float32 percentOverhead ); + +void +PRServ__begin_primitive(); + +int32 +PRServ__end_primitive_and_give_cycles(); + +int32 +PRServ__giveIdealNumWorkUnits(); + +int32 +PRServ__give_number_of_cores_to_schedule_onto(); + +char * +PRServ___give_environment_string(); + +//======================= + +void +PRServ__end_seedVP( SlaveVP *seedSlv ); +//======================= + +inline int32 * +PRServ__create_taskID_of_size( int32 numInts, SlaveVP *animSlv ); + +//========================= +void +PRServ__taskwait(SlaveVP *animSlv); + +inline int32 * +PRServ__give_self_taskID( SlaveVP *animSlv ); + +//======================= Concurrency Stuff ====================== +void +PRServ__start_fn_singleton( int32 singletonID, SlaveVP *animSlv ); + +void +PRServ__end_fn_singleton( int32 singletonID, SlaveVP *animSlv ); + +void +PRServ__start_data_singleton( PRServSingleton **singeltonAddr, SlaveVP *animSlv ); + +void +PRServ__end_data_singleton( PRServSingleton **singletonAddr, SlaveVP *animSlv ); + +void +PRServ__animate_short_fn_in_isolation( PtrToAtomicFn ptrToFnToExecInMaster, + void *data, SlaveVP *animSlv ); + +void +PRServ__start_transaction( int32 transactionID, SlaveVP *animSlv ); + +void +PRServ__end_transaction( int32 transactionID, SlaveVP *animSlv ); + +//============================== DKU ============================= +DKUInstance * +PRServ__DKU_make_empty_DKU_instance( SlaveVP *animSlv ); + +DKUPiece * +PRServ__DKU_make_empty_DKU_piece(); + +DKUPiece * +PRServ__DKU_make_child_piece_from( pieceToDivide ); + +void +PRServ__DKU_set_root_piece_maker( DKUInstance *dkuInstance, + DKURootPieceMaker rootPieceMakerFn, + SlaveVP *animSlv ); +void +PRServ__DKU_set_kernel( DKUInstance *dkuInstance, + DKUKernel kernelFn, + SlaveVP *animSlv ); +void +PRServ__DKU_set_serial_kernel( DKUInstance *dkuInstance, + DKUSerialKernel serialKernelFn, + SlaveVP *animSlv ); +void +PRServ__DKU_set_divider( DKUInstance *dkuInstance, + DKUDivider dividerFn, + SlaveVP *animSlv ); +void +PRServ__DKU_set_undivider( DKUInstance *dkuInstance, + DKUUndivider undividerFn, + SlaveVP *animSlv ); +DKUPiece * +PRServ__DKU_make_root_piece( DKUInstance *dkuInstance, + void *data, + SlaveVP *animSlv ); +void +PRServ__DKU_perform_work_on( DKUPiece *rootPiece, + SlaveVP *animSlv ); +void +PRServ__DKU_wait_for_result_to_be_complete( DKUPiece *rootPiece, + SlaveVP *animSlv ); + +//=========================================================================== +#endif /* _PRServ_H */ + diff -r d460a47ed2d6 -r 6c0691c4f2a6 langlets/prdsl_wrapper_library.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langlets/prdsl_wrapper_library.h Tue Sep 24 09:15:30 2013 -0700 @@ -0,0 +1,93 @@ +/* + * Copyright 2009 OpenSourceResearchInstitute.org + * Licensed under GNU General Public License version 2 + * + * Author: seanhalle@yahoo.com + * + */ + +#ifndef _PRDSL_WRAPPER_H +#define _PRDSL_WRAPPER_H + +#include + +//=========================================================================== + //uniquely identifies PRDSL -- should be a jenkins char-hash of "PRDSL" to int32 +#define PRDSL_MAGIC_NUMBER 0000000004 + +typedef struct _PRDSLTaskStub PRDSLTaskStub; + +//=========================================================================== + +/*This is PRDSL's "lang meta task" + *See the proto-runtime wiki entry to learn about "lang meta task" + *In essence, this holds all the meta information that PRDSL needs about a task + */ +struct _PRDSLTaskStub + { + void **args; //given to the birth Fn + int32 numBlockingProp; + PrivQueueStruc *dependentTasksQ; + bool32 isActive; //active after done adding propendents + bool32 canBeAProp; + + PRDSLTaskStub *parentTaskStub; //for liveness, for the wait construct + int32 numLiveChildTasks; + int32 numLiveChildVPs; + bool32 isWaitingForChildTasksToEnd; + bool32 isWaitingForChildThreadsToEnd; + bool32 isEnded; + +// int32 *taskID; //is in PRMetaTask, in prolog + }; + + +//======================= + +void +PRDSL__start( SlaveVP *seedSlv ); + +void +PRDSL__shutdown( SlaveVP *seedSlv ); + +void +PRDSL__wait_for_all_PRDSL_created_work_to_end( SlaveVP *seedSlv ); + +//======================= + +SlaveVP * +PRDSL__create_thread( BirthFnPtr fnPtr, void *initData, + SlaveVP *creatingThd ); + +void +PRDSL__end_thread( SlaveVP *thdToEnd ); + +//======================= + +#define PRDSL__malloc( numBytes, callingSlave ) PR_App__malloc( numBytes, callingSlave) + +#define PRDSL__free(ptrToFree, callingSlave ) PR_App__free( ptrToFree, callingSlave ) + + +//======================= +PRDSLTaskStub * +PRDSL__create_task_ready_to_run( BirthFnPtr birthFn, void *args, SlaveVP *animSlv); + +//inline int32 * +//PRDSL__create_taskID_of_size( int32 numInts, SlaveVP *animSlv ); + + +void +PRDSL__end_task( SlaveVP *animSlv ); + +//========================= +void +PRDSL__taskwait(SlaveVP *animSlv); + + +inline int32 * +PRDSL__give_self_taskID( SlaveVP *animSlv ); + +//=========================================================================== +#endif +