Mercurial > cgi-bin > hgwebdir.cgi > PR > PR_Implementations > PR__Univ > PR__includes > PR__include
changeset 18:2d96f0ad026e ML_lib_longjmp
Changes for longjmp version of PRT
| author | PhilipeLouchtch |
|---|---|
| date | Fri, 28 Feb 2014 21:16:50 +0100 |
| parents | ad931059d1c4 |
| children | 45f7cf8a80eb |
| files | PR__PI.h PR__structs__common.h __brch__ML_lib __brch__ML_lib_longjmp |
| diffstat | 4 files changed, 509 insertions(+), 501 deletions(-) [+] |
line diff
1.1 --- a/PR__PI.h Sun Oct 06 11:26:20 2013 -0700 1.2 +++ b/PR__PI.h Fri Feb 28 21:16:50 2014 +0100 1.3 @@ -1,124 +1,127 @@ 1.4 -/* 1.5 - * Copyright 2009 OpenSourceResearchInstitute.org 1.6 - * Licensed under GNU General Public License version 2 1.7 - * 1.8 - * Author: seanhalle@yahoo.com 1.9 - * 1.10 - */ 1.11 - 1.12 -#ifndef _PR__PI_H 1.13 -#define _PR__PI_H 1.14 -#define _GNU_SOURCE 1.15 - 1.16 -#include <PR__include/PR__structs__common.h> 1.17 - 1.18 -//========================= Function Prototypes =========================== 1.19 -/* MEANING OF WL PI SS int PROS 1.20 - * These indicate which places the function is safe to use. They stand for: 1.21 - * 1.22 - * WL Wrapper Library -- wrapper lib code should only use these 1.23 - * PI Plugin -- plugin code should only use these 1.24 - * SS Startup and Shutdown -- designates these relate to startup & shutdown 1.25 - * int32internal to PR -- should not be used in wrapper lib or plugin 1.26 - * PROS means "OS functions for applications to use" 1.27 - * 1.28 - * PR_int__ functions touch internal PR data structs and are only safe 1.29 - * to be used inside the master lock. However, occasionally, they appear 1.30 - * in wrapper-lib or plugin code. In those cases, very careful analysis 1.31 - * has been done to be sure no concurrency issues could arise. 1.32 - * 1.33 - * PR_WL__ functions are all safe for use outside the master lock. 1.34 - * 1.35 - * PROS are only safe for applications to use -- they're like a second 1.36 - * language mixed in -- but they can't be used inside plugin code, and 1.37 - * aren't meant for use in wrapper libraries, because they are themselves 1.38 - * wrapper-library calls! 1.39 - */ 1.40 - 1.41 -#define \ 1.42 -PR_PI__create_slaveVP PR_int__create_slaveVP_helper 1.43 - 1.44 -//============== 1.45 -//=== Lang Data 1.46 -//= 1.47 -#define \ 1.48 -PR_PI__give_lang_data_from_slave PR_int__give_lang_data_from_slave 1.49 -#define \ 1.50 -PR_SS__give_lang_data_from_slave PR_int__give_lang_data_from_slave 1.51 - 1.52 -#define \ 1.53 -PR_PI__give_num_cores PR_SS__give_num_cores 1.54 - 1.55 - 1.56 -//============ 1.57 -//=== Lang Env 1.58 -//= 1.59 -#define \ 1.60 -PR_PI__give_proto_lang_env_for_slave PR_int__give_proto_lang_env_for_slave 1.61 -#define \ 1.62 -PR_PI__give_lang_env_for_slave PR_int__give_lang_env_for_slave 1.63 -#define \ 1.64 -PR_PI__give_lang_env_from_process PR_int__give_lang_env_from_process 1.65 - 1.66 - 1.67 -//========= 1.68 -//=== Meta Task 1.69 -//= 1.70 -#define \ 1.71 -PR_PI__give_lang_meta_task_from_slave PR_int__give_lang_meta_task_from_slave 1.72 -#define \ 1.73 -PR_PI__give_prolog_of_lang_meta_task PR_int__give_prolog_of_lang_meta_task 1.74 - 1.75 -SlaveVP * 1.76 -PR_PI__give_slave_lang_meta_task_is_assigned_to( void *langMetaTask ); 1.77 - 1.78 -#define \ 1.79 -PR_PI__free_lang_meta_task_and_remove_from_slave PR_int__free_lang_meta_task_and_remove_from_coll 1.80 - 1.81 -#define \ 1.82 -PR_PI__free_lang_meta_task PR_int__free_lang_meta_task 1.83 - 1.84 -void 1.85 -PR_PI__set_no_del_flag_in_lang_meta_task( void *langMetaTask ); 1.86 -void 1.87 -PR_PI__clear_no_del_flag_in_lang_meta_task( void *langMetaTask ); 1.88 - 1.89 -//========== 1.90 -//=== 1.91 -//= 1.92 -#define \ 1.93 -PR_PI__give_ID_from_lang_meta_task PR__give_ID_from_lang_meta_task 1.94 -#define \ 1.95 -PR_PI__give_ID_from_slave PR__give_ID_from_slave 1.96 - 1.97 -//============= 1.98 -//=== 1.99 -//= 1.100 -#define \ 1.101 -PR_PI__put_slave_into_slot PR_int__put_slave_into_slot 1.102 -#define \ 1.103 -PR_PI__put_task_into_slot PR_int__put_task_into_slot 1.104 - 1.105 -PRReqst * 1.106 -PR_PI__take_next_request_out_of( SlaveVP *slaveWithReq ); 1.107 - 1.108 -#define \ 1.109 -PR_PI__take_lang_reqst_from( req ) req->langReq 1.110 - 1.111 -void 1.112 -PR_PI__resume_slave_in_PRServ( SlaveVP *slave ); 1.113 - 1.114 -#define \ 1.115 -PR_PI__malloc PR_int__malloc 1.116 -#define \ 1.117 -PR_PI__malloc_aligned PR_int__malloc_aligned 1.118 -#define \ 1.119 -PR_PI__free PR_int__free 1.120 - 1.121 - 1.122 -#define \ 1.123 -PR_PI__throw_exception PR_int__throw_exception 1.124 - 1.125 -//================================================ 1.126 -#endif /* _PR__PI_H */ 1.127 - 1.128 +/* 1.129 + * Copyright 2009 OpenSourceResearchInstitute.org 1.130 + * Licensed under GNU General Public License version 2 1.131 + * 1.132 + * Author: seanhalle@yahoo.com 1.133 + * 1.134 + */ 1.135 + 1.136 +#ifndef _PR__PI_H 1.137 +#define _PR__PI_H 1.138 +#define _GNU_SOURCE 1.139 + 1.140 +#include <PR__include/PR__structs__common.h> 1.141 + 1.142 +//========================= Function Prototypes =========================== 1.143 +/* MEANING OF WL PI SS int PROS 1.144 + * These indicate which places the function is safe to use. They stand for: 1.145 + * 1.146 + * WL Wrapper Library -- wrapper lib code should only use these 1.147 + * PI Plugin -- plugin code should only use these 1.148 + * SS Startup and Shutdown -- designates these relate to startup & shutdown 1.149 + * int32internal to PR -- should not be used in wrapper lib or plugin 1.150 + * PROS means "OS functions for applications to use" 1.151 + * 1.152 + * PR_int__ functions touch internal PR data structs and are only safe 1.153 + * to be used inside the master lock. However, occasionally, they appear 1.154 + * in wrapper-lib or plugin code. In those cases, very careful analysis 1.155 + * has been done to be sure no concurrency issues could arise. 1.156 + * 1.157 + * PR_WL__ functions are all safe for use outside the master lock. 1.158 + * 1.159 + * PROS are only safe for applications to use -- they're like a second 1.160 + * language mixed in -- but they can't be used inside plugin code, and 1.161 + * aren't meant for use in wrapper libraries, because they are themselves 1.162 + * wrapper-library calls! 1.163 + */ 1.164 + 1.165 +//#define PR_PI__get_fresh_slaveVP PR_int__create_slaveVP_helper 1.166 + 1.167 +inline 1.168 +SlaveVP * 1.169 +PR_PI__get_fresh_slaveVP( BirthFnPtr fnPtr, void *dataParam ); 1.170 + 1.171 +//============== 1.172 +//=== Lang Data 1.173 +//= 1.174 +#define \ 1.175 +PR_PI__give_lang_data_from_slave PR_int__give_lang_data_from_slave 1.176 +#define \ 1.177 +PR_SS__give_lang_data_from_slave PR_int__give_lang_data_from_slave 1.178 + 1.179 +#define \ 1.180 +PR_PI__give_num_cores PR_SS__give_num_cores 1.181 + 1.182 + 1.183 +//============ 1.184 +//=== Lang Env 1.185 +//= 1.186 +#define \ 1.187 +PR_PI__give_proto_lang_env_for_slave PR_int__give_proto_lang_env_for_slave 1.188 +#define \ 1.189 +PR_PI__give_lang_env_for_slave PR_int__give_lang_env_for_slave 1.190 +#define \ 1.191 +PR_PI__give_lang_env_from_process PR_int__give_lang_env_from_process 1.192 + 1.193 + 1.194 +//========= 1.195 +//=== Meta Task 1.196 +//= 1.197 +#define \ 1.198 +PR_PI__give_lang_meta_task_from_slave PR_int__give_lang_meta_task_from_slave 1.199 +#define \ 1.200 +PR_PI__give_prolog_of_lang_meta_task PR_int__give_prolog_of_lang_meta_task 1.201 + 1.202 +SlaveVP * 1.203 +PR_PI__give_slave_lang_meta_task_is_assigned_to( void *langMetaTask ); 1.204 + 1.205 +#define \ 1.206 +PR_PI__free_lang_meta_task_and_remove_from_slave PR_int__free_lang_meta_task_and_remove_from_coll 1.207 + 1.208 +#define \ 1.209 +PR_PI__free_lang_meta_task PR_int__free_lang_meta_task 1.210 + 1.211 +void 1.212 +PR_PI__set_no_del_flag_in_lang_meta_task( void *langMetaTask ); 1.213 +void 1.214 +PR_PI__clear_no_del_flag_in_lang_meta_task( void *langMetaTask ); 1.215 + 1.216 +//========== 1.217 +//=== 1.218 +//= 1.219 +#define \ 1.220 +PR_PI__give_ID_from_lang_meta_task PR__give_ID_from_lang_meta_task 1.221 +#define \ 1.222 +PR_PI__give_ID_from_slave PR__give_ID_from_slave 1.223 + 1.224 +//============= 1.225 +//=== 1.226 +//= 1.227 +#define \ 1.228 +PR_PI__put_slave_into_slot PR_int__put_slave_into_slot 1.229 +#define \ 1.230 +PR_PI__put_task_into_slot PR_int__put_task_into_slot 1.231 + 1.232 +PRReqst * 1.233 +PR_PI__take_next_request_out_of( SlaveVP *slaveWithReq ); 1.234 + 1.235 +#define \ 1.236 +PR_PI__take_lang_reqst_from( req ) req->langReq 1.237 + 1.238 +void 1.239 +PR_PI__resume_slave_in_PRServ( SlaveVP *slave ); 1.240 + 1.241 +#define \ 1.242 +PR_PI__malloc PR_int__malloc 1.243 +#define \ 1.244 +PR_PI__malloc_aligned PR_int__malloc_aligned 1.245 +#define \ 1.246 +PR_PI__free PR_int__free 1.247 + 1.248 + 1.249 +#define \ 1.250 +PR_PI__throw_exception PR_int__throw_exception 1.251 + 1.252 +//================================================ 1.253 +#endif /* _PR__PI_H */ 1.254 +
2.1 --- a/PR__structs__common.h Sun Oct 06 11:26:20 2013 -0700 2.2 +++ b/PR__structs__common.h Fri Feb 28 21:16:50 2014 +0100 2.3 @@ -1,349 +1,354 @@ 2.4 -/* 2.5 - * Copyright 2009 OpenSourceResearchInstitute.org 2.6 - * Licensed under GNU General Public License version 2 2.7 - * 2.8 - * Author: seanhalle@yahoo.com 2.9 - * 2.10 - */ 2.11 - 2.12 -#ifndef _PR__structs__common_H 2.13 -#define _PR__structs__common_H 2.14 -#define _GNU_SOURCE 2.15 - 2.16 -#include <pthread.h> 2.17 -#include <sys/time.h> 2.18 - 2.19 -//#include "PR_defs__turn_on_and_off.h" 2.20 -#include <PR__include/PR__primitive_data_types.h> 2.21 -#include <PR__include/Services_offered_by_PR/DEBUG__macros.h> 2.22 -#include <PR__include/Services_offered_by_PR/MEAS__macros.h> 2.23 - 2.24 -#include <PR__include/prhistogram.h> //reqd by PRProcess 2.25 -#include <PR__include/prhash.h> //reqd by PRProcess 2.26 -#include <PR__include/prdynarray.h> //reqd by PRProcess 2.27 -#include <PR__include/prqueue.h> //reqd by PRLangEnv, in turn reqd by PRProcess 2.28 - 2.29 -//================================ Typedefs ================================= 2.30 -//=== 2.31 -//= 2.32 -#define ZERO 0 2.33 - 2.34 -//typedef unsigned long long TSCount; 2.35 - 2.36 -typedef struct _AnimSlot AnimSlot; 2.37 -typedef struct _PRReqst PRReqst; 2.38 -typedef struct _SlaveVP SlaveVP; 2.39 -//typedef struct _MasterVP MasterVP; 2.40 -typedef struct _IntervalProbe IntervalProbe; 2.41 -typedef struct _PRLangEnv PRLangEnv; //a prolog 2.42 -typedef struct _PRMetaTask PRMetaTask; //a prolog 2.43 -typedef struct _PRLangData PRLangData; //a prolog 2.44 -typedef struct _PRCollElem PRCollElem; //generic form of the prologs 2.45 - 2.46 -typedef bool32 (*SlaveAssigner) ( void *, AnimSlot* ); //langEnv, slot for HW info 2.47 -typedef void (*RequestHandler) ( void *, SlaveVP *, void * ); //req, slv, langEnv 2.48 -typedef void *(*CreateHandler) ( void *, SlaveVP *, void * ); //req, slv, langEnv 2.49 -typedef void (*LangShutdownHdlr) ( void * ); //langEnv 2.50 -typedef void *(*LangDataCreator) ( SlaveVP * ); 2.51 -typedef void (*LangDataFreer) ( void * ); //lang data to free 2.52 -typedef void *(*LangMetaTaskCreator)( SlaveVP * ); //when slave has no meta task for magic num 2.53 -typedef void (*LangMetaTaskFreer) ( void * ); //lang meta task to free 2.54 -typedef void (*MakeSlaveReadyFn) ( SlaveVP *, void * ); //slave and langEnv 2.55 -typedef void (*MakeTaskReadyFn) ( void *, void * ); //langTask and langEnv 2.56 -typedef void (*BirthFnPtr) ( void *, SlaveVP * ); //initData, animSlv 2.57 -typedef void BirthFn ( void *, SlaveVP * ); //initData, animSlv 2.58 -typedef void (*ResumeSlvFnPtr) ( SlaveVP *, void * ); 2.59 - //=========== MEASUREMENT STUFF ========== 2.60 - MEAS__Insert_Counter_Handler 2.61 - //======================================== 2.62 - 2.63 - 2.64 -typedef struct 2.65 - { //These are set by the plugin during startup and the application 2.66 - char *assignerInfo; 2.67 - char *appInfo; 2.68 - char *inputInfo; 2.69 - } 2.70 -PRSysMetaInfo; 2.71 - 2.72 -//===================== Process Data Struct ====================== 2.73 - 2.74 -/*This structure holds all the information PR needs to manage a program. PR 2.75 - * stores information about what percent of CPU time the program is getting, 2.76 - * 2.77 - */ 2.78 - 2.79 -typedef struct 2.80 - { 2.81 - int32 numEnvsWithWork; 2.82 - void *resultToReturn; 2.83 - 2.84 - PRLangEnv **langEnvs; //used as a hash table 2.85 - PRLangEnv **protoLangEnvsList; //for fast linear scan of envs 2.86 - int32 numLangEnvs; //for fast linear scan of envs 2.87 - 2.88 - SlaveVP *seedSlv; 2.89 - 2.90 - int32 numLiveGenericSlvs; 2.91 - int32 numLiveTasks; 2.92 - 2.93 - SlaveAssigner overrideAssigner; 2.94 - 2.95 - int32 numConsecutiveTasks; 2.96 - 2.97 - 2.98 - //These are used to coord with an OS thread waiting for process to end 2.99 - bool32 hasWaitingToEnd; 2.100 - bool32 executionIsComplete; 2.101 - pthread_mutex_t doneLock; 2.102 - pthread_cond_t doneCond; 2.103 - pthread_mutex_t doneAckLock; //waiter gets, then releases when done waiting 2.104 - 2.105 - //=========== MEASUREMENT STUFF ============= 2.106 - IntervalProbe **intervalProbes; 2.107 - PrivDynArrayInfo *dynIntervalProbesInfo; 2.108 - HashTable *probeNameHashTbl; 2.109 - int32 masterCreateProbeID; 2.110 - float64 createPtInSecs; //real-clock time PR initialized 2.111 - Histogram **measHists; 2.112 - PrivDynArrayInfo *measHistsInfo; 2.113 - MEAS__Insert_Susp_Meas_Fields_into_MasterEnv; 2.114 - MEAS__Insert_Master_Meas_Fields_into_MasterEnv; 2.115 - MEAS__Insert_Master_Lock_Meas_Fields_into_MasterEnv; 2.116 - MEAS__Insert_Malloc_Meas_Fields_into_MasterEnv; 2.117 - MEAS__Insert_Plugin_Meas_Fields_into_MasterEnv; 2.118 - MEAS__Insert_System_Meas_Fields_into_MasterEnv; 2.119 - MEAS__Insert_Counter_Meas_Fields_into_MasterEnv; 2.120 - //========================================== 2.121 - } 2.122 -PRProcess; 2.123 - 2.124 - 2.125 -//============= Request Related =========== 2.126 -// 2.127 - 2.128 -enum PRReqstType //avoid starting enums at 0, for debug reasons 2.129 - { 2.130 - TaskCreate = 1, 2.131 - TaskEnd, 2.132 - SlvCreate, 2.133 - SlvDissipate, 2.134 - Language, 2.135 - Service, //To invoke a PR provided equivalent of a language request (ex: probe) 2.136 - Hardware, 2.137 - IO, 2.138 - OSCall, 2.139 - LangShutdown, 2.140 - ProcessEnd, 2.141 - PRShutdown 2.142 - }; 2.143 - 2.144 - 2.145 -struct _PRReqst 2.146 - { 2.147 - enum PRReqstType reqType;//used for special forms that have PR behavior 2.148 - void *langReq; 2.149 - PRProcess *processReqIsIn; 2.150 - int32 langMagicNumber; 2.151 - SlaveVP *requestingSlave; 2.152 - 2.153 - BirthFnPtr birthFn; 2.154 - void *initData; 2.155 - int32 *ID; 2.156 - 2.157 - //The request handling structure is a bit messy.. for special forms, 2.158 - // such as create and dissipate, the language inserts pointer to handler 2.159 - // fn directly into the request.. might change to this for all requests 2.160 - RequestHandler handler; //pointer to handler fn 2.161 - CreateHandler createHdlr; //special because returns something 2.162 - int32 createSuspendedGroup; //must be non-zero 2.163 - 2.164 - PRReqst *nextReqst; 2.165 - }; 2.166 -//PRReqst 2.167 - 2.168 -enum PRServiceReqType //These are equivalent to lang requests, but for 2.169 - { // PR's services available directly to app, like OS 2.170 - make_probe = 1, // and probe services -- like a PR-wide built-in lang 2.171 - throw_excp, 2.172 - openFile, 2.173 - otherIO 2.174 - }; 2.175 - 2.176 -typedef struct 2.177 - { enum PRServiceReqType reqType; 2.178 - SlaveVP *requestingSlv; 2.179 - char *nameStr; //for create probe 2.180 - char *msgStr; //for exception 2.181 - void *exceptionData; 2.182 - } 2.183 -PRServiceReq; 2.184 - 2.185 - 2.186 -//==================== Core data structures =================== 2.187 - 2.188 -typedef struct 2.189 - { 2.190 - //for future expansion 2.191 - } 2.192 -SlotPerfInfo; 2.193 - 2.194 -struct _AnimSlot 2.195 - { 2.196 - int32 workIsDone; 2.197 - int32 needsWorkAssigned; 2.198 - SlaveVP *slaveAssignedToSlot; 2.199 - 2.200 -// int32 slotIdx; //needed by Holistic Model's data gathering 2.201 - int32 coreSlotIsOn; 2.202 - SlotPerfInfo *perfInfo; //used by assigner to pick best slave for core 2.203 - }; 2.204 -//AnimSlot 2.205 - 2.206 -enum VPtype 2.207 - { SlotTaskSlv = 1,//Slave tied to an anim slot, only animates tasks 2.208 - FreeTaskSlv, //When a suspended task ends, the slave becomes this 2.209 - GenericSlv, //the VP is explicitly seen in the app code, or task suspends 2.210 - SeedSlv, 2.211 - Master_VP, 2.212 - ShutdownVP, 2.213 - IdleVP 2.214 - }; 2.215 - 2.216 -/*This structure embodies the state of a slaveVP. It is reused for masterVP 2.217 - * and shutdownVPs. 2.218 - */ 2.219 -struct _SlaveVP 2.220 - { //The offsets of these fields are hard-coded into assembly 2.221 - void *stackPtr; //save the core's stack ptr when suspend 2.222 - void *framePtr; //save core's frame ptr when suspend 2.223 - void *resumeInstrPtr; //save core's program-counter when suspend 2.224 - void *coreCtlrFramePtr; //restore before jmp back to core controller 2.225 - void *coreCtlrStackPtr; //restore before jmp back to core controller 2.226 - 2.227 - //============ below this, no fields are used in asm ============= 2.228 - 2.229 - void *startOfStack; //used to free, and to point slave to Fn 2.230 - PRProcess *processSlaveIsIn; 2.231 - enum VPtype typeOfVP; //Slave vs Master vs Shutdown.. 2.232 - int32 slaveNum; //each slave given it's seq in creation 2.233 - int32 *ID; //App defines meaning of each int in array 2.234 - int32 coreAnimatedBy; 2.235 - int32 numTimesAssignedToASlot; //Each assign is for one work-unit, so is an ID 2.236 - //note, a scheduling decision is uniquely identified by the triple: 2.237 - // <slaveNum, coreAnimatedBy, numTimesAssignedToASlot> -- used in record & replay 2.238 - 2.239 - //for comm -- between master and coreCtlr & btwn wrapper lib and plugin 2.240 - AnimSlot *animSlotAssignedTo; 2.241 - PRReqst *request; //wrapper lib puts in requests, plugin takes out 2.242 - void *dataRetFromReq;//Return vals from plugin to Wrapper Lib 2.243 - 2.244 - //For language specific data that needs to be in the slave 2.245 - //These are accessed directly for single-lang, but multi-lang places 2.246 - // a holder here instead, then uses magic num to get lang's version 2.247 - PRLangData **langDatas; //Lang saves lang-specific things in slave here 2.248 - PRMetaTask **metaTasks; 2.249 - 2.250 -// PRGhostInfo *ghostInfo; 2.251 - 2.252 - //=========== MEASUREMENT STUFF ========== 2.253 - MEAS__Insert_Meas_Fields_into_Slave; 2.254 - float64 createPtInSecs; //time VP created, in seconds 2.255 - //======================================== 2.256 - 2.257 -// int8 cacheLinePad[512 - sizeof(contents)]; //for false sharing 2.258 - }; 2.259 -//SlaveVP 2.260 - 2.261 - 2.262 -enum PRMode 2.263 - { SingleLang = 1, 2.264 - StandaloneWTasks, 2.265 - MultiLang 2.266 - }; 2.267 - 2.268 - 2.269 -//===================== These are prologs ==================== 2.270 -//===A prolog is data immediately before pointer returned by a create function. 2.271 -//= 2.272 -struct _PRLangEnv 2.273 - { //============== First two must match PRCollElem ============== 2.274 - int32 langMagicNumber; //indexes into hash array of langEnvs in PRProcess 2.275 - PRLangEnv *chainedLangEnv; //chains to langEnvs with same hash 2.276 - //============================================================= 2.277 - 2.278 - SlaveAssigner workAssigner; 2.279 - LangShutdownHdlr shutdownHdlr; //called when lang ended or process shutdown 2.280 - LangDataCreator langDataCreator; 2.281 - LangMetaTaskCreator langMetaTaskCreator; 2.282 - MakeSlaveReadyFn makeSlaveReadyFn; 2.283 - MakeTaskReadyFn makeTaskReadyFn; 2.284 - 2.285 - //when multi-lang, master polls lang env's to find one with work in it.. 2.286 - // in single-lang case, flag ignored, master always asks lang for work 2.287 - int32 hasWork; 2.288 - PRProcess *processEnvIsIn; 2.289 - 2.290 - int32 idxInProcess; //index into array of langEnvs in the process 2.291 - 2.292 - int32 numReadyWork; 2.293 - 2.294 - int32 numLiveWork; 2.295 - PrivQueueStruc *waitingForWorkToEndQ; 2.296 - }; 2.297 -//PRLangEnv -- this is the prolog of every lang's lang env 2.298 - 2.299 -enum PRTaskType 2.300 - { GenericSlave = 1, 2.301 - SlotTask, 2.302 - FreeTask 2.303 - }; 2.304 - 2.305 -struct _PRMetaTask 2.306 - { //============== First two must match PRCollElem ============== 2.307 - int32 langMagicNumber; 2.308 - PRMetaTask *chainedMetaTask; 2.309 - //============================================================= 2.310 - enum PRTaskType taskType; 2.311 - int32 *ID; //is standard PR ID 2.312 - PRProcess *processTaskIsIn; 2.313 - SlaveVP *slaveAssignedTo; //not valid until task animated 2.314 - BirthFnPtr birthFn; //This is the Fn executes as the task 2.315 - void *initData; //The data taken by the function 2.316 - LangMetaTaskFreer freer; 2.317 - bool32 goAheadAndFree; 2.318 - 2.319 - //NOTE: info needed for "wait" functionality is inside lang's metaTask 2.320 - }; 2.321 -//PRMetaTask -- prolog of every lang's meta task 2.322 - 2.323 -struct _PRLangData 2.324 - { //============== First two must match PRCollElem ============== 2.325 - int32 langMagicNumber; 2.326 - PRLangData *chainedLangData; 2.327 - //============================================================= 2.328 - LangDataFreer freer; 2.329 - bool32 goAheadAndFree; 2.330 - SlaveVP *slaveAssignedTo; 2.331 - }; 2.332 -//PRLangData -- this is the prolog of each lang's lang data 2.333 - 2.334 -struct _PRCollElem 2.335 - { 2.336 - int32 hash; 2.337 - PRCollElem *chained; 2.338 - }; 2.339 -//PRCollElem -- this is generic form of all the prologs 2.340 - 2.341 - 2.342 - 2.343 -//========================= Extra Stuff Data Strucs ======================= 2.344 -typedef struct 2.345 - { 2.346 - 2.347 - } 2.348 -PRExcp; //exception 2.349 - 2.350 - 2.351 -#endif /* _PR__structs_H */ 2.352 - 2.353 +/* 2.354 + * Copyright 2009 OpenSourceResearchInstitute.org 2.355 + * Licensed under GNU General Public License version 2 2.356 + * 2.357 + * Author: seanhalle@yahoo.com 2.358 + * 2.359 + */ 2.360 + 2.361 +#ifndef _PR__structs__common_H 2.362 +#define _PR__structs__common_H 2.363 +#define _GNU_SOURCE 2.364 + 2.365 +#include <pthread.h> 2.366 +#include <sys/time.h> 2.367 + 2.368 +//#include "PR_defs__turn_on_and_off.h" 2.369 +#include <PR__include/PR__primitive_data_types.h> 2.370 +#include <PR__include/Services_offered_by_PR/DEBUG__macros.h> 2.371 +#include <PR__include/Services_offered_by_PR/MEAS__macros.h> 2.372 + 2.373 +#include <PR__include/prhistogram.h> //reqd by PRProcess 2.374 +#include <PR__include/prhash.h> //reqd by PRProcess 2.375 +#include <PR__include/prdynarray.h> //reqd by PRProcess 2.376 +#include <PR__include/prqueue.h> //reqd by PRLangEnv, in turn reqd by PRProcess 2.377 + 2.378 +//================================ Typedefs ================================= 2.379 +//=== 2.380 +//= 2.381 +#define ZERO 0 2.382 + 2.383 +//typedef unsigned long long TSCount; 2.384 + 2.385 +typedef struct _AnimSlot AnimSlot; 2.386 +typedef struct _PRReqst PRReqst; 2.387 +typedef struct _SlaveVP SlaveVP; 2.388 +//typedef struct _MasterVP MasterVP; 2.389 +typedef struct _IntervalProbe IntervalProbe; 2.390 +typedef struct _PRLangEnv PRLangEnv; //a prolog 2.391 +typedef struct _PRMetaTask PRMetaTask; //a prolog 2.392 +typedef struct _PRLangData PRLangData; //a prolog 2.393 +typedef struct _PRCollElem PRCollElem; //generic form of the prologs 2.394 + 2.395 +typedef bool32 (*SlaveAssigner) ( void *, AnimSlot* ); //langEnv, slot for HW info 2.396 +typedef void (*RequestHandler) ( void *, SlaveVP *, void * ); //req, slv, langEnv 2.397 +typedef void *(*CreateHandler) ( void *, SlaveVP *, void * ); //req, slv, langEnv 2.398 +typedef void (*LangShutdownHdlr) ( void * ); //langEnv 2.399 +typedef void *(*LangDataCreator) ( SlaveVP * ); 2.400 +typedef void (*LangDataFreer) ( void * ); //lang data to free 2.401 +typedef void *(*LangMetaTaskCreator)( SlaveVP * ); //when slave has no meta task for magic num 2.402 +typedef void (*LangMetaTaskFreer) ( void * ); //lang meta task to free 2.403 +typedef void (*MakeSlaveReadyFn) ( SlaveVP *, void * ); //slave and langEnv 2.404 +typedef void (*MakeTaskReadyFn) ( void *, void * ); //langTask and langEnv 2.405 +typedef void (*BirthFnPtr) ( void *, SlaveVP * ); //initData, animSlv 2.406 +typedef void BirthFn ( void *, SlaveVP * ); //initData, animSlv 2.407 +typedef void (*ResumeSlvFnPtr) ( SlaveVP *, void * ); 2.408 + //=========== MEASUREMENT STUFF ========== 2.409 + MEAS__Insert_Counter_Handler 2.410 + //======================================== 2.411 + 2.412 + 2.413 +typedef struct 2.414 + { //These are set by the plugin during startup and the application 2.415 + char *assignerInfo; 2.416 + char *appInfo; 2.417 + char *inputInfo; 2.418 + } 2.419 +PRSysMetaInfo; 2.420 + 2.421 +//===================== Process Data Struct ====================== 2.422 + 2.423 +/*This structure holds all the information PR needs to manage a program. PR 2.424 + * stores information about what percent of CPU time the program is getting, 2.425 + * 2.426 + */ 2.427 + 2.428 +typedef struct 2.429 + { 2.430 + int32 numEnvsWithWork; 2.431 + void *resultToReturn; 2.432 + 2.433 + PRLangEnv **langEnvs; //used as a hash table 2.434 + PRLangEnv **protoLangEnvsList; //for fast linear scan of envs 2.435 + int32 numLangEnvs; //for fast linear scan of envs 2.436 + 2.437 + SlaveVP *seedSlv; 2.438 + 2.439 + int32 numLiveGenericSlvs; 2.440 + int32 numLiveTasks; 2.441 + 2.442 + SlaveAssigner overrideAssigner; 2.443 + 2.444 + int32 numConsecutiveTasks; 2.445 + 2.446 + 2.447 + //These are used to coord with an OS thread waiting for process to end 2.448 + bool32 hasWaitingToEnd; 2.449 + bool32 executionIsComplete; 2.450 + pthread_mutex_t doneLock; 2.451 + pthread_cond_t doneCond; 2.452 + pthread_mutex_t doneAckLock; //waiter gets, then releases when done waiting 2.453 + 2.454 + //=========== MEASUREMENT STUFF ============= 2.455 + IntervalProbe **intervalProbes; 2.456 + PrivDynArrayInfo *dynIntervalProbesInfo; 2.457 + HashTable *probeNameHashTbl; 2.458 + int32 masterCreateProbeID; 2.459 + float64 createPtInSecs; //real-clock time PR initialized 2.460 + Histogram **measHists; 2.461 + PrivDynArrayInfo *measHistsInfo; 2.462 + MEAS__Insert_Susp_Meas_Fields_into_MasterEnv; 2.463 + MEAS__Insert_Master_Meas_Fields_into_MasterEnv; 2.464 + MEAS__Insert_Master_Lock_Meas_Fields_into_MasterEnv; 2.465 + MEAS__Insert_Malloc_Meas_Fields_into_MasterEnv; 2.466 + MEAS__Insert_Plugin_Meas_Fields_into_MasterEnv; 2.467 + MEAS__Insert_System_Meas_Fields_into_MasterEnv; 2.468 + MEAS__Insert_Counter_Meas_Fields_into_MasterEnv; 2.469 + //========================================== 2.470 + } 2.471 +PRProcess; 2.472 + 2.473 + 2.474 +//============= Request Related =========== 2.475 +// 2.476 + 2.477 +enum PRReqstType //avoid starting enums at 0, for debug reasons 2.478 + { 2.479 + TaskCreate = 1, 2.480 + TaskEnd, 2.481 + SlvCreate, 2.482 + SlvDissipate, 2.483 + Language, 2.484 + Service, //To invoke a PR provided equivalent of a language request (ex: probe) 2.485 + Hardware, 2.486 + IO, 2.487 + OSCall, 2.488 + LangShutdown, 2.489 + ProcessEnd, 2.490 + PRShutdown 2.491 + }; 2.492 + 2.493 + 2.494 +struct _PRReqst 2.495 + { 2.496 + enum PRReqstType reqType;//used for special forms that have PR behavior 2.497 + void *langReq; 2.498 + PRProcess *processReqIsIn; 2.499 + int32 langMagicNumber; 2.500 + SlaveVP *requestingSlave; 2.501 + 2.502 + BirthFnPtr birthFn; 2.503 + void *initData; 2.504 + int32 *ID; 2.505 + 2.506 + //The request handling structure is a bit messy.. for special forms, 2.507 + // such as create and dissipate, the language inserts pointer to handler 2.508 + // fn directly into the request.. might change to this for all requests 2.509 + RequestHandler handler; //pointer to handler fn 2.510 + CreateHandler createHdlr; //special because returns something 2.511 + int32 createSuspendedGroup; //must be non-zero 2.512 + 2.513 + PRReqst *nextReqst; 2.514 + }; 2.515 +//PRReqst 2.516 + 2.517 +enum PRServiceReqType //These are equivalent to lang requests, but for 2.518 + { // PR's services available directly to app, like OS 2.519 + make_probe = 1, // and probe services -- like a PR-wide built-in lang 2.520 + throw_excp, 2.521 + openFile, 2.522 + otherIO 2.523 + }; 2.524 + 2.525 +typedef struct 2.526 + { enum PRServiceReqType reqType; 2.527 + SlaveVP *requestingSlv; 2.528 + char *nameStr; //for create probe 2.529 + char *msgStr; //for exception 2.530 + void *exceptionData; 2.531 + } 2.532 +PRServiceReq; 2.533 + 2.534 + 2.535 +//==================== Core data structures =================== 2.536 + 2.537 +typedef struct 2.538 + { 2.539 + //for future expansion 2.540 + } 2.541 +SlotPerfInfo; 2.542 + 2.543 +struct _AnimSlot 2.544 + { 2.545 + int32 workIsDone; 2.546 + int32 needsWorkAssigned; 2.547 + SlaveVP *slaveAssignedToSlot; 2.548 + 2.549 +// int32 slotIdx; //needed by Holistic Model's data gathering 2.550 + int32 coreSlotIsOn; 2.551 + SlotPerfInfo *perfInfo; //used by assigner to pick best slave for core 2.552 + }; 2.553 +//AnimSlot 2.554 + 2.555 +enum VPtype 2.556 + { SlotTaskSlv = 1,//Slave tied to an anim slot, only animates tasks 2.557 + FreeTaskSlv, //When a suspended task ends, the slave becomes this 2.558 + GenericSlv, //the VP is explicitly seen in the app code, or task suspends 2.559 + SeedSlv, 2.560 + Master_VP, 2.561 + ShutdownVP, 2.562 + IdleVP 2.563 + }; 2.564 + 2.565 +/*This structure embodies the state of a slaveVP. It is reused for masterVP 2.566 + * and shutdownVPs. 2.567 + */ 2.568 +struct _SlaveVP 2.569 + { //The offsets of these fields are hard-coded into assembly 2.570 + void *stackPtr; //save the core's stack ptr when suspend 2.571 + void *framePtr; //save core's frame ptr when suspend 2.572 + void *resumeInstrPtr; //save core's program-counter when suspend 2.573 + void *coreCtlrFramePtr; //restore before jmp back to core controller 2.574 + void *coreCtlrStackPtr; //restore before jmp back to core controller 2.575 + 2.576 + //============ below this, no fields are used in asm ============= 2.577 + 2.578 + PRProcess *processSlaveIsIn; 2.579 + enum VPtype typeOfVP; //Slave vs Master vs Shutdown.. 2.580 + int32 slaveNum; //each slave given it's seq in creation 2.581 + int32 *ID; //App defines meaning of each int in array 2.582 + int32 coreAnimatedBy; 2.583 + int32 numTimesAssignedToASlot; //Each assign is for one work-unit, so is an ID 2.584 + //note, a scheduling decision is uniquely identified by the triple: 2.585 + // <slaveNum, coreAnimatedBy, numTimesAssignedToASlot> -- used in record & replay 2.586 + 2.587 + //for comm -- between master and coreCtlr & btwn wrapper lib and plugin 2.588 + AnimSlot *animSlotAssignedTo; 2.589 + PRReqst *request; //wrapper lib puts in requests, plugin takes out 2.590 + void *dataRetFromReq;//Return vals from plugin to Wrapper Lib 2.591 + 2.592 + //For language specific data that needs to be in the slave 2.593 + //These are accessed directly for single-lang, but multi-lang places 2.594 + // a holder here instead, then uses magic num to get lang's version 2.595 + PRLangData **langDatas; //Lang saves lang-specific things in slave here 2.596 + PRMetaTask **metaTasks; 2.597 + 2.598 + jmp_buf ctxt; 2.599 + jmp_buf virginCtxt; 2.600 + 2.601 + BirthFnPtr birthFn; 2.602 + void *initData; 2.603 + 2.604 +// PRGhostInfo *ghostInfo; 2.605 + 2.606 + //=========== MEASUREMENT STUFF ========== 2.607 + MEAS__Insert_Meas_Fields_into_Slave; 2.608 + float64 createPtInSecs; //time VP created, in seconds 2.609 + //======================================== 2.610 + 2.611 +// int8 cacheLinePad[512 - sizeof(contents)]; //for false sharing 2.612 + }; 2.613 +//SlaveVP 2.614 + 2.615 + 2.616 +enum PRMode 2.617 + { SingleLang = 1, 2.618 + StandaloneWTasks, 2.619 + MultiLang 2.620 + }; 2.621 + 2.622 + 2.623 +//===================== These are prologs ==================== 2.624 +//===A prolog is data immediately before pointer returned by a create function. 2.625 +//= 2.626 +struct _PRLangEnv 2.627 + { //============== First two must match PRCollElem ============== 2.628 + int32 langMagicNumber; //indexes into hash array of langEnvs in PRProcess 2.629 + PRLangEnv *chainedLangEnv; //chains to langEnvs with same hash 2.630 + //============================================================= 2.631 + 2.632 + SlaveAssigner workAssigner; 2.633 + LangShutdownHdlr shutdownHdlr; //called when lang ended or process shutdown 2.634 + LangDataCreator langDataCreator; 2.635 + LangMetaTaskCreator langMetaTaskCreator; 2.636 + MakeSlaveReadyFn makeSlaveReadyFn; 2.637 + MakeTaskReadyFn makeTaskReadyFn; 2.638 + 2.639 + //when multi-lang, master polls lang env's to find one with work in it.. 2.640 + // in single-lang case, flag ignored, master always asks lang for work 2.641 + int32 hasWork; 2.642 + PRProcess *processEnvIsIn; 2.643 + 2.644 + int32 idxInProcess; //index into array of langEnvs in the process 2.645 + 2.646 + int32 numReadyWork; 2.647 + 2.648 + int32 numLiveWork; 2.649 + PrivQueueStruc *waitingForWorkToEndQ; 2.650 + }; 2.651 +//PRLangEnv -- this is the prolog of every lang's lang env 2.652 + 2.653 +enum PRTaskType 2.654 + { GenericSlave = 1, 2.655 + SlotTask, 2.656 + FreeTask 2.657 + }; 2.658 + 2.659 +struct _PRMetaTask 2.660 + { //============== First two must match PRCollElem ============== 2.661 + int32 langMagicNumber; 2.662 + PRMetaTask *chainedMetaTask; 2.663 + //============================================================= 2.664 + enum PRTaskType taskType; 2.665 + int32 *ID; //is standard PR ID 2.666 + PRProcess *processTaskIsIn; 2.667 + SlaveVP *slaveAssignedTo; //not valid until task animated 2.668 + BirthFnPtr birthFn; //This is the Fn executes as the task 2.669 + void *initData; //The data taken by the function 2.670 + LangMetaTaskFreer freer; 2.671 + bool32 goAheadAndFree; 2.672 + 2.673 + //NOTE: info needed for "wait" functionality is inside lang's metaTask 2.674 + }; 2.675 +//PRMetaTask -- prolog of every lang's meta task 2.676 + 2.677 +struct _PRLangData 2.678 + { //============== First two must match PRCollElem ============== 2.679 + int32 langMagicNumber; 2.680 + PRLangData *chainedLangData; 2.681 + //============================================================= 2.682 + LangDataFreer freer; 2.683 + bool32 goAheadAndFree; 2.684 + SlaveVP *slaveAssignedTo; 2.685 + }; 2.686 +//PRLangData -- this is the prolog of each lang's lang data 2.687 + 2.688 +struct _PRCollElem 2.689 + { 2.690 + int32 hash; 2.691 + PRCollElem *chained; 2.692 + }; 2.693 +//PRCollElem -- this is generic form of all the prologs 2.694 + 2.695 + 2.696 + 2.697 +//========================= Extra Stuff Data Strucs ======================= 2.698 +typedef struct 2.699 + { 2.700 + 2.701 + } 2.702 +PRExcp; //exception 2.703 + 2.704 + 2.705 +#endif /* _PR__structs_H */ 2.706 +
3.1 --- a/__brch__ML_lib Sun Oct 06 11:26:20 2013 -0700 3.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 3.3 @@ -1,28 +0,0 @@ 3.4 -This branch is for developing the multi-language capability in VMS. The idea is to define langlets, whose constructs can be freely mixed together inside application code. No need to separate into distinct modules. A single function can use constructs from all the different langlets together inside itself. 3.5 - 3.6 - 3.7 -======== Background on branch naming ========= 3.8 - 3.9 -There are two kinds of branchs: ones used to develop features, and ones tuned to particular hardware. A given HW branch may combine features from several feature-branches, picking and choosing among them. 3.10 - 3.11 -After Feb 2012, branches are named by the scheme: 3.12 - 3.13 -feat__<feat_descr>__<HW_feat_dev_on> 3.14 - 3.15 -HW__<desc_of_HW_brch_tuned_for> 3.16 - 3.17 -where <HW_feat_dev_on> and <desc_of_HW_brch_tuned_for> follow the pattern: 3.18 - 3.19 -<num_socket> x <num_cores>_<Manuf>_<special_features> 3.20 - 3.21 -Examples: 3.22 - 3.23 -feat__exp_array_malloc 3.24 - 3.25 -feat__rand_backoff__4x10_Intel_WestmereEx 3.26 - 3.27 -HW__1x4_Intel_SandyBridge 3.28 - 3.29 -HW__4x10_Intel_WestmereEx 3.30 - 3.31 -HW__1x4_AMD_mobile
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 4.2 +++ b/__brch__ML_lib_longjmp Fri Feb 28 21:16:50 2014 +0100 4.3 @@ -0,0 +1,28 @@ 4.4 +This branch is for developing the multi-language capability in VMS. The idea is to define langlets, whose constructs can be freely mixed together inside application code. No need to separate into distinct modules. A single function can use constructs from all the different langlets together inside itself. 4.5 + 4.6 + 4.7 +======== Background on branch naming ========= 4.8 + 4.9 +There are two kinds of branchs: ones used to develop features, and ones tuned to particular hardware. A given HW branch may combine features from several feature-branches, picking and choosing among them. 4.10 + 4.11 +After Feb 2012, branches are named by the scheme: 4.12 + 4.13 +feat__<feat_descr>__<HW_feat_dev_on> 4.14 + 4.15 +HW__<desc_of_HW_brch_tuned_for> 4.16 + 4.17 +where <HW_feat_dev_on> and <desc_of_HW_brch_tuned_for> follow the pattern: 4.18 + 4.19 +<num_socket> x <num_cores>_<Manuf>_<special_features> 4.20 + 4.21 +Examples: 4.22 + 4.23 +feat__exp_array_malloc 4.24 + 4.25 +feat__rand_backoff__4x10_Intel_WestmereEx 4.26 + 4.27 +HW__1x4_Intel_SandyBridge 4.28 + 4.29 +HW__4x10_Intel_WestmereEx 4.30 + 4.31 +HW__1x4_AMD_mobile
