Mercurial > cgi-bin > hgwebdir.cgi > PR > PR_Implementations > PR__Univ > PR__includes > PR__include
changeset 0:d460a47ed2d6 Dev_Univ
public headers for the initial ML split into libraries, as seed for Univ
| author | Sean Halle <seanhalle@yahoo.com> |
|---|---|
| date | Thu, 08 Aug 2013 02:39:56 -0700 |
| parents | |
| children | 14241f07f742 e6b7ac0e6d73 10986666560d 6c0691c4f2a6 |
| files | .hgeol PR__PI.h PR__SS.h PR__WL.h PR__int.h PR__primitive_data_types.h PR__structs__common.h Services_offered_by_PR/DEBUG__macros.h Services_offered_by_PR/MEAS__Counter_Recording.h Services_offered_by_PR/MEAS__macros.h Services_offered_by_PR/prdependency.h Services_offered_by_PR/probes__wrapper_library.h __README__about_dir.txt __brch__Dev_Univ langlets/vreo_wrapper_library.h prdynarray.h prhash.h prhistogram.h prlistofarrays.h prmalloc.h prparam.h prqueue.h |
| diffstat | 22 files changed, 2699 insertions(+), 0 deletions(-) [+] |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/.hgeol Thu Aug 08 02:39:56 2013 -0700 1.3 @@ -0,0 +1,12 @@ 1.4 + 1.5 +[patterns] 1.6 +**.py = native 1.7 +**.txt = native 1.8 +**.c = native 1.9 +**.h = native 1.10 +**.cpp = native 1.11 +**.java = native 1.12 +**.sh = native 1.13 +**.pl = native 1.14 +**.jpg = bin 1.15 +**.gif = bin
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/PR__PI.h Thu Aug 08 02:39:56 2013 -0700 2.3 @@ -0,0 +1,196 @@ 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__PI_H 2.13 +#define _PR__PI_H 2.14 +#define _GNU_SOURCE 2.15 + 2.16 +#include <PR__include/PR__structs__common.h> 2.17 + 2.18 +//========================= Function Prototypes =========================== 2.19 +/* MEANING OF WL PI SS int PROS 2.20 + * These indicate which places the function is safe to use. They stand for: 2.21 + * 2.22 + * WL Wrapper Library -- wrapper lib code should only use these 2.23 + * PI Plugin -- plugin code should only use these 2.24 + * SS Startup and Shutdown -- designates these relate to startup & shutdown 2.25 + * int32internal to PR -- should not be used in wrapper lib or plugin 2.26 + * PROS means "OS functions for applications to use" 2.27 + * 2.28 + * PR_int__ functions touch internal PR data structs and are only safe 2.29 + * to be used inside the master lock. However, occasionally, they appear 2.30 + * in wrapper-lib or plugin code. In those cases, very careful analysis 2.31 + * has been done to be sure no concurrency issues could arise. 2.32 + * 2.33 + * PR_WL__ functions are all safe for use outside the master lock. 2.34 + * 2.35 + * PROS are only safe for applications to use -- they're like a second 2.36 + * language mixed in -- but they can't be used inside plugin code, and 2.37 + * aren't meant for use in wrapper libraries, because they are themselves 2.38 + * wrapper-library calls! 2.39 + */ 2.40 + 2.41 +#define \ 2.42 +PR_PI__create_slaveVP PR_int__create_slaveVP_helper 2.43 + 2.44 +//============== 2.45 +//=== Lang Data 2.46 +//= 2.47 +#define \ 2.48 +PR_PI__give_lang_data_from_slave PR_int__give_lang_data_from_slave 2.49 +#define \ 2.50 +PR_SS__give_lang_data_from_slave PR_int__give_lang_data_from_slave 2.51 + 2.52 +int32 2.53 +PR_PI__give_num_cores(); 2.54 + 2.55 +//============ 2.56 +//=== Lang Env 2.57 +//= 2.58 +#define \ 2.59 +PR_PI__give_proto_lang_env_for_slave PR_int__give_proto_lang_env_for_slave 2.60 +#define \ 2.61 +PR_PI__give_lang_env_for_slave PR_int__give_lang_env_for_slave 2.62 +#define \ 2.63 +PR_PI__give_lang_env_from_process PR_int__give_lang_env_from_process 2.64 + 2.65 + 2.66 +//========= 2.67 +//=== Meta Task 2.68 +//= 2.69 +#define \ 2.70 +PR_PI__give_lang_meta_task_from_slave PR_int__give_lang_meta_task_from_slave 2.71 +#define \ 2.72 +PR_PI__give_prolog_of_lang_meta_task PR_int__give_prolog_of_lang_meta_task 2.73 + 2.74 +SlaveVP * 2.75 +PR_PI__give_slave_lang_meta_task_is_assigned_to( void *langMetaTask ); 2.76 + 2.77 +#define \ 2.78 +PR_PI__free_lang_meta_task_and_remove_from_slave PR_int__free_lang_meta_task_and_remove_from_coll 2.79 + 2.80 +#define \ 2.81 +PR_PI__free_lang_meta_task PR_int__free_lang_meta_task 2.82 + 2.83 +void 2.84 +PR_PI__set_no_del_flag_in_lang_meta_task( void *langMetaTask ); 2.85 +void 2.86 +PR_PI__clear_no_del_flag_in_lang_meta_task( void *langMetaTask ); 2.87 + 2.88 +//========== 2.89 +//=== 2.90 +//= 2.91 +#define \ 2.92 +PR_PI__give_ID_from_lang_meta_task PR__give_ID_from_lang_meta_task 2.93 +#define \ 2.94 +PR_PI__give_ID_from_slave PR__give_ID_from_slave 2.95 + 2.96 +//============= 2.97 +//=== 2.98 +//= 2.99 +#define \ 2.100 +PR_PI__put_slave_into_slot PR_int__put_slave_into_slot 2.101 +#define \ 2.102 +PR_PI__put_task_into_slot PR_int__put_task_into_slot 2.103 + 2.104 +PRReqst * 2.105 +PR_PI__take_next_request_out_of( SlaveVP *slaveWithReq ); 2.106 + 2.107 +#define \ 2.108 +PR_PI__take_lang_reqst_from( req ) req->langReq 2.109 + 2.110 +void 2.111 +PR_PI__resume_slave_in_PRServ( SlaveVP *slave ); 2.112 + 2.113 +#define \ 2.114 +PR_PI__malloc PR_int__malloc 2.115 +#define \ 2.116 +PR_PI__malloc_aligned PR_int__malloc_aligned 2.117 +#define \ 2.118 +PR_PI__free PR_int__free 2.119 + 2.120 + 2.121 +#define \ 2.122 +PR_PI__throw_exception PR_int__throw_exception 2.123 + 2.124 +//=============== Startup and Shutdown ================ 2.125 +//=== 2.126 +//= 2.127 +void 2.128 +PR_SS__create_topEnv(); 2.129 + 2.130 +AnimSlot ** 2.131 +PR_SS__create_anim_slots( int32 coreSlotsAreOn ); 2.132 + 2.133 +void 2.134 +PR_SS__create_the_coreCtlr_OS_threads(); 2.135 + 2.136 +//=================== 2.137 +void * 2.138 +PR_SS__create_lang_env( int32 size, SlaveVP *slave, int32 magicNum ); 2.139 + 2.140 +void 2.141 +PR_SS__register_assigner( SlaveAssigner assigner, SlaveVP *seedVP, int32 magicNum ); 2.142 +void 2.143 +PR_SS__register_lang_shutdown_handler( LangShutdownHdlr shutdownHdlr, SlaveVP *seedVP, 2.144 + int32 magicNum ); 2.145 +void 2.146 +PR_SS__register_lang_data_creator( LangDataCreator langDataCreator, 2.147 + SlaveVP *seedVP, int32 magicNum ); 2.148 +void 2.149 +PR_SS__register_lang_meta_task_creator( LangDataCreator langMetaTaskCreator, 2.150 + SlaveVP *seedVP, int32 magicNum ); 2.151 +void 2.152 +PR_SS__register_make_slave_ready_fn( MakeSlaveReadyFn fn, SlaveVP *seedVP, 2.153 + int32 magicNum ); 2.154 +void 2.155 +PR_SS__register_make_task_ready_fn( MakeTaskReadyFn fn, SlaveVP *seedVP, 2.156 + int32 magicNum ); 2.157 +//=================== 2.158 + 2.159 +void 2.160 +PR_SS__end_process_normally( PRProcess *process ); 2.161 + 2.162 +void 2.163 +PR_SS__shutdown_OS_threads(); 2.164 + 2.165 +SlaveVP* 2.166 +PR_SS__create_shutdown_slave(); 2.167 + 2.168 +void 2.169 +PR_SS__cleanup_at_end_of_shutdown(); 2.170 + 2.171 +void 2.172 +PR_SS__print_out_measurements(); 2.173 + 2.174 +void 2.175 +PR_SS__wait_for_PR_to_shutdown(); 2.176 + 2.177 + 2.178 +//============================= 2.179 +//=== 2.180 +//= 2.181 + 2.182 +#define \ 2.183 +PR_SS__give_proto_lang_env_for_slave PR_int__give_proto_lang_env_for_slave 2.184 + 2.185 +#define \ 2.186 +PR_SS__give_lang_meta_task_from_slave PR_int__give_lang_meta_task_from_slave 2.187 +#define \ 2.188 +PR_SS__give_lang_env_for_slave PR_int__give_lang_env_for_slave 2.189 +#define \ 2.190 +PR_SS__give_lang_env_from_process PR_int__give_lang_env_from_process 2.191 + 2.192 +#define \ 2.193 +PR_SS__malloc PR_WL__malloc /*SS happens outside the Master*/ 2.194 +#define \ 2.195 +PR_SS__free PR_WL__free 2.196 + 2.197 +//================================================ 2.198 +#endif /* _PR__PI_H */ 2.199 +
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/PR__SS.h Thu Aug 08 02:39:56 2013 -0700 3.3 @@ -0,0 +1,119 @@ 3.4 +/* 3.5 + * Copyright 2009 OpenSourceResearchInstitute.org 3.6 + * Licensed under GNU General Public License version 2 3.7 + * 3.8 + * Author: seanhalle@yahoo.com 3.9 + * 3.10 + */ 3.11 + 3.12 +#ifndef _PR__SS_H 3.13 +#define _PR__SS_H 3.14 +#define _GNU_SOURCE 3.15 + 3.16 +#include <PR__include/PR__structs__common.h> 3.17 + 3.18 +//========================= Function Prototypes =========================== 3.19 +/* MEANING OF WL PI SS int PROS 3.20 + * These indicate which places the function is safe to use. They stand for: 3.21 + * 3.22 + * WL Wrapper Library -- wrapper lib code should only use these 3.23 + * PI Plugin -- plugin code should only use these 3.24 + * SS Startup and Shutdown -- designates these relate to startup & shutdown 3.25 + * int32internal to PR -- should not be used in wrapper lib or plugin 3.26 + * PROS means "OS functions for applications to use" 3.27 + * 3.28 + * PR_int__ functions touch internal PR data structs and are only safe 3.29 + * to be used inside the master lock. However, occasionally, they appear 3.30 + * in wrapper-lib or plugin code. In those cases, very careful analysis 3.31 + * has been done to be sure no concurrency issues could arise. 3.32 + * 3.33 + * PR_WL__ functions are all safe for use outside the master lock. 3.34 + * 3.35 + * PROS are only safe for applications to use -- they're like a second 3.36 + * language mixed in -- but they can't be used inside plugin code, and 3.37 + * aren't meant for use in wrapper libraries, because they are themselves 3.38 + * wrapper-library calls! 3.39 + */ 3.40 + 3.41 +//=============== Startup and Shutdown ================ 3.42 +//=== 3.43 +//= Some of these are for PR internal use only, others for langlet use 3.44 + 3.45 + 3.46 +#define \ 3.47 +PR_SS__malloc PR_WL__malloc /*SS happens outside the Master*/ 3.48 +#define \ 3.49 +PR_SS__free PR_WL__free 3.50 + 3.51 +//=================== 3.52 +void * 3.53 +PR_SS__create_lang_env( int32 size, SlaveVP *slave, int32 magicNum ); 3.54 + 3.55 +void 3.56 +PR_SS__register_assigner( SlaveAssigner assigner, SlaveVP *seedVP, int32 magicNum ); 3.57 +void 3.58 +PR_SS__register_lang_shutdown_handler( LangShutdownHdlr shutdownHdlr, SlaveVP *seedVP, 3.59 + int32 magicNum ); 3.60 +void 3.61 +PR_SS__register_lang_data_creator( LangDataCreator langDataCreator, 3.62 + SlaveVP *seedVP, int32 magicNum ); 3.63 +void 3.64 +PR_SS__register_lang_meta_task_creator( LangDataCreator langMetaTaskCreator, 3.65 + SlaveVP *seedVP, int32 magicNum ); 3.66 +void 3.67 +PR_SS__register_make_slave_ready_fn( MakeSlaveReadyFn fn, SlaveVP *seedVP, 3.68 + int32 magicNum ); 3.69 +void 3.70 +PR_SS__register_make_task_ready_fn( MakeTaskReadyFn fn, SlaveVP *seedVP, 3.71 + int32 magicNum ); 3.72 + 3.73 + 3.74 +//================================ 3.75 +//=== 3.76 +//= PR internal use only 3.77 +void 3.78 +PR_SS__create_topEnv(); 3.79 + 3.80 +AnimSlot ** 3.81 +PR_SS__create_anim_slots( int32 coreSlotsAreOn ); 3.82 + 3.83 +void 3.84 +PR_SS__create_the_coreCtlr_OS_threads(); 3.85 +//=================== 3.86 + 3.87 +void 3.88 +PR_SS__end_process_normally( PRProcess *process ); 3.89 + 3.90 +void 3.91 +PR_SS__shutdown_OS_threads(); 3.92 + 3.93 +SlaveVP* 3.94 +PR_SS__create_shutdown_slave(); 3.95 + 3.96 +void 3.97 +PR_SS__cleanup_at_end_of_shutdown(); 3.98 + 3.99 +void 3.100 +PR_SS__print_out_measurements(); 3.101 + 3.102 +void 3.103 +PR_SS__wait_for_PR_to_shutdown(); 3.104 + 3.105 +//============================= 3.106 +//=== 3.107 +//= 3.108 + 3.109 +#define \ 3.110 +PR_SS__give_lang_data_from_slave PR_int__give_lang_data_from_slave 3.111 +#define \ 3.112 +PR_SS__give_lang_meta_task_from_slave PR_int__give_lang_meta_task_from_slave 3.113 +#define \ 3.114 +PR_SS__give_proto_lang_env_for_slave PR_int__give_proto_lang_env_for_slave 3.115 +#define \ 3.116 +PR_SS__give_lang_env_for_slave PR_int__give_lang_env_for_slave 3.117 +#define \ 3.118 +PR_SS__give_lang_env_from_process PR_int__give_lang_env_from_process 3.119 + 3.120 +//================================================ 3.121 +#endif /* */ 3.122 +
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 4.2 +++ b/PR__WL.h Thu Aug 08 02:39:56 2013 -0700 4.3 @@ -0,0 +1,142 @@ 4.4 +/* 4.5 + * Copyright 2009 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__WL_H 4.13 +#define _PR__WL_H 4.14 +#define _GNU_SOURCE 4.15 + 4.16 +#include <PR__include/PR__primitive_data_types.h> 4.17 +#include <PR__include/PR__structs__common.h> 4.18 +//========================= Function Prototypes =========================== 4.19 +/* MEANING OF WL PI SS int PROS 4.20 + * These indicate which places the function is safe to use. They stand for: 4.21 + * 4.22 + * WL Wrapper Library -- wrapper lib code should only use these 4.23 + * PI Plugin -- plugin code should only use these 4.24 + * SS Startup and Shutdown -- designates these relate to startup & shutdown 4.25 + * int32internal to PR -- should not be used in wrapper lib or plugin 4.26 + * PROS means "OS functions for applications to use" 4.27 + * 4.28 + * PR_int__ functions touch internal PR data structs and are only safe 4.29 + * to be used inside the master lock. However, occasionally, they appear 4.30 + * in wrapper-lib or plugin code. In those cases, very careful analysis 4.31 + * has been done to be sure no concurrency issues could arise. 4.32 + * 4.33 + * PR_WL__ functions are all safe for use outside the master lock. 4.34 + * 4.35 + * PROS are only safe for applications to use -- they're like a second 4.36 + * language mixed in -- but they can't be used inside plugin code, and 4.37 + * aren't meant for use in wrapper libraries, because they are themselves 4.38 + * wrapper-library calls! 4.39 + */ 4.40 + 4.41 +//============== Top level Fns called from main =============== 4.42 +void 4.43 +PR__start(); 4.44 + 4.45 +PRProcess * 4.46 +PR__create_process( BirthFnPtr seed_Fn, void *seedData ); 4.47 + 4.48 +void 4.49 +PR__end_seedVP( SlaveVP *seedSlv ); 4.50 + 4.51 +void 4.52 +PR__end_process_from_inside( SlaveVP *seedSlv ); 4.53 + 4.54 +void * 4.55 +PR__give_results_from_process_when_ready( PRProcess *process ); 4.56 + 4.57 +void 4.58 +PR__wait_for_process_to_end( PRProcess *process ); 4.59 + 4.60 +void 4.61 +PR__wait_for_all_activity_to_end(); 4.62 + 4.63 +void 4.64 +PR__shutdown(); 4.65 + 4.66 +#define \ 4.67 +PR__create_taskID_of_size PR_WL__create_taskID_of_size 4.68 + 4.69 +inline 4.70 +int32 * 4.71 +PR__give_ID_from_slave( SlaveVP *animSlv, int32 magicNumber ); 4.72 + 4.73 +inline 4.74 +int32 * 4.75 +PR__give_ID_from_lang_meta_task( void *_task ); 4.76 + 4.77 + 4.78 +//============== include internally used fn prototypes ================ 4.79 +#include "PR__int.h" 4.80 + 4.81 +#define PR_WL__give_lang_data PR_int__give_lang_data_from_slave 4.82 + 4.83 +#define \ 4.84 +PR_WL__create_slaveVP PR_int__create_slaveVP_helper 4.85 + 4.86 +#define \ 4.87 +PR_WL__give_lang_meta_task_from_slave PR_int__give_lang_meta_task_from_slave 4.88 + 4.89 +#define \ 4.90 +PR_WL__give_prolog_of_lang_meta_task PR_int__give_prolog_of_lang_meta_task 4.91 + 4.92 +//============== Request Related =============== 4.93 + 4.94 +void 4.95 +PR_WL__suspend_slaveVP_and_send_req( SlaveVP *callingSlv ); 4.96 + 4.97 +inline void 4.98 +PR_WL__add_lang_request_in_mallocd_PRReqst( void *langReqData, 4.99 + SlaveVP *callingSlv ); 4.100 + 4.101 +inline void 4.102 +PR_WL__send_lang_request( void *langReq, RequestHandler handler, 4.103 + SlaveVP *callingSlv, int32 magicNum ); 4.104 + 4.105 +void 4.106 +PR_WL__send_create_slaveVP_req( void *langReq, int32 *ID, CreateHandler handler, 4.107 + SlaveVP *reqstingSlv, int32 magicNum ); 4.108 + 4.109 +void inline 4.110 +PR_WL__send_end_slave_req( void *langReq, RequestHandler handler, 4.111 + SlaveVP *slvToDissipate, int32 magicNum ); 4.112 + 4.113 +inline void 4.114 +PR_WL__send_service_request( void *langReqData, SlaveVP *callingSlv ); 4.115 + 4.116 +inline void 4.117 +PR_WL__send_lang_shutdown_request( SlaveVP *callingSlv, int32 magicNum ); 4.118 + 4.119 +inline 4.120 +int32 * 4.121 +PR_WL__create_taskID_of_size( int32 numInts ); 4.122 + 4.123 +//======================== MEASUREMENT ====================== 4.124 +uint64 4.125 +PR_WL__give_num_plugin_cycles(); 4.126 +uint32 4.127 +PR_WL__give_num_plugin_animations(); 4.128 + 4.129 + 4.130 +//========================= Utilities ======================= 4.131 +void 4.132 +PR_WL__throw_exception( char *msgStr, SlaveVP *reqstSlv, PRExcp *excpData ); 4.133 +#define PR_App__throw_exception PR_WL__throw_exception 4.134 + 4.135 + 4.136 +//======================================================================= 4.137 + 4.138 +//========================= Services ======================= 4.139 +//#include "Services_Offered_by_PR/Measurement_and_Stats/probes.h" 4.140 +//#include "Services_Offered_by_PR/Services_Language/PRServ.h" 4.141 +//#include "Services_Offered_by_PR/Services_Language/libPRServ.h" 4.142 + 4.143 +//================================================ 4.144 +#endif /* _PR_H */ 4.145 +
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 5.2 +++ b/PR__int.h Thu Aug 08 02:39:56 2013 -0700 5.3 @@ -0,0 +1,246 @@ 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_INT_H 5.13 +#define _PR_INT_H 5.14 +#define _GNU_SOURCE 5.15 + 5.16 + 5.17 +#define LOCKED 1 5.18 +#define UNLOCKED 0 5.19 + 5.20 +/* MEANING OF WL PI SS int 5.21 + * These indicate which places the function is safe to use. They stand for: 5.22 + * WL: Wrapper Library 5.23 + * PI: Plugin 5.24 + * SS: Startup and Shutdown 5.25 + * int: internal to the PR implementation 5.26 + */ 5.27 + 5.28 +inline 5.29 +void 5.30 +PR_int__reset_slaveVP_to_BirthFn( SlaveVP *slaveVP, BirthFnPtr fnPtr, 5.31 + void *dataParam); 5.32 + 5.33 +inline 5.34 +void 5.35 +PR_int__point_slaveVP_to_OneParamFn( SlaveVP *slaveVP, void *fnPtr, 5.36 + void *param); 5.37 + 5.38 +inline 5.39 +void 5.40 +PR_int__point_slaveVP_to_TwoParamFn( SlaveVP *slaveVP, void *fnPtr, 5.41 + void *param1, void *param2); 5.42 + 5.43 +//=========================================================================== 5.44 +// 5.45 +//=========================================================================== 5.46 +inline 5.47 +SlaveVP * 5.48 +PR_int__create_slaveVP_helper( BirthFnPtr fnPtr, void *dataParam ); 5.49 + 5.50 +inline 5.51 +SlaveVP * 5.52 +PR_int__create_slaveVP( BirthFnPtr fnPtr, void *dataParam, PRProcess *process ); 5.53 + 5.54 +SlaveVP * 5.55 +PR_int__get_recycled_slot_slave( ); 5.56 + 5.57 +SlaveVP * 5.58 +PR_int__create_slot_slave( ); 5.59 + 5.60 +inline 5.61 +void 5.62 +PR_int__replace_with_new_slot_slv( SlaveVP *slave ); 5.63 + 5.64 +void 5.65 +idle_fn(void* data, SlaveVP *animatingSlv); 5.66 + 5.67 +inline 5.68 +void 5.69 +PR_int__put_task_into_slot( void *task, AnimSlot *slot ); 5.70 + 5.71 +inline 5.72 +void 5.73 +PR_int__put_slave_into_slot( SlaveVP *slave, AnimSlot *slot ); 5.74 + 5.75 +void inline 5.76 +PRHandle__ServiceReq( SlaveVP *requestingSlv ); 5.77 + 5.78 +void 5.79 +PR_int__free_slaveVP( SlaveVP *slave ); 5.80 + 5.81 +void 5.82 +PR_int__recycle_slaveVP( SlaveVP *slave ); 5.83 + 5.84 +void 5.85 +freeLangDataAsElem( void *elem ); 5.86 + 5.87 +void 5.88 +freeMetaTaskAsElem( void *elem ); 5.89 + 5.90 + 5.91 +//============================= 5.92 +//=== Lange Env 5.93 +//= 5.94 +inline 5.95 +void * 5.96 +PR_int__give_lang_env( PRLangEnv *protoLangEnv ); 5.97 + 5.98 +inline 5.99 +PRLangEnv * 5.100 +PR_int__give_proto_lang_env( void *langEnv ); 5.101 + 5.102 +//inline 5.103 +void * 5.104 +PR_int__create_lang_env_in_process( int32 size, PRProcess *process, int32 magicNum ); 5.105 + 5.106 +inline 5.107 +void * 5.108 +PR_int__remove_lang_env_from_process_and_free( void *langEnv ); 5.109 + 5.110 +inline 5.111 +void * 5.112 +PR_int__give_lang_env_of_req( PRReqst *req, SlaveVP *requestingSlv ); 5.113 + 5.114 +inline 5.115 +void * 5.116 +PR_int__give_lang_env_for_slave( SlaveVP *slave, int32 magicNum ); 5.117 +//No WL version -- not safe! if use env in WL, be sure data rd & wr is stable 5.118 + 5.119 +inline 5.120 +PRLangEnv * 5.121 +PR_int__give_proto_lang_env_for_slave( SlaveVP *slave, int32 magicNumber ); 5.122 +//No WL version -- not safe! if use env in WL, be sure data rd & wr is stable 5.123 + 5.124 +inline 5.125 +void * 5.126 +PR_int__give_lang_env_from_process( PRProcess *process, int32 magicNum ); 5.127 +//No WL version -- not safe! if use env in WL, be sure data rd & wr is stable 5.128 + 5.129 +inline 5.130 +PRLangEnv * 5.131 +PR_int__give_proto_lang_env_from_process( PRProcess *process, int32 magicNum ); 5.132 + 5.133 +//======================= 5.134 +//=== Meta Task 5.135 +//= 5.136 +inline 5.137 +PRMetaTask * 5.138 +PR_int__give_prolog_of_lang_meta_task( void *task ); 5.139 + 5.140 +inline 5.141 +void * 5.142 +PR_int__give_lang_meta_task_of_prolog( PRMetaTask *metaTask); 5.143 + 5.144 +inline 5.145 +void * 5.146 +PR_int__create_lang_meta_task( int32 size, LangMetaTaskFreer freer, int32 magicNum ); 5.147 + 5.148 +inline 5.149 +void * 5.150 +PR_int__create_lang_meta_task_in_slave( int32 size, LangMetaTaskFreer freer, 5.151 + SlaveVP *slave, int32 magicNum ); 5.152 + 5.153 +inline 5.154 +PRMetaTask * 5.155 +PR_int__create_generic_slave_meta_task( void *initData ); 5.156 + 5.157 +void 5.158 +PR_int__free_lang_meta_task_and_remove_from_coll( void *langMetaTask ); 5.159 + 5.160 +inline 5.161 +void 5.162 +PR_int__insert_meta_task_into_slave( PRMetaTask *task, SlaveVP *slave ); 5.163 + 5.164 +inline 5.165 +void 5.166 +PR_int__insert_lang_meta_task_into_slave__ML( void *langMetaTask, SlaveVP *slave ); 5.167 + 5.168 +inline 5.169 +void * 5.170 +PR_int__give_lang_meta_task_from_slave( SlaveVP *slave, int32 magicNumer ); 5.171 + 5.172 +inline 5.173 +SlaveVP * 5.174 +PR_PI__give_slave_lang_meta_task_is_assigned_to( void *langMetaTask ); 5.175 + 5.176 +//============== 5.177 +//=== Lang Data 5.178 +//= 5.179 +inline 5.180 +void * 5.181 +PR_PI__create_lang_data_in_slave( int32 size, LangDataFreer freer, 5.182 + SlaveVP *slave, int32 magicNum ); 5.183 + 5.184 +inline 5.185 +void * 5.186 +PR_int__give_lang_data_from_slave( SlaveVP *slave, int32 magicNumer ); 5.187 + 5.188 +inline 5.189 +void * 5.190 +PR_int__give_lang_data_of_prolog( PRLangData *langData); 5.191 + 5.192 +//================================================== 5.193 +//=== Collection 5.194 +//= 5.195 +PRCollElem ** //return an array of pointers 5.196 +PR_int__make_collection_of_size( int32 numInColl ); 5.197 + 5.198 +inline 5.199 +void 5.200 +PR_int__insert_elem_into_collection( PRCollElem *elem, PRCollElem **coll, int32 hash ); 5.201 + 5.202 +inline 5.203 +void * 5.204 +PR_int__lookup_elem_in_collection( int32 hash, PRCollElem **coll ); 5.205 + 5.206 +inline 5.207 +void 5.208 +PR_int__remove_elem_from_collection( int32 hash, PRCollElem **coll ); 5.209 + 5.210 +inline 5.211 +void 5.212 +PR_int__set_collection_to_empty( PRCollElem **coll ); 5.213 + 5.214 +inline 5.215 +void 5.216 +PR_int__apply_Fn_to_all_in_collection( void (*Fn)(void *), PRCollElem **coll ); 5.217 + 5.218 +//=========== 5.219 +//=== 5.220 +//= 5.221 +void 5.222 +PR_int__error( char *msgStr ); 5.223 + 5.224 +void 5.225 +PR_int__throw_exception( char *msgStr, SlaveVP *reqstSlv, PRExcp *excpData ); 5.226 + 5.227 +char * 5.228 +PR_int__strDup( char *str ); 5.229 + 5.230 +inline void 5.231 +PR_int__get_wrapper_lock(); 5.232 + 5.233 +inline void 5.234 +PR_int__get_malloc_lock(); 5.235 + 5.236 +#define PR_int__release_master_lock() _PRTopEnv->masterLock = UNLOCKED 5.237 + 5.238 +#define PR_int__release_wrapper_lock() _PRTopEnv->wrapperLock = UNLOCKED 5.239 + 5.240 +#define PR_int__release_malloc_lock() _PRTopEnv->mallocLock = UNLOCKED 5.241 + 5.242 +inline uint32_t 5.243 +PR_int__randomNumber(); 5.244 + 5.245 +inline void 5.246 +PR_int__backoff_for_TooLongToGetLock( int32 numTriesToGetLock ); 5.247 + 5.248 +#endif /* _PR_INT_H */ 5.249 +
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 6.2 +++ b/PR__primitive_data_types.h Thu Aug 08 02:39:56 2013 -0700 6.3 @@ -0,0 +1,42 @@ 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 + 6.13 +#ifndef _PRIMITIVE_DATA_TYPES_H 6.14 +#define _PRIMITIVE_DATA_TYPES_H 6.15 + 6.16 + 6.17 +/*For portability, need primitive data types that have a well defined 6.18 + * size, and well-defined layout into bytes 6.19 + *To do this, provide standard aliases for all primitive data types 6.20 + *These aliases must be used in all functions instead of the ANSI types 6.21 + * 6.22 + *When PR is used together with BLIS, these definitions will be replaced 6.23 + * inside each specialization module according to the compiler used in 6.24 + * that module and the hardware being specialized to. 6.25 + */ 6.26 +typedef char bool8; 6.27 +typedef char int8; 6.28 +typedef char uint8; 6.29 +typedef short int16; 6.30 +typedef unsigned short uint16; 6.31 +typedef int int32; 6.32 +typedef unsigned int uint32; 6.33 +typedef unsigned int bool32; 6.34 +typedef long long int64; 6.35 +typedef unsigned long long uint64; 6.36 +typedef float float32; 6.37 +typedef double float64; 6.38 +//typedef double double float128; //GCC doesn't like this 6.39 +#define float128 double double 6.40 + 6.41 +#define TRUE 1 6.42 +#define FALSE 0 6.43 + 6.44 +#endif /* _PRIMITIVE_DATA_TYPES_H */ 6.45 +
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 7.2 +++ b/PR__structs__common.h Thu Aug 08 02:39:56 2013 -0700 7.3 @@ -0,0 +1,346 @@ 7.4 +/* 7.5 + * Copyright 2009 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__structs__common_H 7.13 +#define _PR__structs__common_H 7.14 +#define _GNU_SOURCE 7.15 + 7.16 +#include <pthread.h> 7.17 +#include <sys/time.h> 7.18 + 7.19 +//#include "PR_defs__turn_on_and_off.h" 7.20 +#include <PR__include/PR__primitive_data_types.h> 7.21 +#include <PR__include/Services_offered_by_PR/DEBUG__macros.h> 7.22 +#include <PR__include/Services_offered_by_PR/MEAS__macros.h> 7.23 + 7.24 +#include <PR__include/prhistogram.h> //reqd by PRProcess 7.25 +#include <PR__include/prhash.h> //reqd by PRProcess 7.26 +#include <PR__include/prdynarray.h> //reqd by PRProcess 7.27 +#include <PR__include/prqueue.h> //reqd by PRLangEnv, in turn reqd by PRProcess 7.28 + 7.29 +//================================ Typedefs ================================= 7.30 +//=== 7.31 +//= 7.32 +#define ZERO 0 7.33 + 7.34 +//typedef unsigned long long TSCount; 7.35 + 7.36 +typedef struct _AnimSlot AnimSlot; 7.37 +typedef struct _PRReqst PRReqst; 7.38 +typedef struct _SlaveVP SlaveVP; 7.39 +//typedef struct _MasterVP MasterVP; 7.40 +typedef struct _IntervalProbe IntervalProbe; 7.41 +typedef struct _PRLangEnv PRLangEnv; //a prolog 7.42 +typedef struct _PRMetaTask PRMetaTask; //a prolog 7.43 +typedef struct _PRLangData PRLangData; //a prolog 7.44 +typedef struct _PRCollElem PRCollElem; //generic form of the prologs 7.45 + 7.46 +typedef bool32 (*SlaveAssigner) ( void *, AnimSlot* ); //langEnv, slot for HW info 7.47 +typedef void (*RequestHandler) ( void *, SlaveVP *, void * ); //req, slv, langEnv 7.48 +typedef void *(*CreateHandler) ( void *, SlaveVP *, void * ); //req, slv, langEnv 7.49 +typedef void (*LangShutdownHdlr) ( void * ); //langEnv 7.50 +typedef void *(*LangDataCreator) ( SlaveVP * ); 7.51 +typedef void (*LangDataFreer) ( void * ); //lang data to free 7.52 +typedef void *(*LangMetaTaskCreator)( SlaveVP * ); //when slave has no meta task for magic num 7.53 +typedef void (*LangMetaTaskFreer) ( void * ); //lang meta task to free 7.54 +typedef void (*MakeSlaveReadyFn) ( SlaveVP *, void * ); //slave and langEnv 7.55 +typedef void (*MakeTaskReadyFn) ( void *, void * ); //langTask and langEnv 7.56 +typedef void (*BirthFnPtr) ( void *, SlaveVP * ); //initData, animSlv 7.57 +typedef void BirthFn ( void *, SlaveVP * ); //initData, animSlv 7.58 +typedef void (*ResumeSlvFnPtr) ( SlaveVP *, void * ); 7.59 + //=========== MEASUREMENT STUFF ========== 7.60 + MEAS__Insert_Counter_Handler 7.61 + //======================================== 7.62 + 7.63 + 7.64 +typedef struct 7.65 + { //These are set by the plugin during startup and the application 7.66 + char *assignerInfo; 7.67 + char *appInfo; 7.68 + char *inputInfo; 7.69 + } 7.70 +PRSysMetaInfo; 7.71 + 7.72 +//===================== Process Data Struct ====================== 7.73 + 7.74 +/*This structure holds all the information PR needs to manage a program. PR 7.75 + * stores information about what percent of CPU time the program is getting, 7.76 + * 7.77 + */ 7.78 + 7.79 +typedef struct 7.80 + { 7.81 + int32 numEnvsWithWork; 7.82 + void *resultToReturn; 7.83 + 7.84 + PRLangEnv **langEnvs; //used as a hash table 7.85 + PRLangEnv **protoLangEnvsList; //for fast linear scan of envs 7.86 + int32 numLangEnvs; //for fast linear scan of envs 7.87 + 7.88 + SlaveVP *seedSlv; 7.89 + 7.90 + int32 numLiveGenericSlvs; 7.91 + int32 numLiveTasks; 7.92 + 7.93 + SlaveAssigner overrideAssigner; 7.94 + 7.95 + 7.96 + 7.97 + //These are used to coord with an OS thread waiting for process to end 7.98 + bool32 hasWaitingToEnd; 7.99 + bool32 executionIsComplete; 7.100 + pthread_mutex_t doneLock; 7.101 + pthread_cond_t doneCond; 7.102 + pthread_mutex_t doneAckLock; //waiter gets, then releases when done waiting 7.103 + 7.104 + //=========== MEASUREMENT STUFF ============= 7.105 + IntervalProbe **intervalProbes; 7.106 + PrivDynArrayInfo *dynIntervalProbesInfo; 7.107 + HashTable *probeNameHashTbl; 7.108 + int32 masterCreateProbeID; 7.109 + float64 createPtInSecs; //real-clock time PR initialized 7.110 + Histogram **measHists; 7.111 + PrivDynArrayInfo *measHistsInfo; 7.112 + MEAS__Insert_Susp_Meas_Fields_into_MasterEnv; 7.113 + MEAS__Insert_Master_Meas_Fields_into_MasterEnv; 7.114 + MEAS__Insert_Master_Lock_Meas_Fields_into_MasterEnv; 7.115 + MEAS__Insert_Malloc_Meas_Fields_into_MasterEnv; 7.116 + MEAS__Insert_Plugin_Meas_Fields_into_MasterEnv; 7.117 + MEAS__Insert_System_Meas_Fields_into_MasterEnv; 7.118 + MEAS__Insert_Counter_Meas_Fields_into_MasterEnv; 7.119 + //========================================== 7.120 + } 7.121 +PRProcess; 7.122 + 7.123 + 7.124 +//============= Request Related =========== 7.125 +// 7.126 + 7.127 +enum PRReqstType //avoid starting enums at 0, for debug reasons 7.128 + { 7.129 + TaskCreate = 1, 7.130 + TaskEnd, 7.131 + SlvCreate, 7.132 + SlvDissipate, 7.133 + Language, 7.134 + Service, //To invoke a PR provided equivalent of a language request (ex: probe) 7.135 + Hardware, 7.136 + IO, 7.137 + OSCall, 7.138 + LangShutdown, 7.139 + ProcessEnd, 7.140 + PRShutdown 7.141 + }; 7.142 + 7.143 + 7.144 +struct _PRReqst 7.145 + { 7.146 + enum PRReqstType reqType;//used for special forms that have PR behavior 7.147 + void *langReq; 7.148 + PRProcess *processReqIsIn; 7.149 + int32 langMagicNumber; 7.150 + SlaveVP *requestingSlave; 7.151 + 7.152 + BirthFnPtr topLevelFn; 7.153 + void *initData; 7.154 + int32 *ID; 7.155 + 7.156 + //The request handling structure is a bit messy.. for special forms, 7.157 + // such as create and dissipate, the language inserts pointer to handler 7.158 + // fn directly into the request.. might change to this for all requests 7.159 + RequestHandler handler; //pointer to handler fn 7.160 + CreateHandler createHdlr; //special because returns something 7.161 + int32 createSuspendedGroup; //must be non-zero 7.162 + 7.163 + PRReqst *nextReqst; 7.164 + }; 7.165 +//PRReqst 7.166 + 7.167 +enum PRServiceReqType //These are equivalent to lang requests, but for 7.168 + { // PR's services available directly to app, like OS 7.169 + make_probe = 1, // and probe services -- like a PR-wide built-in lang 7.170 + throw_excp, 7.171 + openFile, 7.172 + otherIO 7.173 + }; 7.174 + 7.175 +typedef struct 7.176 + { enum PRServiceReqType reqType; 7.177 + SlaveVP *requestingSlv; 7.178 + char *nameStr; //for create probe 7.179 + char *msgStr; //for exception 7.180 + void *exceptionData; 7.181 + } 7.182 +PRServiceReq; 7.183 + 7.184 + 7.185 +//==================== Core data structures =================== 7.186 + 7.187 +typedef struct 7.188 + { 7.189 + //for future expansion 7.190 + } 7.191 +SlotPerfInfo; 7.192 + 7.193 +struct _AnimSlot 7.194 + { 7.195 + int32 workIsDone; 7.196 + int32 needsWorkAssigned; 7.197 + SlaveVP *slaveAssignedToSlot; 7.198 + 7.199 + int32 slotIdx; //needed by Holistic Model's data gathering 7.200 + int32 coreSlotIsOn; 7.201 + SlotPerfInfo *perfInfo; //used by assigner to pick best slave for core 7.202 + }; 7.203 +//AnimSlot 7.204 + 7.205 +enum VPtype 7.206 + { SlotTaskSlv = 1,//Slave tied to an anim slot, only animates tasks 7.207 + FreeTaskSlv, //When a suspended task ends, the slave becomes this 7.208 + GenericSlv, //the VP is explicitly seen in the app code, or task suspends 7.209 + SeedSlv, 7.210 + Master_VP, 7.211 + ShutdownVP, 7.212 + IdleVP 7.213 + }; 7.214 + 7.215 +/*This structure embodies the state of a slaveVP. It is reused for masterVP 7.216 + * and shutdownVPs. 7.217 + */ 7.218 +struct _SlaveVP 7.219 + { //The offsets of these fields are hard-coded into assembly 7.220 + void *stackPtr; //save the core's stack ptr when suspend 7.221 + void *framePtr; //save core's frame ptr when suspend 7.222 + void *resumeInstrPtr; //save core's program-counter when suspend 7.223 + void *coreCtlrFramePtr; //restore before jmp back to core controller 7.224 + void *coreCtlrStackPtr; //restore before jmp back to core controller 7.225 + 7.226 + //============ below this, no fields are used in asm ============= 7.227 + 7.228 + void *startOfStack; //used to free, and to point slave to Fn 7.229 + PRProcess *processSlaveIsIn; 7.230 + enum VPtype typeOfVP; //Slave vs Master vs Shutdown.. 7.231 + int32 slaveNum; //each slave given it's seq in creation 7.232 + int32 *ID; //App defines meaning of each int in array 7.233 + int32 coreAnimatedBy; 7.234 + int32 numTimesAssignedToASlot; //Each assign is for one work-unit, so is an ID 7.235 + //note, a scheduling decision is uniquely identified by the triple: 7.236 + // <slaveNum, coreAnimatedBy, numTimesAssignedToASlot> -- used in record & replay 7.237 + 7.238 + //for comm -- between master and coreCtlr & btwn wrapper lib and plugin 7.239 + AnimSlot *animSlotAssignedTo; 7.240 + PRReqst *request; //wrapper lib puts in requests, plugin takes out 7.241 + void *dataRetFromReq;//Return vals from plugin to Wrapper Lib 7.242 + 7.243 + //For language specific data that needs to be in the slave 7.244 + //These are accessed directly for single-lang, but multi-lang places 7.245 + // a holder here instead, then uses magic num to get lang's version 7.246 + PRLangData **langDatas; //Lang saves lang-specific things in slave here 7.247 + PRMetaTask **metaTasks; 7.248 + 7.249 + //=========== MEASUREMENT STUFF ========== 7.250 + MEAS__Insert_Meas_Fields_into_Slave; 7.251 + float64 createPtInSecs; //time VP created, in seconds 7.252 + //======================================== 7.253 + 7.254 +// int8 cacheLinePad[512 - sizeof(contents)]; //for false sharing 7.255 + }; 7.256 +//SlaveVP 7.257 + 7.258 + 7.259 +enum PRMode 7.260 + { SingleLang = 1, 7.261 + StandaloneWTasks, 7.262 + MultiLang 7.263 + }; 7.264 + 7.265 + 7.266 +//===================== These are prologs ==================== 7.267 +//===A prolog is data immediately before pointer returned by a create function. 7.268 +//= 7.269 +struct _PRLangEnv 7.270 + { //============== First two must match PRCollElem ============== 7.271 + int32 langMagicNumber; //indexes into hash array of langEnvs in PRProcess 7.272 + PRLangEnv *chainedLangEnv; //chains to langEnvs with same hash 7.273 + //============================================================= 7.274 + 7.275 + SlaveAssigner workAssigner; 7.276 + LangShutdownHdlr shutdownHdlr; //called when lang ended or process shutdown 7.277 + LangDataCreator langDataCreator; 7.278 + LangMetaTaskCreator langMetaTaskCreator; 7.279 + MakeSlaveReadyFn makeSlaveReadyFn; 7.280 + MakeTaskReadyFn makeTaskReadyFn; 7.281 + 7.282 + //when multi-lang, master polls lang env's to find one with work in it.. 7.283 + // in single-lang case, flag ignored, master always asks lang for work 7.284 + int32 hasWork; 7.285 + PRProcess *processEnvIsIn; 7.286 + 7.287 + int32 idxInProcess; //index into array of langEnvs in the process 7.288 + 7.289 + int32 numReadyWork; 7.290 + 7.291 + int32 numLiveWork; 7.292 + PrivQueueStruc *waitingForWorkToEndQ; 7.293 + }; 7.294 +//PRLangEnv -- this is the prolog of every lang's lang env 7.295 + 7.296 +enum PRTaskType 7.297 + { GenericSlave = 1, 7.298 + SlotTask, 7.299 + FreeTask 7.300 + }; 7.301 + 7.302 +struct _PRMetaTask 7.303 + { //============== First two must match PRCollElem ============== 7.304 + int32 langMagicNumber; 7.305 + PRMetaTask *chainedMetaTask; 7.306 + //============================================================= 7.307 + enum PRTaskType taskType; 7.308 + int32 *ID; //is standard PR ID 7.309 + PRProcess *processTaskIsIn; 7.310 + SlaveVP *slaveAssignedTo; //not valid until task animated 7.311 + BirthFnPtr topLevelFn; //This is the Fn executes as the task 7.312 + void *initData; //The data taken by the function 7.313 + LangMetaTaskFreer freer; 7.314 + bool32 goAheadAndFree; 7.315 + 7.316 + //NOTE: info needed for "wait" functionality is inside lang's metaTask 7.317 + }; 7.318 +//PRMetaTask -- prolog of every lang's meta task 7.319 + 7.320 +struct _PRLangData 7.321 + { //============== First two must match PRCollElem ============== 7.322 + int32 langMagicNumber; 7.323 + PRLangData *chainedLangData; 7.324 + //============================================================= 7.325 + LangDataFreer freer; 7.326 + bool32 goAheadAndFree; 7.327 + SlaveVP *slaveAssignedTo; 7.328 + }; 7.329 +//PRLangData -- this is the prolog of each lang's lang data 7.330 + 7.331 +struct _PRCollElem 7.332 + { 7.333 + int32 hash; 7.334 + PRCollElem *chained; 7.335 + }; 7.336 +//PRCollElem -- this is generic form of all the prologs 7.337 + 7.338 + 7.339 + 7.340 +//========================= Extra Stuff Data Strucs ======================= 7.341 +typedef struct 7.342 + { 7.343 + 7.344 + } 7.345 +PRExcp; //exception 7.346 + 7.347 + 7.348 +#endif /* _PR__structs_H */ 7.349 +
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 8.2 +++ b/Services_offered_by_PR/DEBUG__macros.h Thu Aug 08 02:39:56 2013 -0700 8.3 @@ -0,0 +1,65 @@ 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 _DEBUG__macros_H 8.13 +#define _DEBUG__macros_H 8.14 +#define _GNU_SOURCE 8.15 + 8.16 +/* 8.17 + */ 8.18 +#ifdef DEBUG__TURN_ON_DEBUG_PRINT 8.19 + #define DEBUG__printf( bool, ...) \ 8.20 + do{\ 8.21 + if(bool)\ 8.22 + { printf(__VA_ARGS__);\ 8.23 + printf(" | function: %s\n", __FUNCTION__);\ 8.24 + fflush(stdin);\ 8.25 + }\ 8.26 + }while(0);/*macro magic to isolate var-names*/ 8.27 + 8.28 + #define DEBUG__printf1( bool, msg, param) \ 8.29 + do{\ 8.30 + if(bool)\ 8.31 + { printf(msg, param);\ 8.32 + printf(" | function: %s\n", __FUNCTION__);\ 8.33 + fflush(stdin);\ 8.34 + }\ 8.35 + }while(0);/*macro magic to isolate var-names*/ 8.36 + 8.37 + #define DEBUG__printf2( bool, msg, p1, p2) \ 8.38 + do{\ 8.39 + if(bool)\ 8.40 + { printf(msg, p1, p2); \ 8.41 + printf(" | function: %s\n", __FUNCTION__);\ 8.42 + fflush(stdin);\ 8.43 + }\ 8.44 + }while(0);/*macro magic to isolate var-names*/ 8.45 + 8.46 + #define DEBUG__printf3( bool, msg, p1, p2, p3) \ 8.47 + do{\ 8.48 + if(bool)\ 8.49 + { printf(msg, p1, p2, p3); \ 8.50 + printf(" | function: %s\n", __FUNCTION__);\ 8.51 + fflush(stdin);\ 8.52 + }\ 8.53 + }while(0);/*macro magic to isolate var-names*/ 8.54 + 8.55 +#else 8.56 + #define DEBUG__printf( bool, ...) 8.57 + #define DEBUG__printf1( bool, msg, param) 8.58 + #define DEBUG__printf2( bool, msg, p1, p2) 8.59 +#endif 8.60 + 8.61 +//============================= ERROR MSGs ============================ 8.62 +#define ERROR(msg) printf(msg); 8.63 +#define ERROR1(msg, param) printf(msg, param); 8.64 +#define ERROR2(msg, p1, p2) printf(msg, p1, p2); 8.65 + 8.66 +//=========================================================================== 8.67 +#endif /* _PR_DEFS_H */ 8.68 +
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 9.2 +++ b/Services_offered_by_PR/MEAS__Counter_Recording.h Thu Aug 08 02:39:56 2013 -0700 9.3 @@ -0,0 +1,36 @@ 9.4 +/* 9.5 + * File: MEAS__Counter_Recording.h 9.6 + * Author: nengel 9.7 + * 9.8 + * Created on January 11, 2012, 3:03 PM 9.9 + */ 9.10 + 9.11 +#ifndef MEAS__COUNTER_RECORDING_H 9.12 +#define MEAS__COUNTER_RECORDING_H 9.13 + 9.14 +#include "PR__common_includes/PR__common_structs.h" 9.15 + 9.16 +typedef struct 9.17 + { 9.18 + int event_type; 9.19 + int coreID; 9.20 + AnimSlot* slot; 9.21 + int vp; 9.22 + int task; 9.23 + uint64 cycles; 9.24 + uint64 instrs; 9.25 + } 9.26 +CounterEvent; 9.27 + 9.28 +FILE* counterfile; //pass file handle via side effect because 9.29 + // doAllInListOfArrays only takes Fns with a single input 9.30 + 9.31 +void MEAS__init_counter_data_structs_for_lang( SlaveVP *slv, int32 magicNum ); 9.32 + 9.33 +void MEAS__counter_handler(int evt_type, int vpid, int task, SlaveVP* pr, uint64 cycles, uint64 instrs); 9.34 + 9.35 +void MEAS__set_counter_file(FILE* f); 9.36 + 9.37 +void MEAS__print_counter_event_to_file( void* _e ); 9.38 +#endif /* PRServ_COUNTER_RECORDING_H */ 9.39 +
10.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 10.2 +++ b/Services_offered_by_PR/MEAS__macros.h Thu Aug 08 02:39:56 2013 -0700 10.3 @@ -0,0 +1,514 @@ 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 +#ifndef _MEAS_MACROS_H 10.13 +#define _MEAS_MACROS_H 10.14 +#define _GNU_SOURCE 10.15 + 10.16 +//================== Macros define types of meas want ===================== 10.17 +// 10.18 +/*Generic measurement macro -- has name-space collision potential, which 10.19 + * compiler will catch.. so only use one pair inside a given set of 10.20 + * curly braces. 10.21 + */ 10.22 +//TODO: finish generic capture interval in hist 10.23 +enum histograms 10.24 + { generic1 10.25 + }; 10.26 + #define MEAS__Capture_Pre_Point \ 10.27 + int32 startStamp, endStamp; \ 10.28 + saveLowTimeStampCountInto( startStamp ); 10.29 + 10.30 + #define MEAS__Capture_Post_Point( histName ) \ 10.31 + saveLowTimeStampCountInto( endStamp ); \ 10.32 + addIntervalToHist( startStamp, endStamp, _PRTopEnv->histName ); 10.33 + 10.34 + 10.35 + 10.36 + 10.37 +//================== Macros define types of meas want ===================== 10.38 + 10.39 +#ifdef MEAS__TURN_ON_SUSP_MEAS 10.40 + #define MEAS__Insert_Susp_Meas_Fields_into_Slave \ 10.41 + uint32 preSuspTSCLow; \ 10.42 + uint32 postSuspTSCLow; 10.43 + 10.44 + #define MEAS__Insert_Susp_Meas_Fields_into_MasterEnv \ 10.45 + Histogram *suspLowTimeHist; \ 10.46 + Histogram *suspHighTimeHist; 10.47 + 10.48 + #define MEAS__Make_Meas_Hists_for_Susp_Meas \ 10.49 + _PRTopEnv->suspLowTimeHist = makeFixedBinHistExt( 100, 0, 200,\ 10.50 + "master_low_time_hist");\ 10.51 + _PRTopEnv->suspHighTimeHist = makeFixedBinHistExt( 100, 0, 200,\ 10.52 + "master_high_time_hist"); 10.53 + 10.54 + //record time stamp: compare to time-stamp recorded below 10.55 + #define MEAS__Capture_Pre_Susp_Point \ 10.56 + saveLowTimeStampCountInto( animatingSlv->preSuspTSCLow ); 10.57 + 10.58 + //NOTE: only take low part of count -- do sanity check when take diff 10.59 + #define MEAS__Capture_Post_Susp_Point \ 10.60 + saveLowTimeStampCountInto( animatingSlv->postSuspTSCLow );\ 10.61 + addIntervalToHist( preSuspTSCLow, postSuspTSCLow,\ 10.62 + _PRTopEnv->suspLowTimeHist ); \ 10.63 + addIntervalToHist( preSuspTSCLow, postSuspTSCLow,\ 10.64 + _PRTopEnv->suspHighTimeHist ); 10.65 + 10.66 + #define MEAS__Print_Hists_for_Susp_Meas \ 10.67 + printHist( _PRTopEnv->pluginTimeHist ); 10.68 + 10.69 +#else 10.70 + #define MEAS__Insert_Susp_Meas_Fields_into_Slave 10.71 + #define MEAS__Insert_Susp_Meas_Fields_into_MasterEnv 10.72 + #define MEAS__Make_Meas_Hists_for_Susp_Meas 10.73 + #define MEAS__Capture_Pre_Susp_Point 10.74 + #define MEAS__Capture_Post_Susp_Point 10.75 + #define MEAS__Print_Hists_for_Susp_Meas 10.76 +#endif 10.77 + 10.78 +#ifdef MEAS__TURN_ON_MASTER_MEAS 10.79 + #define MEAS__Insert_Master_Meas_Fields_into_Slave \ 10.80 + uint32 startMasterTSCLow; \ 10.81 + uint32 endMasterTSCLow; 10.82 + 10.83 + #define MEAS__Insert_Master_Meas_Fields_into_MasterEnv \ 10.84 + Histogram *masterLowTimeHist; \ 10.85 + Histogram *masterHighTimeHist; 10.86 + 10.87 + #define MEAS__Make_Meas_Hists_for_Master_Meas \ 10.88 + _PRTopEnv->masterLowTimeHist = makeFixedBinHistExt( 100, 0, 200,\ 10.89 + "master_low_time_hist");\ 10.90 + _PRTopEnv->masterHighTimeHist = makeFixedBinHistExt( 100, 0, 200,\ 10.91 + "master_high_time_hist"); 10.92 + 10.93 + //Total Master time includes one coreloop time -- just assume the core 10.94 + // loop time is same for Master as for AppSlvs, even though it may be 10.95 + // smaller due to higher predictability of the fixed jmp. 10.96 + #define MEAS__Capture_Pre_Master_Point\ 10.97 + saveLowTimeStampCountInto( masterVP->startMasterTSCLow ); 10.98 + 10.99 + #define MEAS__Capture_Post_Master_Point \ 10.100 + saveLowTimeStampCountInto( masterVP->endMasterTSCLow );\ 10.101 + addIntervalToHist( startMasterTSCLow, endMasterTSCLow,\ 10.102 + _PRTopEnv->masterLowTimeHist ); \ 10.103 + addIntervalToHist( startMasterTSCLow, endMasterTSCLow,\ 10.104 + _PRTopEnv->masterHighTimeHist ); 10.105 + 10.106 + #define MEAS__Print_Hists_for_Master_Meas \ 10.107 + printHist( _PRTopEnv->pluginTimeHist ); 10.108 + 10.109 +#else 10.110 + #define MEAS__Insert_Master_Meas_Fields_into_Slave 10.111 + #define MEAS__Insert_Master_Meas_Fields_into_MasterEnv 10.112 + #define MEAS__Make_Meas_Hists_for_Master_Meas 10.113 + #define MEAS__Capture_Pre_Master_Point 10.114 + #define MEAS__Capture_Post_Master_Point 10.115 + #define MEAS__Print_Hists_for_Master_Meas 10.116 +#endif 10.117 + 10.118 + 10.119 +#ifdef MEAS__TURN_ON_MASTER_LOCK_MEAS 10.120 + #define MEAS__Insert_Master_Lock_Meas_Fields_into_MasterEnv \ 10.121 + Histogram *masterLockLowTimeHist; \ 10.122 + Histogram *masterLockHighTimeHist; 10.123 + 10.124 + #define MEAS__Make_Meas_Hists_for_Master_Lock_Meas \ 10.125 + _PRTopEnv->masterLockLowTimeHist = makeFixedBinHist( 50, 0, 2, \ 10.126 + "master lock low time hist");\ 10.127 + _PRTopEnv->masterLockHighTimeHist = makeFixedBinHist( 50, 0, 100,\ 10.128 + "master lock high time hist"); 10.129 + 10.130 + #define MEAS__Capture_Pre_Master_Lock_Point \ 10.131 + int32 startStamp, endStamp; \ 10.132 + saveLowTimeStampCountInto( startStamp ); 10.133 + 10.134 + #define MEAS__Capture_Post_Master_Lock_Point \ 10.135 + saveLowTimeStampCountInto( endStamp ); \ 10.136 + addIntervalToHist( startStamp, endStamp,\ 10.137 + _PRTopEnv->masterLockLowTimeHist ); \ 10.138 + addIntervalToHist( startStamp, endStamp,\ 10.139 + _PRTopEnv->masterLockHighTimeHist ); 10.140 + 10.141 + #define MEAS__Print_Hists_for_Master_Lock_Meas \ 10.142 + printHist( _PRTopEnv->masterLockLowTimeHist ); \ 10.143 + printHist( _PRTopEnv->masterLockHighTimeHist ); 10.144 + 10.145 +#else 10.146 + #define MEAS__Insert_Master_Lock_Meas_Fields_into_MasterEnv 10.147 + #define MEAS__Make_Meas_Hists_for_Master_Lock_Meas 10.148 + #define MEAS__Capture_Pre_Master_Lock_Point 10.149 + #define MEAS__Capture_Post_Master_Lock_Point 10.150 + #define MEAS__Print_Hists_for_Master_Lock_Meas 10.151 +#endif 10.152 + 10.153 + 10.154 +#ifdef MEAS__TURN_ON_MALLOC_MEAS 10.155 + #define MEAS__Insert_Malloc_Meas_Fields_into_MasterEnv\ 10.156 + Histogram *mallocTimeHist; \ 10.157 + Histogram *freeTimeHist; 10.158 + 10.159 + #define MEAS__Make_Meas_Hists_for_Malloc_Meas \ 10.160 + _PRTopEnv->mallocTimeHist = makeFixedBinHistExt( 100, 0, 30,\ 10.161 + "malloc_time_hist");\ 10.162 + _PRTopEnv->freeTimeHist = makeFixedBinHistExt( 100, 0, 30,\ 10.163 + "free_time_hist"); 10.164 + 10.165 + #define MEAS__Capture_Pre_Malloc_Point \ 10.166 + int32 startStamp, endStamp; \ 10.167 + saveLowTimeStampCountInto( startStamp ); 10.168 + 10.169 + #define MEAS__Capture_Post_Malloc_Point \ 10.170 + saveLowTimeStampCountInto( endStamp ); \ 10.171 + addIntervalToHist( startStamp, endStamp,\ 10.172 + _PRTopEnv->mallocTimeHist ); 10.173 + 10.174 + #define MEAS__Capture_Pre_Free_Point \ 10.175 + int32 startStamp, endStamp; \ 10.176 + saveLowTimeStampCountInto( startStamp ); 10.177 + 10.178 + #define MEAS__Capture_Post_Free_Point \ 10.179 + saveLowTimeStampCountInto( endStamp ); \ 10.180 + addIntervalToHist( startStamp, endStamp,\ 10.181 + _PRTopEnv->freeTimeHist ); 10.182 + 10.183 + #define MEAS__Print_Hists_for_Malloc_Meas \ 10.184 + printHist( _PRTopEnv->mallocTimeHist ); \ 10.185 + saveHistToFile( _PRTopEnv->mallocTimeHist ); \ 10.186 + printHist( _PRTopEnv->freeTimeHist ); \ 10.187 + saveHistToFile( _PRTopEnv->freeTimeHist ); \ 10.188 + freeHistExt( _PRTopEnv->mallocTimeHist ); \ 10.189 + freeHistExt( _PRTopEnv->freeTimeHist ); 10.190 + 10.191 +#else 10.192 + #define MEAS__Insert_Malloc_Meas_Fields_into_MasterEnv 10.193 + #define MEAS__Make_Meas_Hists_for_Malloc_Meas 10.194 + #define MEAS__Capture_Pre_Malloc_Point 10.195 + #define MEAS__Capture_Post_Malloc_Point 10.196 + #define MEAS__Capture_Pre_Free_Point 10.197 + #define MEAS__Capture_Post_Free_Point 10.198 + #define MEAS__Print_Hists_for_Malloc_Meas 10.199 +#endif 10.200 + 10.201 + 10.202 + 10.203 +#ifdef MEAS__TURN_ON_PLUGIN_MEAS 10.204 + #define MEAS__Insert_Plugin_Meas_Fields_into_MasterEnv \ 10.205 + Histogram *reqHdlrLowTimeHist; \ 10.206 + Histogram *reqHdlrHighTimeHist; 10.207 + 10.208 + #define MEAS__Make_Meas_Hists_for_Plugin_Meas \ 10.209 + _PRTopEnv->reqHdlrLowTimeHist = makeFixedBinHistExt( 100, 0, 200,\ 10.210 + "plugin_low_time_hist");\ 10.211 + _PRTopEnv->reqHdlrHighTimeHist = makeFixedBinHistExt( 100, 0, 200,\ 10.212 + "plugin_high_time_hist"); 10.213 + 10.214 + #define MEAS__startReqHdlr \ 10.215 + int32 startStamp1, endStamp1; \ 10.216 + saveLowTimeStampCountInto( startStamp1 ); 10.217 + 10.218 + #define MEAS__endReqHdlr \ 10.219 + saveLowTimeStampCountInto( endStamp1 ); \ 10.220 + addIntervalToHist( startStamp1, endStamp1, \ 10.221 + _PRTopEnv->reqHdlrLowTimeHist ); \ 10.222 + addIntervalToHist( startStamp1, endStamp1, \ 10.223 + _PRTopEnv->reqHdlrHighTimeHist ); 10.224 + 10.225 + #define MEAS__Print_Hists_for_Plugin_Meas \ 10.226 + printHist( _PRTopEnv->reqHdlrLowTimeHist ); \ 10.227 + saveHistToFile( _PRTopEnv->reqHdlrLowTimeHist ); \ 10.228 + printHist( _PRTopEnv->reqHdlrHighTimeHist ); \ 10.229 + saveHistToFile( _PRTopEnv->reqHdlrHighTimeHist ); \ 10.230 + freeHistExt( _PRTopEnv->reqHdlrLowTimeHist ); \ 10.231 + freeHistExt( _PRTopEnv->reqHdlrHighTimeHist ); 10.232 +#else 10.233 + #define MEAS__Insert_Plugin_Meas_Fields_into_MasterEnv 10.234 + #define MEAS__Make_Meas_Hists_for_Plugin_Meas 10.235 + #define MEAS__startReqHdlr 10.236 + #define MEAS__endReqHdlr 10.237 + #define MEAS__Print_Hists_for_Plugin_Meas 10.238 + 10.239 +#endif 10.240 + 10.241 + 10.242 +#ifdef MEAS__TURN_ON_SYSTEM_MEAS 10.243 + #define MEAS__Insert_System_Meas_Fields_into_Slave \ 10.244 + TSCountLowHigh startSusp; \ 10.245 + uint64 totalSuspCycles; \ 10.246 + uint32 numGoodSusp; 10.247 + 10.248 + #define MEAS__Insert_System_Meas_Fields_into_MasterEnv \ 10.249 + TSCountLowHigh startMaster; \ 10.250 + uint64 totalMasterCycles; \ 10.251 + uint32 numMasterAnimations; \ 10.252 + TSCountLowHigh startReqHdlr; \ 10.253 + uint64 totalPluginCycles; \ 10.254 + uint32 numPluginAnimations; \ 10.255 + uint64 cyclesTillStartAnimationMaster; \ 10.256 + TSCountLowHigh endAnimationMaster; 10.257 + 10.258 + #define MEAS__startAnimationMaster_forSys \ 10.259 + TSCountLowHigh startStamp1, endStamp1; \ 10.260 + saveTSCLowHigh( endStamp1 ); \ 10.261 + _PRTopEnv->cyclesTillStartAnimationMaster = \ 10.262 + endStamp1.longVal - masterVP->startSusp.longVal; 10.263 + 10.264 + #define Meas_startReqHdlr_forSys \ 10.265 + saveTSCLowHigh( startStamp1 ); \ 10.266 + _PRTopEnv->startReqHdlr.longVal = startStamp1.longVal; 10.267 + 10.268 + #define MEAS__endAnimationMaster_forSys \ 10.269 + saveTSCLowHigh( startStamp1 ); \ 10.270 + _PRTopEnv->endAnimationMaster.longVal = startStamp1.longVal; 10.271 + 10.272 + /*A TSC is stored in VP first thing inside wrapper-lib 10.273 + * Now, measures cycles from there to here 10.274 + * Master and Plugin will add this value to other trace-seg measures 10.275 + */ 10.276 + #define MEAS__Capture_End_Susp_in_CoreCtlr_ForSys\ 10.277 + saveTSCLowHigh(endSusp); \ 10.278 + numCycles = endSusp.longVal - currVP->startSusp.longVal; \ 10.279 + /*sanity check (400K is about 20K iters)*/ \ 10.280 + if( numCycles < 400000 ) \ 10.281 + { currVP->totalSuspCycles += numCycles; \ 10.282 + currVP->numGoodSusp++; \ 10.283 + } \ 10.284 + /*recorded every time, but only read if currVP == MasterVP*/ \ 10.285 + _PRTopEnv->startMaster.longVal = endSusp.longVal; 10.286 + 10.287 +#else 10.288 + #define MEAS__Insert_System_Meas_Fields_into_Slave 10.289 + #define MEAS__Insert_System_Meas_Fields_into_MasterEnv 10.290 + #define MEAS__Make_Meas_Hists_for_System_Meas 10.291 + #define MEAS__startAnimationMaster_forSys 10.292 + #define MEAS__startReqHdlr_forSys 10.293 + #define MEAS__endAnimationMaster_forSys 10.294 + #define MEAS__Capture_End_Susp_in_CoreCtlr_ForSys 10.295 + #define MEAS__Print_Hists_for_System_Meas 10.296 +#endif 10.297 + 10.298 +#ifdef HOLISTIC__TURN_ON_PERF_COUNTERS 10.299 + 10.300 + #define MEAS__Insert_Counter_Handler \ 10.301 + typedef void (*CounterHandler) (int,int,int,SlaveVP*,uint64,uint64,uint64); 10.302 + 10.303 + enum eventType { 10.304 + DebugEvt = 0, 10.305 + AppResponderInvocation_start, 10.306 + AppResponder_start, 10.307 + AppResponder_end, 10.308 + AssignerInvocation_start, 10.309 + NextAssigner_start, 10.310 + Assigner_start, 10.311 + Assigner_end, 10.312 + Work_start, 10.313 + Work_end, 10.314 + HwResponderInvocation_start, 10.315 + Timestamp_start, 10.316 + Timestamp_end 10.317 + }; 10.318 + 10.319 + #define saveCyclesAndInstrs(core,cycles,instrs,cachem) do{ \ 10.320 + int cycles_fd = _PRTopEnv->cycles_counter_fd[core]; \ 10.321 + int instrs_fd = _PRTopEnv->instrs_counter_fd[core]; \ 10.322 + int cachem_fd = _PRTopEnv->cachem_counter_fd[core]; \ 10.323 + int nread; \ 10.324 + \ 10.325 + nread = read(cycles_fd,&(cycles),sizeof(cycles)); \ 10.326 + if(nread<0){ \ 10.327 + perror("Error reading cycles counter"); \ 10.328 + cycles = 0; \ 10.329 + } \ 10.330 + \ 10.331 + nread = read(instrs_fd,&(instrs),sizeof(instrs)); \ 10.332 + if(nread<0){ \ 10.333 + perror("Error reading cycles counter"); \ 10.334 + instrs = 0; \ 10.335 + } \ 10.336 + nread = read(cachem_fd,&(cachem),sizeof(cachem)); \ 10.337 + if(nread<0){ \ 10.338 + perror("Error reading last level cache miss counter"); \ 10.339 + cachem = 0; \ 10.340 + } \ 10.341 + } while (0) 10.342 + 10.343 + #define MEAS__Insert_Counter_Meas_Fields_into_MasterEnv \ 10.344 + int cycles_counter_fd[NUM_CORES]; \ 10.345 + int instrs_counter_fd[NUM_CORES]; \ 10.346 + int cachem_counter_fd[NUM_CORES]; \ 10.347 + uint64 start_master_lock[NUM_CORES][3]; \ 10.348 + CounterHandler counterHandler; 10.349 + 10.350 + #define HOLISTIC__Setup_Perf_Counters setup_perf_counters(); 10.351 + 10.352 + 10.353 + #define HOLISTIC__CoreCtrl_Setup \ 10.354 + CounterHandler counterHandler = _PRTopEnv->counterHandler; \ 10.355 + SlaveVP *lastVPBeforeMaster = NULL; \ 10.356 + /*if(thisCoresThdParams->coreNum == 0){ \ 10.357 + uint64 initval = tsc_offset_send(thisCoresThdParams,0); \ 10.358 + while(!coreCtlrThdParams[NUM_CORES - 2]->ret_tsc); \ 10.359 + } \ 10.360 + if(0 < (thisCoresThdParams->coreNum) && (thisCoresThdParams->coreNum) < (NUM_CORES - 1)){ \ 10.361 + ThdParams* sendCoresThdParams = coreCtlrThdParams[thisCoresThdParams->coreNum - 1]; \ 10.362 + int sndctr = tsc_offset_resp(sendCoresThdParams, 0); \ 10.363 + uint64 initval = tsc_offset_send(thisCoresThdParams,0); \ 10.364 + while(!coreCtlrThdParams[NUM_CORES - 2]->ret_tsc); \ 10.365 + } \ 10.366 + if(thisCoresThdParams->coreNum == (NUM_CORES - 1)){ \ 10.367 + ThdParams* sendCoresThdParams = coreCtlrThdParams[thisCoresThdParams->coreNum - 1]; \ 10.368 + int sndctr = tsc_offset_resp(sendCoresThdParams,0); \ 10.369 + }*/ 10.370 + 10.371 + 10.372 + #define HOLISTIC__Insert_Master_Global_Vars \ 10.373 + int vpid,task; \ 10.374 + CounterHandler counterHandler = _PRTopEnv->counterHandler; 10.375 + 10.376 + #define HOLISTIC__Record_last_work lastVPBeforeMaster = currVP; 10.377 + 10.378 + #define HOLISTIC__Record_AppResponderInvocation_start \ 10.379 + uint64 cycles,instrs,cachem; \ 10.380 + saveCyclesAndInstrs(thisCoresIdx,cycles, instrs,cachem); \ 10.381 + if(lastVPBeforeMaster){ \ 10.382 + (*counterHandler)(AppResponderInvocation_start,lastVPBeforeMaster->slaveNum,lastVPBeforeMaster->numTimesAssignedToASlot,lastVPBeforeMaster,cycles,instrs,cachem); \ 10.383 + lastVPBeforeMaster = NULL; \ 10.384 + } else { \ 10.385 + _PRTopEnv->start_master_lock[thisCoresIdx][0] = cycles; \ 10.386 + _PRTopEnv->start_master_lock[thisCoresIdx][1] = instrs; \ 10.387 + _PRTopEnv->start_master_lock[thisCoresIdx][2] = cachem; \ 10.388 + } 10.389 + 10.390 + /* Request Handler may call resume() on the VP, but we want to 10.391 + * account the whole interval to the same task. Therefore, need 10.392 + * to save task ID at the beginning. 10.393 + * 10.394 + * Using this value as "end of AppResponder Invocation Time" 10.395 + * is possible if there is only one SchedSlot per core - 10.396 + * invoking processor is last to be treated here! If more than 10.397 + * one slot, MasterLoop processing time for all but the last VP 10.398 + * would be erroneously counted as invocation time. 10.399 + */ 10.400 + #define HOLISTIC__Record_AppResponder_start \ 10.401 + vpid = currSlot->slaveAssignedToSlot->slaveNum; \ 10.402 + task = currSlot->slaveAssignedToSlot->numTimesAssignedToASlot; \ 10.403 + uint64 cycles, instrs, cachem; \ 10.404 + saveCyclesAndInstrs(thisCoresIdx,cycles, instrs,cachem); \ 10.405 + (*counterHandler)(AppResponder_start,vpid,task,currSlot->slaveAssignedToSlot,cycles,instrs,cachem); 10.406 + 10.407 + #define HOLISTIC__Record_AppResponder_end \ 10.408 + uint64 cycles2,instrs2,cachem2; \ 10.409 + saveCyclesAndInstrs(thisCoresIdx,cycles2, instrs2,cachem2); \ 10.410 + (*counterHandler)(AppResponder_end,vpid,task,currSlot->slaveAssignedToSlot,cycles2,instrs2,cachem2); \ 10.411 + (*counterHandler)(Timestamp_end,vpid,task,currSlot->slaveAssignedToSlot,rdtsc(),0,0); 10.412 + 10.413 + 10.414 + /* Don't know who to account time to yet - goes to assigned VP 10.415 + * after the call. 10.416 + */ 10.417 + #define HOLISTIC__Record_Assigner_start \ 10.418 + int empty = FALSE; \ 10.419 + if(currSlot->slaveAssignedToSlot == NULL){ \ 10.420 + empty= TRUE; \ 10.421 + } \ 10.422 + uint64 tmp_cycles, tmp_instrs, tmp_cachem; \ 10.423 + saveCyclesAndInstrs(thisCoresIdx,tmp_cycles,tmp_instrs,tmp_cachem); \ 10.424 + uint64 tsc = rdtsc(); \ 10.425 + if(vpid > 0) { \ 10.426 + (*counterHandler)(NextAssigner_start,vpid,task,currSlot->slaveAssignedToSlot,tmp_cycles,tmp_instrs,tmp_cachem); \ 10.427 + vpid = 0; \ 10.428 + task = 0; \ 10.429 + } 10.430 + 10.431 + #define HOLISTIC__Record_Assigner_end \ 10.432 + uint64 cycles,instrs,cachem; \ 10.433 + saveCyclesAndInstrs(thisCoresIdx,cycles,instrs,cachem); \ 10.434 + if(empty){ \ 10.435 + (*counterHandler)(AssignerInvocation_start,assignedSlaveVP->slaveNum,assignedSlaveVP->numTimesAssignedToASlot,assignedSlaveVP,_PRTopEnv->start_master_lock[thisCoresIdx][0],_PRTopEnv->start_master_lock[thisCoresIdx][1],masterEnv->start_master_lock[thisCoresIdx][2]); \ 10.436 + } \ 10.437 + (*counterHandler)(Timestamp_start,assignedSlaveVP->slaveNum,assignedSlaveVP->numTimesAssignedToASlot,assignedSlaveVP,tsc,0,0); \ 10.438 + (*counterHandler)(Assigner_start,assignedSlaveVP->slaveNum,assignedSlaveVP->numTimesAssignedToASlot,assignedSlaveVP,tmp_cycles,tmp_instrs,tmp_cachem); \ 10.439 + (*counterHandler)(Assigner_end,assignedSlaveVP->slaveNum,assignedSlaveVP->numTimesAssignedToASlot,assignedSlaveVP,cycles,instrs,tmp_cachem); 10.440 + 10.441 + #define HOLISTIC__Record_Work_start \ 10.442 + if(currVP){ \ 10.443 + uint64 cycles,instrs,cachem; \ 10.444 + saveCyclesAndInstrs(thisCoresIdx,cycles, instrs,cachem); \ 10.445 + (*counterHandler)(Work_start,currVP->slaveNum,currVP->numTimesAssignedToASlot,currVP,cycles,instrs,cachem); \ 10.446 + } 10.447 + 10.448 + #define HOLISTIC__Record_Work_end \ 10.449 + if(currVP){ \ 10.450 + uint64 cycles,instrs,cachem; \ 10.451 + saveCyclesAndInstrs(thisCoresIdx,cycles, instrs,cachem); \ 10.452 + (*counterHandler)(Work_end,currVP->slaveNum,currVP->numTimesAssignedToASlot,currVP,cycles,instrs,cachem); \ 10.453 + } 10.454 + 10.455 + #define HOLISTIC__Record_HwResponderInvocation_start \ 10.456 + uint64 cycles,instrs,cachem; \ 10.457 + saveCyclesAndInstrs(animatingSlv->coreAnimatedBy,cycles, instrs,cachem); \ 10.458 + (*(_PRTopEnv->counterHandler))(HwResponderInvocation_start,animatingSlv->slaveNum,animatingSlv->numTimesAssignedToASlot,animatingSlv,cycles,instrs,cachem); 10.459 + 10.460 + 10.461 + #define getReturnAddressBeforeLibraryCall(vp_ptr, res_ptr) do{ \ 10.462 +void* frame_ptr0 = vp_ptr->framePtr; \ 10.463 +void* frame_ptr1 = *((void**)frame_ptr0); \ 10.464 +void* frame_ptr2 = *((void**)frame_ptr1); \ 10.465 +void* frame_ptr3 = *((void**)frame_ptr2); \ 10.466 +void* ret_addr = *((void**)frame_ptr3 + 1); \ 10.467 +*res_ptr = ret_addr; \ 10.468 +} while (0) 10.469 + 10.470 +#else 10.471 + #define MEAS__Insert_Counter_Handler 10.472 + #define MEAS__Insert_Counter_Meas_Fields_into_MasterEnv 10.473 + #define HOLISTIC__Setup_Perf_Counters 10.474 + #define HOLISTIC__CoreCtrl_Setup 10.475 + #define HOLISTIC__Insert_Master_Global_Vars 10.476 + #define HOLISTIC__Record_last_work 10.477 + #define HOLISTIC__Record_AppResponderInvocation_start 10.478 + #define HOLISTIC__Record_AppResponder_start 10.479 + #define HOLISTIC__Record_AppResponder_end 10.480 + #define HOLISTIC__Record_Assigner_start 10.481 + #define HOLISTIC__Record_Assigner_end 10.482 + #define HOLISTIC__Record_Work_start 10.483 + #define HOLISTIC__Record_Work_end 10.484 + #define HOLISTIC__Record_HwResponderInvocation_start 10.485 + #define getReturnAddressBeforeLibraryCall(vp_ptr, res_ptr) 10.486 +#endif 10.487 + 10.488 +//Experiment in two-step macros -- if doesn't work, insert each separately 10.489 +#define MEAS__Insert_Meas_Fields_into_Slave \ 10.490 + MEAS__Insert_Susp_Meas_Fields_into_Slave \ 10.491 + MEAS__Insert_Master_Meas_Fields_into_Slave \ 10.492 + MEAS__Insert_System_Meas_Fields_into_Slave 10.493 + 10.494 + 10.495 +//====================== Histogram Macros -- Create ======================== 10.496 +// 10.497 +// 10.498 + 10.499 +//The language implementation should include a definition of this macro, 10.500 +// which creates all the histograms the language uses to collect measurements 10.501 +// of plugin operation -- so, if the language didn't define it, must 10.502 +// define it here (as empty), to avoid compile error 10.503 +#ifndef MEAS__Make_Meas_Hists_for_Language 10.504 +#define MEAS__Make_Meas_Hists_for_Language 10.505 +#endif 10.506 + 10.507 +#define makeAMeasHist( histInfo, idx, name, numBins, startVal, binWidth ) \ 10.508 + makeHighestDynArrayIndexBeAtLeast( _PRTopEnv->measHistsInfo, idx ); \ 10.509 + _PRTopEnv->measHists[idx] = \ 10.510 + makeFixedBinHist( numBins, startVal, binWidth, name ); 10.511 + 10.512 +//============================== Probes =================================== 10.513 + 10.514 + 10.515 +//=========================================================================== 10.516 +#endif /* _PR_DEFS_MEAS_H */ 10.517 +
11.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 11.2 +++ b/Services_offered_by_PR/prdependency.h Thu Aug 08 02:39:56 2013 -0700 11.3 @@ -0,0 +1,57 @@ 11.4 +/* 11.5 + * Copyright 2011 OpenSourceResearchInstitute.org 11.6 + * Licensed under GNU General Public License version 2 11.7 + * 11.8 + * Author: Nina Engelhardt 11.9 + * 11.10 + */ 11.11 + 11.12 +#ifndef _PRDEPENDENCY_H 11.13 +#define _PRDEPENDENCY_H 11.14 + 11.15 + 11.16 +#include <stdio.h> 11.17 +#include <PR__include/prlistofarrays.h> 11.18 + 11.19 +typedef struct { 11.20 + int vp; 11.21 + int task; 11.22 +} Unit; 11.23 + 11.24 +typedef struct { 11.25 + int from_vp; 11.26 + int from_task; 11.27 + int to_vp; 11.28 + int to_task; 11.29 +} Dependency; 11.30 + 11.31 +typedef struct { 11.32 + int32 id; 11.33 + ListOfArrays* senders; 11.34 + ListOfArrays* receivers; 11.35 +} NtoN; 11.36 + 11.37 +FILE* dependency_file; 11.38 + 11.39 +Dependency* new_dependency(int from_vp, int from_task, int to_vp, int to_task); 11.40 + 11.41 +NtoN* new_NtoN(int id); 11.42 + 11.43 +int set_dependency_file(FILE* file); 11.44 + 11.45 +void print_ctl_dependency_to_file(void* _dep); 11.46 + 11.47 +void print_comm_dependency_to_file(void* _dep); 11.48 + 11.49 +void print_dyn_dependency_to_file(void* _dep); 11.50 + 11.51 +void print_hw_dependency_to_file(void* _dep); 11.52 + 11.53 +void print_dependency_to_file(void* dep); 11.54 + 11.55 +void print_unit_to_file(void* unit); 11.56 + 11.57 +void print_nton_to_file(void* _nton); 11.58 + 11.59 +#endif /* DEPENDENCY_H */ 11.60 +
12.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 12.2 +++ b/Services_offered_by_PR/probes__wrapper_library.h Thu Aug 08 02:39:56 2013 -0700 12.3 @@ -0,0 +1,44 @@ 12.4 +/* 12.5 + * Copyright 2009 OpenSourceStewardshipFoundation.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 +/*NOTE: this file should only be included AFTER some other 12.13 + * file has defined which kind of probe to use, and whether 12.14 + * probes are turned on or off.. 12.15 + * 12.16 + *In other words, this is a static library that uses macros, 12.17 + * and there are multiple versions of the same macro.. which 12.18 + * version gets used depends on #define statements in a 12.19 + * DIFFERENT file.. (traditionally PR_defs__turn_on_and_off.h) 12.20 + * 12.21 + *So, this file relies on #defines that appear in other files, 12.22 + * which must come first in the sequence of #includes that 12.23 + * include this one.. 12.24 + */ 12.25 + 12.26 +#ifndef _PROBES_wrapper_library_H 12.27 +#define _PROBES_wrapper_library_H 12.28 +#define _GNU_SOURCE 12.29 + 12.30 +//========================================================= 12.31 +// Use only these aliases within application code 12.32 +//========================================================= 12.33 + 12.34 + 12.35 +#define PR_App__record_time_point_into_new_probe PR_WL__record_time_point_into_new_probe 12.36 +#define PR_App__create_single_interval_probe PR_WL__create_single_interval_probe 12.37 +#define PR_App__create_histogram_probe PR_WL__create_histogram_probe 12.38 +#define PR_App__index_probe_by_its_name PR_WL__index_probe_by_its_name 12.39 +#define PR_App__get_probe_by_name PR_WL__get_probe_by_name 12.40 +#define PR_App__record_sched_choice_into_probe PR_WL__record_sched_choice_into_probe 12.41 +#define PR_App__record_interval_start_in_probe PR_WL__record_interval_start_in_probe 12.42 +#define PR_App__record_interval_end_in_probe PR_WL__record_interval_end_in_probe 12.43 +#define PR_App__print_stats_of_probe PR_WL__print_stats_of_probe 12.44 +#define PR_App__print_stats_of_all_probes PR_WL__print_stats_of_all_probes 12.45 + 12.46 +#endif /* top ifndef */ 12.47 +
13.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 13.2 +++ b/__README__about_dir.txt Thu Aug 08 02:39:56 2013 -0700 13.3 @@ -0,0 +1,7 @@ 13.4 + 13.5 +This directory is a copy of /usr/include/PR__include 13.6 + 13.7 +It holds the header files that are public, for all the independent libraries created, related to proto-runtime (as of now, just the universal version). 13.8 + 13.9 +In particular, the individual repositories do NOT contain these header files! If any of them change these, then the /usr/include/PR__include directory has to be copied to the windows shadow copy, then committed to the repository. 13.10 +
14.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 14.2 +++ b/__brch__Dev_Univ Thu Aug 08 02:39:56 2013 -0700 14.3 @@ -0,0 +1,28 @@ 14.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. 14.5 + 14.6 + 14.7 +======== Background on branch naming ========= 14.8 + 14.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. 14.10 + 14.11 +After Feb 2012, branches are named by the scheme: 14.12 + 14.13 +feat__<feat_descr>__<HW_feat_dev_on> 14.14 + 14.15 +HW__<desc_of_HW_brch_tuned_for> 14.16 + 14.17 +where <HW_feat_dev_on> and <desc_of_HW_brch_tuned_for> follow the pattern: 14.18 + 14.19 +<num_socket> x <num_cores>_<Manuf>_<special_features> 14.20 + 14.21 +Examples: 14.22 + 14.23 +feat__exp_array_malloc 14.24 + 14.25 +feat__rand_backoff__4x10_Intel_WestmereEx 14.26 + 14.27 +HW__1x4_Intel_SandyBridge 14.28 + 14.29 +HW__4x10_Intel_WestmereEx 14.30 + 14.31 +HW__1x4_AMD_mobile
15.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 15.2 +++ b/langlets/vreo_wrapper_library.h Thu Aug 08 02:39:56 2013 -0700 15.3 @@ -0,0 +1,264 @@ 15.4 +/* 15.5 + * Copyright 2009 OpenSourceResearchInstitute.org 15.6 + * Licensed under GNU General Public License version 2 15.7 + * 15.8 + * Author: seanhalle@yahoo.com 15.9 + * 15.10 + */ 15.11 + 15.12 +#ifndef _VREO_WRAPPER_H 15.13 +#define _VREO_WRAPPER_H 15.14 + 15.15 +#include <PR__include/PR__structs__common.h> 15.16 +//#include <PR__include/prqueue.h> 15.17 +//#include <PR__include/prhash.h> 15.18 +//#include "Measurement/dependency.h" 15.19 + 15.20 + //uniquely identifies VSs -- should be a jenkins char-hash of "VSs" to int32 15.21 +#define VReo_MAGIC_NUMBER 0000000003 15.22 + 15.23 +//=========================================================================== 15.24 +/* 15.25 + //uniquely identifies VSs -- should be a jenkins char-hash of "VSs" to int32 15.26 +#define VReo_MAGIC_NUMBER 0000000003 15.27 + 15.28 +#define NUM_STRUCS_IN_LANG_ENV 1000 15.29 + 15.30 + //This is hardware dependent -- it's the number of cycles of scheduling 15.31 + // overhead -- if a work unit is fewer than this, it is better being 15.32 + // combined sequentially with other work 15.33 + //This value depends on both PR overhead and VSs's plugin. At some point 15.34 + // it will be derived by perf-counter measurements during init of VSs 15.35 +#define MIN_WORK_UNIT_CYCLES 20000 15.36 +*/ 15.37 + 15.38 +//=========================================================================== 15.39 +/*This header defines everything specific to the VReo semantic plug-in 15.40 + */ 15.41 +typedef struct _VReoIsland VReoIsland; 15.42 + 15.43 +//typedef struct _VReoLangReq VReoLangReq; 15.44 +//typedef struct _VReoTaskStub VReoTaskStub; 15.45 +//typedef void (*VReoTaskFnPtr ) ( void *, SlaveVP *); 15.46 +typedef bool32 (*VReoCheckerFn ) ( VReoIsland * ); 15.47 +typedef void (*VReoDoerFn ) ( VReoIsland * ); 15.48 +//=========================================================================== 15.49 + 15.50 +/* 15.51 +#define IS_A_VP NULL 15.52 +#define IS_ENDED NULL 15.53 +#define SEED_SLV NULL 15.54 + 15.55 +#define NO_ID NULL 15.56 +#define ANY_CORE -1 15.57 +*/ 15.58 + 15.59 +//=========================================================================== 15.60 + 15.61 +typedef struct 15.62 + { 15.63 + void *buffer; 15.64 + bool32 portIsFull; 15.65 + SlaveVP *waitingReaderVP; //doubles as flag 15.66 + SlaveVP *waitingWriterVP; 15.67 + 15.68 + void *reader; //either island or VP 15.69 + void *writer; //either island or VP 15.70 + 15.71 + int32 numReaderCheckerFns; 15.72 + VReoCheckerFn *readerCheckerFns; //checkers triggered when port state changes 15.73 + VReoDoerFn *readerDoerFns; //corresponding doer functions 15.74 + 15.75 + int32 numWriterCheckerFns; 15.76 + VReoCheckerFn *writerCheckerFns; //checkers triggered when port state changes 15.77 + VReoDoerFn *writerDoerFns; //corresponding doer functions 15.78 + } 15.79 +VReoPort; 15.80 + 15.81 +struct _VReoIsland 15.82 + { 15.83 + int32 numPorts; 15.84 + VReoPort **ports; //array of pointers to port structs 15.85 + 15.86 + int32 numCheckerFns; 15.87 + VReoCheckerFn *checkerFns; //checkers triggered when state changes 15.88 + VReoDoerFn *doerFns; //corresponding doer functions 15.89 + 15.90 + int32 lastCheckerToSucceed; 15.91 + }; 15.92 +//VReoIsland 15.93 + 15.94 +typedef struct _VReoListElem VReoListElem; 15.95 + 15.96 +struct _VReoListElem 15.97 + { 15.98 + void *payload; 15.99 + VReoListElem *next; 15.100 + }; 15.101 +//VReoListElem 15.102 + 15.103 +typedef struct 15.104 + { 15.105 + int32 numPorts; // 15.106 + VReoPort *ports; //array of port structs 15.107 + VReoPort **boundaryPorts; 15.108 + 15.109 + int32 numIslands; 15.110 + VReoIsland *islands; //array of island structs -- no pointers 15.111 + 15.112 + int32 numVPs; 15.113 + VReoListElem *VPs; 15.114 + 15.115 + int32 suspendScope; //given to PR -- VPs created suspended 15.116 + } 15.117 +VReoCircuit; 15.118 + 15.119 +//Every application-defined birth param struct must have a pointer to a 15.120 +// circuit as its first field. An instance of one of those app-defined 15.121 +// structs is then cast to be a VReoBirthParams, in order for VReo to 15.122 +// access the circuit field without knowing anything about the app-specific 15.123 +// part of the structure 15.124 +typedef struct 15.125 + { 15.126 + VReoCircuit *circuit; 15.127 + } 15.128 +VReoBirthParams; 15.129 + 15.130 +/*This is VReo's "lang meta task" 15.131 + *See the proto-runtime wiki entry to learn about "lang meta task" 15.132 + *In essence, this holds all the meta information that VReo needs about a task 15.133 + */ 15.134 +/* 15.135 +struct _VReoTaskStub 15.136 + { 15.137 + VReoTaskStub *parentTaskStub; //for liveness, for the wait construct 15.138 + int32 numLiveChildTasks; 15.139 + int32 numLiveChildVPs; 15.140 + bool32 isWaitingForChildTasksToEnd; 15.141 + bool32 isWaitingForChildVPsToEnd; 15.142 + bool32 isEnded; 15.143 + }; 15.144 +*/ 15.145 + 15.146 + 15.147 +/*Semantic-layer-specific data sent inside a request from lib call in app 15.148 + * to request handler called in AnimationMaster 15.149 + */ 15.150 +/* 15.151 +struct _VReoLangReq 15.152 + { 15.153 + SlaveVP *callingVP; 15.154 + 15.155 + BirthFnPtr fnPtr; 15.156 + void *initData; 15.157 + int32 coreToAssignOnto; 15.158 + int32 createSuspendedGroup; 15.159 + 15.160 + VReoCircuit *circuit; 15.161 + VReoPort *port; 15.162 + void *itemToPut; 15.163 + } 15.164 +*/ 15.165 +/* VReoLangReq */; 15.166 + 15.167 + 15.168 +/* 15.169 +typedef struct 15.170 + { 15.171 + PrivQueueStruc *slaveReadyQ; //Shared (slaves not pinned) 15.172 + PrivQueueStruc *taskReadyQ; //Shared (tasks not pinned) 15.173 + 15.174 + int32 nextCoreToGetNewSlv; 15.175 + int32 primitiveStartTime; 15.176 + 15.177 + VReoCircuit *circuit; //used during debugging, to get access when no work 15.178 + 15.179 + #ifdef HOLISTIC__TURN_ON_OBSERVE_UCC 15.180 + ListOfArrays* unitList; 15.181 + ListOfArrays* ctlDependenciesList; 15.182 + ListOfArrays* commDependenciesList; 15.183 + NtoN** ntonGroups; 15.184 + PrivDynArrayInfo* ntonGroupsInfo; 15.185 + ListOfArrays* dynDependenciesList; 15.186 + Unit last_in_slot[NUM_CORES * NUM_ANIM_SLOTS]; 15.187 + ListOfArrays* hwArcs; 15.188 + #endif 15.189 + 15.190 + #ifdef HOLISTIC__TURN_ON_PERF_COUNTERS 15.191 + ListOfArrays* counterList[NUM_CORES]; 15.192 + #endif 15.193 + } 15.194 +VReoLangEnv; 15.195 + 15.196 + 15.197 +typedef struct 15.198 + { 15.199 + VReoCircuit *circuit; 15.200 + int32 numPorts; 15.201 + int32 *ports; 15.202 + } 15.203 +VReoVPParams; 15.204 + 15.205 +typedef struct 15.206 + { 15.207 + VReoVPParams *params; //keep here, so can free when end VP 15.208 + } 15.209 +VReoLangData; 15.210 +*/ 15.211 + 15.212 +//=========================================================================== 15.213 + 15.214 +//======================= 15.215 + 15.216 +void 15.217 +VReo__start( SlaveVP *seedVP ); 15.218 + 15.219 +void 15.220 +VReo__shutdown( SlaveVP *seedVP ); 15.221 + 15.222 +void 15.223 +VReo__wait_for_all_VReo_created_work_to_end( SlaveVP *seedVP ); 15.224 + 15.225 +//======================= 15.226 + 15.227 +void 15.228 +VReo__put_into_port( void *itemToPut, VReoPort *port, SlaveVP *callingVP ); 15.229 + 15.230 +void * 15.231 +VReo__get_from_port( VReoPort *port, SlaveVP *callingVP ); 15.232 + 15.233 + 15.234 + 15.235 +SlaveVP * 15.236 +VReo__create_VP( BirthFnPtr fnPtr, void *_params, 15.237 + VReoCircuit *circuit, SlaveVP *creatingVP ); 15.238 + 15.239 +void 15.240 +VReo__end_VP( SlaveVP *VPToEnd ); 15.241 + 15.242 + 15.243 +//======================= 15.244 + 15.245 + 15.246 +//========================= Internal use only ============================= 15.247 +/* 15.248 +bool32 15.249 +VReo__assign_work_to_slot( void *_langEnv, AnimSlot *slot ); 15.250 + 15.251 +SlaveVP * 15.252 +VReo__create_slave_with_affinity( BirthFnPtr fnPtr, void *initData, 15.253 + SlaveVP *creatingSlv, int32 coreToAssignOnto); 15.254 + 15.255 +void 15.256 +VReo__cleanup_after_shutdown(); 15.257 + 15.258 +//===================== ===================== 15.259 + 15.260 +#include "VReo_Request_Handlers.h" 15.261 + 15.262 +//===================== Measurement of Lang Overheads ===================== 15.263 +#include "Measurement/VReo_Measurement.h" 15.264 +*/ 15.265 +//=========================================================================== 15.266 +#endif /* _VReo_H */ 15.267 +
16.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 16.2 +++ b/prdynarray.h Thu Aug 08 02:39:56 2013 -0700 16.3 @@ -0,0 +1,91 @@ 16.4 +/* 16.5 + * File: Vector.h 16.6 + * Author: Me 16.7 + * 16.8 + * Created on May 14, 2010, 3:08 PM 16.9 + */ 16.10 + 16.11 +#ifndef _DYNARRAY_H 16.12 +#define _DYNARRAY_H 16.13 + 16.14 +#include <PR__include/PR__primitive_data_types.h> 16.15 + 16.16 + 16.17 + 16.18 +/*WARNING: Passing a DynArray as a param is dangerous if add to the DynArray 16.19 + * inside the function called! After adding or other operation that might 16.20 + * change the size, must re-read the addr of the chunk of memory that is the 16.21 + * array, via the DynArrayInfo. 16.22 + *Here's why: An array variable is a location, either on the stack 16.23 + * or in a field of a struct, whose contents is an addr. That addr is of the 16.24 + * first location of a chunk of locations. The DynArray works by changing 16.25 + * the chunk of locations, then modifying the contents of the original 16.26 + * array variable. It overwrites the addr of the old chunk of locations 16.27 + * with the addr of the new chunk. 16.28 + *But when the array variable is passed as a parameter, such as 16.29 + * in this: "foo( myDynArray )", then there are now two locations that hold 16.30 + * the addr of the same chunk of locations. So when a call is made that 16.31 + * adds to the DynArray, and inside the DynArray expands, it only updates 16.32 + * the original location with the new addr. Hence, the function will begin 16.33 + * overwriting memory past the end of the old chunk, because it still has 16.34 + * the pointer to the old chunk of locations. 16.35 + * 16.36 + *A dynamic array is accessed same as any other array. However, must use 16.37 + * dyn array calls, defined in here, in order to add or increase the size. 16.38 + * Must re-read the original array variable after any size-changing calls. 16.39 + *To pass a DynArray as a parameter to a function, can only pass the 16.40 + * DynArrayInfo, then inside the function, to read the addr of the first 16.41 + * location in the chunk of locations that is the array, do this: 16.42 + * "localArrayCopy = *(myDynArrayInfo->addrOfPtrToArray). After that, can 16.43 + * treat localArrayCopy as a normal array, as long as don't make any calls 16.44 + * that add or otherwise could increase the size of the array. If do make 16.45 + * such a call, then re-copy the array via the above. Can then use the 16.46 + * copy up until another add to the array. 16.47 + * 16.48 + */ 16.49 +typedef struct 16.50 + { 16.51 + void ***addrOfPtrToArray; //addr of var that is array of ptrs == triple * 16.52 + int32 numInArray; //num entries added 16.53 + int32 sizeOfArray; //num elems alloc'd 16.54 + int32 sizeOfElem; //num bytes in one elem of array -- used in 2nd version 16.55 + } 16.56 +PrivDynArrayInfo; 16.57 + 16.58 +PrivDynArrayInfo * 16.59 +makePrivDynArrayInfoFrom( void ***addrOfPtrToArray, int32 sizeOfArray ); 16.60 + 16.61 +PrivDynArrayInfo * 16.62 +makePrivDynArrayOfSize( void ***addrOfPtrToArray, int32 sizeOfArray ); 16.63 + 16.64 +PrivDynArrayInfo * 16.65 +makePrivDynArrayOfSize_Ext( void ***addrOfPtrToArray, int32 sizeOfArray ); 16.66 + 16.67 +int32 16.68 +addToDynArray( void *value, PrivDynArrayInfo *info ); 16.69 + 16.70 +void 16.71 +makeHighestDynArrayIndexBe( PrivDynArrayInfo *info, int32 highestIndex ); 16.72 + 16.73 +void 16.74 +makeHighestDynArrayIndexBeAtLeast(PrivDynArrayInfo *info,int32 highestIndex); 16.75 + 16.76 +void 16.77 +increaseSizeOfDynArrayTo( PrivDynArrayInfo *info, int32 newSize ); 16.78 + 16.79 +typedef void (*FreeFnPtr) ( void * ); //fn has to cast void * to whatever 16.80 + 16.81 +void 16.82 +freeDynArrayDeep( PrivDynArrayInfo *info, FreeFnPtr freeFnPtr ); 16.83 + 16.84 +void 16.85 +freeDynArrayFlat( PrivDynArrayInfo *info ); 16.86 + 16.87 + 16.88 +typedef void (*DynArrayFnPtr) ( void * ); //fn has to cast void * 16.89 + 16.90 +void 16.91 +forAllInDynArrayDo( PrivDynArrayInfo *info, DynArrayFnPtr fnPtr ); 16.92 + 16.93 +#endif /* _DYNARRAY_H */ 16.94 +
17.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 17.2 +++ b/prhash.h Thu Aug 08 02:39:56 2013 -0700 17.3 @@ -0,0 +1,96 @@ 17.4 +/* 17.5 + * Copyright 2009 OpenSourceResearchInstitute.org 17.6 + * Licensed under GNU General Public License version 2 17.7 + * 17.8 + * Author: seanhalle@yahoo.com 17.9 + */ 17.10 + 17.11 +#ifndef _PRHASH_H 17.12 +#define _PRHASH_H 17.13 + 17.14 +#include <stdio.h> 17.15 +#include <string.h> 17.16 +#include <errno.h> 17.17 +#include <stdlib.h> 17.18 + 17.19 +#include <PR__include/PR__primitive_data_types.h> 17.20 + 17.21 +//===================== defines ===================== 17.22 +#define TRUE 1 17.23 +#define FALSE 0 17.24 + 17.25 +#define DEFAULT_HASH_TABLE_SIZE 1 << 10 17.26 +#define DEFAULT_POWER_OF_2_TABLE_SIZE 10 17.27 + 17.28 + 17.29 +//===================== structs ===================== 17.30 +union hashkey_t{ 17.31 + char hashable[8]; 17.32 + int32 parts[2]; 17.33 +}; 17.34 + 17.35 +typedef union hashkey_t hashkey_t; 17.36 + 17.37 +typedef struct _HashEntry HashEntry; 17.38 + 17.39 +struct _HashEntry 17.40 + { 17.41 + char *key; 17.42 + void *content; 17.43 + HashEntry *next; 17.44 + }; 17.45 + 17.46 +typedef void (*FreeEntryContentFnPtr) ( void * ); 17.47 + 17.48 +typedef struct 17.49 + { int32 tableSz; 17.50 + int32 numEntries; 17.51 + HashEntry* *entries; 17.52 + int32 hashMask; 17.53 + int32 prevHash; 17.54 + FreeEntryContentFnPtr freeEntryContentFn; 17.55 + } 17.56 +HashTable; 17.57 + 17.58 + 17.59 +//=========================================================================== 17.60 +// Public functions 17.61 +HashTable *makeHashTable( int numHashSlots, FreeEntryContentFnPtr freeFn ); 17.62 + 17.63 +int32 putEntryIntoTable( HashEntry *entry, HashTable *table); 17.64 +int32 addValueIntoTable( char* key, void *value, HashTable *table); 17.65 +HashEntry *getEntryFromTable( char *key, HashTable *table ); 17.66 +void *getValueFromTable( char *key, HashTable *table ); 17.67 + 17.68 +bool8 deleteEntryFromTable( char *key, HashTable *table ); 17.69 +bool8 deleteThisEntryFromTable( HashEntry *entry, HashTable *table ); 17.70 +bool8 deleteEntrysValueInTable( char *key, HashTable *table ); 17.71 +bool8 deleteEntryFromTableAndFreeValue( char *key, HashTable *table ); 17.72 +void freeHashTable( HashTable *table ); 17.73 +//char *paramBagToString( ParamBag * bag ) 17.74 + 17.75 +//================= Same Fns, but for 32b array key hash fn ================ 17.76 +HashTable *makeHashTable32(int32 powerOf2OfSz, FreeEntryContentFnPtr freeFn); 17.77 +HashTable *makeDefaultSizeHashTable32( FreeEntryContentFnPtr freeFn ); 17.78 + 17.79 +int32 putEntryIntoTable32( HashEntry *entry, HashTable *table); 17.80 +HashEntry *addValueIntoTable32( uint32 key[], void *value, HashTable *table); 17.81 +HashEntry *getEntryFromTable32( uint32 key[], HashTable *table ); 17.82 +void *getValueFromTable32( uint32 key[], HashTable *table ); 17.83 + 17.84 +bool32 deleteEntryFromTable32( uint32 key[], HashTable *table ); 17.85 + 17.86 +//=========================================================================== 17.87 +// Internal functions 17.88 +void freeHashEntryUsing( HashEntry *entry, HashTable *table ); 17.89 +unsigned int hashThisKey( char *s, int hashSz ); 17.90 +void nullOutTablesArray( HashTable *table ); 17.91 +void doubleTableSize( HashTable *table ); 17.92 +void freeHashEntryButNotContent( HashEntry *entry ); 17.93 + 17.94 +uint32 17.95 +jenkHash32( const uint32 *key, /* array of uint32 values */ 17.96 + int32 length); /* num uint32 in the key */ 17.97 + 17.98 +#endif /* _PRIVATE_HASH_H */ 17.99 +
18.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 18.2 +++ b/prhistogram.h Thu Aug 08 02:39:56 2013 -0700 18.3 @@ -0,0 +1,102 @@ 18.4 +/* 18.5 + * Copyright 2010 OpenSourceResearchInstitute.org 18.6 + * Licensed under GNU General Public License version 2 18.7 + * 18.8 + * Author: seanhalle@yahoo.com 18.9 + * 18.10 + */ 18.11 + 18.12 + 18.13 +#ifndef _PRHISTOGRAM_H 18.14 +#define _PRHISTOGRAM_H 18.15 + 18.16 +#include <PR__include/prmalloc.h> 18.17 +#include <PR__include/PR__primitive_data_types.h> 18.18 + 18.19 + 18.20 +typedef struct 18.21 + { 18.22 + char *name; 18.23 + int32 startOfRange; 18.24 + int32 endOfRange; 18.25 + int32 numBins; 18.26 + int32 binWidth; 18.27 + int32 *bins; 18.28 + } 18.29 +Histogram; 18.30 + 18.31 +typedef struct 18.32 + { 18.33 + float32 startOfRange; 18.34 + float32 endOfRange; 18.35 + int32 numBins; 18.36 + float32 binWidth; 18.37 + int32 *bins; 18.38 + } 18.39 +FloatHist; 18.40 + 18.41 +typedef struct 18.42 + { 18.43 + float64 startOfRange; 18.44 + float64 endOfRange; 18.45 + int32 numBins; 18.46 + float64 binWidth; 18.47 + int32 *bins; 18.48 + } 18.49 +DblHist; 18.50 + 18.51 +Histogram * 18.52 +makeHistogram( int32 numBins, int32 startOfRange, int32 endOfRange ); 18.53 + 18.54 +Histogram * 18.55 +makeFixedBinHist( int32 numBins, int32 startOfRange, int32 binWidth, 18.56 + char *name ); 18.57 + 18.58 +Histogram * 18.59 +makeFixedBinHistExt( int32 numBins, int32 startOfRange, int32 binWidth, 18.60 + char *name ); 18.61 + 18.62 +void inline 18.63 +addToHist( int32 value, Histogram *hist ); 18.64 + 18.65 +void inline 18.66 +addIntervalToHist( uint32 startIntvl, uint32 endIntvl, Histogram *hist ); 18.67 + 18.68 +void inline 18.69 +subIntervalFromHist( int32 startIntvl, int32 endIntvl, Histogram *hist ); 18.70 + 18.71 +void 18.72 +saveHistToFile(Histogram *hist); 18.73 + 18.74 +void 18.75 +printHist( Histogram *hist ); 18.76 + 18.77 +FloatHist * 18.78 +makeFloatHistogram( int numBins, float32 startOfRange, float32 binWidth ); 18.79 + 18.80 +void 18.81 +addToFloatHist( float32 value, FloatHist *hist ); 18.82 + 18.83 +void 18.84 +printFloatHist( FloatHist *hist ); 18.85 + 18.86 +void 18.87 +freeHistExt( Histogram *hist ); 18.88 + 18.89 +void 18.90 +freeHist( Histogram *hist ); 18.91 + 18.92 +DblHist * 18.93 +makeDblHistogram( int numBins, float64 startOfRange, float64 binWidth ); 18.94 + 18.95 +void 18.96 +addToDblHist( float64 value, DblHist *hist ); 18.97 + 18.98 +void 18.99 +printDblHist( DblHist *hist ); 18.100 + 18.101 +void 18.102 +freeDblHist( DblHist *hist ); 18.103 + 18.104 +#endif /* _HISTOGRAM_H */ 18.105 +
19.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 19.2 +++ b/prlistofarrays.h Thu Aug 08 02:39:56 2013 -0700 19.3 @@ -0,0 +1,67 @@ 19.4 +/* 19.5 + * File: ListOfArrays.h 19.6 + * Author: Nina Engelhardt 19.7 + * 19.8 + * Created on December 16, 2011, 2:06 PM 19.9 + */ 19.10 + 19.11 +#ifndef _LISTOFARRAYS_H 19.12 +#define _LISTOFARRAYS_H 19.13 + 19.14 +#include<stddef.h> 19.15 +#include <inttypes.h> 19.16 + 19.17 +#include <PR__include/PR__primitive_data_types.h> 19.18 +#include <PR__include/prdynarray.h> 19.19 + 19.20 + 19.21 +typedef struct { 19.22 + void* next; 19.23 + void* data; 19.24 +} ArrayFragment; 19.25 + 19.26 +typedef struct { 19.27 + void** dim1; 19.28 + PrivDynArrayInfo* dim1info; 19.29 + //ArrayFragment* last; 19.30 + size_t entry_size; 19.31 + int num_entries_per_fragment; 19.32 + int next_free_index; 19.33 +} ListOfArrays; 19.34 + 19.35 +ListOfArrays* makeListOfArrays(size_t entry_size, int num_entries_per_block); 19.36 + 19.37 +#define addToListOfArrays(type,value,list) do { \ 19.38 + int offset_in_fragment = list->next_free_index % list->num_entries_per_fragment; \ 19.39 + if(offset_in_fragment == 0){ \ 19.40 + void* newBlock = PR__malloc(list->entry_size * list->num_entries_per_fragment); \ 19.41 + addToDynArray(newBlock,list->dim1info); \ 19.42 + } \ 19.43 + type* typedFragment = (type*) ((list->dim1)[list->dim1info->numInArray -1]); \ 19.44 + typedFragment[offset_in_fragment] = value; \ 19.45 + list->next_free_index++; \ 19.46 +} while (0) 19.47 + 19.48 +#define addToListOfArrays_ext(type,value,list) do { \ 19.49 + int offset_in_fragment = list->next_free_index % list->num_entries_per_fragment; \ 19.50 + if(offset_in_fragment == 0){ \ 19.51 + void* newBlock = malloc(list->entry_size * list->num_entries_per_fragment); \ 19.52 + addToDynArray(newBlock,list->dim1info); \ 19.53 + } \ 19.54 + type* typedFragment = (type*) ((list->dim1)[list->dim1info->numInArray -1]); \ 19.55 + typedFragment[offset_in_fragment] = value; \ 19.56 + list->next_free_index++; \ 19.57 +} while (0) 19.58 + 19.59 +typedef void (*ListOfArraysFnPtr) ( void * ); //fn has to cast void * 19.60 + 19.61 +void forAllInListOfArraysDo(ListOfArrays* list, ListOfArraysFnPtr fnPtr); 19.62 + 19.63 +#define valueInListOfArrays(type,index,list) ((type*)((list->dim1)[index / list->num_entries_per_fragment]))[index % list->num_entries_per_fragment] 19.64 + 19.65 +#define setValueInListOfArrays(type,index,value,list) ((type*)((list->dim1)[index / list->num_entries_per_fragment]))[index % list->num_entries_per_fragment] = value 19.66 + 19.67 +void freeListOfArrays(ListOfArrays* list); 19.68 + 19.69 +#endif /* LISTOFARRAYS_H */ 19.70 +
20.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 20.2 +++ b/prmalloc.h Thu Aug 08 02:39:56 2013 -0700 20.3 @@ -0,0 +1,52 @@ 20.4 +/* 20.5 + * Copyright 2009 OpenSourceCodeStewardshipFoundation.org 20.6 + * Licensed under GNU General Public License version 2 20.7 + * 20.8 + * Author: seanhalle@yahoo.com 20.9 + * 20.10 + * Created on November 14, 2009, 9:07 PM 20.11 + */ 20.12 + 20.13 +#ifndef _PRMALLOC_H 20.14 +#define _PRMALLOC_H 20.15 + 20.16 +#include <malloc.h> 20.17 +#include <inttypes.h> 20.18 +#include <math.h> 20.19 +#include <PR__include/PR__primitive_data_types.h> 20.20 + 20.21 +void * 20.22 +PR_int__malloc( size_t sizeRequested ); 20.23 + 20.24 +void * 20.25 +PR_int__malloc_aligned( size_t sizeRequested ); 20.26 + 20.27 +void 20.28 +PR_int__free( void *ptrToFree ); 20.29 + 20.30 +//Use these in application code directly 20.31 +#define \ 20.32 +PR__malloc PR_WL__malloc 20.33 + 20.34 +#define \ 20.35 +PR__free PR_WL__free 20.36 + 20.37 +//these are implemented in the PR leaf implementation 20.38 +void * 20.39 +PR_WL__malloc( int32 sizeRequested ); 20.40 + 20.41 +void 20.42 +PR_WL__free( void *ptrToFree ); 20.43 + 20.44 + 20.45 +/*Allocates memory from the external system -- higher overhead 20.46 + */ 20.47 +void * 20.48 +PR_ext__malloc_in_ext( size_t sizeRequested ); 20.49 + 20.50 +/*Frees memory that was allocated in the external system -- higher overhead 20.51 + */ 20.52 +void 20.53 +PR_ext__free_in_ext( void *ptrToFree ); 20.54 + 20.55 +#endif 20.56 \ No newline at end of file
21.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 21.2 +++ b/prparam.h Thu Aug 08 02:39:56 2013 -0700 21.3 @@ -0,0 +1,59 @@ 21.4 +/* 21.5 + * 21.6 + * Author: SeanHalle@yahoo.com 21.7 + * 21.8 + * Created on November 19, 2009, 6:30 PM 21.9 + */ 21.10 + 21.11 +#ifndef _PARAM_H 21.12 +#define _PARAM_H 21.13 + 21.14 +#include <PR__include/PR__primitive_data_types.h> 21.15 + 21.16 + 21.17 +typedef 21.18 +struct 21.19 + { int type; 21.20 + int intValue; 21.21 + char * strValue; 21.22 + float floatValue; 21.23 + } 21.24 +ParamStruc; 21.25 + 21.26 +#define INT_PARAM_TYPE 0 21.27 +#define STRING_PARAM_TYPE 1 21.28 +#define FLOAT_PARAM_TYPE 2 21.29 + 21.30 +#define PARAM_BAG_HASHSIZE 1024 21.31 + 21.32 +typedef struct _ParamBagHashEntry ParamBagHashEntry; 21.33 + 21.34 +struct _ParamBagHashEntry 21.35 + { 21.36 + char *key; 21.37 + ParamStruc *param; 21.38 + struct _ParamBagHashEntry *next; 21.39 + } 21.40 +/*ParamBagHashEntry*/; 21.41 + 21.42 + 21.43 +typedef 21.44 +struct 21.45 + { int bagSz; 21.46 + ParamBagHashEntry* *entries; 21.47 + } 21.48 +ParamBag; 21.49 + 21.50 + 21.51 +ParamBag *makeParamBag(); 21.52 +void readParamFileIntoBag( char *paramFileName, ParamBag * bag ); 21.53 +ParamStruc *getParamFromBag( char *key, ParamBag * bag ); 21.54 +int addParamToBag( char* key, ParamStruc *param, ParamBag *bag ); 21.55 +void freeParamBag( ParamBag *bag ); 21.56 +//char *paramBagToString( ParamBag * bag ); 21.57 +ParamStruc *makeParamStruc(); 21.58 +ParamStruc *makeParamFromStrs( char * type, char *value ); 21.59 +ssize_t getline( char **lineptr, size_t *n, FILE *stream ); 21.60 + 21.61 +#endif /* _PARAM_H */ 21.62 +
22.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 22.2 +++ b/prqueue.h Thu Aug 08 02:39:56 2013 -0700 22.3 @@ -0,0 +1,114 @@ 22.4 +/* 22.5 + * Copyright 2009 OpenSourceResearchInstitute.org 22.6 + * Licensed under GNU General Public License version 2 22.7 + * 22.8 + * Author: seanhalle@yahoo.com 22.9 + */ 22.10 + 22.11 +#ifndef _PRQUEUE_H 22.12 +#define _PRQUEUE_H 22.13 + 22.14 +#include <PR__include/PR__primitive_data_types.h> 22.15 +#include <pthread.h> 22.16 + 22.17 +#define TRUE 1 22.18 +#define FALSE 0 22.19 + 22.20 +//================== Private Queue stuff =================== 22.21 +/* It is the data that is shared so only need one mutex. */ 22.22 +typedef struct 22.23 + { void **insertPos; 22.24 + void **extractPos; 22.25 + void **startOfData; //data is pointers 22.26 + void **endOfData; //set when alloc data 22.27 + } 22.28 +PrivQueueStruc; 22.29 + 22.30 +typedef void (*DynArrayFnPtr) ( void * ); //fn has to cast void * 22.31 + 22.32 +PrivQueueStruc* makePrivQ ( ); 22.33 +bool32 isEmptyPrivQ ( PrivQueueStruc *Q ); //ret TRUE if empty 22.34 +void* peekPrivQ ( PrivQueueStruc *Q ); //ret NULL if empty 22.35 +void* readPrivQ ( PrivQueueStruc *Q ); //ret NULL if empty 22.36 +void writePrivQ( void *in, PrivQueueStruc *Q ); 22.37 + //return false when full 22.38 +bool32 writeIfSpacePrivQ( void * in, PrivQueueStruc* Q ); 22.39 +int32 numInPrivQ( PrivQueueStruc *Q ); 22.40 +void pushPrivQ( void * in, PrivQueueStruc* Q ); 22.41 +void freePrivQ( PrivQueueStruc *Q ); 22.42 + 22.43 + 22.44 +//====================== Parallel Queue Stuff ==================== 22.45 + 22.46 +//========== pThreads based queue ========== 22.47 +/* It is the data that is shared so only need one mutex. */ 22.48 +typedef 22.49 +struct 22.50 + { pthread_mutex_t mutex_t; 22.51 + pthread_cond_t cond_w_t; 22.52 + pthread_cond_t cond_r_t; 22.53 + int32 count; 22.54 + int32 readPos; 22.55 + int32 writePos; 22.56 + void* data[1024]; //an array of pointers 22.57 + int w_empty; 22.58 + int w_full; 22.59 + } 22.60 +PThdQueueStruc; 22.61 + 22.62 +PThdQueueStruc* makePThdQ(); 22.63 +void* readPThdQ( PThdQueueStruc *Q ); 22.64 +void writePThdQ( void *in, PThdQueueStruc *Q ); 22.65 + 22.66 + 22.67 +//========== CAS based queue ========== 22.68 +typedef 22.69 +struct 22.70 + { volatile int32 insertLock; 22.71 + volatile int32 extractLock; 22.72 + volatile void* *insertPos; 22.73 + volatile void* *extractPos; 22.74 + void* startOfData[1024]; //data is pointers 22.75 + void* *endOfData; //set when make queue 22.76 + } 22.77 +CASQueueStruc; 22.78 + 22.79 +CASQueueStruc* makeCASQ(); 22.80 +void* readCASQ( CASQueueStruc *Q ); 22.81 +void writeCASQ( void *in, CASQueueStruc *Q ); 22.82 + 22.83 + 22.84 +//========= non-atomic instr based queue =========== 22.85 +typedef 22.86 +struct 22.87 + { void* *insertPos; 22.88 + void* *extractPos; 22.89 + void* startOfData[1024]; //data is pointers 22.90 + void* *endOfData; //set when make queue 22.91 + } 22.92 +SRSWQueueStruc; 22.93 + 22.94 +SRSWQueueStruc* makeSRSWQ(); 22.95 +void freeSRSWQ( SRSWQueueStruc* Q ); 22.96 +void* readSRSWQ( SRSWQueueStruc *Q ); 22.97 +void writeSRSWQ( void *in, SRSWQueueStruc *Q ); 22.98 + 22.99 + 22.100 +//========= non-atomic instr S R M W queue =========== 22.101 +typedef 22.102 +struct 22.103 + { int32 lastQReadFrom; 22.104 + int32 numInternalQs; 22.105 + int32 internalQsSz; 22.106 + SRSWQueueStruc* *internalQs; 22.107 + } 22.108 +SRMWQueueStruc; 22.109 + 22.110 +SRMWQueueStruc* makeSRMWQ(); 22.111 +int addWriterToSRMWQ( SRMWQueueStruc *Q ); 22.112 +void* readSRMWQ( SRMWQueueStruc *Q ); 22.113 +void writeSRMWQ( void *in, SRMWQueueStruc *Q, int writerID ); 22.114 + 22.115 + 22.116 +#endif /* _PRIVATE_QUEUE_H */ 22.117 +
