Mercurial > cgi-bin > hgwebdir.cgi > PR > PR_Implementations > PR__Univ > PR__includes > PR__common_includes
changeset 0:e2db79e48144 Dev_libs
initial add -- into Dev_libs branch -- just junk copied -- will cut down
| author | Sean Halle <seanhalle@yahoo.com> |
|---|---|
| date | Fri, 19 Jul 2013 12:09:34 -0700 |
| parents | |
| children | c68d04a82e0b 26458f2b5c23 |
| files | Defines/MEAS__macros_to_be_moved_to_langs.h Defines/PR_defs.h Defines/PR_defs__HW_constants.h PR.h PR__PI.h PR__WL.h PR__common.h PR__common_structs.h PR__int.h PR__primitive_data_types.h PR__primitives.h PR__structs.h __README_repo_purpose__.txt __brch__Dev_libs__ |
| diffstat | 14 files changed, 1941 insertions(+), 0 deletions(-) [+] |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/Defines/MEAS__macros_to_be_moved_to_langs.h Fri Jul 19 12:09:34 2013 -0700 1.3 @@ -0,0 +1,64 @@ 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_LANG_SPEC_DEFS_H 1.13 +#define _PR_LANG_SPEC_DEFS_H 1.14 + 1.15 + 1.16 + 1.17 +//=================== Language-specific Measurement Stuff =================== 1.18 +// 1.19 +//TODO: move these into the language implementation directories 1.20 +// 1.21 + 1.22 + 1.23 +//=========================================================================== 1.24 +//VCilk 1.25 + 1.26 +#ifdef VCILK 1.27 + 1.28 +/*These defines are used in the macros below*/ 1.29 +#define spawnHistIdx 1 //note: starts at 1 1.30 +#define syncHistIdx 2 1.31 + 1.32 +#define MEAS__Make_Meas_Hists_for_VCilk( slave, magicNum ) \ 1.33 + do \ 1.34 + { VCilkLangEnv * \ 1.35 + langEnv = PR_PI__get_lang_env_from_slave( slave, magicNum ); \ 1.36 + langEnv->measHistsInfo = \ 1.37 + makePrivDynArrayOfSize( (void***)&(_PRTopEnv->measHists), 200); \ 1.38 + histInfo = langEnv->measHistsInfo; 1.39 + makeAMeasHist( histInfo, spawnHistIdx, "Spawn", 50, 0, 200 ) \ 1.40 + makeAMeasHist( histInfo, syncHistIdx, "Sync", 50, 0, 200 ) \ 1.41 + }while(FALSE); /* macro magic to protect local vars from name collision */ 1.42 + 1.43 +#define Meas_startSpawn fixme; /* changed names -- added __Cilk to end*/ 1.44 + 1.45 +#define Meas_startSpawn__Cilk \ 1.46 + int32 startStamp, endStamp; \ 1.47 + saveLowTimeStampCountInto( startStamp ); \ 1.48 + 1.49 +#define Meas_endSpawn__Cilk \ 1.50 + saveLowTimeStampCountInto( endStamp ); \ 1.51 + addIntervalToHist( startStamp, endStamp, \ 1.52 + _PRTopEnv->measHists[ spawnHistIdx ] ); 1.53 + 1.54 +#define Meas_startSync__Cilk \ 1.55 + int32 startStamp, endStamp; \ 1.56 + saveLowTimeStampCountInto( startStamp ); \ 1.57 + 1.58 +#define Meas_endSync__Cilk \ 1.59 + saveLowTimeStampCountInto( endStamp ); \ 1.60 + addIntervalToHist( startStamp, endStamp, \ 1.61 + _PRTopEnv->measHists[ syncHistIdx ] ); 1.62 +#endif 1.63 + 1.64 +//=========================================================================== 1.65 + 1.66 +#endif /* _PR_DEFS_H */ 1.67 +
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/Defines/PR_defs.h Fri Jul 19 12:09:34 2013 -0700 2.3 @@ -0,0 +1,43 @@ 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_DEFS_MAIN_H 2.13 +#define _PR_DEFS_MAIN_H 2.14 +#define _GNU_SOURCE 2.15 + 2.16 +//=========================== PR-wide defs =============================== 2.17 + 2.18 +#define SUCCESS 0 2.19 + 2.20 + //only after macro-expansion are the defs of writePrivQ, aso looked up 2.21 + // so these defs can be at the top, and writePrivQ defined later on.. 2.22 +#define writePRQ writePrivQ 2.23 +#define readPRQ readPrivQ 2.24 +#define makePRQ makePrivQ 2.25 +#define numInPRQ numInPrivQ 2.26 +#define PRQueueStruc PrivQueueStruc 2.27 + 2.28 + 2.29 +/*The language should re-define this, but need a default in case it doesn't*/ 2.30 +#ifndef _LANG_NAME_ 2.31 +#define _LANG_NAME_ "" 2.32 +#endif 2.33 + 2.34 +//====================== Hardware Constants ============================ 2.35 +#include "PR_defs__HW_constants.h" 2.36 + 2.37 +//====================== Macros ====================== 2.38 + //for turning macros and other PR features on and off 2.39 +#include "PR_defs__turn_on_and_off.h" 2.40 + 2.41 +#include "../Services_Offered_by_PR/Debugging/DEBUG__macros.h" 2.42 +#include "../Services_Offered_by_PR/Measurement_and_Stats/MEAS__macros.h" 2.43 + 2.44 +//=========================================================================== 2.45 +#endif /* */ 2.46 +
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/Defines/PR_defs__HW_constants.h Fri Jul 19 12:09:34 2013 -0700 3.3 @@ -0,0 +1,67 @@ 3.4 +/* 3.5 + * Copyright 2012 OpenSourceResearchInstitute 3.6 + * Licensed under BSD 3.7 + * 3.8 + * Author: seanhalle@yahoo.com 3.9 + * 3.10 + */ 3.11 + 3.12 +#ifndef _PR_HW_SPEC_DEFS_H 3.13 +#define _PR_HW_SPEC_DEFS_H 3.14 +#define _GNU_SOURCE 3.15 + 3.16 + 3.17 +//========================= Hardware related Constants ===================== 3.18 + //This value is the number of hardware threads in the shared memory 3.19 + // machine 3.20 +#define NUM_CORES 4 3.21 + //Now, check if sequential mode is on, and set num cores to 1, so that 3.22 + // lang plugin code doesn't have to check for sequential mode 3.23 +#ifdef DEBUG__TURN_ON_SEQUENTIAL_MODE 3.24 + #undef NUM_CORES 3.25 + #define NUM_CORES 1 3.26 +#endif 3.27 + 3.28 + 3.29 + //tradeoff amortizing master fixed overhead vs imbalance potential 3.30 + // when work-stealing, can make bigger, at risk of losing cache affinity 3.31 +#define NUM_ANIM_SLOTS 1 3.32 + 3.33 + //number of PRLangEnv structs created inside a process -- can't start more 3.34 + // than this many langlets inside a single process 3.35 +#define NUM_IN_COLLECTION 64 3.36 + 3.37 + //These are for backoff inside core-loop, which reduces lock contention 3.38 +#define NUM_REPS_W_NO_WORK_BEFORE_YIELD 10 3.39 +#define NUM_REPS_W_NO_WORK_BEFORE_BACKOFF 2 3.40 +#define MASTERLOCK_RETRIES_BEFORE_YIELD 100 3.41 +#define NUM_TRIES_BEFORE_DO_BACKOFF 10 3.42 +#define GET_LOCK_BACKOFF_WEIGHT 100 3.43 + 3.44 + // stack size in virtual processors created 3.45 +#define VIRT_PROCR_STACK_SIZE 0x8000 /* 32K */ 3.46 + 3.47 + // memory for PR_int__malloc 3.48 +#define MALLOC_ADDITIONAL_MEM_FROM_OS_SIZE 0x8000000 /* 128M */ 3.49 + 3.50 + //Frequency of TS counts -- have to do tests to verify 3.51 + //NOTE: turn off (in BIOS) TURBO-BOOST and SPEED-STEP else won't be const 3.52 +#define TSCOUNT_FREQ 3180000000 3.53 +#define TSC_LOW_CYCLES 27 3.54 +#define TSC_LOWHI_CYCLES 45 3.55 + 3.56 +#define CACHE_LINE_SZ 256 3.57 +#define PAGE_SIZE 4096 3.58 + 3.59 +//To prevent false-sharing, aligns a variable to a cache-line boundary. 3.60 +//No need to use for local vars because those are never shared between cores 3.61 +#define __align_to_cacheline__ __attribute__ ((aligned(CACHE_LINE_SZ))) 3.62 + 3.63 +//aligns a pointer to cacheline. The memory area has to contain at least 3.64 +//CACHE_LINE_SZ bytes more then needed 3.65 +#define __align_address(ptr) ((void*)(((uintptr_t)(ptr))&((uintptr_t)(~0x0FF)))) 3.66 + 3.67 +//=========================================================================== 3.68 + 3.69 +#endif /* _PR_DEFS_H */ 3.70 +
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 4.2 +++ b/PR.h Fri Jul 19 12:09:34 2013 -0700 4.3 @@ -0,0 +1,100 @@ 4.4 +/* 4.5 + * Copyright 2012 OpenSourceResearchInstitute.org 4.6 + * Licensed under GNU General Public License version 2 4.7 + * 4.8 + * Author: seanhalle@yahoo.com 4.9 + * 4.10 + */ 4.11 + 4.12 +#ifndef _PR_H 4.13 +#define _PR_H 4.14 +#define _GNU_SOURCE 4.15 + 4.16 +#include "DynArray/DynArray.h" 4.17 +#include "Hash_impl/PrivateHash.h" 4.18 +#include "Histogram/Histogram.h" 4.19 +#include "Queue_impl/PrivateQueue.h" 4.20 + 4.21 +#include "PR_primitive_data_types.h" 4.22 +#include "Services_Offered_by_PR/Memory_Handling/vmalloc.h" 4.23 + 4.24 +#include <pthread.h> 4.25 +#include <sys/time.h> 4.26 + 4.27 +//================= Defines: included from separate files ================= 4.28 +// 4.29 +// Note: ALL defines are in other files, none are in here 4.30 +// 4.31 +#include "Defines/PR_defs.h" 4.32 + 4.33 + 4.34 +//================================ Typedefs ================================= 4.35 +// 4.36 +#include "PR__structs.h" 4.37 + 4.38 +//============================ HW Dependent Fns ================================ 4.39 + 4.40 +#include "HW_Dependent_Primitives/PR__HW_measurement.h" 4.41 +#include "HW_Dependent_Primitives/PR__primitives.h" 4.42 + 4.43 + 4.44 +//============================= Global Vars ================================ 4.45 + 4.46 +volatile TopEnv *_PRTopEnv __align_to_cacheline__; 4.47 + 4.48 + //these are global, but only used for startup and shutdown 4.49 +pthread_t coreCtlrThdHandles[ NUM_CORES ]; //pthread's virt-procr state 4.50 +ThdParams *coreCtlrThdParams [ NUM_CORES ]; 4.51 + 4.52 +pthread_mutex_t suspendLock; 4.53 +pthread_cond_t suspendCond; 4.54 + 4.55 +//========================= Function Prototypes =========================== 4.56 +/* MEANING OF WL PI SS int PROS 4.57 + * These indicate which places the function is safe to use. They stand for: 4.58 + * 4.59 + * WL Wrapper Library -- wrapper lib code should only use these 4.60 + * PI Plugin -- plugin code should only use these 4.61 + * SS Startup and Shutdown -- designates these relate to startup & shutdown 4.62 + * int32internal to PR -- should not be used in wrapper lib or plugin 4.63 + * PROS means "OS functions for applications to use" 4.64 + * 4.65 + * PR_int__ functions touch internal PR data structs and are only safe 4.66 + * to be used inside the master lock. However, occasionally, they appear 4.67 + * in wrapper-lib or plugin code. In those cases, very careful analysis 4.68 + * has been done to be sure no concurrency issues could arise. 4.69 + * 4.70 + * PR_WL__ functions are all safe for use outside the master lock. 4.71 + * 4.72 + * PR_OS are only safe for applications to use -- they're like a second 4.73 + * language mixed in -- but they can't be used inside plugin code, and 4.74 + * aren't meant for use in wrapper libraries, because they are themselves 4.75 + * wrapper-library calls! 4.76 + */ 4.77 + 4.78 +inline bool32 masterFunction( AnimSlot *slot ); 4.79 + 4.80 +//============== include internally used fn prototypes ================ 4.81 + 4.82 +//include fn prototypes used internally in the proto-runtime implementation 4.83 +#include "PR__int.h" 4.84 + 4.85 +//include fn prototypes used by plugin 4.86 +#include "PR__PI.h" 4.87 + 4.88 +//include fn prototype used by wrapper library 4.89 +#include "PR__WL.h" 4.90 + 4.91 +//================================= 4.92 +#define implement_me() printf("Unimpl Fn: \n%s \n%s : %d\n", __FILE__, __FUNCTION__, __LINE__) 4.93 +//#define fix_me printf("Fix me at: \n%s \n%s : %s\n", __FILE__, __FUNCTION__, __LINE__) 4.94 + 4.95 + 4.96 +//========================= Services ======================= 4.97 +#include "Services_Offered_by_PR/Measurement_and_Stats/probes.h" 4.98 +#include "Services_Offered_by_PR/Services_Language/PRServ.h" 4.99 +//#include "Services_Offered_by_PR/Services_Language/libPRServ.h" 4.100 + 4.101 +//================================================ 4.102 +#endif /* _PR_H */ 4.103 +
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 5.2 +++ b/PR__PI.h Fri Jul 19 12:09:34 2013 -0700 5.3 @@ -0,0 +1,195 @@ 5.4 +/* 5.5 + * Copyright 2009 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 _PR__PI_H 5.13 +#define _PR__PI_H 5.14 +#define _GNU_SOURCE 5.15 + 5.16 + 5.17 +#include "PR_primitive_data_types.h" 5.18 + 5.19 +//========================= Function Prototypes =========================== 5.20 +/* MEANING OF WL PI SS int PROS 5.21 + * These indicate which places the function is safe to use. They stand for: 5.22 + * 5.23 + * WL Wrapper Library -- wrapper lib code should only use these 5.24 + * PI Plugin -- plugin code should only use these 5.25 + * SS Startup and Shutdown -- designates these relate to startup & shutdown 5.26 + * int32internal to PR -- should not be used in wrapper lib or plugin 5.27 + * PROS means "OS functions for applications to use" 5.28 + * 5.29 + * PR_int__ functions touch internal PR data structs and are only safe 5.30 + * to be used inside the master lock. However, occasionally, they appear 5.31 + * in wrapper-lib or plugin code. In those cases, very careful analysis 5.32 + * has been done to be sure no concurrency issues could arise. 5.33 + * 5.34 + * PR_WL__ functions are all safe for use outside the master lock. 5.35 + * 5.36 + * PROS are only safe for applications to use -- they're like a second 5.37 + * language mixed in -- but they can't be used inside plugin code, and 5.38 + * aren't meant for use in wrapper libraries, because they are themselves 5.39 + * wrapper-library calls! 5.40 + */ 5.41 + 5.42 +#define \ 5.43 +PR_PI__create_slaveVP PR_int__create_slaveVP_helper 5.44 + 5.45 +//============== 5.46 +//=== Lang Data 5.47 +//= 5.48 +#define \ 5.49 +PR_PI__give_lang_data_from_slave PR_int__give_lang_data_from_slave 5.50 +#define \ 5.51 +PR_SS__give_lang_data_from_slave PR_int__give_lang_data_from_slave 5.52 + 5.53 + 5.54 +//============ 5.55 +//=== Lang Env 5.56 +//= 5.57 +#define \ 5.58 +PR_PI__give_proto_lang_env_for_slave PR_int__give_proto_lang_env_for_slave 5.59 +#define \ 5.60 +PR_PI__give_lang_env_for_slave PR_int__give_lang_env_for_slave 5.61 +#define \ 5.62 +PR_PI__give_lang_env_from_process PR_int__give_lang_env_from_process 5.63 + 5.64 + 5.65 +//========= 5.66 +//=== Meta Task 5.67 +//= 5.68 +#define \ 5.69 +PR_PI__give_lang_meta_task_from_slave PR_int__give_lang_meta_task_from_slave 5.70 +#define \ 5.71 +PR_PI__give_prolog_of_lang_meta_task PR_int__give_prolog_of_lang_meta_task 5.72 + 5.73 +SlaveVP * 5.74 +PR_PI__give_slave_lang_meta_task_is_assigned_to( void *langMetaTask ); 5.75 + 5.76 +#define \ 5.77 +PR_PI__free_lang_meta_task_and_remove_from_slave PR_int__free_lang_meta_task_and_remove_from_coll 5.78 + 5.79 +#define \ 5.80 +PR_PI__free_lang_meta_task PR_int__free_lang_meta_task 5.81 + 5.82 +void 5.83 +PR_PI__set_no_del_flag_in_lang_meta_task( void *langMetaTask ); 5.84 +void 5.85 +PR_PI__clear_no_del_flag_in_lang_meta_task( void *langMetaTask ); 5.86 + 5.87 +//========== 5.88 +//=== 5.89 +//= 5.90 +#define \ 5.91 +PR_PI__give_ID_from_lang_meta_task PR__give_ID_from_lang_meta_task 5.92 +#define \ 5.93 +PR_PI__give_ID_from_slave PR__give_ID_from_slave 5.94 + 5.95 +//============= 5.96 +//=== 5.97 +//= 5.98 +#define \ 5.99 +PR_PI__put_slave_into_slot PR_int__put_slave_into_slot 5.100 +#define \ 5.101 +PR_PI__put_task_into_slot PR_int__put_task_into_slot 5.102 + 5.103 +PRReqst * 5.104 +PR_PI__take_next_request_out_of( SlaveVP *slaveWithReq ); 5.105 + 5.106 +#define \ 5.107 +PR_PI__take_lang_reqst_from( req ) req->langReq 5.108 + 5.109 +void 5.110 +PR_PI__resume_slave_in_PRServ( SlaveVP *slave ); 5.111 + 5.112 +#define \ 5.113 +PR_PI__malloc PR_int__malloc 5.114 +#define \ 5.115 +PR_PI__malloc_aligned PR_int__malloc_aligned 5.116 +#define \ 5.117 +PR_PI__free PR_int__free 5.118 + 5.119 + 5.120 +#define \ 5.121 +PR_PI__throw_exception PR_int__throw_exception 5.122 + 5.123 +//=============== Startup and Shutdown ================ 5.124 +//=== 5.125 +//= 5.126 +void 5.127 +PR_SS__create_topEnv(); 5.128 + 5.129 +AnimSlot ** 5.130 +PR_SS__create_anim_slots( int32 coreSlotsAreOn ); 5.131 + 5.132 +void 5.133 +PR_SS__create_the_coreCtlr_OS_threads(); 5.134 + 5.135 +//=================== 5.136 +void * 5.137 +PR_SS__create_lang_env( int32 size, SlaveVP *slave, int32 magicNum ); 5.138 + 5.139 +void 5.140 +PR_SS__register_assigner( SlaveAssigner assigner, SlaveVP *seedVP, int32 magicNum ); 5.141 +void 5.142 +PR_SS__register_lang_shutdown_handler( LangShutdownHdlr shutdownHdlr, SlaveVP *seedVP, 5.143 + int32 magicNum ); 5.144 +void 5.145 +PR_SS__register_lang_data_creator( LangDataCreator langDataCreator, 5.146 + SlaveVP *seedVP, int32 magicNum ); 5.147 +void 5.148 +PR_SS__register_lang_meta_task_creator( LangDataCreator langMetaTaskCreator, 5.149 + SlaveVP *seedVP, int32 magicNum ); 5.150 +void 5.151 +PR_SS__register_make_slave_ready_fn( MakeSlaveReadyFn fn, SlaveVP *seedVP, 5.152 + int32 magicNum ); 5.153 +void 5.154 +PR_SS__register_make_task_ready_fn( MakeTaskReadyFn fn, SlaveVP *seedVP, 5.155 + int32 magicNum ); 5.156 +//=================== 5.157 + 5.158 +void 5.159 +PR_SS__end_process_normally( PRProcess *process ); 5.160 + 5.161 +void 5.162 +PR_SS__shutdown_OS_threads(); 5.163 + 5.164 +SlaveVP* 5.165 +PR_SS__create_shutdown_slave(); 5.166 + 5.167 +void 5.168 +PR_SS__cleanup_at_end_of_shutdown(); 5.169 + 5.170 +void 5.171 +PR_SS__print_out_measurements(); 5.172 + 5.173 +void 5.174 +PR_SS__wait_for_PR_to_shutdown(); 5.175 + 5.176 + 5.177 +//============================= 5.178 +//=== 5.179 +//= 5.180 + 5.181 +#define \ 5.182 +PR_SS__give_proto_lang_env_for_slave PR_int__give_proto_lang_env_for_slave 5.183 + 5.184 +#define \ 5.185 +PR_SS__give_lang_meta_task_from_slave PR_int__give_lang_meta_task_from_slave 5.186 +#define \ 5.187 +PR_SS__give_lang_env_for_slave PR_int__give_lang_env_for_slave 5.188 +#define \ 5.189 +PR_SS__give_lang_env_from_process PR_int__give_lang_env_from_process 5.190 + 5.191 +#define \ 5.192 +PR_SS__malloc PR_WL__malloc /*SS happens outside the Master*/ 5.193 +#define \ 5.194 +PR_SS__free PR_WL__free 5.195 + 5.196 +//================================================ 5.197 +#endif /* _PR__PI_H */ 5.198 +
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 6.2 +++ b/PR__WL.h Fri Jul 19 12:09:34 2013 -0700 6.3 @@ -0,0 +1,148 @@ 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 _PR__WL_H 6.13 +#define _PR__WL_H 6.14 +#define _GNU_SOURCE 6.15 + 6.16 +#include "PR_primitive_data_types.h" 6.17 +#include "PR__structs.h" 6.18 +//========================= Function Prototypes =========================== 6.19 +/* MEANING OF WL PI SS int PROS 6.20 + * These indicate which places the function is safe to use. They stand for: 6.21 + * 6.22 + * WL Wrapper Library -- wrapper lib code should only use these 6.23 + * PI Plugin -- plugin code should only use these 6.24 + * SS Startup and Shutdown -- designates these relate to startup & shutdown 6.25 + * int32internal to PR -- should not be used in wrapper lib or plugin 6.26 + * PROS means "OS functions for applications to use" 6.27 + * 6.28 + * PR_int__ functions touch internal PR data structs and are only safe 6.29 + * to be used inside the master lock. However, occasionally, they appear 6.30 + * in wrapper-lib or plugin code. In those cases, very careful analysis 6.31 + * has been done to be sure no concurrency issues could arise. 6.32 + * 6.33 + * PR_WL__ functions are all safe for use outside the master lock. 6.34 + * 6.35 + * PROS are only safe for applications to use -- they're like a second 6.36 + * language mixed in -- but they can't be used inside plugin code, and 6.37 + * aren't meant for use in wrapper libraries, because they are themselves 6.38 + * wrapper-library calls! 6.39 + */ 6.40 + 6.41 +//============== Top level Fns called from main =============== 6.42 +void 6.43 +PR__start(); 6.44 + 6.45 +PRProcess * 6.46 +PR__create_process( BirthFnPtr seed_Fn, void *seedData ); 6.47 + 6.48 +void 6.49 +PR__end_seedVP( SlaveVP *seedSlv ); 6.50 + 6.51 +void 6.52 +PR__end_process_from_inside( SlaveVP *seedSlv ); 6.53 + 6.54 +void * 6.55 +PR__give_results_from_process_when_ready( PRProcess *process ); 6.56 + 6.57 +void 6.58 +PR__wait_for_process_to_end( PRProcess *process ); 6.59 + 6.60 +void 6.61 +PR__wait_for_all_activity_to_end(); 6.62 + 6.63 +void 6.64 +PR__shutdown(); 6.65 + 6.66 +#define \ 6.67 +PR__create_taskID_of_size PR_WL__create_taskID_of_size 6.68 + 6.69 +inline 6.70 +int32 * 6.71 +PR__give_ID_from_slave( SlaveVP *animSlv, int32 magicNumber ); 6.72 + 6.73 +inline 6.74 +int32 * 6.75 +PR__give_ID_from_lang_meta_task( void *_task ); 6.76 + 6.77 +#define \ 6.78 +PR__malloc PR_WL__malloc 6.79 + 6.80 +#define \ 6.81 +PR__free PR_WL__free 6.82 + 6.83 + 6.84 + 6.85 +//============== include internally used fn prototypes ================ 6.86 +#include "PR__int.h" 6.87 + 6.88 + 6.89 +#define \ 6.90 +PR_WL__create_slaveVP PR_int__create_slaveVP_helper 6.91 + 6.92 +#define \ 6.93 +PR_WL__give_lang_meta_task_from_slave PR_int__give_lang_meta_task_from_slave 6.94 + 6.95 +#define \ 6.96 +PR_WL__give_prolog_of_lang_meta_task PR_int__give_prolog_of_lang_meta_task 6.97 + 6.98 +//============== Request Related =============== 6.99 + 6.100 +void 6.101 +PR_WL__suspend_slaveVP_and_send_req( SlaveVP *callingSlv ); 6.102 + 6.103 +inline void 6.104 +PR_WL__add_lang_request_in_mallocd_PRReqst( void *langReqData, 6.105 + SlaveVP *callingSlv ); 6.106 + 6.107 +inline void 6.108 +PR_WL__send_lang_request( void *langReq, RequestHandler handler, 6.109 + SlaveVP *callingSlv, int32 magicNum ); 6.110 + 6.111 +void 6.112 +PR_WL__send_create_slaveVP_req( void *langReq, int32 *ID, CreateHandler handler, 6.113 + SlaveVP *reqstingSlv, int32 magicNum ); 6.114 + 6.115 +void inline 6.116 +PR_WL__send_end_slave_req( void *langReq, RequestHandler handler, 6.117 + SlaveVP *slvToDissipate, int32 magicNum ); 6.118 + 6.119 +inline void 6.120 +PR_WL__send_service_request( void *langReqData, SlaveVP *callingSlv ); 6.121 + 6.122 +inline void 6.123 +PR_WL__send_lang_shutdown_request( SlaveVP *callingSlv, int32 magicNum ); 6.124 + 6.125 +inline 6.126 +int32 * 6.127 +PR_WL__create_taskID_of_size( int32 numInts ); 6.128 + 6.129 +//======================== MEASUREMENT ====================== 6.130 +uint64 6.131 +PR_WL__give_num_plugin_cycles(); 6.132 +uint32 6.133 +PR_WL__give_num_plugin_animations(); 6.134 + 6.135 + 6.136 +//========================= Utilities ======================= 6.137 +void 6.138 +PR_WL__throw_exception( char *msgStr, SlaveVP *reqstSlv, PRExcp *excpData ); 6.139 +#define PR_App__throw_exception PR_WL__throw_exception 6.140 + 6.141 + 6.142 +//======================================================================= 6.143 + 6.144 +//========================= Services ======================= 6.145 +//#include "Services_Offered_by_PR/Measurement_and_Stats/probes.h" 6.146 +//#include "Services_Offered_by_PR/Services_Language/PRServ.h" 6.147 +//#include "Services_Offered_by_PR/Services_Language/libPRServ.h" 6.148 + 6.149 +//================================================ 6.150 +#endif /* _PR_H */ 6.151 +
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 7.2 +++ b/PR__common.h Fri Jul 19 12:09:34 2013 -0700 7.3 @@ -0,0 +1,100 @@ 7.4 +/* 7.5 + * Copyright 2012 OpenSourceResearchInstitute.org 7.6 + * Licensed under GNU General Public License version 2 7.7 + * 7.8 + * Author: seanhalle@yahoo.com 7.9 + * 7.10 + */ 7.11 + 7.12 +#ifndef _PR_H 7.13 +#define _PR_H 7.14 +#define _GNU_SOURCE 7.15 + 7.16 +#include "DynArray/DynArray.h" 7.17 +#include "Hash_impl/PrivateHash.h" 7.18 +#include "Histogram/Histogram.h" 7.19 +#include "Queue_impl/PrivateQueue.h" 7.20 + 7.21 +#include "PR_primitive_data_types.h" 7.22 +#include "Services_Offered_by_PR/Memory_Handling/vmalloc.h" 7.23 + 7.24 +#include <pthread.h> 7.25 +#include <sys/time.h> 7.26 + 7.27 +//================= Defines: included from separate files ================= 7.28 +// 7.29 +// Note: ALL defines are in other files, none are in here 7.30 +// 7.31 +#include "Defines/PR_defs.h" 7.32 + 7.33 + 7.34 +//================================ Typedefs ================================= 7.35 +// 7.36 +#include "PR__structs.h" 7.37 + 7.38 +//============================ HW Dependent Fns ================================ 7.39 + 7.40 +#include "HW_Dependent_Primitives/PR__HW_measurement.h" 7.41 +#include "HW_Dependent_Primitives/PR__primitives.h" 7.42 + 7.43 + 7.44 +//============================= Global Vars ================================ 7.45 + 7.46 +volatile TopEnv *_PRTopEnv __align_to_cacheline__; 7.47 + 7.48 + //these are global, but only used for startup and shutdown 7.49 +pthread_t coreCtlrThdHandles[ NUM_CORES ]; //pthread's virt-procr state 7.50 +ThdParams *coreCtlrThdParams [ NUM_CORES ]; 7.51 + 7.52 +pthread_mutex_t suspendLock; 7.53 +pthread_cond_t suspendCond; 7.54 + 7.55 +//========================= Function Prototypes =========================== 7.56 +/* MEANING OF WL PI SS int PROS 7.57 + * These indicate which places the function is safe to use. They stand for: 7.58 + * 7.59 + * WL Wrapper Library -- wrapper lib code should only use these 7.60 + * PI Plugin -- plugin code should only use these 7.61 + * SS Startup and Shutdown -- designates these relate to startup & shutdown 7.62 + * int32internal to PR -- should not be used in wrapper lib or plugin 7.63 + * PROS means "OS functions for applications to use" 7.64 + * 7.65 + * PR_int__ functions touch internal PR data structs and are only safe 7.66 + * to be used inside the master lock. However, occasionally, they appear 7.67 + * in wrapper-lib or plugin code. In those cases, very careful analysis 7.68 + * has been done to be sure no concurrency issues could arise. 7.69 + * 7.70 + * PR_WL__ functions are all safe for use outside the master lock. 7.71 + * 7.72 + * PR_OS are only safe for applications to use -- they're like a second 7.73 + * language mixed in -- but they can't be used inside plugin code, and 7.74 + * aren't meant for use in wrapper libraries, because they are themselves 7.75 + * wrapper-library calls! 7.76 + */ 7.77 + 7.78 +inline bool32 masterFunction( AnimSlot *slot ); 7.79 + 7.80 +//============== include internally used fn prototypes ================ 7.81 + 7.82 +//include fn prototypes used internally in the proto-runtime implementation 7.83 +#include "PR__int.h" 7.84 + 7.85 +//include fn prototypes used by plugin 7.86 +#include "PR__PI.h" 7.87 + 7.88 +//include fn prototype used by wrapper library 7.89 +#include "PR__WL.h" 7.90 + 7.91 +//================================= 7.92 +#define implement_me() printf("Unimpl Fn: \n%s \n%s : %d\n", __FILE__, __FUNCTION__, __LINE__) 7.93 +//#define fix_me printf("Fix me at: \n%s \n%s : %s\n", __FILE__, __FUNCTION__, __LINE__) 7.94 + 7.95 + 7.96 +//========================= Services ======================= 7.97 +#include "Services_Offered_by_PR/Measurement_and_Stats/probes.h" 7.98 +#include "Services_Offered_by_PR/Services_Language/PRServ.h" 7.99 +//#include "Services_Offered_by_PR/Services_Language/libPRServ.h" 7.100 + 7.101 +//================================================ 7.102 +#endif /* _PR_H */ 7.103 +
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 8.2 +++ b/PR__common_structs.h Fri Jul 19 12:09:34 2013 -0700 8.3 @@ -0,0 +1,432 @@ 8.4 +/* 8.5 + * Copyright 2009 OpenSourceResearchInstitute.org 8.6 + * Licensed under GNU General Public License version 2 8.7 + * 8.8 + * Author: seanhalle@yahoo.com 8.9 + * 8.10 + */ 8.11 + 8.12 +#ifndef _PR__structs_H 8.13 +#define _PR__structs_H 8.14 +#define _GNU_SOURCE 8.15 + 8.16 +#include "PR_primitive_data_types.h" 8.17 + 8.18 +#include <pthread.h> 8.19 +#include <sys/time.h> 8.20 + 8.21 + 8.22 +//================================ Typedefs ================================= 8.23 +//=== 8.24 +//= 8.25 +#define ZERO 0 8.26 + 8.27 +typedef unsigned long long TSCount; 8.28 + 8.29 +typedef struct _AnimSlot AnimSlot; 8.30 +typedef struct _PRReqst PRReqst; 8.31 +typedef struct _SlaveVP SlaveVP; 8.32 +typedef struct _MasterVP MasterVP; 8.33 +typedef struct _IntervalProbe IntervalProbe; 8.34 +typedef struct _PRLangEnv PRLangEnv; //a prolog 8.35 +typedef struct _PRMetaTask PRMetaTask; //a prolog 8.36 +typedef struct _PRLangData PRLangData; //a prolog 8.37 +typedef struct _PRCollElem PRCollElem; //generic form of the prologs 8.38 + 8.39 +typedef bool32 (*SlaveAssigner) ( void *, AnimSlot* ); //langEnv, slot for HW info 8.40 +typedef void (*RequestHandler) ( void *, SlaveVP *, void * ); //req, slv, langEnv 8.41 +typedef void *(*CreateHandler) ( void *, SlaveVP *, void * ); //req, slv, langEnv 8.42 +typedef void (*LangShutdownHdlr) ( void * ); //langEnv 8.43 +typedef void *(*LangDataCreator) ( SlaveVP * ); 8.44 +typedef void (*LangDataFreer) ( void * ); //lang data to free 8.45 +typedef void *(*LangMetaTaskCreator)( SlaveVP * ); //when slave has no meta task for magic num 8.46 +typedef void (*LangMetaTaskFreer) ( void * ); //lang meta task to free 8.47 +typedef void (*MakeSlaveReadyFn) ( SlaveVP *, void * ); //slave and langEnv 8.48 +typedef void (*MakeTaskReadyFn) ( void *, void * ); //langTask and langEnv 8.49 +typedef void (*BirthFnPtr) ( void *, SlaveVP * ); //initData, animSlv 8.50 +typedef void BirthFn ( void *, SlaveVP * ); //initData, animSlv 8.51 +typedef void (*ResumeSlvFnPtr) ( SlaveVP *, void * ); 8.52 + //=========== MEASUREMENT STUFF ========== 8.53 + MEAS__Insert_Counter_Handler 8.54 + //======================================== 8.55 + 8.56 +//============================ HW Dependent Fns ================================ 8.57 + 8.58 +#include "HW_Dependent_Primitives/PR__HW_measurement.h" 8.59 +#include "HW_Dependent_Primitives/PR__primitives.h" 8.60 + 8.61 + 8.62 +typedef struct 8.63 + { //These are set by the plugin during startup and the application 8.64 + char *assignerInfo; 8.65 + char *appInfo; 8.66 + char *inputInfo; 8.67 + } 8.68 +PRSysMetaInfo; 8.69 + 8.70 +//===================== Process Data Struct ====================== 8.71 + 8.72 +/*This structure holds all the information PR needs to manage a program. PR 8.73 + * stores information about what percent of CPU time the program is getting, 8.74 + * 8.75 + */ 8.76 +typedef struct 8.77 + { 8.78 + int32 numEnvsWithWork; 8.79 + void *resultToReturn; 8.80 + 8.81 + PRLangEnv **langEnvs; //used as a hash table 8.82 + PRLangEnv **protoLangEnvsList; //for fast linear scan of envs 8.83 + int32 numLangEnvs; //for fast linear scan of envs 8.84 + 8.85 + SlaveVP *seedSlv; 8.86 + 8.87 + int32 numLiveGenericSlvs; 8.88 + int32 numLiveTasks; 8.89 + 8.90 + SlaveAssigner overrideAssigner; 8.91 + 8.92 + 8.93 + 8.94 + //These are used to coord with an OS thread waiting for process to end 8.95 + bool32 hasWaitingToEnd; 8.96 + bool32 executionIsComplete; 8.97 + pthread_mutex_t doneLock; 8.98 + pthread_cond_t doneCond; 8.99 + pthread_mutex_t doneAckLock; //waiter gets, then releases when done waiting 8.100 + 8.101 + //=========== MEASUREMENT STUFF ============= 8.102 + IntervalProbe **intervalProbes; 8.103 + PrivDynArrayInfo *dynIntervalProbesInfo; 8.104 + HashTable *probeNameHashTbl; 8.105 + int32 masterCreateProbeID; 8.106 + float64 createPtInSecs; //real-clock time PR initialized 8.107 + Histogram **measHists; 8.108 + PrivDynArrayInfo *measHistsInfo; 8.109 + MEAS__Insert_Susp_Meas_Fields_into_MasterEnv; 8.110 + MEAS__Insert_Master_Meas_Fields_into_MasterEnv; 8.111 + MEAS__Insert_Master_Lock_Meas_Fields_into_MasterEnv; 8.112 + MEAS__Insert_Malloc_Meas_Fields_into_MasterEnv; 8.113 + MEAS__Insert_Plugin_Meas_Fields_into_MasterEnv; 8.114 + MEAS__Insert_System_Meas_Fields_into_MasterEnv; 8.115 + MEAS__Insert_Counter_Meas_Fields_into_MasterEnv; 8.116 + //========================================== 8.117 + } 8.118 +PRProcess; 8.119 + 8.120 + 8.121 +//============= Request Related =========== 8.122 +// 8.123 + 8.124 +enum PRReqstType //avoid starting enums at 0, for debug reasons 8.125 + { 8.126 + TaskCreate = 1, 8.127 + TaskEnd, 8.128 + SlvCreate, 8.129 + SlvDissipate, 8.130 + Language, 8.131 + Service, //To invoke a PR provided equivalent of a language request (ex: probe) 8.132 + Hardware, 8.133 + IO, 8.134 + OSCall, 8.135 + LangShutdown, 8.136 + ProcessEnd, 8.137 + PRShutdown 8.138 + }; 8.139 + 8.140 + 8.141 +struct _PRReqst 8.142 + { 8.143 + enum PRReqstType reqType;//used for special forms that have PR behavior 8.144 + void *langReq; 8.145 + PRProcess *processReqIsIn; 8.146 + int32 langMagicNumber; 8.147 + SlaveVP *requestingSlave; 8.148 + 8.149 + BirthFnPtr topLevelFn; 8.150 + void *initData; 8.151 + int32 *ID; 8.152 + 8.153 + //The request handling structure is a bit messy.. for special forms, 8.154 + // such as create and dissipate, the language inserts pointer to handler 8.155 + // fn directly into the request.. might change to this for all requests 8.156 + RequestHandler handler; //pointer to handler fn 8.157 + CreateHandler createHdlr; //special because returns something 8.158 + int32 createSuspendedGroup; //must be non-zero 8.159 + 8.160 + PRReqst *nextReqst; 8.161 + }; 8.162 +//PRReqst 8.163 + 8.164 +enum PRServiceReqType //These are equivalent to lang requests, but for 8.165 + { // PR's services available directly to app, like OS 8.166 + make_probe = 1, // and probe services -- like a PR-wide built-in lang 8.167 + throw_excp, 8.168 + openFile, 8.169 + otherIO 8.170 + }; 8.171 + 8.172 +typedef struct 8.173 + { enum PRServiceReqType reqType; 8.174 + SlaveVP *requestingSlv; 8.175 + char *nameStr; //for create probe 8.176 + char *msgStr; //for exception 8.177 + void *exceptionData; 8.178 + } 8.179 +PRServiceReq; 8.180 + 8.181 + 8.182 +//==================== Core data structures =================== 8.183 + 8.184 +typedef struct 8.185 + { 8.186 + //for future expansion 8.187 + } 8.188 +SlotPerfInfo; 8.189 + 8.190 +struct _AnimSlot 8.191 + { 8.192 + int32 workIsDone; 8.193 + int32 needsWorkAssigned; 8.194 + SlaveVP *slaveAssignedToSlot; 8.195 + 8.196 + int32 slotIdx; //needed by Holistic Model's data gathering 8.197 + int32 coreSlotIsOn; 8.198 + SlotPerfInfo *perfInfo; //used by assigner to pick best slave for core 8.199 + }; 8.200 +//AnimSlot 8.201 + 8.202 +enum VPtype 8.203 + { SlotTaskSlv = 1,//Slave tied to an anim slot, only animates tasks 8.204 + FreeTaskSlv, //When a suspended task ends, the slave becomes this 8.205 + GenericSlv, //the VP is explicitly seen in the app code, or task suspends 8.206 + SeedSlv, 8.207 + Master_VP, 8.208 + ShutdownVP, 8.209 + IdleVP 8.210 + }; 8.211 + 8.212 +/*This structure embodies the state of a slaveVP. It is reused for masterVP 8.213 + * and shutdownVPs. 8.214 + */ 8.215 +struct _SlaveVP 8.216 + { //The offsets of these fields are hard-coded into assembly 8.217 + void *stackPtr; //save the core's stack ptr when suspend 8.218 + void *framePtr; //save core's frame ptr when suspend 8.219 + void *resumeInstrPtr; //save core's program-counter when suspend 8.220 + void *coreCtlrFramePtr; //restore before jmp back to core controller 8.221 + void *coreCtlrStackPtr; //restore before jmp back to core controller 8.222 + 8.223 + //============ below this, no fields are used in asm ============= 8.224 + 8.225 + void *startOfStack; //used to free, and to point slave to Fn 8.226 + PRProcess *processSlaveIsIn; 8.227 + enum VPtype typeOfVP; //Slave vs Master vs Shutdown.. 8.228 + int32 slaveNum; //each slave given it's seq in creation 8.229 + int32 *ID; //App defines meaning of each int in array 8.230 + int32 coreAnimatedBy; 8.231 + int32 numTimesAssignedToASlot; //Each assign is for one work-unit, so is an ID 8.232 + //note, a scheduling decision is uniquely identified by the triple: 8.233 + // <slaveNum, coreAnimatedBy, numTimesAssignedToASlot> -- used in record & replay 8.234 + 8.235 + //for comm -- between master and coreCtlr & btwn wrapper lib and plugin 8.236 + AnimSlot *animSlotAssignedTo; 8.237 + PRReqst *request; //wrapper lib puts in requests, plugin takes out 8.238 + void *dataRetFromReq;//Return vals from plugin to Wrapper Lib 8.239 + 8.240 + //For language specific data that needs to be in the slave 8.241 + //These are accessed directly for single-lang, but multi-lang places 8.242 + // a holder here instead, then uses magic num to get lang's version 8.243 + PRLangData **langDatas; //Lang saves lang-specific things in slave here 8.244 + PRMetaTask **metaTasks; 8.245 + 8.246 + //=========== MEASUREMENT STUFF ========== 8.247 + MEAS__Insert_Meas_Fields_into_Slave; 8.248 + float64 createPtInSecs; //time VP created, in seconds 8.249 + //======================================== 8.250 + 8.251 +// int8 cacheLinePad[512 - sizeof(contents)]; //for false sharing 8.252 + }; 8.253 +//SlaveVP 8.254 + 8.255 + 8.256 +enum PRMode 8.257 + { SingleLang = 1, 8.258 + StandaloneWTasks, 8.259 + MultiLang 8.260 + }; 8.261 + 8.262 +/* The one and only global variable, holds many odds and ends 8.263 + */ 8.264 +typedef struct 8.265 + { //The offsets of these fields are hard-coded into assembly 8.266 + void *coreCtlrReturnPt; //offset to this field used in asm 8.267 + int8 falseSharePad1[256 - sizeof(void*)]; 8.268 + int32 masterLock; //offset to this field used in asm 8.269 + int8 falseSharePad2[256 - sizeof(int32)]; 8.270 + int32 wrapperLock; //offset to this field used in asm 8.271 + int8 falseSharePad3[256 - sizeof(int32)]; 8.272 + int32 mallocLock; //offset to this field used in asm 8.273 + int8 falseSharePad4[256 - sizeof(int32)]; 8.274 + //============ below this, no fields are used in asm ============= 8.275 + 8.276 + //Basic PR infrastructure 8.277 +// enum PRMode mode; 8.278 + SlaveVP **masterVPs; 8.279 + AnimSlot ***allAnimSlots; 8.280 + PrivQueueStruc *slaveRecycleQ; 8.281 + SlaveVP *slotTaskSlvs[NUM_CORES][NUM_ANIM_SLOTS]; 8.282 + SlaveVP *idleSlv[NUM_CORES][NUM_ANIM_SLOTS]; 8.283 + 8.284 + //Memory management related 8.285 + MallocArrays *freeLists; 8.286 + int32 amtOfOutstandingMem;//total currently allocated 8.287 + 8.288 + //Random number seeds -- random nums used in various places 8.289 + uint32_t seed1; 8.290 + uint32_t seed2; 8.291 + 8.292 + PRSysMetaInfo *metaInfo; //info about this PR system -- vers, build, etc 8.293 + 8.294 + //============== This only used by multi-lang mode ============ 8.295 + PRProcess **processes; 8.296 + int32 numProcesses; 8.297 + int32 currProcessIdx; //used to choose which process gets slot 8.298 + int32 firstProcessReady; //use while starting up coreCtlr 8.299 + 8.300 + //initialize flags for waiting for activity within PR to complete 8.301 + bool32 allActivityIsDone; 8.302 + pthread_mutex_t activityDoneLock; 8.303 + pthread_cond_t activityDoneCond; 8.304 + 8.305 + SlaveAssigner overrideAssigner; 8.306 + 8.307 + //============== Below this is only used by single-lang mode ============== 8.308 + void *protoLangEnv; 8.309 + //Slave creation -- global count of slaves existing, across langs and processes 8.310 + int32 numSlavesCreated; //used to give unique ID to processor 8.311 + int32 numTasksCreated; //to give unique ID to a task 8.312 + int32 numSlavesAlive; 8.313 + 8.314 + bool32 *coreIsDone; 8.315 + int32 numCoresDone; 8.316 + int32 shutdownInitiated; 8.317 + 8.318 + 8.319 + //=========== MEASUREMENT STUFF ============= 8.320 + IntervalProbe **intervalProbes; 8.321 + PrivDynArrayInfo *dynIntervalProbesInfo; 8.322 + HashTable *probeNameHashTbl; 8.323 + int32 masterCreateProbeID; 8.324 + float64 createPtInSecs; //real-clock time PR initialized 8.325 + Histogram **measHists; 8.326 + PrivDynArrayInfo *measHistsInfo; 8.327 + MEAS__Insert_Susp_Meas_Fields_into_MasterEnv; 8.328 + MEAS__Insert_Master_Meas_Fields_into_MasterEnv; 8.329 + MEAS__Insert_Master_Lock_Meas_Fields_into_MasterEnv; 8.330 + MEAS__Insert_Malloc_Meas_Fields_into_MasterEnv; 8.331 + MEAS__Insert_Plugin_Meas_Fields_into_MasterEnv; 8.332 + MEAS__Insert_System_Meas_Fields_into_MasterEnv; 8.333 + MEAS__Insert_Counter_Meas_Fields_into_MasterEnv; 8.334 + //========================================== 8.335 + } 8.336 +TopEnv; 8.337 + 8.338 + 8.339 +//===================== These are prologs ==================== 8.340 +//===A prolog is data immediately before pointer returned by a create function. 8.341 +//= 8.342 +struct _PRLangEnv 8.343 + { //============== First two must match PRCollElem ============== 8.344 + int32 langMagicNumber; //indexes into hash array of langEnvs in PRProcess 8.345 + PRLangEnv *chainedLangEnv; //chains to langEnvs with same hash 8.346 + //============================================================= 8.347 + 8.348 + SlaveAssigner workAssigner; 8.349 + LangShutdownHdlr shutdownHdlr; //called when lang ended or process shutdown 8.350 + LangDataCreator langDataCreator; 8.351 + LangMetaTaskCreator langMetaTaskCreator; 8.352 + MakeSlaveReadyFn makeSlaveReadyFn; 8.353 + MakeTaskReadyFn makeTaskReadyFn; 8.354 + 8.355 + //when multi-lang, master polls lang env's to find one with work in it.. 8.356 + // in single-lang case, flag ignored, master always asks lang for work 8.357 + int32 hasWork; 8.358 + PRProcess *processEnvIsIn; 8.359 + 8.360 + int32 idxInProcess; //index into array of langEnvs in the process 8.361 + 8.362 + int32 numReadyWork; 8.363 + 8.364 + int32 numLiveWork; 8.365 + PrivQueueStruc *waitingForWorkToEndQ; 8.366 + }; 8.367 +//PRLangEnv -- this is the prolog of every lang's lang env 8.368 + 8.369 +enum PRTaskType 8.370 + { GenericSlave = 1, 8.371 + SlotTask, 8.372 + FreeTask 8.373 + }; 8.374 + 8.375 +struct _PRMetaTask 8.376 + { //============== First two must match PRCollElem ============== 8.377 + int32 langMagicNumber; 8.378 + PRMetaTask *chainedMetaTask; 8.379 + //============================================================= 8.380 + enum PRTaskType taskType; 8.381 + int32 *ID; //is standard PR ID 8.382 + PRProcess *processTaskIsIn; 8.383 + SlaveVP *slaveAssignedTo; //not valid until task animated 8.384 + BirthFnPtr topLevelFn; //This is the Fn executes as the task 8.385 + void *initData; //The data taken by the function 8.386 + LangMetaTaskFreer freer; 8.387 + bool32 goAheadAndFree; 8.388 + 8.389 + //NOTE: info needed for "wait" functionality is inside lang's metaTask 8.390 + }; 8.391 +//PRMetaTask -- prolog of every lang's meta task 8.392 + 8.393 +struct _PRLangData 8.394 + { //============== First two must match PRCollElem ============== 8.395 + int32 langMagicNumber; 8.396 + PRLangData *chainedLangData; 8.397 + //============================================================= 8.398 + LangDataFreer freer; 8.399 + bool32 goAheadAndFree; 8.400 + SlaveVP *slaveAssignedTo; 8.401 + }; 8.402 +//PRLangData -- this is the prolog of each lang's lang data 8.403 + 8.404 +struct _PRCollElem 8.405 + { 8.406 + int32 hash; 8.407 + PRCollElem *chained; 8.408 + }; 8.409 +//PRCollElem -- this is generic form of all the prologs 8.410 + 8.411 + 8.412 + 8.413 +//========================= Extra Stuff Data Strucs ======================= 8.414 +typedef struct 8.415 + { 8.416 + 8.417 + } 8.418 +PRExcp; //exception 8.419 + 8.420 +//======================= OS Thread related =============================== 8.421 + 8.422 +void * coreController( void *paramsIn ); //standard PThreads fn prototype 8.423 +void * coreCtlr_Seq( void *paramsIn ); //standard PThreads fn prototype 8.424 +void animationMaster( void *initData, SlaveVP *masterVP ); 8.425 + 8.426 + 8.427 +typedef struct 8.428 + { 8.429 + void *endThdPt; 8.430 + unsigned int coreNum; 8.431 + } 8.432 +ThdParams; 8.433 + 8.434 +#endif /* _PR__structs_H */ 8.435 +
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 9.2 +++ b/PR__int.h Fri Jul 19 12:09:34 2013 -0700 9.3 @@ -0,0 +1,244 @@ 9.4 +/* 9.5 + * Copyright 2009 OpenSourceResearchInstitute.org 9.6 + * Licensed under GNU General Public License version 2 9.7 + * 9.8 + * Author: seanhalle@yahoo.com 9.9 + * 9.10 + */ 9.11 + 9.12 +#ifndef _PR_INT_H 9.13 +#define _PR_INT_H 9.14 +#define _GNU_SOURCE 9.15 + 9.16 + 9.17 +/* MEANING OF WL PI SS int 9.18 + * These indicate which places the function is safe to use. They stand for: 9.19 + * WL: Wrapper Library 9.20 + * PI: Plugin 9.21 + * SS: Startup and Shutdown 9.22 + * int: internal to the PR implementation 9.23 + */ 9.24 + 9.25 +inline 9.26 +void 9.27 +PR_int__reset_slaveVP_to_BirthFn( SlaveVP *slaveVP, BirthFnPtr fnPtr, 9.28 + void *dataParam); 9.29 + 9.30 +inline 9.31 +void 9.32 +PR_int__point_slaveVP_to_OneParamFn( SlaveVP *slaveVP, void *fnPtr, 9.33 + void *param); 9.34 + 9.35 +inline 9.36 +void 9.37 +PR_int__point_slaveVP_to_TwoParamFn( SlaveVP *slaveVP, void *fnPtr, 9.38 + void *param1, void *param2); 9.39 + 9.40 +//=========================================================================== 9.41 +// 9.42 +//=========================================================================== 9.43 +inline 9.44 +SlaveVP * 9.45 +PR_int__create_slaveVP_helper( BirthFnPtr fnPtr, void *dataParam ); 9.46 + 9.47 +inline 9.48 +SlaveVP * 9.49 +PR_int__create_slaveVP( BirthFnPtr fnPtr, void *dataParam, PRProcess *process ); 9.50 + 9.51 +SlaveVP * 9.52 +PR_int__get_recycled_slot_slave( ); 9.53 + 9.54 +SlaveVP * 9.55 +PR_int__create_slot_slave( ); 9.56 + 9.57 +inline 9.58 +void 9.59 +PR_int__replace_with_new_slot_slv( SlaveVP *slave ); 9.60 + 9.61 +void 9.62 +idle_fn(void* data, SlaveVP *animatingSlv); 9.63 + 9.64 +inline 9.65 +void 9.66 +PR_int__put_task_into_slot( void *task, AnimSlot *slot ); 9.67 + 9.68 +inline 9.69 +void 9.70 +PR_int__put_slave_into_slot( SlaveVP *slave, AnimSlot *slot ); 9.71 + 9.72 +void inline 9.73 +PRHandle__ServiceReq( SlaveVP *requestingSlv ); 9.74 + 9.75 +void 9.76 +PR_int__free_slaveVP( SlaveVP *slave ); 9.77 + 9.78 +void 9.79 +PR_int__recycle_slaveVP( SlaveVP *slave ); 9.80 + 9.81 +void 9.82 +freeLangDataAsElem( void *elem ); 9.83 + 9.84 +void 9.85 +freeMetaTaskAsElem( void *elem ); 9.86 + 9.87 + 9.88 +//============================= 9.89 +//=== Lange Env 9.90 +//= 9.91 +inline 9.92 +void * 9.93 +PR_int__give_lang_env( PRLangEnv *protoLangEnv ); 9.94 + 9.95 +inline 9.96 +PRLangEnv * 9.97 +PR_int__give_proto_lang_env( void *langEnv ); 9.98 + 9.99 +//inline 9.100 +void * 9.101 +PR_int__create_lang_env_in_process( int32 size, PRProcess *process, int32 magicNum ); 9.102 + 9.103 +inline 9.104 +void * 9.105 +PR_int__remove_lang_env_from_process_and_free( void *langEnv ); 9.106 + 9.107 +inline 9.108 +void * 9.109 +PR_int__give_lang_env_of_req( PRReqst *req, SlaveVP *requestingSlv ); 9.110 + 9.111 +inline 9.112 +void * 9.113 +PR_int__give_lang_env_for_slave( SlaveVP *slave, int32 magicNum ); 9.114 +//No WL version -- not safe! if use env in WL, be sure data rd & wr is stable 9.115 + 9.116 +inline 9.117 +PRLangEnv * 9.118 +PR_int__give_proto_lang_env_for_slave( SlaveVP *slave, int32 magicNumber ); 9.119 +//No WL version -- not safe! if use env in WL, be sure data rd & wr is stable 9.120 + 9.121 +inline 9.122 +void * 9.123 +PR_int__give_lang_env_from_process( PRProcess *process, int32 magicNum ); 9.124 +//No WL version -- not safe! if use env in WL, be sure data rd & wr is stable 9.125 + 9.126 +inline 9.127 +PRLangEnv * 9.128 +PR_int__give_proto_lang_env_from_process( PRProcess *process, int32 magicNum ); 9.129 + 9.130 +//======================= 9.131 +//=== Meta Task 9.132 +//= 9.133 +inline 9.134 +PRMetaTask * 9.135 +PR_int__give_prolog_of_lang_meta_task( void *task ); 9.136 + 9.137 +inline 9.138 +void * 9.139 +PR_int__give_lang_meta_task_of_prolog( PRMetaTask *metaTask); 9.140 + 9.141 +inline 9.142 +void * 9.143 +PR_int__create_lang_meta_task( int32 size, LangMetaTaskFreer freer, int32 magicNum ); 9.144 + 9.145 +inline 9.146 +void * 9.147 +PR_int__create_lang_meta_task_in_slave( int32 size, LangMetaTaskFreer freer, 9.148 + SlaveVP *slave, int32 magicNum ); 9.149 + 9.150 +inline 9.151 +PRMetaTask * 9.152 +PR_int__create_generic_slave_meta_task( void *initData ); 9.153 + 9.154 +void 9.155 +PR_int__free_lang_meta_task_and_remove_from_coll( void *langMetaTask ); 9.156 + 9.157 +inline 9.158 +void 9.159 +PR_int__insert_meta_task_into_slave( PRMetaTask *task, SlaveVP *slave ); 9.160 + 9.161 +inline 9.162 +void 9.163 +PR_int__insert_lang_meta_task_into_slave__ML( void *langMetaTask, SlaveVP *slave ); 9.164 + 9.165 +inline 9.166 +void * 9.167 +PR_int__give_lang_meta_task_from_slave( SlaveVP *slave, int32 magicNumer ); 9.168 + 9.169 +inline 9.170 +SlaveVP * 9.171 +PR_PI__give_slave_lang_meta_task_is_assigned_to( void *langMetaTask ); 9.172 + 9.173 +//============== 9.174 +//=== Lang Data 9.175 +//= 9.176 +inline 9.177 +void * 9.178 +PR_PI__create_lang_data_in_slave( int32 size, LangDataFreer freer, 9.179 + SlaveVP *slave, int32 magicNum ); 9.180 + 9.181 +inline 9.182 +void * 9.183 +PR_int__give_lang_data_from_slave( SlaveVP *slave, int32 magicNumer ); 9.184 +#define PR_WL__give_lang_data PR_int__give_lang_data_from_slave 9.185 + 9.186 +inline 9.187 +void * 9.188 +PR_int__give_lang_data_of_prolog( PRLangData *langData); 9.189 + 9.190 +//================================================== 9.191 +//=== Collection 9.192 +//= 9.193 +PRCollElem ** //return an array of pointers 9.194 +PR_int__make_collection_of_size( int32 numInColl ); 9.195 + 9.196 +inline 9.197 +void 9.198 +PR_int__insert_elem_into_collection( PRCollElem *elem, PRCollElem **coll, int32 hash ); 9.199 + 9.200 +inline 9.201 +void * 9.202 +PR_int__lookup_elem_in_collection( int32 hash, PRCollElem **coll ); 9.203 + 9.204 +inline 9.205 +void 9.206 +PR_int__remove_elem_from_collection( int32 hash, PRCollElem **coll ); 9.207 + 9.208 +inline 9.209 +void 9.210 +PR_int__set_collection_to_empty( PRCollElem **coll ); 9.211 + 9.212 +inline 9.213 +void 9.214 +PR_int__apply_Fn_to_all_in_collection( void (*Fn)(void *), PRCollElem **coll ); 9.215 + 9.216 +//=========== 9.217 +//=== 9.218 +//= 9.219 +void 9.220 +PR_int__error( char *msgStr ); 9.221 + 9.222 +void 9.223 +PR_int__throw_exception( char *msgStr, SlaveVP *reqstSlv, PRExcp *excpData ); 9.224 + 9.225 +char * 9.226 +PR_int__strDup( char *str ); 9.227 + 9.228 +inline void 9.229 +PR_int__get_wrapper_lock(); 9.230 + 9.231 +inline void 9.232 +PR_int__get_malloc_lock(); 9.233 + 9.234 +#define PR_int__release_master_lock() _PRTopEnv->masterLock = UNLOCKED 9.235 + 9.236 +#define PR_int__release_wrapper_lock() _PRTopEnv->wrapperLock = UNLOCKED 9.237 + 9.238 +#define PR_int__release_malloc_lock() _PRTopEnv->mallocLock = UNLOCKED 9.239 + 9.240 +inline uint32_t 9.241 +PR_int__randomNumber(); 9.242 + 9.243 +inline void 9.244 +PR_int__backoff_for_TooLongToGetLock( int32 numTriesToGetLock ); 9.245 + 9.246 +#endif /* _PR_INT_H */ 9.247 +
10.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 10.2 +++ b/PR__primitive_data_types.h Fri Jul 19 12:09:34 2013 -0700 10.3 @@ -0,0 +1,42 @@ 10.4 +/* 10.5 + * Copyright 2009 OpenSourceResearchInstitute.org 10.6 + * Licensed under GNU General Public License version 2 10.7 + * 10.8 + * Author: seanhalle@yahoo.com 10.9 + * 10.10 + 10.11 + */ 10.12 + 10.13 +#ifndef _PRIMITIVE_DATA_TYPES_H 10.14 +#define _PRIMITIVE_DATA_TYPES_H 10.15 + 10.16 + 10.17 +/*For portability, need primitive data types that have a well defined 10.18 + * size, and well-defined layout into bytes 10.19 + *To do this, provide standard aliases for all primitive data types 10.20 + *These aliases must be used in all functions instead of the ANSI types 10.21 + * 10.22 + *When PR is used together with BLIS, these definitions will be replaced 10.23 + * inside each specialization module according to the compiler used in 10.24 + * that module and the hardware being specialized to. 10.25 + */ 10.26 +typedef char bool8; 10.27 +typedef char int8; 10.28 +typedef char uint8; 10.29 +typedef short int16; 10.30 +typedef unsigned short uint16; 10.31 +typedef int int32; 10.32 +typedef unsigned int uint32; 10.33 +typedef unsigned int bool32; 10.34 +typedef long long int64; 10.35 +typedef unsigned long long uint64; 10.36 +typedef float float32; 10.37 +typedef double float64; 10.38 +//typedef double double float128; //GCC doesn't like this 10.39 +#define float128 double double 10.40 + 10.41 +#define TRUE 1 10.42 +#define FALSE 0 10.43 + 10.44 +#endif /* _PRIMITIVE_DATA_TYPES_H */ 10.45 +
11.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 11.2 +++ b/PR__primitives.h Fri Jul 19 12:09:34 2013 -0700 11.3 @@ -0,0 +1,57 @@ 11.4 +/* 11.5 + * Copyright 2009 OpenSourceResearchInstitute.org 11.6 + * Licensed under GNU General Public License version 2 11.7 + * 11.8 + * Author: seanhalle@yahoo.com 11.9 + * 11.10 + */ 11.11 + 11.12 +#ifndef _PR__PRIMITIVES_H 11.13 +#define _PR__PRIMITIVES_H 11.14 +#define _GNU_SOURCE 11.15 + 11.16 +void 11.17 +recordCoreCtlrReturnLabelAddr(void **returnAddress); 11.18 + 11.19 +void 11.20 +switchToSlv(SlaveVP *nextSlave); 11.21 + 11.22 +void 11.23 +switchToCoreCtlr(SlaveVP *nextSlave); 11.24 + 11.25 +void 11.26 +masterSwitchToCoreCtlr(SlaveVP *nextSlave); 11.27 + 11.28 +void 11.29 +startUpBirthFn(); 11.30 + 11.31 +void 11.32 +jmpToOneParamFn(); 11.33 + 11.34 +void 11.35 +jmpToTwoParamFn(); 11.36 + 11.37 +void 11.38 +asmTerminateCoreCtlr(SlaveVP *currSlv); 11.39 +void 11.40 +asmTerminateCoreCtlrSeq(SlaveVP *animatingSlv); 11.41 + 11.42 +#define flushRegisters() \ 11.43 + asm volatile ("":::"%rbx", "%r12", "%r13","%r14","%r15") 11.44 + 11.45 +void 11.46 +PR_int__save_return_into_ptd_to_loc_then_do_ret(void *ptdToLoc); 11.47 + 11.48 +void 11.49 +PR_int__return_to_addr_in_ptd_to_loc(void *ptdToLoc); 11.50 + 11.51 +inline void 11.52 +PR_int__point_slaveVP_to_OneParamFn( SlaveVP *slaveVP, void *fnPtr, 11.53 + void *param); 11.54 + 11.55 +inline void 11.56 +PR_int__point_slaveVP_to_TwoParamFn( SlaveVP *slaveVP, void *fnPtr, 11.57 + void *param1, void *param2); 11.58 + 11.59 +#endif /* _PR__HW_DEPENDENT_H */ 11.60 +
12.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 12.2 +++ b/PR__structs.h Fri Jul 19 12:09:34 2013 -0700 12.3 @@ -0,0 +1,432 @@ 12.4 +/* 12.5 + * Copyright 2009 OpenSourceResearchInstitute.org 12.6 + * Licensed under GNU General Public License version 2 12.7 + * 12.8 + * Author: seanhalle@yahoo.com 12.9 + * 12.10 + */ 12.11 + 12.12 +#ifndef _PR__structs_H 12.13 +#define _PR__structs_H 12.14 +#define _GNU_SOURCE 12.15 + 12.16 +#include "PR_primitive_data_types.h" 12.17 + 12.18 +#include <pthread.h> 12.19 +#include <sys/time.h> 12.20 + 12.21 + 12.22 +//================================ Typedefs ================================= 12.23 +//=== 12.24 +//= 12.25 +#define ZERO 0 12.26 + 12.27 +typedef unsigned long long TSCount; 12.28 + 12.29 +typedef struct _AnimSlot AnimSlot; 12.30 +typedef struct _PRReqst PRReqst; 12.31 +typedef struct _SlaveVP SlaveVP; 12.32 +typedef struct _MasterVP MasterVP; 12.33 +typedef struct _IntervalProbe IntervalProbe; 12.34 +typedef struct _PRLangEnv PRLangEnv; //a prolog 12.35 +typedef struct _PRMetaTask PRMetaTask; //a prolog 12.36 +typedef struct _PRLangData PRLangData; //a prolog 12.37 +typedef struct _PRCollElem PRCollElem; //generic form of the prologs 12.38 + 12.39 +typedef bool32 (*SlaveAssigner) ( void *, AnimSlot* ); //langEnv, slot for HW info 12.40 +typedef void (*RequestHandler) ( void *, SlaveVP *, void * ); //req, slv, langEnv 12.41 +typedef void *(*CreateHandler) ( void *, SlaveVP *, void * ); //req, slv, langEnv 12.42 +typedef void (*LangShutdownHdlr) ( void * ); //langEnv 12.43 +typedef void *(*LangDataCreator) ( SlaveVP * ); 12.44 +typedef void (*LangDataFreer) ( void * ); //lang data to free 12.45 +typedef void *(*LangMetaTaskCreator)( SlaveVP * ); //when slave has no meta task for magic num 12.46 +typedef void (*LangMetaTaskFreer) ( void * ); //lang meta task to free 12.47 +typedef void (*MakeSlaveReadyFn) ( SlaveVP *, void * ); //slave and langEnv 12.48 +typedef void (*MakeTaskReadyFn) ( void *, void * ); //langTask and langEnv 12.49 +typedef void (*BirthFnPtr) ( void *, SlaveVP * ); //initData, animSlv 12.50 +typedef void BirthFn ( void *, SlaveVP * ); //initData, animSlv 12.51 +typedef void (*ResumeSlvFnPtr) ( SlaveVP *, void * ); 12.52 + //=========== MEASUREMENT STUFF ========== 12.53 + MEAS__Insert_Counter_Handler 12.54 + //======================================== 12.55 + 12.56 +//============================ HW Dependent Fns ================================ 12.57 + 12.58 +#include "HW_Dependent_Primitives/PR__HW_measurement.h" 12.59 +#include "HW_Dependent_Primitives/PR__primitives.h" 12.60 + 12.61 + 12.62 +typedef struct 12.63 + { //These are set by the plugin during startup and the application 12.64 + char *assignerInfo; 12.65 + char *appInfo; 12.66 + char *inputInfo; 12.67 + } 12.68 +PRSysMetaInfo; 12.69 + 12.70 +//===================== Process Data Struct ====================== 12.71 + 12.72 +/*This structure holds all the information PR needs to manage a program. PR 12.73 + * stores information about what percent of CPU time the program is getting, 12.74 + * 12.75 + */ 12.76 +typedef struct 12.77 + { 12.78 + int32 numEnvsWithWork; 12.79 + void *resultToReturn; 12.80 + 12.81 + PRLangEnv **langEnvs; //used as a hash table 12.82 + PRLangEnv **protoLangEnvsList; //for fast linear scan of envs 12.83 + int32 numLangEnvs; //for fast linear scan of envs 12.84 + 12.85 + SlaveVP *seedSlv; 12.86 + 12.87 + int32 numLiveGenericSlvs; 12.88 + int32 numLiveTasks; 12.89 + 12.90 + SlaveAssigner overrideAssigner; 12.91 + 12.92 + 12.93 + 12.94 + //These are used to coord with an OS thread waiting for process to end 12.95 + bool32 hasWaitingToEnd; 12.96 + bool32 executionIsComplete; 12.97 + pthread_mutex_t doneLock; 12.98 + pthread_cond_t doneCond; 12.99 + pthread_mutex_t doneAckLock; //waiter gets, then releases when done waiting 12.100 + 12.101 + //=========== MEASUREMENT STUFF ============= 12.102 + IntervalProbe **intervalProbes; 12.103 + PrivDynArrayInfo *dynIntervalProbesInfo; 12.104 + HashTable *probeNameHashTbl; 12.105 + int32 masterCreateProbeID; 12.106 + float64 createPtInSecs; //real-clock time PR initialized 12.107 + Histogram **measHists; 12.108 + PrivDynArrayInfo *measHistsInfo; 12.109 + MEAS__Insert_Susp_Meas_Fields_into_MasterEnv; 12.110 + MEAS__Insert_Master_Meas_Fields_into_MasterEnv; 12.111 + MEAS__Insert_Master_Lock_Meas_Fields_into_MasterEnv; 12.112 + MEAS__Insert_Malloc_Meas_Fields_into_MasterEnv; 12.113 + MEAS__Insert_Plugin_Meas_Fields_into_MasterEnv; 12.114 + MEAS__Insert_System_Meas_Fields_into_MasterEnv; 12.115 + MEAS__Insert_Counter_Meas_Fields_into_MasterEnv; 12.116 + //========================================== 12.117 + } 12.118 +PRProcess; 12.119 + 12.120 + 12.121 +//============= Request Related =========== 12.122 +// 12.123 + 12.124 +enum PRReqstType //avoid starting enums at 0, for debug reasons 12.125 + { 12.126 + TaskCreate = 1, 12.127 + TaskEnd, 12.128 + SlvCreate, 12.129 + SlvDissipate, 12.130 + Language, 12.131 + Service, //To invoke a PR provided equivalent of a language request (ex: probe) 12.132 + Hardware, 12.133 + IO, 12.134 + OSCall, 12.135 + LangShutdown, 12.136 + ProcessEnd, 12.137 + PRShutdown 12.138 + }; 12.139 + 12.140 + 12.141 +struct _PRReqst 12.142 + { 12.143 + enum PRReqstType reqType;//used for special forms that have PR behavior 12.144 + void *langReq; 12.145 + PRProcess *processReqIsIn; 12.146 + int32 langMagicNumber; 12.147 + SlaveVP *requestingSlave; 12.148 + 12.149 + BirthFnPtr topLevelFn; 12.150 + void *initData; 12.151 + int32 *ID; 12.152 + 12.153 + //The request handling structure is a bit messy.. for special forms, 12.154 + // such as create and dissipate, the language inserts pointer to handler 12.155 + // fn directly into the request.. might change to this for all requests 12.156 + RequestHandler handler; //pointer to handler fn 12.157 + CreateHandler createHdlr; //special because returns something 12.158 + int32 createSuspendedGroup; //must be non-zero 12.159 + 12.160 + PRReqst *nextReqst; 12.161 + }; 12.162 +//PRReqst 12.163 + 12.164 +enum PRServiceReqType //These are equivalent to lang requests, but for 12.165 + { // PR's services available directly to app, like OS 12.166 + make_probe = 1, // and probe services -- like a PR-wide built-in lang 12.167 + throw_excp, 12.168 + openFile, 12.169 + otherIO 12.170 + }; 12.171 + 12.172 +typedef struct 12.173 + { enum PRServiceReqType reqType; 12.174 + SlaveVP *requestingSlv; 12.175 + char *nameStr; //for create probe 12.176 + char *msgStr; //for exception 12.177 + void *exceptionData; 12.178 + } 12.179 +PRServiceReq; 12.180 + 12.181 + 12.182 +//==================== Core data structures =================== 12.183 + 12.184 +typedef struct 12.185 + { 12.186 + //for future expansion 12.187 + } 12.188 +SlotPerfInfo; 12.189 + 12.190 +struct _AnimSlot 12.191 + { 12.192 + int32 workIsDone; 12.193 + int32 needsWorkAssigned; 12.194 + SlaveVP *slaveAssignedToSlot; 12.195 + 12.196 + int32 slotIdx; //needed by Holistic Model's data gathering 12.197 + int32 coreSlotIsOn; 12.198 + SlotPerfInfo *perfInfo; //used by assigner to pick best slave for core 12.199 + }; 12.200 +//AnimSlot 12.201 + 12.202 +enum VPtype 12.203 + { SlotTaskSlv = 1,//Slave tied to an anim slot, only animates tasks 12.204 + FreeTaskSlv, //When a suspended task ends, the slave becomes this 12.205 + GenericSlv, //the VP is explicitly seen in the app code, or task suspends 12.206 + SeedSlv, 12.207 + Master_VP, 12.208 + ShutdownVP, 12.209 + IdleVP 12.210 + }; 12.211 + 12.212 +/*This structure embodies the state of a slaveVP. It is reused for masterVP 12.213 + * and shutdownVPs. 12.214 + */ 12.215 +struct _SlaveVP 12.216 + { //The offsets of these fields are hard-coded into assembly 12.217 + void *stackPtr; //save the core's stack ptr when suspend 12.218 + void *framePtr; //save core's frame ptr when suspend 12.219 + void *resumeInstrPtr; //save core's program-counter when suspend 12.220 + void *coreCtlrFramePtr; //restore before jmp back to core controller 12.221 + void *coreCtlrStackPtr; //restore before jmp back to core controller 12.222 + 12.223 + //============ below this, no fields are used in asm ============= 12.224 + 12.225 + void *startOfStack; //used to free, and to point slave to Fn 12.226 + PRProcess *processSlaveIsIn; 12.227 + enum VPtype typeOfVP; //Slave vs Master vs Shutdown.. 12.228 + int32 slaveNum; //each slave given it's seq in creation 12.229 + int32 *ID; //App defines meaning of each int in array 12.230 + int32 coreAnimatedBy; 12.231 + int32 numTimesAssignedToASlot; //Each assign is for one work-unit, so is an ID 12.232 + //note, a scheduling decision is uniquely identified by the triple: 12.233 + // <slaveNum, coreAnimatedBy, numTimesAssignedToASlot> -- used in record & replay 12.234 + 12.235 + //for comm -- between master and coreCtlr & btwn wrapper lib and plugin 12.236 + AnimSlot *animSlotAssignedTo; 12.237 + PRReqst *request; //wrapper lib puts in requests, plugin takes out 12.238 + void *dataRetFromReq;//Return vals from plugin to Wrapper Lib 12.239 + 12.240 + //For language specific data that needs to be in the slave 12.241 + //These are accessed directly for single-lang, but multi-lang places 12.242 + // a holder here instead, then uses magic num to get lang's version 12.243 + PRLangData **langDatas; //Lang saves lang-specific things in slave here 12.244 + PRMetaTask **metaTasks; 12.245 + 12.246 + //=========== MEASUREMENT STUFF ========== 12.247 + MEAS__Insert_Meas_Fields_into_Slave; 12.248 + float64 createPtInSecs; //time VP created, in seconds 12.249 + //======================================== 12.250 + 12.251 +// int8 cacheLinePad[512 - sizeof(contents)]; //for false sharing 12.252 + }; 12.253 +//SlaveVP 12.254 + 12.255 + 12.256 +enum PRMode 12.257 + { SingleLang = 1, 12.258 + StandaloneWTasks, 12.259 + MultiLang 12.260 + }; 12.261 + 12.262 +/* The one and only global variable, holds many odds and ends 12.263 + */ 12.264 +typedef struct 12.265 + { //The offsets of these fields are hard-coded into assembly 12.266 + void *coreCtlrReturnPt; //offset to this field used in asm 12.267 + int8 falseSharePad1[256 - sizeof(void*)]; 12.268 + int32 masterLock; //offset to this field used in asm 12.269 + int8 falseSharePad2[256 - sizeof(int32)]; 12.270 + int32 wrapperLock; //offset to this field used in asm 12.271 + int8 falseSharePad3[256 - sizeof(int32)]; 12.272 + int32 mallocLock; //offset to this field used in asm 12.273 + int8 falseSharePad4[256 - sizeof(int32)]; 12.274 + //============ below this, no fields are used in asm ============= 12.275 + 12.276 + //Basic PR infrastructure 12.277 +// enum PRMode mode; 12.278 + SlaveVP **masterVPs; 12.279 + AnimSlot ***allAnimSlots; 12.280 + PrivQueueStruc *slaveRecycleQ; 12.281 + SlaveVP *slotTaskSlvs[NUM_CORES][NUM_ANIM_SLOTS]; 12.282 + SlaveVP *idleSlv[NUM_CORES][NUM_ANIM_SLOTS]; 12.283 + 12.284 + //Memory management related 12.285 + MallocArrays *freeLists; 12.286 + int32 amtOfOutstandingMem;//total currently allocated 12.287 + 12.288 + //Random number seeds -- random nums used in various places 12.289 + uint32_t seed1; 12.290 + uint32_t seed2; 12.291 + 12.292 + PRSysMetaInfo *metaInfo; //info about this PR system -- vers, build, etc 12.293 + 12.294 + //============== This only used by multi-lang mode ============ 12.295 + PRProcess **processes; 12.296 + int32 numProcesses; 12.297 + int32 currProcessIdx; //used to choose which process gets slot 12.298 + int32 firstProcessReady; //use while starting up coreCtlr 12.299 + 12.300 + //initialize flags for waiting for activity within PR to complete 12.301 + bool32 allActivityIsDone; 12.302 + pthread_mutex_t activityDoneLock; 12.303 + pthread_cond_t activityDoneCond; 12.304 + 12.305 + SlaveAssigner overrideAssigner; 12.306 + 12.307 + //============== Below this is only used by single-lang mode ============== 12.308 + void *protoLangEnv; 12.309 + //Slave creation -- global count of slaves existing, across langs and processes 12.310 + int32 numSlavesCreated; //used to give unique ID to processor 12.311 + int32 numTasksCreated; //to give unique ID to a task 12.312 + int32 numSlavesAlive; 12.313 + 12.314 + bool32 *coreIsDone; 12.315 + int32 numCoresDone; 12.316 + int32 shutdownInitiated; 12.317 + 12.318 + 12.319 + //=========== MEASUREMENT STUFF ============= 12.320 + IntervalProbe **intervalProbes; 12.321 + PrivDynArrayInfo *dynIntervalProbesInfo; 12.322 + HashTable *probeNameHashTbl; 12.323 + int32 masterCreateProbeID; 12.324 + float64 createPtInSecs; //real-clock time PR initialized 12.325 + Histogram **measHists; 12.326 + PrivDynArrayInfo *measHistsInfo; 12.327 + MEAS__Insert_Susp_Meas_Fields_into_MasterEnv; 12.328 + MEAS__Insert_Master_Meas_Fields_into_MasterEnv; 12.329 + MEAS__Insert_Master_Lock_Meas_Fields_into_MasterEnv; 12.330 + MEAS__Insert_Malloc_Meas_Fields_into_MasterEnv; 12.331 + MEAS__Insert_Plugin_Meas_Fields_into_MasterEnv; 12.332 + MEAS__Insert_System_Meas_Fields_into_MasterEnv; 12.333 + MEAS__Insert_Counter_Meas_Fields_into_MasterEnv; 12.334 + //========================================== 12.335 + } 12.336 +TopEnv; 12.337 + 12.338 + 12.339 +//===================== These are prologs ==================== 12.340 +//===A prolog is data immediately before pointer returned by a create function. 12.341 +//= 12.342 +struct _PRLangEnv 12.343 + { //============== First two must match PRCollElem ============== 12.344 + int32 langMagicNumber; //indexes into hash array of langEnvs in PRProcess 12.345 + PRLangEnv *chainedLangEnv; //chains to langEnvs with same hash 12.346 + //============================================================= 12.347 + 12.348 + SlaveAssigner workAssigner; 12.349 + LangShutdownHdlr shutdownHdlr; //called when lang ended or process shutdown 12.350 + LangDataCreator langDataCreator; 12.351 + LangMetaTaskCreator langMetaTaskCreator; 12.352 + MakeSlaveReadyFn makeSlaveReadyFn; 12.353 + MakeTaskReadyFn makeTaskReadyFn; 12.354 + 12.355 + //when multi-lang, master polls lang env's to find one with work in it.. 12.356 + // in single-lang case, flag ignored, master always asks lang for work 12.357 + int32 hasWork; 12.358 + PRProcess *processEnvIsIn; 12.359 + 12.360 + int32 idxInProcess; //index into array of langEnvs in the process 12.361 + 12.362 + int32 numReadyWork; 12.363 + 12.364 + int32 numLiveWork; 12.365 + PrivQueueStruc *waitingForWorkToEndQ; 12.366 + }; 12.367 +//PRLangEnv -- this is the prolog of every lang's lang env 12.368 + 12.369 +enum PRTaskType 12.370 + { GenericSlave = 1, 12.371 + SlotTask, 12.372 + FreeTask 12.373 + }; 12.374 + 12.375 +struct _PRMetaTask 12.376 + { //============== First two must match PRCollElem ============== 12.377 + int32 langMagicNumber; 12.378 + PRMetaTask *chainedMetaTask; 12.379 + //============================================================= 12.380 + enum PRTaskType taskType; 12.381 + int32 *ID; //is standard PR ID 12.382 + PRProcess *processTaskIsIn; 12.383 + SlaveVP *slaveAssignedTo; //not valid until task animated 12.384 + BirthFnPtr topLevelFn; //This is the Fn executes as the task 12.385 + void *initData; //The data taken by the function 12.386 + LangMetaTaskFreer freer; 12.387 + bool32 goAheadAndFree; 12.388 + 12.389 + //NOTE: info needed for "wait" functionality is inside lang's metaTask 12.390 + }; 12.391 +//PRMetaTask -- prolog of every lang's meta task 12.392 + 12.393 +struct _PRLangData 12.394 + { //============== First two must match PRCollElem ============== 12.395 + int32 langMagicNumber; 12.396 + PRLangData *chainedLangData; 12.397 + //============================================================= 12.398 + LangDataFreer freer; 12.399 + bool32 goAheadAndFree; 12.400 + SlaveVP *slaveAssignedTo; 12.401 + }; 12.402 +//PRLangData -- this is the prolog of each lang's lang data 12.403 + 12.404 +struct _PRCollElem 12.405 + { 12.406 + int32 hash; 12.407 + PRCollElem *chained; 12.408 + }; 12.409 +//PRCollElem -- this is generic form of all the prologs 12.410 + 12.411 + 12.412 + 12.413 +//========================= Extra Stuff Data Strucs ======================= 12.414 +typedef struct 12.415 + { 12.416 + 12.417 + } 12.418 +PRExcp; //exception 12.419 + 12.420 +//======================= OS Thread related =============================== 12.421 + 12.422 +void * coreController( void *paramsIn ); //standard PThreads fn prototype 12.423 +void * coreCtlr_Seq( void *paramsIn ); //standard PThreads fn prototype 12.424 +void animationMaster( void *initData, SlaveVP *masterVP ); 12.425 + 12.426 + 12.427 +typedef struct 12.428 + { 12.429 + void *endThdPt; 12.430 + unsigned int coreNum; 12.431 + } 12.432 +ThdParams; 12.433 + 12.434 +#endif /* _PR__structs_H */ 12.435 +
13.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 13.2 +++ b/__README_repo_purpose__.txt Fri Jul 19 12:09:34 2013 -0700 13.3 @@ -0,0 +1,16 @@ 13.4 + 13.5 +This repository contains the common definitions that are used by all the other sub-directories.. 13.6 + 13.7 +That is, the wrapper libraries, as well as the core implementations of both PR and the language, all include the files from this directory. 13.8 + 13.9 +Any includes that are needed by multiple other repositories are held in this repository. 13.10 + 13.11 +Hence, this repo will be included with the application, along with the language's wrapper lib and PR's wrapper lib. 13.12 + 13.13 +This repo will also be included in the place where a given leaf-level proto-runtime library is developed, and where each upper level proto-runtime library is developed. 13.14 + 13.15 +And, it will be included where the language's plugin dynamic library is developed. 13.16 + 13.17 +So, any defines or function prototypes, or data structs that are needed in two or more of those places are included in here. 13.18 + 13.19 +Note that because this repo is included in the application development environment, anything in it will be visible to application code.. hence, the less it has the better. 13.20 \ No newline at end of file
