Mercurial > cgi-bin > hgwebdir.cgi > PR > PR_Implementations > PR__Univ > PR__includes > PR__include
changeset 8:6c0691c4f2a6 Dev_Univ
Added prdsl and PRServ wrapper libraries
| author | Sean Halle <seanhalle@yahoo.com> |
|---|---|
| date | Tue, 24 Sep 2013 09:15:30 -0700 |
| parents | d460a47ed2d6 |
| children | bc0d410c3f58 |
| files | PR__PI.h PR__int.h PR__structs__common.h Services_offered_by_PR/MEAS__Counter_Recording.h langlets/PRServ__wrapper_library.h langlets/prdsl_wrapper_library.h |
| diffstat | 6 files changed, 298 insertions(+), 6 deletions(-) [+] |
line diff
1.1 --- a/PR__PI.h Thu Aug 08 02:39:56 2013 -0700 1.2 +++ b/PR__PI.h Tue Sep 24 09:15:30 2013 -0700 1.3 @@ -46,8 +46,9 @@ 1.4 #define \ 1.5 PR_SS__give_lang_data_from_slave PR_int__give_lang_data_from_slave 1.6 1.7 -int32 1.8 -PR_PI__give_num_cores(); 1.9 +#define \ 1.10 +PR_PI__give_num_cores PR_SS__give_num_cores 1.11 + 1.12 1.13 //============ 1.14 //=== Lang Env 1.15 @@ -130,6 +131,9 @@ 1.16 void 1.17 PR_SS__create_the_coreCtlr_OS_threads(); 1.18 1.19 +int 1.20 +PR_SS__give_num_cores(); 1.21 + 1.22 //=================== 1.23 void * 1.24 PR_SS__create_lang_env( int32 size, SlaveVP *slave, int32 magicNum );
2.1 --- a/PR__int.h Thu Aug 08 02:39:56 2013 -0700 2.2 +++ b/PR__int.h Tue Sep 24 09:15:30 2013 -0700 2.3 @@ -197,6 +197,12 @@ 2.4 PR_int__insert_elem_into_collection( PRCollElem *elem, PRCollElem **coll, int32 hash ); 2.5 2.6 inline 2.7 +void 2.8 +PR_int__replace_or_insert_elem_into_collection( PRCollElem *elem, 2.9 + PRCollElem **coll, 2.10 + int32 hash ); 2.11 + 2.12 +inline 2.13 void * 2.14 PR_int__lookup_elem_in_collection( int32 hash, PRCollElem **coll ); 2.15 2.16 @@ -221,6 +227,20 @@ 2.17 void 2.18 PR_int__throw_exception( char *msgStr, SlaveVP *reqstSlv, PRExcp *excpData ); 2.19 2.20 +/*Some macro magic -- the __FILE__ turns into a string, and the 2.21 + * preprocessor merges the quotes. But the __LINE__ turns into an int, 2.22 + * so have to use the # operator to turn it into a string.. but the 2.23 + * # operator doesn't expand what comes after, so have to do an extra 2.24 + * level so that pre-processor first expands __LINE__ into number then 2.25 + * hands to the # operator, which turns into string (then it merges 2.26 + * quotes) 2.27 + */ 2.28 +#define PR__throw_simple_exception( throwingVP ) \ 2.29 + do{ PR_int__throw_exception( __FILE__ ", " STR(__LINE__), throwingVP, NULL ); \ 2.30 + } while(0) 2.31 + 2.32 +#define STR( s ) #s 2.33 + 2.34 char * 2.35 PR_int__strDup( char *str ); 2.36
3.1 --- a/PR__structs__common.h Thu Aug 08 02:39:56 2013 -0700 3.2 +++ b/PR__structs__common.h Tue Sep 24 09:15:30 2013 -0700 3.3 @@ -80,7 +80,7 @@ 3.4 3.5 PRLangEnv **langEnvs; //used as a hash table 3.6 PRLangEnv **protoLangEnvsList; //for fast linear scan of envs 3.7 - int32 numLangEnvs; //for fast linear scan of envs 3.8 + int32 numLangEnvs; //for fast linear scan of envs 3.9 3.10 SlaveVP *seedSlv; 3.11 3.12 @@ -89,6 +89,7 @@ 3.13 3.14 SlaveAssigner overrideAssigner; 3.15 3.16 + int32 numConsecutiveTasks; 3.17 3.18 3.19 //These are used to coord with an OS thread waiting for process to end 3.20 @@ -146,7 +147,7 @@ 3.21 int32 langMagicNumber; 3.22 SlaveVP *requestingSlave; 3.23 3.24 - BirthFnPtr topLevelFn; 3.25 + BirthFnPtr birthFn; 3.26 void *initData; 3.27 int32 *ID; 3.28 3.29 @@ -243,6 +244,8 @@ 3.30 PRLangData **langDatas; //Lang saves lang-specific things in slave here 3.31 PRMetaTask **metaTasks; 3.32 3.33 +// PRGhostInfo *ghostInfo; 3.34 + 3.35 //=========== MEASUREMENT STUFF ========== 3.36 MEAS__Insert_Meas_Fields_into_Slave; 3.37 float64 createPtInSecs; //time VP created, in seconds 3.38 @@ -305,7 +308,7 @@ 3.39 int32 *ID; //is standard PR ID 3.40 PRProcess *processTaskIsIn; 3.41 SlaveVP *slaveAssignedTo; //not valid until task animated 3.42 - BirthFnPtr topLevelFn; //This is the Fn executes as the task 3.43 + BirthFnPtr birthFn; //This is the Fn executes as the task 3.44 void *initData; //The data taken by the function 3.45 LangMetaTaskFreer freer; 3.46 bool32 goAheadAndFree;
4.1 --- a/Services_offered_by_PR/MEAS__Counter_Recording.h Thu Aug 08 02:39:56 2013 -0700 4.2 +++ b/Services_offered_by_PR/MEAS__Counter_Recording.h Tue Sep 24 09:15:30 2013 -0700 4.3 @@ -8,7 +8,8 @@ 4.4 #ifndef MEAS__COUNTER_RECORDING_H 4.5 #define MEAS__COUNTER_RECORDING_H 4.6 4.7 -#include "PR__common_includes/PR__common_structs.h" 4.8 + 4.9 +#include <PR__include/PR__structs__common.h> 4.10 4.11 typedef struct 4.12 {
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 5.2 +++ b/langlets/PRServ__wrapper_library.h Tue Sep 24 09:15:30 2013 -0700 5.3 @@ -0,0 +1,171 @@ 5.4 +/* 5.5 + * Copyright 2009-2013 OpenSourceResearchInstitute.org 5.6 + * Licensed under GNU General Public License version 2 5.7 + * 5.8 + * Author: seanhalle@yahoo.com 5.9 + * 5.10 + */ 5.11 + 5.12 +#ifndef _PRServ_wrapper_library_H 5.13 +#define _PRServ_wrapper_library_H 5.14 + 5.15 +#include <PR__include/PR__structs__common.h> 5.16 + 5.17 + 5.18 +//=========================================================================== 5.19 +typedef void (*PtrToAtomicFn ) ( void * ); //executed atomically in master 5.20 + 5.21 +typedef struct _DKUPiece DKUPiece; 5.22 +typedef struct _DKUInstance DKUInstance; 5.23 + 5.24 +typedef void (*DKUKernel ) ( void *, SlaveVP * ); //used as task birth Fn 5.25 +typedef void (*DKUSerialKernel ) ( void *, SlaveVP * ); //used as task birth Fn 5.26 +typedef void (*DKUDivider ) ( DKUPiece * ); 5.27 +typedef void (*DKUUndivider ) ( DKUPiece * ); 5.28 + 5.29 +typedef DKUPiece * (*DKURootPieceMaker) ( void *, DKUInstance * ); 5.30 + 5.31 +struct _DKUInstance 5.32 + { 5.33 + DKURootPieceMaker rootPieceMaker; 5.34 + DKUKernel kernel; 5.35 + DKUSerialKernel serialKernel; 5.36 + DKUDivider divider; 5.37 + DKUUndivider undivider; 5.38 + }; 5.39 + 5.40 +struct _DKUPiece 5.41 + { 5.42 + void *payload; 5.43 + DKUPiece *parent; 5.44 + DKUPiece **children; 5.45 + int32 numChildren; 5.46 + int32 numUnfinishedChildren; 5.47 + DKUInstance *dkuInstance; //to get kernel and undivider 5.48 + void *undividerInfo; //divider communicates to undivider 5.49 + SlaveVP *waitingVP; 5.50 + bool32 wasRecursivelyDivided; 5.51 + }; 5.52 + 5.53 + 5.54 + 5.55 + 5.56 + 5.57 + 5.58 + 5.59 + 5.60 +/*WARNING: assembly hard-codes position of endInstrAddr as first field 5.61 + */ 5.62 +typedef struct 5.63 + { 5.64 + void *endInstrAddr; 5.65 + int32 hasBeenStarted; 5.66 + int32 hasFinished; 5.67 + PrivQueueStruc *waitQ; 5.68 + } 5.69 +PRServSingleton; 5.70 + 5.71 + 5.72 +//=========================================================================== 5.73 + 5.74 +int32 5.75 +PRServ__giveMinWorkUnitCycles( float32 percentOverhead ); 5.76 + 5.77 +void 5.78 +PRServ__begin_primitive(); 5.79 + 5.80 +int32 5.81 +PRServ__end_primitive_and_give_cycles(); 5.82 + 5.83 +int32 5.84 +PRServ__giveIdealNumWorkUnits(); 5.85 + 5.86 +int32 5.87 +PRServ__give_number_of_cores_to_schedule_onto(); 5.88 + 5.89 +char * 5.90 +PRServ___give_environment_string(); 5.91 + 5.92 +//======================= 5.93 + 5.94 +void 5.95 +PRServ__end_seedVP( SlaveVP *seedSlv ); 5.96 +//======================= 5.97 + 5.98 +inline int32 * 5.99 +PRServ__create_taskID_of_size( int32 numInts, SlaveVP *animSlv ); 5.100 + 5.101 +//========================= 5.102 +void 5.103 +PRServ__taskwait(SlaveVP *animSlv); 5.104 + 5.105 +inline int32 * 5.106 +PRServ__give_self_taskID( SlaveVP *animSlv ); 5.107 + 5.108 +//======================= Concurrency Stuff ====================== 5.109 +void 5.110 +PRServ__start_fn_singleton( int32 singletonID, SlaveVP *animSlv ); 5.111 + 5.112 +void 5.113 +PRServ__end_fn_singleton( int32 singletonID, SlaveVP *animSlv ); 5.114 + 5.115 +void 5.116 +PRServ__start_data_singleton( PRServSingleton **singeltonAddr, SlaveVP *animSlv ); 5.117 + 5.118 +void 5.119 +PRServ__end_data_singleton( PRServSingleton **singletonAddr, SlaveVP *animSlv ); 5.120 + 5.121 +void 5.122 +PRServ__animate_short_fn_in_isolation( PtrToAtomicFn ptrToFnToExecInMaster, 5.123 + void *data, SlaveVP *animSlv ); 5.124 + 5.125 +void 5.126 +PRServ__start_transaction( int32 transactionID, SlaveVP *animSlv ); 5.127 + 5.128 +void 5.129 +PRServ__end_transaction( int32 transactionID, SlaveVP *animSlv ); 5.130 + 5.131 +//============================== DKU ============================= 5.132 +DKUInstance * 5.133 +PRServ__DKU_make_empty_DKU_instance( SlaveVP *animSlv ); 5.134 + 5.135 +DKUPiece * 5.136 +PRServ__DKU_make_empty_DKU_piece(); 5.137 + 5.138 +DKUPiece * 5.139 +PRServ__DKU_make_child_piece_from( pieceToDivide ); 5.140 + 5.141 +void 5.142 +PRServ__DKU_set_root_piece_maker( DKUInstance *dkuInstance, 5.143 + DKURootPieceMaker rootPieceMakerFn, 5.144 + SlaveVP *animSlv ); 5.145 +void 5.146 +PRServ__DKU_set_kernel( DKUInstance *dkuInstance, 5.147 + DKUKernel kernelFn, 5.148 + SlaveVP *animSlv ); 5.149 +void 5.150 +PRServ__DKU_set_serial_kernel( DKUInstance *dkuInstance, 5.151 + DKUSerialKernel serialKernelFn, 5.152 + SlaveVP *animSlv ); 5.153 +void 5.154 +PRServ__DKU_set_divider( DKUInstance *dkuInstance, 5.155 + DKUDivider dividerFn, 5.156 + SlaveVP *animSlv ); 5.157 +void 5.158 +PRServ__DKU_set_undivider( DKUInstance *dkuInstance, 5.159 + DKUUndivider undividerFn, 5.160 + SlaveVP *animSlv ); 5.161 +DKUPiece * 5.162 +PRServ__DKU_make_root_piece( DKUInstance *dkuInstance, 5.163 + void *data, 5.164 + SlaveVP *animSlv ); 5.165 +void 5.166 +PRServ__DKU_perform_work_on( DKUPiece *rootPiece, 5.167 + SlaveVP *animSlv ); 5.168 +void 5.169 +PRServ__DKU_wait_for_result_to_be_complete( DKUPiece *rootPiece, 5.170 + SlaveVP *animSlv ); 5.171 + 5.172 +//=========================================================================== 5.173 +#endif /* _PRServ_H */ 5.174 +
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 6.2 +++ b/langlets/prdsl_wrapper_library.h Tue Sep 24 09:15:30 2013 -0700 6.3 @@ -0,0 +1,93 @@ 6.4 +/* 6.5 + * Copyright 2009 OpenSourceResearchInstitute.org 6.6 + * Licensed under GNU General Public License version 2 6.7 + * 6.8 + * Author: seanhalle@yahoo.com 6.9 + * 6.10 + */ 6.11 + 6.12 +#ifndef _PRDSL_WRAPPER_H 6.13 +#define _PRDSL_WRAPPER_H 6.14 + 6.15 +#include <PR__include/PR__structs__common.h> 6.16 + 6.17 +//=========================================================================== 6.18 + //uniquely identifies PRDSL -- should be a jenkins char-hash of "PRDSL" to int32 6.19 +#define PRDSL_MAGIC_NUMBER 0000000004 6.20 + 6.21 +typedef struct _PRDSLTaskStub PRDSLTaskStub; 6.22 + 6.23 +//=========================================================================== 6.24 + 6.25 +/*This is PRDSL's "lang meta task" 6.26 + *See the proto-runtime wiki entry to learn about "lang meta task" 6.27 + *In essence, this holds all the meta information that PRDSL needs about a task 6.28 + */ 6.29 +struct _PRDSLTaskStub 6.30 + { 6.31 + void **args; //given to the birth Fn 6.32 + int32 numBlockingProp; 6.33 + PrivQueueStruc *dependentTasksQ; 6.34 + bool32 isActive; //active after done adding propendents 6.35 + bool32 canBeAProp; 6.36 + 6.37 + PRDSLTaskStub *parentTaskStub; //for liveness, for the wait construct 6.38 + int32 numLiveChildTasks; 6.39 + int32 numLiveChildVPs; 6.40 + bool32 isWaitingForChildTasksToEnd; 6.41 + bool32 isWaitingForChildThreadsToEnd; 6.42 + bool32 isEnded; 6.43 + 6.44 +// int32 *taskID; //is in PRMetaTask, in prolog 6.45 + }; 6.46 + 6.47 + 6.48 +//======================= 6.49 + 6.50 +void 6.51 +PRDSL__start( SlaveVP *seedSlv ); 6.52 + 6.53 +void 6.54 +PRDSL__shutdown( SlaveVP *seedSlv ); 6.55 + 6.56 +void 6.57 +PRDSL__wait_for_all_PRDSL_created_work_to_end( SlaveVP *seedSlv ); 6.58 + 6.59 +//======================= 6.60 + 6.61 +SlaveVP * 6.62 +PRDSL__create_thread( BirthFnPtr fnPtr, void *initData, 6.63 + SlaveVP *creatingThd ); 6.64 + 6.65 +void 6.66 +PRDSL__end_thread( SlaveVP *thdToEnd ); 6.67 + 6.68 +//======================= 6.69 + 6.70 +#define PRDSL__malloc( numBytes, callingSlave ) PR_App__malloc( numBytes, callingSlave) 6.71 + 6.72 +#define PRDSL__free(ptrToFree, callingSlave ) PR_App__free( ptrToFree, callingSlave ) 6.73 + 6.74 + 6.75 +//======================= 6.76 +PRDSLTaskStub * 6.77 +PRDSL__create_task_ready_to_run( BirthFnPtr birthFn, void *args, SlaveVP *animSlv); 6.78 + 6.79 +//inline int32 * 6.80 +//PRDSL__create_taskID_of_size( int32 numInts, SlaveVP *animSlv ); 6.81 + 6.82 + 6.83 +void 6.84 +PRDSL__end_task( SlaveVP *animSlv ); 6.85 + 6.86 +//========================= 6.87 +void 6.88 +PRDSL__taskwait(SlaveVP *animSlv); 6.89 + 6.90 + 6.91 +inline int32 * 6.92 +PRDSL__give_self_taskID( SlaveVP *animSlv ); 6.93 + 6.94 +//=========================================================================== 6.95 +#endif 6.96 +
