Mercurial > cgi-bin > hgwebdir.cgi > PR > PR_Implementations > PR__Univ > PR__includes > PR__include
changeset 1:14241f07f742 Dev_Univ
committing files from /usr/include/PR__include directly.. test..
| author | Sean Halle <seanhalle@yahoo.com> |
|---|---|
| date | Thu, 08 Aug 2013 03:00:36 -0700 |
| parents | d460a47ed2d6 |
| children | c3829f630c2f |
| 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 | 18 files changed, 2532 insertions(+), 2532 deletions(-) [+] |
line diff
1.1 --- a/PR__PI.h Thu Aug 08 02:39:56 2013 -0700 1.2 +++ b/PR__PI.h Thu Aug 08 03:00:36 2013 -0700 1.3 @@ -1,196 +1,196 @@ 1.4 -/* 1.5 - * Copyright 2009 OpenSourceResearchInstitute.org 1.6 - * Licensed under GNU General Public License version 2 1.7 - * 1.8 - * Author: seanhalle@yahoo.com 1.9 - * 1.10 - */ 1.11 - 1.12 -#ifndef _PR__PI_H 1.13 -#define _PR__PI_H 1.14 -#define _GNU_SOURCE 1.15 - 1.16 -#include <PR__include/PR__structs__common.h> 1.17 - 1.18 -//========================= Function Prototypes =========================== 1.19 -/* MEANING OF WL PI SS int PROS 1.20 - * These indicate which places the function is safe to use. They stand for: 1.21 - * 1.22 - * WL Wrapper Library -- wrapper lib code should only use these 1.23 - * PI Plugin -- plugin code should only use these 1.24 - * SS Startup and Shutdown -- designates these relate to startup & shutdown 1.25 - * int32internal to PR -- should not be used in wrapper lib or plugin 1.26 - * PROS means "OS functions for applications to use" 1.27 - * 1.28 - * PR_int__ functions touch internal PR data structs and are only safe 1.29 - * to be used inside the master lock. However, occasionally, they appear 1.30 - * in wrapper-lib or plugin code. In those cases, very careful analysis 1.31 - * has been done to be sure no concurrency issues could arise. 1.32 - * 1.33 - * PR_WL__ functions are all safe for use outside the master lock. 1.34 - * 1.35 - * PROS are only safe for applications to use -- they're like a second 1.36 - * language mixed in -- but they can't be used inside plugin code, and 1.37 - * aren't meant for use in wrapper libraries, because they are themselves 1.38 - * wrapper-library calls! 1.39 - */ 1.40 - 1.41 -#define \ 1.42 -PR_PI__create_slaveVP PR_int__create_slaveVP_helper 1.43 - 1.44 -//============== 1.45 -//=== Lang Data 1.46 -//= 1.47 -#define \ 1.48 -PR_PI__give_lang_data_from_slave PR_int__give_lang_data_from_slave 1.49 -#define \ 1.50 -PR_SS__give_lang_data_from_slave PR_int__give_lang_data_from_slave 1.51 - 1.52 -int32 1.53 -PR_PI__give_num_cores(); 1.54 - 1.55 -//============ 1.56 -//=== Lang Env 1.57 -//= 1.58 -#define \ 1.59 -PR_PI__give_proto_lang_env_for_slave PR_int__give_proto_lang_env_for_slave 1.60 -#define \ 1.61 -PR_PI__give_lang_env_for_slave PR_int__give_lang_env_for_slave 1.62 -#define \ 1.63 -PR_PI__give_lang_env_from_process PR_int__give_lang_env_from_process 1.64 - 1.65 - 1.66 -//========= 1.67 -//=== Meta Task 1.68 -//= 1.69 -#define \ 1.70 -PR_PI__give_lang_meta_task_from_slave PR_int__give_lang_meta_task_from_slave 1.71 -#define \ 1.72 -PR_PI__give_prolog_of_lang_meta_task PR_int__give_prolog_of_lang_meta_task 1.73 - 1.74 -SlaveVP * 1.75 -PR_PI__give_slave_lang_meta_task_is_assigned_to( void *langMetaTask ); 1.76 - 1.77 -#define \ 1.78 -PR_PI__free_lang_meta_task_and_remove_from_slave PR_int__free_lang_meta_task_and_remove_from_coll 1.79 - 1.80 -#define \ 1.81 -PR_PI__free_lang_meta_task PR_int__free_lang_meta_task 1.82 - 1.83 -void 1.84 -PR_PI__set_no_del_flag_in_lang_meta_task( void *langMetaTask ); 1.85 -void 1.86 -PR_PI__clear_no_del_flag_in_lang_meta_task( void *langMetaTask ); 1.87 - 1.88 -//========== 1.89 -//=== 1.90 -//= 1.91 -#define \ 1.92 -PR_PI__give_ID_from_lang_meta_task PR__give_ID_from_lang_meta_task 1.93 -#define \ 1.94 -PR_PI__give_ID_from_slave PR__give_ID_from_slave 1.95 - 1.96 -//============= 1.97 -//=== 1.98 -//= 1.99 -#define \ 1.100 -PR_PI__put_slave_into_slot PR_int__put_slave_into_slot 1.101 -#define \ 1.102 -PR_PI__put_task_into_slot PR_int__put_task_into_slot 1.103 - 1.104 -PRReqst * 1.105 -PR_PI__take_next_request_out_of( SlaveVP *slaveWithReq ); 1.106 - 1.107 -#define \ 1.108 -PR_PI__take_lang_reqst_from( req ) req->langReq 1.109 - 1.110 -void 1.111 -PR_PI__resume_slave_in_PRServ( SlaveVP *slave ); 1.112 - 1.113 -#define \ 1.114 -PR_PI__malloc PR_int__malloc 1.115 -#define \ 1.116 -PR_PI__malloc_aligned PR_int__malloc_aligned 1.117 -#define \ 1.118 -PR_PI__free PR_int__free 1.119 - 1.120 - 1.121 -#define \ 1.122 -PR_PI__throw_exception PR_int__throw_exception 1.123 - 1.124 -//=============== Startup and Shutdown ================ 1.125 -//=== 1.126 -//= 1.127 -void 1.128 -PR_SS__create_topEnv(); 1.129 - 1.130 -AnimSlot ** 1.131 -PR_SS__create_anim_slots( int32 coreSlotsAreOn ); 1.132 - 1.133 -void 1.134 -PR_SS__create_the_coreCtlr_OS_threads(); 1.135 - 1.136 -//=================== 1.137 -void * 1.138 -PR_SS__create_lang_env( int32 size, SlaveVP *slave, int32 magicNum ); 1.139 - 1.140 -void 1.141 -PR_SS__register_assigner( SlaveAssigner assigner, SlaveVP *seedVP, int32 magicNum ); 1.142 -void 1.143 -PR_SS__register_lang_shutdown_handler( LangShutdownHdlr shutdownHdlr, SlaveVP *seedVP, 1.144 - int32 magicNum ); 1.145 -void 1.146 -PR_SS__register_lang_data_creator( LangDataCreator langDataCreator, 1.147 - SlaveVP *seedVP, int32 magicNum ); 1.148 -void 1.149 -PR_SS__register_lang_meta_task_creator( LangDataCreator langMetaTaskCreator, 1.150 - SlaveVP *seedVP, int32 magicNum ); 1.151 -void 1.152 -PR_SS__register_make_slave_ready_fn( MakeSlaveReadyFn fn, SlaveVP *seedVP, 1.153 - int32 magicNum ); 1.154 -void 1.155 -PR_SS__register_make_task_ready_fn( MakeTaskReadyFn fn, SlaveVP *seedVP, 1.156 - int32 magicNum ); 1.157 -//=================== 1.158 - 1.159 -void 1.160 -PR_SS__end_process_normally( PRProcess *process ); 1.161 - 1.162 -void 1.163 -PR_SS__shutdown_OS_threads(); 1.164 - 1.165 -SlaveVP* 1.166 -PR_SS__create_shutdown_slave(); 1.167 - 1.168 -void 1.169 -PR_SS__cleanup_at_end_of_shutdown(); 1.170 - 1.171 -void 1.172 -PR_SS__print_out_measurements(); 1.173 - 1.174 -void 1.175 -PR_SS__wait_for_PR_to_shutdown(); 1.176 - 1.177 - 1.178 -//============================= 1.179 -//=== 1.180 -//= 1.181 - 1.182 -#define \ 1.183 -PR_SS__give_proto_lang_env_for_slave PR_int__give_proto_lang_env_for_slave 1.184 - 1.185 -#define \ 1.186 -PR_SS__give_lang_meta_task_from_slave PR_int__give_lang_meta_task_from_slave 1.187 -#define \ 1.188 -PR_SS__give_lang_env_for_slave PR_int__give_lang_env_for_slave 1.189 -#define \ 1.190 -PR_SS__give_lang_env_from_process PR_int__give_lang_env_from_process 1.191 - 1.192 -#define \ 1.193 -PR_SS__malloc PR_WL__malloc /*SS happens outside the Master*/ 1.194 -#define \ 1.195 -PR_SS__free PR_WL__free 1.196 - 1.197 -//================================================ 1.198 -#endif /* _PR__PI_H */ 1.199 - 1.200 +/* 1.201 + * Copyright 2009 OpenSourceResearchInstitute.org 1.202 + * Licensed under GNU General Public License version 2 1.203 + * 1.204 + * Author: seanhalle@yahoo.com 1.205 + * 1.206 + */ 1.207 + 1.208 +#ifndef _PR__PI_H 1.209 +#define _PR__PI_H 1.210 +#define _GNU_SOURCE 1.211 + 1.212 +#include <PR__include/PR__structs__common.h> 1.213 + 1.214 +//========================= Function Prototypes =========================== 1.215 +/* MEANING OF WL PI SS int PROS 1.216 + * These indicate which places the function is safe to use. They stand for: 1.217 + * 1.218 + * WL Wrapper Library -- wrapper lib code should only use these 1.219 + * PI Plugin -- plugin code should only use these 1.220 + * SS Startup and Shutdown -- designates these relate to startup & shutdown 1.221 + * int32internal to PR -- should not be used in wrapper lib or plugin 1.222 + * PROS means "OS functions for applications to use" 1.223 + * 1.224 + * PR_int__ functions touch internal PR data structs and are only safe 1.225 + * to be used inside the master lock. However, occasionally, they appear 1.226 + * in wrapper-lib or plugin code. In those cases, very careful analysis 1.227 + * has been done to be sure no concurrency issues could arise. 1.228 + * 1.229 + * PR_WL__ functions are all safe for use outside the master lock. 1.230 + * 1.231 + * PROS are only safe for applications to use -- they're like a second 1.232 + * language mixed in -- but they can't be used inside plugin code, and 1.233 + * aren't meant for use in wrapper libraries, because they are themselves 1.234 + * wrapper-library calls! 1.235 + */ 1.236 + 1.237 +#define \ 1.238 +PR_PI__create_slaveVP PR_int__create_slaveVP_helper 1.239 + 1.240 +//============== 1.241 +//=== Lang Data 1.242 +//= 1.243 +#define \ 1.244 +PR_PI__give_lang_data_from_slave PR_int__give_lang_data_from_slave 1.245 +#define \ 1.246 +PR_SS__give_lang_data_from_slave PR_int__give_lang_data_from_slave 1.247 + 1.248 +int32 1.249 +PR_PI__give_num_cores(); 1.250 + 1.251 +//============ 1.252 +//=== Lang Env 1.253 +//= 1.254 +#define \ 1.255 +PR_PI__give_proto_lang_env_for_slave PR_int__give_proto_lang_env_for_slave 1.256 +#define \ 1.257 +PR_PI__give_lang_env_for_slave PR_int__give_lang_env_for_slave 1.258 +#define \ 1.259 +PR_PI__give_lang_env_from_process PR_int__give_lang_env_from_process 1.260 + 1.261 + 1.262 +//========= 1.263 +//=== Meta Task 1.264 +//= 1.265 +#define \ 1.266 +PR_PI__give_lang_meta_task_from_slave PR_int__give_lang_meta_task_from_slave 1.267 +#define \ 1.268 +PR_PI__give_prolog_of_lang_meta_task PR_int__give_prolog_of_lang_meta_task 1.269 + 1.270 +SlaveVP * 1.271 +PR_PI__give_slave_lang_meta_task_is_assigned_to( void *langMetaTask ); 1.272 + 1.273 +#define \ 1.274 +PR_PI__free_lang_meta_task_and_remove_from_slave PR_int__free_lang_meta_task_and_remove_from_coll 1.275 + 1.276 +#define \ 1.277 +PR_PI__free_lang_meta_task PR_int__free_lang_meta_task 1.278 + 1.279 +void 1.280 +PR_PI__set_no_del_flag_in_lang_meta_task( void *langMetaTask ); 1.281 +void 1.282 +PR_PI__clear_no_del_flag_in_lang_meta_task( void *langMetaTask ); 1.283 + 1.284 +//========== 1.285 +//=== 1.286 +//= 1.287 +#define \ 1.288 +PR_PI__give_ID_from_lang_meta_task PR__give_ID_from_lang_meta_task 1.289 +#define \ 1.290 +PR_PI__give_ID_from_slave PR__give_ID_from_slave 1.291 + 1.292 +//============= 1.293 +//=== 1.294 +//= 1.295 +#define \ 1.296 +PR_PI__put_slave_into_slot PR_int__put_slave_into_slot 1.297 +#define \ 1.298 +PR_PI__put_task_into_slot PR_int__put_task_into_slot 1.299 + 1.300 +PRReqst * 1.301 +PR_PI__take_next_request_out_of( SlaveVP *slaveWithReq ); 1.302 + 1.303 +#define \ 1.304 +PR_PI__take_lang_reqst_from( req ) req->langReq 1.305 + 1.306 +void 1.307 +PR_PI__resume_slave_in_PRServ( SlaveVP *slave ); 1.308 + 1.309 +#define \ 1.310 +PR_PI__malloc PR_int__malloc 1.311 +#define \ 1.312 +PR_PI__malloc_aligned PR_int__malloc_aligned 1.313 +#define \ 1.314 +PR_PI__free PR_int__free 1.315 + 1.316 + 1.317 +#define \ 1.318 +PR_PI__throw_exception PR_int__throw_exception 1.319 + 1.320 +//=============== Startup and Shutdown ================ 1.321 +//=== 1.322 +//= 1.323 +void 1.324 +PR_SS__create_topEnv(); 1.325 + 1.326 +AnimSlot ** 1.327 +PR_SS__create_anim_slots( int32 coreSlotsAreOn ); 1.328 + 1.329 +void 1.330 +PR_SS__create_the_coreCtlr_OS_threads(); 1.331 + 1.332 +//=================== 1.333 +void * 1.334 +PR_SS__create_lang_env( int32 size, SlaveVP *slave, int32 magicNum ); 1.335 + 1.336 +void 1.337 +PR_SS__register_assigner( SlaveAssigner assigner, SlaveVP *seedVP, int32 magicNum ); 1.338 +void 1.339 +PR_SS__register_lang_shutdown_handler( LangShutdownHdlr shutdownHdlr, SlaveVP *seedVP, 1.340 + int32 magicNum ); 1.341 +void 1.342 +PR_SS__register_lang_data_creator( LangDataCreator langDataCreator, 1.343 + SlaveVP *seedVP, int32 magicNum ); 1.344 +void 1.345 +PR_SS__register_lang_meta_task_creator( LangDataCreator langMetaTaskCreator, 1.346 + SlaveVP *seedVP, int32 magicNum ); 1.347 +void 1.348 +PR_SS__register_make_slave_ready_fn( MakeSlaveReadyFn fn, SlaveVP *seedVP, 1.349 + int32 magicNum ); 1.350 +void 1.351 +PR_SS__register_make_task_ready_fn( MakeTaskReadyFn fn, SlaveVP *seedVP, 1.352 + int32 magicNum ); 1.353 +//=================== 1.354 + 1.355 +void 1.356 +PR_SS__end_process_normally( PRProcess *process ); 1.357 + 1.358 +void 1.359 +PR_SS__shutdown_OS_threads(); 1.360 + 1.361 +SlaveVP* 1.362 +PR_SS__create_shutdown_slave(); 1.363 + 1.364 +void 1.365 +PR_SS__cleanup_at_end_of_shutdown(); 1.366 + 1.367 +void 1.368 +PR_SS__print_out_measurements(); 1.369 + 1.370 +void 1.371 +PR_SS__wait_for_PR_to_shutdown(); 1.372 + 1.373 + 1.374 +//============================= 1.375 +//=== 1.376 +//= 1.377 + 1.378 +#define \ 1.379 +PR_SS__give_proto_lang_env_for_slave PR_int__give_proto_lang_env_for_slave 1.380 + 1.381 +#define \ 1.382 +PR_SS__give_lang_meta_task_from_slave PR_int__give_lang_meta_task_from_slave 1.383 +#define \ 1.384 +PR_SS__give_lang_env_for_slave PR_int__give_lang_env_for_slave 1.385 +#define \ 1.386 +PR_SS__give_lang_env_from_process PR_int__give_lang_env_from_process 1.387 + 1.388 +#define \ 1.389 +PR_SS__malloc PR_WL__malloc /*SS happens outside the Master*/ 1.390 +#define \ 1.391 +PR_SS__free PR_WL__free 1.392 + 1.393 +//================================================ 1.394 +#endif /* _PR__PI_H */ 1.395 +
2.1 --- a/PR__SS.h Thu Aug 08 02:39:56 2013 -0700 2.2 +++ b/PR__SS.h Thu Aug 08 03:00:36 2013 -0700 2.3 @@ -1,119 +1,119 @@ 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__SS_H 2.13 -#define _PR__SS_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 -//=============== Startup and Shutdown ================ 2.42 -//=== 2.43 -//= Some of these are for PR internal use only, others for langlet use 2.44 - 2.45 - 2.46 -#define \ 2.47 -PR_SS__malloc PR_WL__malloc /*SS happens outside the Master*/ 2.48 -#define \ 2.49 -PR_SS__free PR_WL__free 2.50 - 2.51 -//=================== 2.52 -void * 2.53 -PR_SS__create_lang_env( int32 size, SlaveVP *slave, int32 magicNum ); 2.54 - 2.55 -void 2.56 -PR_SS__register_assigner( SlaveAssigner assigner, SlaveVP *seedVP, int32 magicNum ); 2.57 -void 2.58 -PR_SS__register_lang_shutdown_handler( LangShutdownHdlr shutdownHdlr, SlaveVP *seedVP, 2.59 - int32 magicNum ); 2.60 -void 2.61 -PR_SS__register_lang_data_creator( LangDataCreator langDataCreator, 2.62 - SlaveVP *seedVP, int32 magicNum ); 2.63 -void 2.64 -PR_SS__register_lang_meta_task_creator( LangDataCreator langMetaTaskCreator, 2.65 - SlaveVP *seedVP, int32 magicNum ); 2.66 -void 2.67 -PR_SS__register_make_slave_ready_fn( MakeSlaveReadyFn fn, SlaveVP *seedVP, 2.68 - int32 magicNum ); 2.69 -void 2.70 -PR_SS__register_make_task_ready_fn( MakeTaskReadyFn fn, SlaveVP *seedVP, 2.71 - int32 magicNum ); 2.72 - 2.73 - 2.74 -//================================ 2.75 -//=== 2.76 -//= PR internal use only 2.77 -void 2.78 -PR_SS__create_topEnv(); 2.79 - 2.80 -AnimSlot ** 2.81 -PR_SS__create_anim_slots( int32 coreSlotsAreOn ); 2.82 - 2.83 -void 2.84 -PR_SS__create_the_coreCtlr_OS_threads(); 2.85 -//=================== 2.86 - 2.87 -void 2.88 -PR_SS__end_process_normally( PRProcess *process ); 2.89 - 2.90 -void 2.91 -PR_SS__shutdown_OS_threads(); 2.92 - 2.93 -SlaveVP* 2.94 -PR_SS__create_shutdown_slave(); 2.95 - 2.96 -void 2.97 -PR_SS__cleanup_at_end_of_shutdown(); 2.98 - 2.99 -void 2.100 -PR_SS__print_out_measurements(); 2.101 - 2.102 -void 2.103 -PR_SS__wait_for_PR_to_shutdown(); 2.104 - 2.105 -//============================= 2.106 -//=== 2.107 -//= 2.108 - 2.109 -#define \ 2.110 -PR_SS__give_lang_data_from_slave PR_int__give_lang_data_from_slave 2.111 -#define \ 2.112 -PR_SS__give_lang_meta_task_from_slave PR_int__give_lang_meta_task_from_slave 2.113 -#define \ 2.114 -PR_SS__give_proto_lang_env_for_slave PR_int__give_proto_lang_env_for_slave 2.115 -#define \ 2.116 -PR_SS__give_lang_env_for_slave PR_int__give_lang_env_for_slave 2.117 -#define \ 2.118 -PR_SS__give_lang_env_from_process PR_int__give_lang_env_from_process 2.119 - 2.120 -//================================================ 2.121 -#endif /* */ 2.122 - 2.123 +/* 2.124 + * Copyright 2009 OpenSourceResearchInstitute.org 2.125 + * Licensed under GNU General Public License version 2 2.126 + * 2.127 + * Author: seanhalle@yahoo.com 2.128 + * 2.129 + */ 2.130 + 2.131 +#ifndef _PR__SS_H 2.132 +#define _PR__SS_H 2.133 +#define _GNU_SOURCE 2.134 + 2.135 +#include <PR__include/PR__structs__common.h> 2.136 + 2.137 +//========================= Function Prototypes =========================== 2.138 +/* MEANING OF WL PI SS int PROS 2.139 + * These indicate which places the function is safe to use. They stand for: 2.140 + * 2.141 + * WL Wrapper Library -- wrapper lib code should only use these 2.142 + * PI Plugin -- plugin code should only use these 2.143 + * SS Startup and Shutdown -- designates these relate to startup & shutdown 2.144 + * int32internal to PR -- should not be used in wrapper lib or plugin 2.145 + * PROS means "OS functions for applications to use" 2.146 + * 2.147 + * PR_int__ functions touch internal PR data structs and are only safe 2.148 + * to be used inside the master lock. However, occasionally, they appear 2.149 + * in wrapper-lib or plugin code. In those cases, very careful analysis 2.150 + * has been done to be sure no concurrency issues could arise. 2.151 + * 2.152 + * PR_WL__ functions are all safe for use outside the master lock. 2.153 + * 2.154 + * PROS are only safe for applications to use -- they're like a second 2.155 + * language mixed in -- but they can't be used inside plugin code, and 2.156 + * aren't meant for use in wrapper libraries, because they are themselves 2.157 + * wrapper-library calls! 2.158 + */ 2.159 + 2.160 +//=============== Startup and Shutdown ================ 2.161 +//=== 2.162 +//= Some of these are for PR internal use only, others for langlet use 2.163 + 2.164 + 2.165 +#define \ 2.166 +PR_SS__malloc PR_WL__malloc /*SS happens outside the Master*/ 2.167 +#define \ 2.168 +PR_SS__free PR_WL__free 2.169 + 2.170 +//=================== 2.171 +void * 2.172 +PR_SS__create_lang_env( int32 size, SlaveVP *slave, int32 magicNum ); 2.173 + 2.174 +void 2.175 +PR_SS__register_assigner( SlaveAssigner assigner, SlaveVP *seedVP, int32 magicNum ); 2.176 +void 2.177 +PR_SS__register_lang_shutdown_handler( LangShutdownHdlr shutdownHdlr, SlaveVP *seedVP, 2.178 + int32 magicNum ); 2.179 +void 2.180 +PR_SS__register_lang_data_creator( LangDataCreator langDataCreator, 2.181 + SlaveVP *seedVP, int32 magicNum ); 2.182 +void 2.183 +PR_SS__register_lang_meta_task_creator( LangDataCreator langMetaTaskCreator, 2.184 + SlaveVP *seedVP, int32 magicNum ); 2.185 +void 2.186 +PR_SS__register_make_slave_ready_fn( MakeSlaveReadyFn fn, SlaveVP *seedVP, 2.187 + int32 magicNum ); 2.188 +void 2.189 +PR_SS__register_make_task_ready_fn( MakeTaskReadyFn fn, SlaveVP *seedVP, 2.190 + int32 magicNum ); 2.191 + 2.192 + 2.193 +//================================ 2.194 +//=== 2.195 +//= PR internal use only 2.196 +void 2.197 +PR_SS__create_topEnv(); 2.198 + 2.199 +AnimSlot ** 2.200 +PR_SS__create_anim_slots( int32 coreSlotsAreOn ); 2.201 + 2.202 +void 2.203 +PR_SS__create_the_coreCtlr_OS_threads(); 2.204 +//=================== 2.205 + 2.206 +void 2.207 +PR_SS__end_process_normally( PRProcess *process ); 2.208 + 2.209 +void 2.210 +PR_SS__shutdown_OS_threads(); 2.211 + 2.212 +SlaveVP* 2.213 +PR_SS__create_shutdown_slave(); 2.214 + 2.215 +void 2.216 +PR_SS__cleanup_at_end_of_shutdown(); 2.217 + 2.218 +void 2.219 +PR_SS__print_out_measurements(); 2.220 + 2.221 +void 2.222 +PR_SS__wait_for_PR_to_shutdown(); 2.223 + 2.224 +//============================= 2.225 +//=== 2.226 +//= 2.227 + 2.228 +#define \ 2.229 +PR_SS__give_lang_data_from_slave PR_int__give_lang_data_from_slave 2.230 +#define \ 2.231 +PR_SS__give_lang_meta_task_from_slave PR_int__give_lang_meta_task_from_slave 2.232 +#define \ 2.233 +PR_SS__give_proto_lang_env_for_slave PR_int__give_proto_lang_env_for_slave 2.234 +#define \ 2.235 +PR_SS__give_lang_env_for_slave PR_int__give_lang_env_for_slave 2.236 +#define \ 2.237 +PR_SS__give_lang_env_from_process PR_int__give_lang_env_from_process 2.238 + 2.239 +//================================================ 2.240 +#endif /* */ 2.241 +
3.1 --- a/PR__WL.h Thu Aug 08 02:39:56 2013 -0700 3.2 +++ b/PR__WL.h Thu Aug 08 03:00:36 2013 -0700 3.3 @@ -1,142 +1,142 @@ 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__WL_H 3.13 -#define _PR__WL_H 3.14 -#define _GNU_SOURCE 3.15 - 3.16 -#include <PR__include/PR__primitive_data_types.h> 3.17 -#include <PR__include/PR__structs__common.h> 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 -//============== Top level Fns called from main =============== 3.42 -void 3.43 -PR__start(); 3.44 - 3.45 -PRProcess * 3.46 -PR__create_process( BirthFnPtr seed_Fn, void *seedData ); 3.47 - 3.48 -void 3.49 -PR__end_seedVP( SlaveVP *seedSlv ); 3.50 - 3.51 -void 3.52 -PR__end_process_from_inside( SlaveVP *seedSlv ); 3.53 - 3.54 -void * 3.55 -PR__give_results_from_process_when_ready( PRProcess *process ); 3.56 - 3.57 -void 3.58 -PR__wait_for_process_to_end( PRProcess *process ); 3.59 - 3.60 -void 3.61 -PR__wait_for_all_activity_to_end(); 3.62 - 3.63 -void 3.64 -PR__shutdown(); 3.65 - 3.66 -#define \ 3.67 -PR__create_taskID_of_size PR_WL__create_taskID_of_size 3.68 - 3.69 -inline 3.70 -int32 * 3.71 -PR__give_ID_from_slave( SlaveVP *animSlv, int32 magicNumber ); 3.72 - 3.73 -inline 3.74 -int32 * 3.75 -PR__give_ID_from_lang_meta_task( void *_task ); 3.76 - 3.77 - 3.78 -//============== include internally used fn prototypes ================ 3.79 -#include "PR__int.h" 3.80 - 3.81 -#define PR_WL__give_lang_data PR_int__give_lang_data_from_slave 3.82 - 3.83 -#define \ 3.84 -PR_WL__create_slaveVP PR_int__create_slaveVP_helper 3.85 - 3.86 -#define \ 3.87 -PR_WL__give_lang_meta_task_from_slave PR_int__give_lang_meta_task_from_slave 3.88 - 3.89 -#define \ 3.90 -PR_WL__give_prolog_of_lang_meta_task PR_int__give_prolog_of_lang_meta_task 3.91 - 3.92 -//============== Request Related =============== 3.93 - 3.94 -void 3.95 -PR_WL__suspend_slaveVP_and_send_req( SlaveVP *callingSlv ); 3.96 - 3.97 -inline void 3.98 -PR_WL__add_lang_request_in_mallocd_PRReqst( void *langReqData, 3.99 - SlaveVP *callingSlv ); 3.100 - 3.101 -inline void 3.102 -PR_WL__send_lang_request( void *langReq, RequestHandler handler, 3.103 - SlaveVP *callingSlv, int32 magicNum ); 3.104 - 3.105 -void 3.106 -PR_WL__send_create_slaveVP_req( void *langReq, int32 *ID, CreateHandler handler, 3.107 - SlaveVP *reqstingSlv, int32 magicNum ); 3.108 - 3.109 -void inline 3.110 -PR_WL__send_end_slave_req( void *langReq, RequestHandler handler, 3.111 - SlaveVP *slvToDissipate, int32 magicNum ); 3.112 - 3.113 -inline void 3.114 -PR_WL__send_service_request( void *langReqData, SlaveVP *callingSlv ); 3.115 - 3.116 -inline void 3.117 -PR_WL__send_lang_shutdown_request( SlaveVP *callingSlv, int32 magicNum ); 3.118 - 3.119 -inline 3.120 -int32 * 3.121 -PR_WL__create_taskID_of_size( int32 numInts ); 3.122 - 3.123 -//======================== MEASUREMENT ====================== 3.124 -uint64 3.125 -PR_WL__give_num_plugin_cycles(); 3.126 -uint32 3.127 -PR_WL__give_num_plugin_animations(); 3.128 - 3.129 - 3.130 -//========================= Utilities ======================= 3.131 -void 3.132 -PR_WL__throw_exception( char *msgStr, SlaveVP *reqstSlv, PRExcp *excpData ); 3.133 -#define PR_App__throw_exception PR_WL__throw_exception 3.134 - 3.135 - 3.136 -//======================================================================= 3.137 - 3.138 -//========================= Services ======================= 3.139 -//#include "Services_Offered_by_PR/Measurement_and_Stats/probes.h" 3.140 -//#include "Services_Offered_by_PR/Services_Language/PRServ.h" 3.141 -//#include "Services_Offered_by_PR/Services_Language/libPRServ.h" 3.142 - 3.143 -//================================================ 3.144 -#endif /* _PR_H */ 3.145 - 3.146 +/* 3.147 + * Copyright 2009 OpenSourceResearchInstitute.org 3.148 + * Licensed under GNU General Public License version 2 3.149 + * 3.150 + * Author: seanhalle@yahoo.com 3.151 + * 3.152 + */ 3.153 + 3.154 +#ifndef _PR__WL_H 3.155 +#define _PR__WL_H 3.156 +#define _GNU_SOURCE 3.157 + 3.158 +#include <PR__include/PR__primitive_data_types.h> 3.159 +#include <PR__include/PR__structs__common.h> 3.160 +//========================= Function Prototypes =========================== 3.161 +/* MEANING OF WL PI SS int PROS 3.162 + * These indicate which places the function is safe to use. They stand for: 3.163 + * 3.164 + * WL Wrapper Library -- wrapper lib code should only use these 3.165 + * PI Plugin -- plugin code should only use these 3.166 + * SS Startup and Shutdown -- designates these relate to startup & shutdown 3.167 + * int32internal to PR -- should not be used in wrapper lib or plugin 3.168 + * PROS means "OS functions for applications to use" 3.169 + * 3.170 + * PR_int__ functions touch internal PR data structs and are only safe 3.171 + * to be used inside the master lock. However, occasionally, they appear 3.172 + * in wrapper-lib or plugin code. In those cases, very careful analysis 3.173 + * has been done to be sure no concurrency issues could arise. 3.174 + * 3.175 + * PR_WL__ functions are all safe for use outside the master lock. 3.176 + * 3.177 + * PROS are only safe for applications to use -- they're like a second 3.178 + * language mixed in -- but they can't be used inside plugin code, and 3.179 + * aren't meant for use in wrapper libraries, because they are themselves 3.180 + * wrapper-library calls! 3.181 + */ 3.182 + 3.183 +//============== Top level Fns called from main =============== 3.184 +void 3.185 +PR__start(); 3.186 + 3.187 +PRProcess * 3.188 +PR__create_process( BirthFnPtr seed_Fn, void *seedData ); 3.189 + 3.190 +void 3.191 +PR__end_seedVP( SlaveVP *seedSlv ); 3.192 + 3.193 +void 3.194 +PR__end_process_from_inside( SlaveVP *seedSlv ); 3.195 + 3.196 +void * 3.197 +PR__give_results_from_process_when_ready( PRProcess *process ); 3.198 + 3.199 +void 3.200 +PR__wait_for_process_to_end( PRProcess *process ); 3.201 + 3.202 +void 3.203 +PR__wait_for_all_activity_to_end(); 3.204 + 3.205 +void 3.206 +PR__shutdown(); 3.207 + 3.208 +#define \ 3.209 +PR__create_taskID_of_size PR_WL__create_taskID_of_size 3.210 + 3.211 +inline 3.212 +int32 * 3.213 +PR__give_ID_from_slave( SlaveVP *animSlv, int32 magicNumber ); 3.214 + 3.215 +inline 3.216 +int32 * 3.217 +PR__give_ID_from_lang_meta_task( void *_task ); 3.218 + 3.219 + 3.220 +//============== include internally used fn prototypes ================ 3.221 +#include "PR__int.h" 3.222 + 3.223 +#define PR_WL__give_lang_data PR_int__give_lang_data_from_slave 3.224 + 3.225 +#define \ 3.226 +PR_WL__create_slaveVP PR_int__create_slaveVP_helper 3.227 + 3.228 +#define \ 3.229 +PR_WL__give_lang_meta_task_from_slave PR_int__give_lang_meta_task_from_slave 3.230 + 3.231 +#define \ 3.232 +PR_WL__give_prolog_of_lang_meta_task PR_int__give_prolog_of_lang_meta_task 3.233 + 3.234 +//============== Request Related =============== 3.235 + 3.236 +void 3.237 +PR_WL__suspend_slaveVP_and_send_req( SlaveVP *callingSlv ); 3.238 + 3.239 +inline void 3.240 +PR_WL__add_lang_request_in_mallocd_PRReqst( void *langReqData, 3.241 + SlaveVP *callingSlv ); 3.242 + 3.243 +inline void 3.244 +PR_WL__send_lang_request( void *langReq, RequestHandler handler, 3.245 + SlaveVP *callingSlv, int32 magicNum ); 3.246 + 3.247 +void 3.248 +PR_WL__send_create_slaveVP_req( void *langReq, int32 *ID, CreateHandler handler, 3.249 + SlaveVP *reqstingSlv, int32 magicNum ); 3.250 + 3.251 +void inline 3.252 +PR_WL__send_end_slave_req( void *langReq, RequestHandler handler, 3.253 + SlaveVP *slvToDissipate, int32 magicNum ); 3.254 + 3.255 +inline void 3.256 +PR_WL__send_service_request( void *langReqData, SlaveVP *callingSlv ); 3.257 + 3.258 +inline void 3.259 +PR_WL__send_lang_shutdown_request( SlaveVP *callingSlv, int32 magicNum ); 3.260 + 3.261 +inline 3.262 +int32 * 3.263 +PR_WL__create_taskID_of_size( int32 numInts ); 3.264 + 3.265 +//======================== MEASUREMENT ====================== 3.266 +uint64 3.267 +PR_WL__give_num_plugin_cycles(); 3.268 +uint32 3.269 +PR_WL__give_num_plugin_animations(); 3.270 + 3.271 + 3.272 +//========================= Utilities ======================= 3.273 +void 3.274 +PR_WL__throw_exception( char *msgStr, SlaveVP *reqstSlv, PRExcp *excpData ); 3.275 +#define PR_App__throw_exception PR_WL__throw_exception 3.276 + 3.277 + 3.278 +//======================================================================= 3.279 + 3.280 +//========================= Services ======================= 3.281 +//#include "Services_Offered_by_PR/Measurement_and_Stats/probes.h" 3.282 +//#include "Services_Offered_by_PR/Services_Language/PRServ.h" 3.283 +//#include "Services_Offered_by_PR/Services_Language/libPRServ.h" 3.284 + 3.285 +//================================================ 3.286 +#endif /* _PR_H */ 3.287 +
4.1 --- a/PR__int.h Thu Aug 08 02:39:56 2013 -0700 4.2 +++ b/PR__int.h Thu Aug 08 03:00:36 2013 -0700 4.3 @@ -1,246 +1,246 @@ 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_INT_H 4.13 -#define _PR_INT_H 4.14 -#define _GNU_SOURCE 4.15 - 4.16 - 4.17 -#define LOCKED 1 4.18 -#define UNLOCKED 0 4.19 - 4.20 -/* MEANING OF WL PI SS int 4.21 - * These indicate which places the function is safe to use. They stand for: 4.22 - * WL: Wrapper Library 4.23 - * PI: Plugin 4.24 - * SS: Startup and Shutdown 4.25 - * int: internal to the PR implementation 4.26 - */ 4.27 - 4.28 -inline 4.29 -void 4.30 -PR_int__reset_slaveVP_to_BirthFn( SlaveVP *slaveVP, BirthFnPtr fnPtr, 4.31 - void *dataParam); 4.32 - 4.33 -inline 4.34 -void 4.35 -PR_int__point_slaveVP_to_OneParamFn( SlaveVP *slaveVP, void *fnPtr, 4.36 - void *param); 4.37 - 4.38 -inline 4.39 -void 4.40 -PR_int__point_slaveVP_to_TwoParamFn( SlaveVP *slaveVP, void *fnPtr, 4.41 - void *param1, void *param2); 4.42 - 4.43 -//=========================================================================== 4.44 -// 4.45 -//=========================================================================== 4.46 -inline 4.47 -SlaveVP * 4.48 -PR_int__create_slaveVP_helper( BirthFnPtr fnPtr, void *dataParam ); 4.49 - 4.50 -inline 4.51 -SlaveVP * 4.52 -PR_int__create_slaveVP( BirthFnPtr fnPtr, void *dataParam, PRProcess *process ); 4.53 - 4.54 -SlaveVP * 4.55 -PR_int__get_recycled_slot_slave( ); 4.56 - 4.57 -SlaveVP * 4.58 -PR_int__create_slot_slave( ); 4.59 - 4.60 -inline 4.61 -void 4.62 -PR_int__replace_with_new_slot_slv( SlaveVP *slave ); 4.63 - 4.64 -void 4.65 -idle_fn(void* data, SlaveVP *animatingSlv); 4.66 - 4.67 -inline 4.68 -void 4.69 -PR_int__put_task_into_slot( void *task, AnimSlot *slot ); 4.70 - 4.71 -inline 4.72 -void 4.73 -PR_int__put_slave_into_slot( SlaveVP *slave, AnimSlot *slot ); 4.74 - 4.75 -void inline 4.76 -PRHandle__ServiceReq( SlaveVP *requestingSlv ); 4.77 - 4.78 -void 4.79 -PR_int__free_slaveVP( SlaveVP *slave ); 4.80 - 4.81 -void 4.82 -PR_int__recycle_slaveVP( SlaveVP *slave ); 4.83 - 4.84 -void 4.85 -freeLangDataAsElem( void *elem ); 4.86 - 4.87 -void 4.88 -freeMetaTaskAsElem( void *elem ); 4.89 - 4.90 - 4.91 -//============================= 4.92 -//=== Lange Env 4.93 -//= 4.94 -inline 4.95 -void * 4.96 -PR_int__give_lang_env( PRLangEnv *protoLangEnv ); 4.97 - 4.98 -inline 4.99 -PRLangEnv * 4.100 -PR_int__give_proto_lang_env( void *langEnv ); 4.101 - 4.102 -//inline 4.103 -void * 4.104 -PR_int__create_lang_env_in_process( int32 size, PRProcess *process, int32 magicNum ); 4.105 - 4.106 -inline 4.107 -void * 4.108 -PR_int__remove_lang_env_from_process_and_free( void *langEnv ); 4.109 - 4.110 -inline 4.111 -void * 4.112 -PR_int__give_lang_env_of_req( PRReqst *req, SlaveVP *requestingSlv ); 4.113 - 4.114 -inline 4.115 -void * 4.116 -PR_int__give_lang_env_for_slave( SlaveVP *slave, int32 magicNum ); 4.117 -//No WL version -- not safe! if use env in WL, be sure data rd & wr is stable 4.118 - 4.119 -inline 4.120 -PRLangEnv * 4.121 -PR_int__give_proto_lang_env_for_slave( SlaveVP *slave, int32 magicNumber ); 4.122 -//No WL version -- not safe! if use env in WL, be sure data rd & wr is stable 4.123 - 4.124 -inline 4.125 -void * 4.126 -PR_int__give_lang_env_from_process( PRProcess *process, int32 magicNum ); 4.127 -//No WL version -- not safe! if use env in WL, be sure data rd & wr is stable 4.128 - 4.129 -inline 4.130 -PRLangEnv * 4.131 -PR_int__give_proto_lang_env_from_process( PRProcess *process, int32 magicNum ); 4.132 - 4.133 -//======================= 4.134 -//=== Meta Task 4.135 -//= 4.136 -inline 4.137 -PRMetaTask * 4.138 -PR_int__give_prolog_of_lang_meta_task( void *task ); 4.139 - 4.140 -inline 4.141 -void * 4.142 -PR_int__give_lang_meta_task_of_prolog( PRMetaTask *metaTask); 4.143 - 4.144 -inline 4.145 -void * 4.146 -PR_int__create_lang_meta_task( int32 size, LangMetaTaskFreer freer, int32 magicNum ); 4.147 - 4.148 -inline 4.149 -void * 4.150 -PR_int__create_lang_meta_task_in_slave( int32 size, LangMetaTaskFreer freer, 4.151 - SlaveVP *slave, int32 magicNum ); 4.152 - 4.153 -inline 4.154 -PRMetaTask * 4.155 -PR_int__create_generic_slave_meta_task( void *initData ); 4.156 - 4.157 -void 4.158 -PR_int__free_lang_meta_task_and_remove_from_coll( void *langMetaTask ); 4.159 - 4.160 -inline 4.161 -void 4.162 -PR_int__insert_meta_task_into_slave( PRMetaTask *task, SlaveVP *slave ); 4.163 - 4.164 -inline 4.165 -void 4.166 -PR_int__insert_lang_meta_task_into_slave__ML( void *langMetaTask, SlaveVP *slave ); 4.167 - 4.168 -inline 4.169 -void * 4.170 -PR_int__give_lang_meta_task_from_slave( SlaveVP *slave, int32 magicNumer ); 4.171 - 4.172 -inline 4.173 -SlaveVP * 4.174 -PR_PI__give_slave_lang_meta_task_is_assigned_to( void *langMetaTask ); 4.175 - 4.176 -//============== 4.177 -//=== Lang Data 4.178 -//= 4.179 -inline 4.180 -void * 4.181 -PR_PI__create_lang_data_in_slave( int32 size, LangDataFreer freer, 4.182 - SlaveVP *slave, int32 magicNum ); 4.183 - 4.184 -inline 4.185 -void * 4.186 -PR_int__give_lang_data_from_slave( SlaveVP *slave, int32 magicNumer ); 4.187 - 4.188 -inline 4.189 -void * 4.190 -PR_int__give_lang_data_of_prolog( PRLangData *langData); 4.191 - 4.192 -//================================================== 4.193 -//=== Collection 4.194 -//= 4.195 -PRCollElem ** //return an array of pointers 4.196 -PR_int__make_collection_of_size( int32 numInColl ); 4.197 - 4.198 -inline 4.199 -void 4.200 -PR_int__insert_elem_into_collection( PRCollElem *elem, PRCollElem **coll, int32 hash ); 4.201 - 4.202 -inline 4.203 -void * 4.204 -PR_int__lookup_elem_in_collection( int32 hash, PRCollElem **coll ); 4.205 - 4.206 -inline 4.207 -void 4.208 -PR_int__remove_elem_from_collection( int32 hash, PRCollElem **coll ); 4.209 - 4.210 -inline 4.211 -void 4.212 -PR_int__set_collection_to_empty( PRCollElem **coll ); 4.213 - 4.214 -inline 4.215 -void 4.216 -PR_int__apply_Fn_to_all_in_collection( void (*Fn)(void *), PRCollElem **coll ); 4.217 - 4.218 -//=========== 4.219 -//=== 4.220 -//= 4.221 -void 4.222 -PR_int__error( char *msgStr ); 4.223 - 4.224 -void 4.225 -PR_int__throw_exception( char *msgStr, SlaveVP *reqstSlv, PRExcp *excpData ); 4.226 - 4.227 -char * 4.228 -PR_int__strDup( char *str ); 4.229 - 4.230 -inline void 4.231 -PR_int__get_wrapper_lock(); 4.232 - 4.233 -inline void 4.234 -PR_int__get_malloc_lock(); 4.235 - 4.236 -#define PR_int__release_master_lock() _PRTopEnv->masterLock = UNLOCKED 4.237 - 4.238 -#define PR_int__release_wrapper_lock() _PRTopEnv->wrapperLock = UNLOCKED 4.239 - 4.240 -#define PR_int__release_malloc_lock() _PRTopEnv->mallocLock = UNLOCKED 4.241 - 4.242 -inline uint32_t 4.243 -PR_int__randomNumber(); 4.244 - 4.245 -inline void 4.246 -PR_int__backoff_for_TooLongToGetLock( int32 numTriesToGetLock ); 4.247 - 4.248 -#endif /* _PR_INT_H */ 4.249 - 4.250 +/* 4.251 + * Copyright 2009 OpenSourceResearchInstitute.org 4.252 + * Licensed under GNU General Public License version 2 4.253 + * 4.254 + * Author: seanhalle@yahoo.com 4.255 + * 4.256 + */ 4.257 + 4.258 +#ifndef _PR_INT_H 4.259 +#define _PR_INT_H 4.260 +#define _GNU_SOURCE 4.261 + 4.262 + 4.263 +#define LOCKED 1 4.264 +#define UNLOCKED 0 4.265 + 4.266 +/* MEANING OF WL PI SS int 4.267 + * These indicate which places the function is safe to use. They stand for: 4.268 + * WL: Wrapper Library 4.269 + * PI: Plugin 4.270 + * SS: Startup and Shutdown 4.271 + * int: internal to the PR implementation 4.272 + */ 4.273 + 4.274 +inline 4.275 +void 4.276 +PR_int__reset_slaveVP_to_BirthFn( SlaveVP *slaveVP, BirthFnPtr fnPtr, 4.277 + void *dataParam); 4.278 + 4.279 +inline 4.280 +void 4.281 +PR_int__point_slaveVP_to_OneParamFn( SlaveVP *slaveVP, void *fnPtr, 4.282 + void *param); 4.283 + 4.284 +inline 4.285 +void 4.286 +PR_int__point_slaveVP_to_TwoParamFn( SlaveVP *slaveVP, void *fnPtr, 4.287 + void *param1, void *param2); 4.288 + 4.289 +//=========================================================================== 4.290 +// 4.291 +//=========================================================================== 4.292 +inline 4.293 +SlaveVP * 4.294 +PR_int__create_slaveVP_helper( BirthFnPtr fnPtr, void *dataParam ); 4.295 + 4.296 +inline 4.297 +SlaveVP * 4.298 +PR_int__create_slaveVP( BirthFnPtr fnPtr, void *dataParam, PRProcess *process ); 4.299 + 4.300 +SlaveVP * 4.301 +PR_int__get_recycled_slot_slave( ); 4.302 + 4.303 +SlaveVP * 4.304 +PR_int__create_slot_slave( ); 4.305 + 4.306 +inline 4.307 +void 4.308 +PR_int__replace_with_new_slot_slv( SlaveVP *slave ); 4.309 + 4.310 +void 4.311 +idle_fn(void* data, SlaveVP *animatingSlv); 4.312 + 4.313 +inline 4.314 +void 4.315 +PR_int__put_task_into_slot( void *task, AnimSlot *slot ); 4.316 + 4.317 +inline 4.318 +void 4.319 +PR_int__put_slave_into_slot( SlaveVP *slave, AnimSlot *slot ); 4.320 + 4.321 +void inline 4.322 +PRHandle__ServiceReq( SlaveVP *requestingSlv ); 4.323 + 4.324 +void 4.325 +PR_int__free_slaveVP( SlaveVP *slave ); 4.326 + 4.327 +void 4.328 +PR_int__recycle_slaveVP( SlaveVP *slave ); 4.329 + 4.330 +void 4.331 +freeLangDataAsElem( void *elem ); 4.332 + 4.333 +void 4.334 +freeMetaTaskAsElem( void *elem ); 4.335 + 4.336 + 4.337 +//============================= 4.338 +//=== Lange Env 4.339 +//= 4.340 +inline 4.341 +void * 4.342 +PR_int__give_lang_env( PRLangEnv *protoLangEnv ); 4.343 + 4.344 +inline 4.345 +PRLangEnv * 4.346 +PR_int__give_proto_lang_env( void *langEnv ); 4.347 + 4.348 +//inline 4.349 +void * 4.350 +PR_int__create_lang_env_in_process( int32 size, PRProcess *process, int32 magicNum ); 4.351 + 4.352 +inline 4.353 +void * 4.354 +PR_int__remove_lang_env_from_process_and_free( void *langEnv ); 4.355 + 4.356 +inline 4.357 +void * 4.358 +PR_int__give_lang_env_of_req( PRReqst *req, SlaveVP *requestingSlv ); 4.359 + 4.360 +inline 4.361 +void * 4.362 +PR_int__give_lang_env_for_slave( SlaveVP *slave, int32 magicNum ); 4.363 +//No WL version -- not safe! if use env in WL, be sure data rd & wr is stable 4.364 + 4.365 +inline 4.366 +PRLangEnv * 4.367 +PR_int__give_proto_lang_env_for_slave( SlaveVP *slave, int32 magicNumber ); 4.368 +//No WL version -- not safe! if use env in WL, be sure data rd & wr is stable 4.369 + 4.370 +inline 4.371 +void * 4.372 +PR_int__give_lang_env_from_process( PRProcess *process, int32 magicNum ); 4.373 +//No WL version -- not safe! if use env in WL, be sure data rd & wr is stable 4.374 + 4.375 +inline 4.376 +PRLangEnv * 4.377 +PR_int__give_proto_lang_env_from_process( PRProcess *process, int32 magicNum ); 4.378 + 4.379 +//======================= 4.380 +//=== Meta Task 4.381 +//= 4.382 +inline 4.383 +PRMetaTask * 4.384 +PR_int__give_prolog_of_lang_meta_task( void *task ); 4.385 + 4.386 +inline 4.387 +void * 4.388 +PR_int__give_lang_meta_task_of_prolog( PRMetaTask *metaTask); 4.389 + 4.390 +inline 4.391 +void * 4.392 +PR_int__create_lang_meta_task( int32 size, LangMetaTaskFreer freer, int32 magicNum ); 4.393 + 4.394 +inline 4.395 +void * 4.396 +PR_int__create_lang_meta_task_in_slave( int32 size, LangMetaTaskFreer freer, 4.397 + SlaveVP *slave, int32 magicNum ); 4.398 + 4.399 +inline 4.400 +PRMetaTask * 4.401 +PR_int__create_generic_slave_meta_task( void *initData ); 4.402 + 4.403 +void 4.404 +PR_int__free_lang_meta_task_and_remove_from_coll( void *langMetaTask ); 4.405 + 4.406 +inline 4.407 +void 4.408 +PR_int__insert_meta_task_into_slave( PRMetaTask *task, SlaveVP *slave ); 4.409 + 4.410 +inline 4.411 +void 4.412 +PR_int__insert_lang_meta_task_into_slave__ML( void *langMetaTask, SlaveVP *slave ); 4.413 + 4.414 +inline 4.415 +void * 4.416 +PR_int__give_lang_meta_task_from_slave( SlaveVP *slave, int32 magicNumer ); 4.417 + 4.418 +inline 4.419 +SlaveVP * 4.420 +PR_PI__give_slave_lang_meta_task_is_assigned_to( void *langMetaTask ); 4.421 + 4.422 +//============== 4.423 +//=== Lang Data 4.424 +//= 4.425 +inline 4.426 +void * 4.427 +PR_PI__create_lang_data_in_slave( int32 size, LangDataFreer freer, 4.428 + SlaveVP *slave, int32 magicNum ); 4.429 + 4.430 +inline 4.431 +void * 4.432 +PR_int__give_lang_data_from_slave( SlaveVP *slave, int32 magicNumer ); 4.433 + 4.434 +inline 4.435 +void * 4.436 +PR_int__give_lang_data_of_prolog( PRLangData *langData); 4.437 + 4.438 +//================================================== 4.439 +//=== Collection 4.440 +//= 4.441 +PRCollElem ** //return an array of pointers 4.442 +PR_int__make_collection_of_size( int32 numInColl ); 4.443 + 4.444 +inline 4.445 +void 4.446 +PR_int__insert_elem_into_collection( PRCollElem *elem, PRCollElem **coll, int32 hash ); 4.447 + 4.448 +inline 4.449 +void * 4.450 +PR_int__lookup_elem_in_collection( int32 hash, PRCollElem **coll ); 4.451 + 4.452 +inline 4.453 +void 4.454 +PR_int__remove_elem_from_collection( int32 hash, PRCollElem **coll ); 4.455 + 4.456 +inline 4.457 +void 4.458 +PR_int__set_collection_to_empty( PRCollElem **coll ); 4.459 + 4.460 +inline 4.461 +void 4.462 +PR_int__apply_Fn_to_all_in_collection( void (*Fn)(void *), PRCollElem **coll ); 4.463 + 4.464 +//=========== 4.465 +//=== 4.466 +//= 4.467 +void 4.468 +PR_int__error( char *msgStr ); 4.469 + 4.470 +void 4.471 +PR_int__throw_exception( char *msgStr, SlaveVP *reqstSlv, PRExcp *excpData ); 4.472 + 4.473 +char * 4.474 +PR_int__strDup( char *str ); 4.475 + 4.476 +inline void 4.477 +PR_int__get_wrapper_lock(); 4.478 + 4.479 +inline void 4.480 +PR_int__get_malloc_lock(); 4.481 + 4.482 +#define PR_int__release_master_lock() _PRTopEnv->masterLock = UNLOCKED 4.483 + 4.484 +#define PR_int__release_wrapper_lock() _PRTopEnv->wrapperLock = UNLOCKED 4.485 + 4.486 +#define PR_int__release_malloc_lock() _PRTopEnv->mallocLock = UNLOCKED 4.487 + 4.488 +inline uint32_t 4.489 +PR_int__randomNumber(); 4.490 + 4.491 +inline void 4.492 +PR_int__backoff_for_TooLongToGetLock( int32 numTriesToGetLock ); 4.493 + 4.494 +#endif /* _PR_INT_H */ 4.495 +
5.1 --- a/PR__primitive_data_types.h Thu Aug 08 02:39:56 2013 -0700 5.2 +++ b/PR__primitive_data_types.h Thu Aug 08 03:00:36 2013 -0700 5.3 @@ -1,42 +1,42 @@ 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 - 5.13 -#ifndef _PRIMITIVE_DATA_TYPES_H 5.14 -#define _PRIMITIVE_DATA_TYPES_H 5.15 - 5.16 - 5.17 -/*For portability, need primitive data types that have a well defined 5.18 - * size, and well-defined layout into bytes 5.19 - *To do this, provide standard aliases for all primitive data types 5.20 - *These aliases must be used in all functions instead of the ANSI types 5.21 - * 5.22 - *When PR is used together with BLIS, these definitions will be replaced 5.23 - * inside each specialization module according to the compiler used in 5.24 - * that module and the hardware being specialized to. 5.25 - */ 5.26 -typedef char bool8; 5.27 -typedef char int8; 5.28 -typedef char uint8; 5.29 -typedef short int16; 5.30 -typedef unsigned short uint16; 5.31 -typedef int int32; 5.32 -typedef unsigned int uint32; 5.33 -typedef unsigned int bool32; 5.34 -typedef long long int64; 5.35 -typedef unsigned long long uint64; 5.36 -typedef float float32; 5.37 -typedef double float64; 5.38 -//typedef double double float128; //GCC doesn't like this 5.39 -#define float128 double double 5.40 - 5.41 -#define TRUE 1 5.42 -#define FALSE 0 5.43 - 5.44 -#endif /* _PRIMITIVE_DATA_TYPES_H */ 5.45 - 5.46 +/* 5.47 + * Copyright 2009 OpenSourceResearchInstitute.org 5.48 + * Licensed under GNU General Public License version 2 5.49 + * 5.50 + * Author: seanhalle@yahoo.com 5.51 + * 5.52 + 5.53 + */ 5.54 + 5.55 +#ifndef _PRIMITIVE_DATA_TYPES_H 5.56 +#define _PRIMITIVE_DATA_TYPES_H 5.57 + 5.58 + 5.59 +/*For portability, need primitive data types that have a well defined 5.60 + * size, and well-defined layout into bytes 5.61 + *To do this, provide standard aliases for all primitive data types 5.62 + *These aliases must be used in all functions instead of the ANSI types 5.63 + * 5.64 + *When PR is used together with BLIS, these definitions will be replaced 5.65 + * inside each specialization module according to the compiler used in 5.66 + * that module and the hardware being specialized to. 5.67 + */ 5.68 +typedef char bool8; 5.69 +typedef char int8; 5.70 +typedef char uint8; 5.71 +typedef short int16; 5.72 +typedef unsigned short uint16; 5.73 +typedef int int32; 5.74 +typedef unsigned int uint32; 5.75 +typedef unsigned int bool32; 5.76 +typedef long long int64; 5.77 +typedef unsigned long long uint64; 5.78 +typedef float float32; 5.79 +typedef double float64; 5.80 +//typedef double double float128; //GCC doesn't like this 5.81 +#define float128 double double 5.82 + 5.83 +#define TRUE 1 5.84 +#define FALSE 0 5.85 + 5.86 +#endif /* _PRIMITIVE_DATA_TYPES_H */ 5.87 +
6.1 --- a/PR__structs__common.h Thu Aug 08 02:39:56 2013 -0700 6.2 +++ b/PR__structs__common.h Thu Aug 08 03:00:36 2013 -0700 6.3 @@ -1,346 +1,346 @@ 6.4 -/* 6.5 - * Copyright 2009 OpenSourceResearchInstitute.org 6.6 - * Licensed under GNU General Public License version 2 6.7 - * 6.8 - * Author: seanhalle@yahoo.com 6.9 - * 6.10 - */ 6.11 - 6.12 -#ifndef _PR__structs__common_H 6.13 -#define _PR__structs__common_H 6.14 -#define _GNU_SOURCE 6.15 - 6.16 -#include <pthread.h> 6.17 -#include <sys/time.h> 6.18 - 6.19 -//#include "PR_defs__turn_on_and_off.h" 6.20 -#include <PR__include/PR__primitive_data_types.h> 6.21 -#include <PR__include/Services_offered_by_PR/DEBUG__macros.h> 6.22 -#include <PR__include/Services_offered_by_PR/MEAS__macros.h> 6.23 - 6.24 -#include <PR__include/prhistogram.h> //reqd by PRProcess 6.25 -#include <PR__include/prhash.h> //reqd by PRProcess 6.26 -#include <PR__include/prdynarray.h> //reqd by PRProcess 6.27 -#include <PR__include/prqueue.h> //reqd by PRLangEnv, in turn reqd by PRProcess 6.28 - 6.29 -//================================ Typedefs ================================= 6.30 -//=== 6.31 -//= 6.32 -#define ZERO 0 6.33 - 6.34 -//typedef unsigned long long TSCount; 6.35 - 6.36 -typedef struct _AnimSlot AnimSlot; 6.37 -typedef struct _PRReqst PRReqst; 6.38 -typedef struct _SlaveVP SlaveVP; 6.39 -//typedef struct _MasterVP MasterVP; 6.40 -typedef struct _IntervalProbe IntervalProbe; 6.41 -typedef struct _PRLangEnv PRLangEnv; //a prolog 6.42 -typedef struct _PRMetaTask PRMetaTask; //a prolog 6.43 -typedef struct _PRLangData PRLangData; //a prolog 6.44 -typedef struct _PRCollElem PRCollElem; //generic form of the prologs 6.45 - 6.46 -typedef bool32 (*SlaveAssigner) ( void *, AnimSlot* ); //langEnv, slot for HW info 6.47 -typedef void (*RequestHandler) ( void *, SlaveVP *, void * ); //req, slv, langEnv 6.48 -typedef void *(*CreateHandler) ( void *, SlaveVP *, void * ); //req, slv, langEnv 6.49 -typedef void (*LangShutdownHdlr) ( void * ); //langEnv 6.50 -typedef void *(*LangDataCreator) ( SlaveVP * ); 6.51 -typedef void (*LangDataFreer) ( void * ); //lang data to free 6.52 -typedef void *(*LangMetaTaskCreator)( SlaveVP * ); //when slave has no meta task for magic num 6.53 -typedef void (*LangMetaTaskFreer) ( void * ); //lang meta task to free 6.54 -typedef void (*MakeSlaveReadyFn) ( SlaveVP *, void * ); //slave and langEnv 6.55 -typedef void (*MakeTaskReadyFn) ( void *, void * ); //langTask and langEnv 6.56 -typedef void (*BirthFnPtr) ( void *, SlaveVP * ); //initData, animSlv 6.57 -typedef void BirthFn ( void *, SlaveVP * ); //initData, animSlv 6.58 -typedef void (*ResumeSlvFnPtr) ( SlaveVP *, void * ); 6.59 - //=========== MEASUREMENT STUFF ========== 6.60 - MEAS__Insert_Counter_Handler 6.61 - //======================================== 6.62 - 6.63 - 6.64 -typedef struct 6.65 - { //These are set by the plugin during startup and the application 6.66 - char *assignerInfo; 6.67 - char *appInfo; 6.68 - char *inputInfo; 6.69 - } 6.70 -PRSysMetaInfo; 6.71 - 6.72 -//===================== Process Data Struct ====================== 6.73 - 6.74 -/*This structure holds all the information PR needs to manage a program. PR 6.75 - * stores information about what percent of CPU time the program is getting, 6.76 - * 6.77 - */ 6.78 - 6.79 -typedef struct 6.80 - { 6.81 - int32 numEnvsWithWork; 6.82 - void *resultToReturn; 6.83 - 6.84 - PRLangEnv **langEnvs; //used as a hash table 6.85 - PRLangEnv **protoLangEnvsList; //for fast linear scan of envs 6.86 - int32 numLangEnvs; //for fast linear scan of envs 6.87 - 6.88 - SlaveVP *seedSlv; 6.89 - 6.90 - int32 numLiveGenericSlvs; 6.91 - int32 numLiveTasks; 6.92 - 6.93 - SlaveAssigner overrideAssigner; 6.94 - 6.95 - 6.96 - 6.97 - //These are used to coord with an OS thread waiting for process to end 6.98 - bool32 hasWaitingToEnd; 6.99 - bool32 executionIsComplete; 6.100 - pthread_mutex_t doneLock; 6.101 - pthread_cond_t doneCond; 6.102 - pthread_mutex_t doneAckLock; //waiter gets, then releases when done waiting 6.103 - 6.104 - //=========== MEASUREMENT STUFF ============= 6.105 - IntervalProbe **intervalProbes; 6.106 - PrivDynArrayInfo *dynIntervalProbesInfo; 6.107 - HashTable *probeNameHashTbl; 6.108 - int32 masterCreateProbeID; 6.109 - float64 createPtInSecs; //real-clock time PR initialized 6.110 - Histogram **measHists; 6.111 - PrivDynArrayInfo *measHistsInfo; 6.112 - MEAS__Insert_Susp_Meas_Fields_into_MasterEnv; 6.113 - MEAS__Insert_Master_Meas_Fields_into_MasterEnv; 6.114 - MEAS__Insert_Master_Lock_Meas_Fields_into_MasterEnv; 6.115 - MEAS__Insert_Malloc_Meas_Fields_into_MasterEnv; 6.116 - MEAS__Insert_Plugin_Meas_Fields_into_MasterEnv; 6.117 - MEAS__Insert_System_Meas_Fields_into_MasterEnv; 6.118 - MEAS__Insert_Counter_Meas_Fields_into_MasterEnv; 6.119 - //========================================== 6.120 - } 6.121 -PRProcess; 6.122 - 6.123 - 6.124 -//============= Request Related =========== 6.125 -// 6.126 - 6.127 -enum PRReqstType //avoid starting enums at 0, for debug reasons 6.128 - { 6.129 - TaskCreate = 1, 6.130 - TaskEnd, 6.131 - SlvCreate, 6.132 - SlvDissipate, 6.133 - Language, 6.134 - Service, //To invoke a PR provided equivalent of a language request (ex: probe) 6.135 - Hardware, 6.136 - IO, 6.137 - OSCall, 6.138 - LangShutdown, 6.139 - ProcessEnd, 6.140 - PRShutdown 6.141 - }; 6.142 - 6.143 - 6.144 -struct _PRReqst 6.145 - { 6.146 - enum PRReqstType reqType;//used for special forms that have PR behavior 6.147 - void *langReq; 6.148 - PRProcess *processReqIsIn; 6.149 - int32 langMagicNumber; 6.150 - SlaveVP *requestingSlave; 6.151 - 6.152 - BirthFnPtr topLevelFn; 6.153 - void *initData; 6.154 - int32 *ID; 6.155 - 6.156 - //The request handling structure is a bit messy.. for special forms, 6.157 - // such as create and dissipate, the language inserts pointer to handler 6.158 - // fn directly into the request.. might change to this for all requests 6.159 - RequestHandler handler; //pointer to handler fn 6.160 - CreateHandler createHdlr; //special because returns something 6.161 - int32 createSuspendedGroup; //must be non-zero 6.162 - 6.163 - PRReqst *nextReqst; 6.164 - }; 6.165 -//PRReqst 6.166 - 6.167 -enum PRServiceReqType //These are equivalent to lang requests, but for 6.168 - { // PR's services available directly to app, like OS 6.169 - make_probe = 1, // and probe services -- like a PR-wide built-in lang 6.170 - throw_excp, 6.171 - openFile, 6.172 - otherIO 6.173 - }; 6.174 - 6.175 -typedef struct 6.176 - { enum PRServiceReqType reqType; 6.177 - SlaveVP *requestingSlv; 6.178 - char *nameStr; //for create probe 6.179 - char *msgStr; //for exception 6.180 - void *exceptionData; 6.181 - } 6.182 -PRServiceReq; 6.183 - 6.184 - 6.185 -//==================== Core data structures =================== 6.186 - 6.187 -typedef struct 6.188 - { 6.189 - //for future expansion 6.190 - } 6.191 -SlotPerfInfo; 6.192 - 6.193 -struct _AnimSlot 6.194 - { 6.195 - int32 workIsDone; 6.196 - int32 needsWorkAssigned; 6.197 - SlaveVP *slaveAssignedToSlot; 6.198 - 6.199 - int32 slotIdx; //needed by Holistic Model's data gathering 6.200 - int32 coreSlotIsOn; 6.201 - SlotPerfInfo *perfInfo; //used by assigner to pick best slave for core 6.202 - }; 6.203 -//AnimSlot 6.204 - 6.205 -enum VPtype 6.206 - { SlotTaskSlv = 1,//Slave tied to an anim slot, only animates tasks 6.207 - FreeTaskSlv, //When a suspended task ends, the slave becomes this 6.208 - GenericSlv, //the VP is explicitly seen in the app code, or task suspends 6.209 - SeedSlv, 6.210 - Master_VP, 6.211 - ShutdownVP, 6.212 - IdleVP 6.213 - }; 6.214 - 6.215 -/*This structure embodies the state of a slaveVP. It is reused for masterVP 6.216 - * and shutdownVPs. 6.217 - */ 6.218 -struct _SlaveVP 6.219 - { //The offsets of these fields are hard-coded into assembly 6.220 - void *stackPtr; //save the core's stack ptr when suspend 6.221 - void *framePtr; //save core's frame ptr when suspend 6.222 - void *resumeInstrPtr; //save core's program-counter when suspend 6.223 - void *coreCtlrFramePtr; //restore before jmp back to core controller 6.224 - void *coreCtlrStackPtr; //restore before jmp back to core controller 6.225 - 6.226 - //============ below this, no fields are used in asm ============= 6.227 - 6.228 - void *startOfStack; //used to free, and to point slave to Fn 6.229 - PRProcess *processSlaveIsIn; 6.230 - enum VPtype typeOfVP; //Slave vs Master vs Shutdown.. 6.231 - int32 slaveNum; //each slave given it's seq in creation 6.232 - int32 *ID; //App defines meaning of each int in array 6.233 - int32 coreAnimatedBy; 6.234 - int32 numTimesAssignedToASlot; //Each assign is for one work-unit, so is an ID 6.235 - //note, a scheduling decision is uniquely identified by the triple: 6.236 - // <slaveNum, coreAnimatedBy, numTimesAssignedToASlot> -- used in record & replay 6.237 - 6.238 - //for comm -- between master and coreCtlr & btwn wrapper lib and plugin 6.239 - AnimSlot *animSlotAssignedTo; 6.240 - PRReqst *request; //wrapper lib puts in requests, plugin takes out 6.241 - void *dataRetFromReq;//Return vals from plugin to Wrapper Lib 6.242 - 6.243 - //For language specific data that needs to be in the slave 6.244 - //These are accessed directly for single-lang, but multi-lang places 6.245 - // a holder here instead, then uses magic num to get lang's version 6.246 - PRLangData **langDatas; //Lang saves lang-specific things in slave here 6.247 - PRMetaTask **metaTasks; 6.248 - 6.249 - //=========== MEASUREMENT STUFF ========== 6.250 - MEAS__Insert_Meas_Fields_into_Slave; 6.251 - float64 createPtInSecs; //time VP created, in seconds 6.252 - //======================================== 6.253 - 6.254 -// int8 cacheLinePad[512 - sizeof(contents)]; //for false sharing 6.255 - }; 6.256 -//SlaveVP 6.257 - 6.258 - 6.259 -enum PRMode 6.260 - { SingleLang = 1, 6.261 - StandaloneWTasks, 6.262 - MultiLang 6.263 - }; 6.264 - 6.265 - 6.266 -//===================== These are prologs ==================== 6.267 -//===A prolog is data immediately before pointer returned by a create function. 6.268 -//= 6.269 -struct _PRLangEnv 6.270 - { //============== First two must match PRCollElem ============== 6.271 - int32 langMagicNumber; //indexes into hash array of langEnvs in PRProcess 6.272 - PRLangEnv *chainedLangEnv; //chains to langEnvs with same hash 6.273 - //============================================================= 6.274 - 6.275 - SlaveAssigner workAssigner; 6.276 - LangShutdownHdlr shutdownHdlr; //called when lang ended or process shutdown 6.277 - LangDataCreator langDataCreator; 6.278 - LangMetaTaskCreator langMetaTaskCreator; 6.279 - MakeSlaveReadyFn makeSlaveReadyFn; 6.280 - MakeTaskReadyFn makeTaskReadyFn; 6.281 - 6.282 - //when multi-lang, master polls lang env's to find one with work in it.. 6.283 - // in single-lang case, flag ignored, master always asks lang for work 6.284 - int32 hasWork; 6.285 - PRProcess *processEnvIsIn; 6.286 - 6.287 - int32 idxInProcess; //index into array of langEnvs in the process 6.288 - 6.289 - int32 numReadyWork; 6.290 - 6.291 - int32 numLiveWork; 6.292 - PrivQueueStruc *waitingForWorkToEndQ; 6.293 - }; 6.294 -//PRLangEnv -- this is the prolog of every lang's lang env 6.295 - 6.296 -enum PRTaskType 6.297 - { GenericSlave = 1, 6.298 - SlotTask, 6.299 - FreeTask 6.300 - }; 6.301 - 6.302 -struct _PRMetaTask 6.303 - { //============== First two must match PRCollElem ============== 6.304 - int32 langMagicNumber; 6.305 - PRMetaTask *chainedMetaTask; 6.306 - //============================================================= 6.307 - enum PRTaskType taskType; 6.308 - int32 *ID; //is standard PR ID 6.309 - PRProcess *processTaskIsIn; 6.310 - SlaveVP *slaveAssignedTo; //not valid until task animated 6.311 - BirthFnPtr topLevelFn; //This is the Fn executes as the task 6.312 - void *initData; //The data taken by the function 6.313 - LangMetaTaskFreer freer; 6.314 - bool32 goAheadAndFree; 6.315 - 6.316 - //NOTE: info needed for "wait" functionality is inside lang's metaTask 6.317 - }; 6.318 -//PRMetaTask -- prolog of every lang's meta task 6.319 - 6.320 -struct _PRLangData 6.321 - { //============== First two must match PRCollElem ============== 6.322 - int32 langMagicNumber; 6.323 - PRLangData *chainedLangData; 6.324 - //============================================================= 6.325 - LangDataFreer freer; 6.326 - bool32 goAheadAndFree; 6.327 - SlaveVP *slaveAssignedTo; 6.328 - }; 6.329 -//PRLangData -- this is the prolog of each lang's lang data 6.330 - 6.331 -struct _PRCollElem 6.332 - { 6.333 - int32 hash; 6.334 - PRCollElem *chained; 6.335 - }; 6.336 -//PRCollElem -- this is generic form of all the prologs 6.337 - 6.338 - 6.339 - 6.340 -//========================= Extra Stuff Data Strucs ======================= 6.341 -typedef struct 6.342 - { 6.343 - 6.344 - } 6.345 -PRExcp; //exception 6.346 - 6.347 - 6.348 -#endif /* _PR__structs_H */ 6.349 - 6.350 +/* 6.351 + * Copyright 2009 OpenSourceResearchInstitute.org 6.352 + * Licensed under GNU General Public License version 2 6.353 + * 6.354 + * Author: seanhalle@yahoo.com 6.355 + * 6.356 + */ 6.357 + 6.358 +#ifndef _PR__structs__common_H 6.359 +#define _PR__structs__common_H 6.360 +#define _GNU_SOURCE 6.361 + 6.362 +#include <pthread.h> 6.363 +#include <sys/time.h> 6.364 + 6.365 +//#include "PR_defs__turn_on_and_off.h" 6.366 +#include <PR__include/PR__primitive_data_types.h> 6.367 +#include <PR__include/Services_offered_by_PR/DEBUG__macros.h> 6.368 +#include <PR__include/Services_offered_by_PR/MEAS__macros.h> 6.369 + 6.370 +#include <PR__include/prhistogram.h> //reqd by PRProcess 6.371 +#include <PR__include/prhash.h> //reqd by PRProcess 6.372 +#include <PR__include/prdynarray.h> //reqd by PRProcess 6.373 +#include <PR__include/prqueue.h> //reqd by PRLangEnv, in turn reqd by PRProcess 6.374 + 6.375 +//================================ Typedefs ================================= 6.376 +//=== 6.377 +//= 6.378 +#define ZERO 0 6.379 + 6.380 +//typedef unsigned long long TSCount; 6.381 + 6.382 +typedef struct _AnimSlot AnimSlot; 6.383 +typedef struct _PRReqst PRReqst; 6.384 +typedef struct _SlaveVP SlaveVP; 6.385 +//typedef struct _MasterVP MasterVP; 6.386 +typedef struct _IntervalProbe IntervalProbe; 6.387 +typedef struct _PRLangEnv PRLangEnv; //a prolog 6.388 +typedef struct _PRMetaTask PRMetaTask; //a prolog 6.389 +typedef struct _PRLangData PRLangData; //a prolog 6.390 +typedef struct _PRCollElem PRCollElem; //generic form of the prologs 6.391 + 6.392 +typedef bool32 (*SlaveAssigner) ( void *, AnimSlot* ); //langEnv, slot for HW info 6.393 +typedef void (*RequestHandler) ( void *, SlaveVP *, void * ); //req, slv, langEnv 6.394 +typedef void *(*CreateHandler) ( void *, SlaveVP *, void * ); //req, slv, langEnv 6.395 +typedef void (*LangShutdownHdlr) ( void * ); //langEnv 6.396 +typedef void *(*LangDataCreator) ( SlaveVP * ); 6.397 +typedef void (*LangDataFreer) ( void * ); //lang data to free 6.398 +typedef void *(*LangMetaTaskCreator)( SlaveVP * ); //when slave has no meta task for magic num 6.399 +typedef void (*LangMetaTaskFreer) ( void * ); //lang meta task to free 6.400 +typedef void (*MakeSlaveReadyFn) ( SlaveVP *, void * ); //slave and langEnv 6.401 +typedef void (*MakeTaskReadyFn) ( void *, void * ); //langTask and langEnv 6.402 +typedef void (*BirthFnPtr) ( void *, SlaveVP * ); //initData, animSlv 6.403 +typedef void BirthFn ( void *, SlaveVP * ); //initData, animSlv 6.404 +typedef void (*ResumeSlvFnPtr) ( SlaveVP *, void * ); 6.405 + //=========== MEASUREMENT STUFF ========== 6.406 + MEAS__Insert_Counter_Handler 6.407 + //======================================== 6.408 + 6.409 + 6.410 +typedef struct 6.411 + { //These are set by the plugin during startup and the application 6.412 + char *assignerInfo; 6.413 + char *appInfo; 6.414 + char *inputInfo; 6.415 + } 6.416 +PRSysMetaInfo; 6.417 + 6.418 +//===================== Process Data Struct ====================== 6.419 + 6.420 +/*This structure holds all the information PR needs to manage a program. PR 6.421 + * stores information about what percent of CPU time the program is getting, 6.422 + * 6.423 + */ 6.424 + 6.425 +typedef struct 6.426 + { 6.427 + int32 numEnvsWithWork; 6.428 + void *resultToReturn; 6.429 + 6.430 + PRLangEnv **langEnvs; //used as a hash table 6.431 + PRLangEnv **protoLangEnvsList; //for fast linear scan of envs 6.432 + int32 numLangEnvs; //for fast linear scan of envs 6.433 + 6.434 + SlaveVP *seedSlv; 6.435 + 6.436 + int32 numLiveGenericSlvs; 6.437 + int32 numLiveTasks; 6.438 + 6.439 + SlaveAssigner overrideAssigner; 6.440 + 6.441 + 6.442 + 6.443 + //These are used to coord with an OS thread waiting for process to end 6.444 + bool32 hasWaitingToEnd; 6.445 + bool32 executionIsComplete; 6.446 + pthread_mutex_t doneLock; 6.447 + pthread_cond_t doneCond; 6.448 + pthread_mutex_t doneAckLock; //waiter gets, then releases when done waiting 6.449 + 6.450 + //=========== MEASUREMENT STUFF ============= 6.451 + IntervalProbe **intervalProbes; 6.452 + PrivDynArrayInfo *dynIntervalProbesInfo; 6.453 + HashTable *probeNameHashTbl; 6.454 + int32 masterCreateProbeID; 6.455 + float64 createPtInSecs; //real-clock time PR initialized 6.456 + Histogram **measHists; 6.457 + PrivDynArrayInfo *measHistsInfo; 6.458 + MEAS__Insert_Susp_Meas_Fields_into_MasterEnv; 6.459 + MEAS__Insert_Master_Meas_Fields_into_MasterEnv; 6.460 + MEAS__Insert_Master_Lock_Meas_Fields_into_MasterEnv; 6.461 + MEAS__Insert_Malloc_Meas_Fields_into_MasterEnv; 6.462 + MEAS__Insert_Plugin_Meas_Fields_into_MasterEnv; 6.463 + MEAS__Insert_System_Meas_Fields_into_MasterEnv; 6.464 + MEAS__Insert_Counter_Meas_Fields_into_MasterEnv; 6.465 + //========================================== 6.466 + } 6.467 +PRProcess; 6.468 + 6.469 + 6.470 +//============= Request Related =========== 6.471 +// 6.472 + 6.473 +enum PRReqstType //avoid starting enums at 0, for debug reasons 6.474 + { 6.475 + TaskCreate = 1, 6.476 + TaskEnd, 6.477 + SlvCreate, 6.478 + SlvDissipate, 6.479 + Language, 6.480 + Service, //To invoke a PR provided equivalent of a language request (ex: probe) 6.481 + Hardware, 6.482 + IO, 6.483 + OSCall, 6.484 + LangShutdown, 6.485 + ProcessEnd, 6.486 + PRShutdown 6.487 + }; 6.488 + 6.489 + 6.490 +struct _PRReqst 6.491 + { 6.492 + enum PRReqstType reqType;//used for special forms that have PR behavior 6.493 + void *langReq; 6.494 + PRProcess *processReqIsIn; 6.495 + int32 langMagicNumber; 6.496 + SlaveVP *requestingSlave; 6.497 + 6.498 + BirthFnPtr topLevelFn; 6.499 + void *initData; 6.500 + int32 *ID; 6.501 + 6.502 + //The request handling structure is a bit messy.. for special forms, 6.503 + // such as create and dissipate, the language inserts pointer to handler 6.504 + // fn directly into the request.. might change to this for all requests 6.505 + RequestHandler handler; //pointer to handler fn 6.506 + CreateHandler createHdlr; //special because returns something 6.507 + int32 createSuspendedGroup; //must be non-zero 6.508 + 6.509 + PRReqst *nextReqst; 6.510 + }; 6.511 +//PRReqst 6.512 + 6.513 +enum PRServiceReqType //These are equivalent to lang requests, but for 6.514 + { // PR's services available directly to app, like OS 6.515 + make_probe = 1, // and probe services -- like a PR-wide built-in lang 6.516 + throw_excp, 6.517 + openFile, 6.518 + otherIO 6.519 + }; 6.520 + 6.521 +typedef struct 6.522 + { enum PRServiceReqType reqType; 6.523 + SlaveVP *requestingSlv; 6.524 + char *nameStr; //for create probe 6.525 + char *msgStr; //for exception 6.526 + void *exceptionData; 6.527 + } 6.528 +PRServiceReq; 6.529 + 6.530 + 6.531 +//==================== Core data structures =================== 6.532 + 6.533 +typedef struct 6.534 + { 6.535 + //for future expansion 6.536 + } 6.537 +SlotPerfInfo; 6.538 + 6.539 +struct _AnimSlot 6.540 + { 6.541 + int32 workIsDone; 6.542 + int32 needsWorkAssigned; 6.543 + SlaveVP *slaveAssignedToSlot; 6.544 + 6.545 + int32 slotIdx; //needed by Holistic Model's data gathering 6.546 + int32 coreSlotIsOn; 6.547 + SlotPerfInfo *perfInfo; //used by assigner to pick best slave for core 6.548 + }; 6.549 +//AnimSlot 6.550 + 6.551 +enum VPtype 6.552 + { SlotTaskSlv = 1,//Slave tied to an anim slot, only animates tasks 6.553 + FreeTaskSlv, //When a suspended task ends, the slave becomes this 6.554 + GenericSlv, //the VP is explicitly seen in the app code, or task suspends 6.555 + SeedSlv, 6.556 + Master_VP, 6.557 + ShutdownVP, 6.558 + IdleVP 6.559 + }; 6.560 + 6.561 +/*This structure embodies the state of a slaveVP. It is reused for masterVP 6.562 + * and shutdownVPs. 6.563 + */ 6.564 +struct _SlaveVP 6.565 + { //The offsets of these fields are hard-coded into assembly 6.566 + void *stackPtr; //save the core's stack ptr when suspend 6.567 + void *framePtr; //save core's frame ptr when suspend 6.568 + void *resumeInstrPtr; //save core's program-counter when suspend 6.569 + void *coreCtlrFramePtr; //restore before jmp back to core controller 6.570 + void *coreCtlrStackPtr; //restore before jmp back to core controller 6.571 + 6.572 + //============ below this, no fields are used in asm ============= 6.573 + 6.574 + void *startOfStack; //used to free, and to point slave to Fn 6.575 + PRProcess *processSlaveIsIn; 6.576 + enum VPtype typeOfVP; //Slave vs Master vs Shutdown.. 6.577 + int32 slaveNum; //each slave given it's seq in creation 6.578 + int32 *ID; //App defines meaning of each int in array 6.579 + int32 coreAnimatedBy; 6.580 + int32 numTimesAssignedToASlot; //Each assign is for one work-unit, so is an ID 6.581 + //note, a scheduling decision is uniquely identified by the triple: 6.582 + // <slaveNum, coreAnimatedBy, numTimesAssignedToASlot> -- used in record & replay 6.583 + 6.584 + //for comm -- between master and coreCtlr & btwn wrapper lib and plugin 6.585 + AnimSlot *animSlotAssignedTo; 6.586 + PRReqst *request; //wrapper lib puts in requests, plugin takes out 6.587 + void *dataRetFromReq;//Return vals from plugin to Wrapper Lib 6.588 + 6.589 + //For language specific data that needs to be in the slave 6.590 + //These are accessed directly for single-lang, but multi-lang places 6.591 + // a holder here instead, then uses magic num to get lang's version 6.592 + PRLangData **langDatas; //Lang saves lang-specific things in slave here 6.593 + PRMetaTask **metaTasks; 6.594 + 6.595 + //=========== MEASUREMENT STUFF ========== 6.596 + MEAS__Insert_Meas_Fields_into_Slave; 6.597 + float64 createPtInSecs; //time VP created, in seconds 6.598 + //======================================== 6.599 + 6.600 +// int8 cacheLinePad[512 - sizeof(contents)]; //for false sharing 6.601 + }; 6.602 +//SlaveVP 6.603 + 6.604 + 6.605 +enum PRMode 6.606 + { SingleLang = 1, 6.607 + StandaloneWTasks, 6.608 + MultiLang 6.609 + }; 6.610 + 6.611 + 6.612 +//===================== These are prologs ==================== 6.613 +//===A prolog is data immediately before pointer returned by a create function. 6.614 +//= 6.615 +struct _PRLangEnv 6.616 + { //============== First two must match PRCollElem ============== 6.617 + int32 langMagicNumber; //indexes into hash array of langEnvs in PRProcess 6.618 + PRLangEnv *chainedLangEnv; //chains to langEnvs with same hash 6.619 + //============================================================= 6.620 + 6.621 + SlaveAssigner workAssigner; 6.622 + LangShutdownHdlr shutdownHdlr; //called when lang ended or process shutdown 6.623 + LangDataCreator langDataCreator; 6.624 + LangMetaTaskCreator langMetaTaskCreator; 6.625 + MakeSlaveReadyFn makeSlaveReadyFn; 6.626 + MakeTaskReadyFn makeTaskReadyFn; 6.627 + 6.628 + //when multi-lang, master polls lang env's to find one with work in it.. 6.629 + // in single-lang case, flag ignored, master always asks lang for work 6.630 + int32 hasWork; 6.631 + PRProcess *processEnvIsIn; 6.632 + 6.633 + int32 idxInProcess; //index into array of langEnvs in the process 6.634 + 6.635 + int32 numReadyWork; 6.636 + 6.637 + int32 numLiveWork; 6.638 + PrivQueueStruc *waitingForWorkToEndQ; 6.639 + }; 6.640 +//PRLangEnv -- this is the prolog of every lang's lang env 6.641 + 6.642 +enum PRTaskType 6.643 + { GenericSlave = 1, 6.644 + SlotTask, 6.645 + FreeTask 6.646 + }; 6.647 + 6.648 +struct _PRMetaTask 6.649 + { //============== First two must match PRCollElem ============== 6.650 + int32 langMagicNumber; 6.651 + PRMetaTask *chainedMetaTask; 6.652 + //============================================================= 6.653 + enum PRTaskType taskType; 6.654 + int32 *ID; //is standard PR ID 6.655 + PRProcess *processTaskIsIn; 6.656 + SlaveVP *slaveAssignedTo; //not valid until task animated 6.657 + BirthFnPtr topLevelFn; //This is the Fn executes as the task 6.658 + void *initData; //The data taken by the function 6.659 + LangMetaTaskFreer freer; 6.660 + bool32 goAheadAndFree; 6.661 + 6.662 + //NOTE: info needed for "wait" functionality is inside lang's metaTask 6.663 + }; 6.664 +//PRMetaTask -- prolog of every lang's meta task 6.665 + 6.666 +struct _PRLangData 6.667 + { //============== First two must match PRCollElem ============== 6.668 + int32 langMagicNumber; 6.669 + PRLangData *chainedLangData; 6.670 + //============================================================= 6.671 + LangDataFreer freer; 6.672 + bool32 goAheadAndFree; 6.673 + SlaveVP *slaveAssignedTo; 6.674 + }; 6.675 +//PRLangData -- this is the prolog of each lang's lang data 6.676 + 6.677 +struct _PRCollElem 6.678 + { 6.679 + int32 hash; 6.680 + PRCollElem *chained; 6.681 + }; 6.682 +//PRCollElem -- this is generic form of all the prologs 6.683 + 6.684 + 6.685 + 6.686 +//========================= Extra Stuff Data Strucs ======================= 6.687 +typedef struct 6.688 + { 6.689 + 6.690 + } 6.691 +PRExcp; //exception 6.692 + 6.693 + 6.694 +#endif /* _PR__structs_H */ 6.695 +
7.1 --- a/Services_offered_by_PR/DEBUG__macros.h Thu Aug 08 02:39:56 2013 -0700 7.2 +++ b/Services_offered_by_PR/DEBUG__macros.h Thu Aug 08 03:00:36 2013 -0700 7.3 @@ -1,65 +1,65 @@ 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 _DEBUG__macros_H 7.13 -#define _DEBUG__macros_H 7.14 -#define _GNU_SOURCE 7.15 - 7.16 -/* 7.17 - */ 7.18 -#ifdef DEBUG__TURN_ON_DEBUG_PRINT 7.19 - #define DEBUG__printf( bool, ...) \ 7.20 - do{\ 7.21 - if(bool)\ 7.22 - { printf(__VA_ARGS__);\ 7.23 - printf(" | function: %s\n", __FUNCTION__);\ 7.24 - fflush(stdin);\ 7.25 - }\ 7.26 - }while(0);/*macro magic to isolate var-names*/ 7.27 - 7.28 - #define DEBUG__printf1( bool, msg, param) \ 7.29 - do{\ 7.30 - if(bool)\ 7.31 - { printf(msg, param);\ 7.32 - printf(" | function: %s\n", __FUNCTION__);\ 7.33 - fflush(stdin);\ 7.34 - }\ 7.35 - }while(0);/*macro magic to isolate var-names*/ 7.36 - 7.37 - #define DEBUG__printf2( bool, msg, p1, p2) \ 7.38 - do{\ 7.39 - if(bool)\ 7.40 - { printf(msg, p1, p2); \ 7.41 - printf(" | function: %s\n", __FUNCTION__);\ 7.42 - fflush(stdin);\ 7.43 - }\ 7.44 - }while(0);/*macro magic to isolate var-names*/ 7.45 - 7.46 - #define DEBUG__printf3( bool, msg, p1, p2, p3) \ 7.47 - do{\ 7.48 - if(bool)\ 7.49 - { printf(msg, p1, p2, p3); \ 7.50 - printf(" | function: %s\n", __FUNCTION__);\ 7.51 - fflush(stdin);\ 7.52 - }\ 7.53 - }while(0);/*macro magic to isolate var-names*/ 7.54 - 7.55 -#else 7.56 - #define DEBUG__printf( bool, ...) 7.57 - #define DEBUG__printf1( bool, msg, param) 7.58 - #define DEBUG__printf2( bool, msg, p1, p2) 7.59 -#endif 7.60 - 7.61 -//============================= ERROR MSGs ============================ 7.62 -#define ERROR(msg) printf(msg); 7.63 -#define ERROR1(msg, param) printf(msg, param); 7.64 -#define ERROR2(msg, p1, p2) printf(msg, p1, p2); 7.65 - 7.66 -//=========================================================================== 7.67 -#endif /* _PR_DEFS_H */ 7.68 - 7.69 +/* 7.70 + * Copyright 2009 OpenSourceResearchInstitute.org 7.71 + * Licensed under GNU General Public License version 2 7.72 + * 7.73 + * Author: seanhalle@yahoo.com 7.74 + * 7.75 + */ 7.76 + 7.77 +#ifndef _DEBUG__macros_H 7.78 +#define _DEBUG__macros_H 7.79 +#define _GNU_SOURCE 7.80 + 7.81 +/* 7.82 + */ 7.83 +#ifdef DEBUG__TURN_ON_DEBUG_PRINT 7.84 + #define DEBUG__printf( bool, ...) \ 7.85 + do{\ 7.86 + if(bool)\ 7.87 + { printf(__VA_ARGS__);\ 7.88 + printf(" | function: %s\n", __FUNCTION__);\ 7.89 + fflush(stdin);\ 7.90 + }\ 7.91 + }while(0);/*macro magic to isolate var-names*/ 7.92 + 7.93 + #define DEBUG__printf1( bool, msg, param) \ 7.94 + do{\ 7.95 + if(bool)\ 7.96 + { printf(msg, param);\ 7.97 + printf(" | function: %s\n", __FUNCTION__);\ 7.98 + fflush(stdin);\ 7.99 + }\ 7.100 + }while(0);/*macro magic to isolate var-names*/ 7.101 + 7.102 + #define DEBUG__printf2( bool, msg, p1, p2) \ 7.103 + do{\ 7.104 + if(bool)\ 7.105 + { printf(msg, p1, p2); \ 7.106 + printf(" | function: %s\n", __FUNCTION__);\ 7.107 + fflush(stdin);\ 7.108 + }\ 7.109 + }while(0);/*macro magic to isolate var-names*/ 7.110 + 7.111 + #define DEBUG__printf3( bool, msg, p1, p2, p3) \ 7.112 + do{\ 7.113 + if(bool)\ 7.114 + { printf(msg, p1, p2, p3); \ 7.115 + printf(" | function: %s\n", __FUNCTION__);\ 7.116 + fflush(stdin);\ 7.117 + }\ 7.118 + }while(0);/*macro magic to isolate var-names*/ 7.119 + 7.120 +#else 7.121 + #define DEBUG__printf( bool, ...) 7.122 + #define DEBUG__printf1( bool, msg, param) 7.123 + #define DEBUG__printf2( bool, msg, p1, p2) 7.124 +#endif 7.125 + 7.126 +//============================= ERROR MSGs ============================ 7.127 +#define ERROR(msg) printf(msg); 7.128 +#define ERROR1(msg, param) printf(msg, param); 7.129 +#define ERROR2(msg, p1, p2) printf(msg, p1, p2); 7.130 + 7.131 +//=========================================================================== 7.132 +#endif /* _PR_DEFS_H */ 7.133 +
8.1 --- a/Services_offered_by_PR/MEAS__Counter_Recording.h Thu Aug 08 02:39:56 2013 -0700 8.2 +++ b/Services_offered_by_PR/MEAS__Counter_Recording.h Thu Aug 08 03:00:36 2013 -0700 8.3 @@ -1,36 +1,36 @@ 8.4 -/* 8.5 - * File: MEAS__Counter_Recording.h 8.6 - * Author: nengel 8.7 - * 8.8 - * Created on January 11, 2012, 3:03 PM 8.9 - */ 8.10 - 8.11 -#ifndef MEAS__COUNTER_RECORDING_H 8.12 -#define MEAS__COUNTER_RECORDING_H 8.13 - 8.14 -#include "PR__common_includes/PR__common_structs.h" 8.15 - 8.16 -typedef struct 8.17 - { 8.18 - int event_type; 8.19 - int coreID; 8.20 - AnimSlot* slot; 8.21 - int vp; 8.22 - int task; 8.23 - uint64 cycles; 8.24 - uint64 instrs; 8.25 - } 8.26 -CounterEvent; 8.27 - 8.28 -FILE* counterfile; //pass file handle via side effect because 8.29 - // doAllInListOfArrays only takes Fns with a single input 8.30 - 8.31 -void MEAS__init_counter_data_structs_for_lang( SlaveVP *slv, int32 magicNum ); 8.32 - 8.33 -void MEAS__counter_handler(int evt_type, int vpid, int task, SlaveVP* pr, uint64 cycles, uint64 instrs); 8.34 - 8.35 -void MEAS__set_counter_file(FILE* f); 8.36 - 8.37 -void MEAS__print_counter_event_to_file( void* _e ); 8.38 -#endif /* PRServ_COUNTER_RECORDING_H */ 8.39 - 8.40 +/* 8.41 + * File: MEAS__Counter_Recording.h 8.42 + * Author: nengel 8.43 + * 8.44 + * Created on January 11, 2012, 3:03 PM 8.45 + */ 8.46 + 8.47 +#ifndef MEAS__COUNTER_RECORDING_H 8.48 +#define MEAS__COUNTER_RECORDING_H 8.49 + 8.50 +#include "PR__common_includes/PR__common_structs.h" 8.51 + 8.52 +typedef struct 8.53 + { 8.54 + int event_type; 8.55 + int coreID; 8.56 + AnimSlot* slot; 8.57 + int vp; 8.58 + int task; 8.59 + uint64 cycles; 8.60 + uint64 instrs; 8.61 + } 8.62 +CounterEvent; 8.63 + 8.64 +FILE* counterfile; //pass file handle via side effect because 8.65 + // doAllInListOfArrays only takes Fns with a single input 8.66 + 8.67 +void MEAS__init_counter_data_structs_for_lang( SlaveVP *slv, int32 magicNum ); 8.68 + 8.69 +void MEAS__counter_handler(int evt_type, int vpid, int task, SlaveVP* pr, uint64 cycles, uint64 instrs); 8.70 + 8.71 +void MEAS__set_counter_file(FILE* f); 8.72 + 8.73 +void MEAS__print_counter_event_to_file( void* _e ); 8.74 +#endif /* PRServ_COUNTER_RECORDING_H */ 8.75 +
9.1 --- a/Services_offered_by_PR/MEAS__macros.h Thu Aug 08 02:39:56 2013 -0700 9.2 +++ b/Services_offered_by_PR/MEAS__macros.h Thu Aug 08 03:00:36 2013 -0700 9.3 @@ -1,514 +1,514 @@ 9.4 -/* 9.5 - * Copyright 2009 OpenSourceResearchInstitute.org 9.6 - * Licensed under GNU General Public License version 2 9.7 - * 9.8 - * Author: seanhalle@yahoo.com 9.9 - * 9.10 - */ 9.11 - 9.12 -#ifndef _MEAS_MACROS_H 9.13 -#define _MEAS_MACROS_H 9.14 -#define _GNU_SOURCE 9.15 - 9.16 -//================== Macros define types of meas want ===================== 9.17 -// 9.18 -/*Generic measurement macro -- has name-space collision potential, which 9.19 - * compiler will catch.. so only use one pair inside a given set of 9.20 - * curly braces. 9.21 - */ 9.22 -//TODO: finish generic capture interval in hist 9.23 -enum histograms 9.24 - { generic1 9.25 - }; 9.26 - #define MEAS__Capture_Pre_Point \ 9.27 - int32 startStamp, endStamp; \ 9.28 - saveLowTimeStampCountInto( startStamp ); 9.29 - 9.30 - #define MEAS__Capture_Post_Point( histName ) \ 9.31 - saveLowTimeStampCountInto( endStamp ); \ 9.32 - addIntervalToHist( startStamp, endStamp, _PRTopEnv->histName ); 9.33 - 9.34 - 9.35 - 9.36 - 9.37 -//================== Macros define types of meas want ===================== 9.38 - 9.39 -#ifdef MEAS__TURN_ON_SUSP_MEAS 9.40 - #define MEAS__Insert_Susp_Meas_Fields_into_Slave \ 9.41 - uint32 preSuspTSCLow; \ 9.42 - uint32 postSuspTSCLow; 9.43 - 9.44 - #define MEAS__Insert_Susp_Meas_Fields_into_MasterEnv \ 9.45 - Histogram *suspLowTimeHist; \ 9.46 - Histogram *suspHighTimeHist; 9.47 - 9.48 - #define MEAS__Make_Meas_Hists_for_Susp_Meas \ 9.49 - _PRTopEnv->suspLowTimeHist = makeFixedBinHistExt( 100, 0, 200,\ 9.50 - "master_low_time_hist");\ 9.51 - _PRTopEnv->suspHighTimeHist = makeFixedBinHistExt( 100, 0, 200,\ 9.52 - "master_high_time_hist"); 9.53 - 9.54 - //record time stamp: compare to time-stamp recorded below 9.55 - #define MEAS__Capture_Pre_Susp_Point \ 9.56 - saveLowTimeStampCountInto( animatingSlv->preSuspTSCLow ); 9.57 - 9.58 - //NOTE: only take low part of count -- do sanity check when take diff 9.59 - #define MEAS__Capture_Post_Susp_Point \ 9.60 - saveLowTimeStampCountInto( animatingSlv->postSuspTSCLow );\ 9.61 - addIntervalToHist( preSuspTSCLow, postSuspTSCLow,\ 9.62 - _PRTopEnv->suspLowTimeHist ); \ 9.63 - addIntervalToHist( preSuspTSCLow, postSuspTSCLow,\ 9.64 - _PRTopEnv->suspHighTimeHist ); 9.65 - 9.66 - #define MEAS__Print_Hists_for_Susp_Meas \ 9.67 - printHist( _PRTopEnv->pluginTimeHist ); 9.68 - 9.69 -#else 9.70 - #define MEAS__Insert_Susp_Meas_Fields_into_Slave 9.71 - #define MEAS__Insert_Susp_Meas_Fields_into_MasterEnv 9.72 - #define MEAS__Make_Meas_Hists_for_Susp_Meas 9.73 - #define MEAS__Capture_Pre_Susp_Point 9.74 - #define MEAS__Capture_Post_Susp_Point 9.75 - #define MEAS__Print_Hists_for_Susp_Meas 9.76 -#endif 9.77 - 9.78 -#ifdef MEAS__TURN_ON_MASTER_MEAS 9.79 - #define MEAS__Insert_Master_Meas_Fields_into_Slave \ 9.80 - uint32 startMasterTSCLow; \ 9.81 - uint32 endMasterTSCLow; 9.82 - 9.83 - #define MEAS__Insert_Master_Meas_Fields_into_MasterEnv \ 9.84 - Histogram *masterLowTimeHist; \ 9.85 - Histogram *masterHighTimeHist; 9.86 - 9.87 - #define MEAS__Make_Meas_Hists_for_Master_Meas \ 9.88 - _PRTopEnv->masterLowTimeHist = makeFixedBinHistExt( 100, 0, 200,\ 9.89 - "master_low_time_hist");\ 9.90 - _PRTopEnv->masterHighTimeHist = makeFixedBinHistExt( 100, 0, 200,\ 9.91 - "master_high_time_hist"); 9.92 - 9.93 - //Total Master time includes one coreloop time -- just assume the core 9.94 - // loop time is same for Master as for AppSlvs, even though it may be 9.95 - // smaller due to higher predictability of the fixed jmp. 9.96 - #define MEAS__Capture_Pre_Master_Point\ 9.97 - saveLowTimeStampCountInto( masterVP->startMasterTSCLow ); 9.98 - 9.99 - #define MEAS__Capture_Post_Master_Point \ 9.100 - saveLowTimeStampCountInto( masterVP->endMasterTSCLow );\ 9.101 - addIntervalToHist( startMasterTSCLow, endMasterTSCLow,\ 9.102 - _PRTopEnv->masterLowTimeHist ); \ 9.103 - addIntervalToHist( startMasterTSCLow, endMasterTSCLow,\ 9.104 - _PRTopEnv->masterHighTimeHist ); 9.105 - 9.106 - #define MEAS__Print_Hists_for_Master_Meas \ 9.107 - printHist( _PRTopEnv->pluginTimeHist ); 9.108 - 9.109 -#else 9.110 - #define MEAS__Insert_Master_Meas_Fields_into_Slave 9.111 - #define MEAS__Insert_Master_Meas_Fields_into_MasterEnv 9.112 - #define MEAS__Make_Meas_Hists_for_Master_Meas 9.113 - #define MEAS__Capture_Pre_Master_Point 9.114 - #define MEAS__Capture_Post_Master_Point 9.115 - #define MEAS__Print_Hists_for_Master_Meas 9.116 -#endif 9.117 - 9.118 - 9.119 -#ifdef MEAS__TURN_ON_MASTER_LOCK_MEAS 9.120 - #define MEAS__Insert_Master_Lock_Meas_Fields_into_MasterEnv \ 9.121 - Histogram *masterLockLowTimeHist; \ 9.122 - Histogram *masterLockHighTimeHist; 9.123 - 9.124 - #define MEAS__Make_Meas_Hists_for_Master_Lock_Meas \ 9.125 - _PRTopEnv->masterLockLowTimeHist = makeFixedBinHist( 50, 0, 2, \ 9.126 - "master lock low time hist");\ 9.127 - _PRTopEnv->masterLockHighTimeHist = makeFixedBinHist( 50, 0, 100,\ 9.128 - "master lock high time hist"); 9.129 - 9.130 - #define MEAS__Capture_Pre_Master_Lock_Point \ 9.131 - int32 startStamp, endStamp; \ 9.132 - saveLowTimeStampCountInto( startStamp ); 9.133 - 9.134 - #define MEAS__Capture_Post_Master_Lock_Point \ 9.135 - saveLowTimeStampCountInto( endStamp ); \ 9.136 - addIntervalToHist( startStamp, endStamp,\ 9.137 - _PRTopEnv->masterLockLowTimeHist ); \ 9.138 - addIntervalToHist( startStamp, endStamp,\ 9.139 - _PRTopEnv->masterLockHighTimeHist ); 9.140 - 9.141 - #define MEAS__Print_Hists_for_Master_Lock_Meas \ 9.142 - printHist( _PRTopEnv->masterLockLowTimeHist ); \ 9.143 - printHist( _PRTopEnv->masterLockHighTimeHist ); 9.144 - 9.145 -#else 9.146 - #define MEAS__Insert_Master_Lock_Meas_Fields_into_MasterEnv 9.147 - #define MEAS__Make_Meas_Hists_for_Master_Lock_Meas 9.148 - #define MEAS__Capture_Pre_Master_Lock_Point 9.149 - #define MEAS__Capture_Post_Master_Lock_Point 9.150 - #define MEAS__Print_Hists_for_Master_Lock_Meas 9.151 -#endif 9.152 - 9.153 - 9.154 -#ifdef MEAS__TURN_ON_MALLOC_MEAS 9.155 - #define MEAS__Insert_Malloc_Meas_Fields_into_MasterEnv\ 9.156 - Histogram *mallocTimeHist; \ 9.157 - Histogram *freeTimeHist; 9.158 - 9.159 - #define MEAS__Make_Meas_Hists_for_Malloc_Meas \ 9.160 - _PRTopEnv->mallocTimeHist = makeFixedBinHistExt( 100, 0, 30,\ 9.161 - "malloc_time_hist");\ 9.162 - _PRTopEnv->freeTimeHist = makeFixedBinHistExt( 100, 0, 30,\ 9.163 - "free_time_hist"); 9.164 - 9.165 - #define MEAS__Capture_Pre_Malloc_Point \ 9.166 - int32 startStamp, endStamp; \ 9.167 - saveLowTimeStampCountInto( startStamp ); 9.168 - 9.169 - #define MEAS__Capture_Post_Malloc_Point \ 9.170 - saveLowTimeStampCountInto( endStamp ); \ 9.171 - addIntervalToHist( startStamp, endStamp,\ 9.172 - _PRTopEnv->mallocTimeHist ); 9.173 - 9.174 - #define MEAS__Capture_Pre_Free_Point \ 9.175 - int32 startStamp, endStamp; \ 9.176 - saveLowTimeStampCountInto( startStamp ); 9.177 - 9.178 - #define MEAS__Capture_Post_Free_Point \ 9.179 - saveLowTimeStampCountInto( endStamp ); \ 9.180 - addIntervalToHist( startStamp, endStamp,\ 9.181 - _PRTopEnv->freeTimeHist ); 9.182 - 9.183 - #define MEAS__Print_Hists_for_Malloc_Meas \ 9.184 - printHist( _PRTopEnv->mallocTimeHist ); \ 9.185 - saveHistToFile( _PRTopEnv->mallocTimeHist ); \ 9.186 - printHist( _PRTopEnv->freeTimeHist ); \ 9.187 - saveHistToFile( _PRTopEnv->freeTimeHist ); \ 9.188 - freeHistExt( _PRTopEnv->mallocTimeHist ); \ 9.189 - freeHistExt( _PRTopEnv->freeTimeHist ); 9.190 - 9.191 -#else 9.192 - #define MEAS__Insert_Malloc_Meas_Fields_into_MasterEnv 9.193 - #define MEAS__Make_Meas_Hists_for_Malloc_Meas 9.194 - #define MEAS__Capture_Pre_Malloc_Point 9.195 - #define MEAS__Capture_Post_Malloc_Point 9.196 - #define MEAS__Capture_Pre_Free_Point 9.197 - #define MEAS__Capture_Post_Free_Point 9.198 - #define MEAS__Print_Hists_for_Malloc_Meas 9.199 -#endif 9.200 - 9.201 - 9.202 - 9.203 -#ifdef MEAS__TURN_ON_PLUGIN_MEAS 9.204 - #define MEAS__Insert_Plugin_Meas_Fields_into_MasterEnv \ 9.205 - Histogram *reqHdlrLowTimeHist; \ 9.206 - Histogram *reqHdlrHighTimeHist; 9.207 - 9.208 - #define MEAS__Make_Meas_Hists_for_Plugin_Meas \ 9.209 - _PRTopEnv->reqHdlrLowTimeHist = makeFixedBinHistExt( 100, 0, 200,\ 9.210 - "plugin_low_time_hist");\ 9.211 - _PRTopEnv->reqHdlrHighTimeHist = makeFixedBinHistExt( 100, 0, 200,\ 9.212 - "plugin_high_time_hist"); 9.213 - 9.214 - #define MEAS__startReqHdlr \ 9.215 - int32 startStamp1, endStamp1; \ 9.216 - saveLowTimeStampCountInto( startStamp1 ); 9.217 - 9.218 - #define MEAS__endReqHdlr \ 9.219 - saveLowTimeStampCountInto( endStamp1 ); \ 9.220 - addIntervalToHist( startStamp1, endStamp1, \ 9.221 - _PRTopEnv->reqHdlrLowTimeHist ); \ 9.222 - addIntervalToHist( startStamp1, endStamp1, \ 9.223 - _PRTopEnv->reqHdlrHighTimeHist ); 9.224 - 9.225 - #define MEAS__Print_Hists_for_Plugin_Meas \ 9.226 - printHist( _PRTopEnv->reqHdlrLowTimeHist ); \ 9.227 - saveHistToFile( _PRTopEnv->reqHdlrLowTimeHist ); \ 9.228 - printHist( _PRTopEnv->reqHdlrHighTimeHist ); \ 9.229 - saveHistToFile( _PRTopEnv->reqHdlrHighTimeHist ); \ 9.230 - freeHistExt( _PRTopEnv->reqHdlrLowTimeHist ); \ 9.231 - freeHistExt( _PRTopEnv->reqHdlrHighTimeHist ); 9.232 -#else 9.233 - #define MEAS__Insert_Plugin_Meas_Fields_into_MasterEnv 9.234 - #define MEAS__Make_Meas_Hists_for_Plugin_Meas 9.235 - #define MEAS__startReqHdlr 9.236 - #define MEAS__endReqHdlr 9.237 - #define MEAS__Print_Hists_for_Plugin_Meas 9.238 - 9.239 -#endif 9.240 - 9.241 - 9.242 -#ifdef MEAS__TURN_ON_SYSTEM_MEAS 9.243 - #define MEAS__Insert_System_Meas_Fields_into_Slave \ 9.244 - TSCountLowHigh startSusp; \ 9.245 - uint64 totalSuspCycles; \ 9.246 - uint32 numGoodSusp; 9.247 - 9.248 - #define MEAS__Insert_System_Meas_Fields_into_MasterEnv \ 9.249 - TSCountLowHigh startMaster; \ 9.250 - uint64 totalMasterCycles; \ 9.251 - uint32 numMasterAnimations; \ 9.252 - TSCountLowHigh startReqHdlr; \ 9.253 - uint64 totalPluginCycles; \ 9.254 - uint32 numPluginAnimations; \ 9.255 - uint64 cyclesTillStartAnimationMaster; \ 9.256 - TSCountLowHigh endAnimationMaster; 9.257 - 9.258 - #define MEAS__startAnimationMaster_forSys \ 9.259 - TSCountLowHigh startStamp1, endStamp1; \ 9.260 - saveTSCLowHigh( endStamp1 ); \ 9.261 - _PRTopEnv->cyclesTillStartAnimationMaster = \ 9.262 - endStamp1.longVal - masterVP->startSusp.longVal; 9.263 - 9.264 - #define Meas_startReqHdlr_forSys \ 9.265 - saveTSCLowHigh( startStamp1 ); \ 9.266 - _PRTopEnv->startReqHdlr.longVal = startStamp1.longVal; 9.267 - 9.268 - #define MEAS__endAnimationMaster_forSys \ 9.269 - saveTSCLowHigh( startStamp1 ); \ 9.270 - _PRTopEnv->endAnimationMaster.longVal = startStamp1.longVal; 9.271 - 9.272 - /*A TSC is stored in VP first thing inside wrapper-lib 9.273 - * Now, measures cycles from there to here 9.274 - * Master and Plugin will add this value to other trace-seg measures 9.275 - */ 9.276 - #define MEAS__Capture_End_Susp_in_CoreCtlr_ForSys\ 9.277 - saveTSCLowHigh(endSusp); \ 9.278 - numCycles = endSusp.longVal - currVP->startSusp.longVal; \ 9.279 - /*sanity check (400K is about 20K iters)*/ \ 9.280 - if( numCycles < 400000 ) \ 9.281 - { currVP->totalSuspCycles += numCycles; \ 9.282 - currVP->numGoodSusp++; \ 9.283 - } \ 9.284 - /*recorded every time, but only read if currVP == MasterVP*/ \ 9.285 - _PRTopEnv->startMaster.longVal = endSusp.longVal; 9.286 - 9.287 -#else 9.288 - #define MEAS__Insert_System_Meas_Fields_into_Slave 9.289 - #define MEAS__Insert_System_Meas_Fields_into_MasterEnv 9.290 - #define MEAS__Make_Meas_Hists_for_System_Meas 9.291 - #define MEAS__startAnimationMaster_forSys 9.292 - #define MEAS__startReqHdlr_forSys 9.293 - #define MEAS__endAnimationMaster_forSys 9.294 - #define MEAS__Capture_End_Susp_in_CoreCtlr_ForSys 9.295 - #define MEAS__Print_Hists_for_System_Meas 9.296 -#endif 9.297 - 9.298 -#ifdef HOLISTIC__TURN_ON_PERF_COUNTERS 9.299 - 9.300 - #define MEAS__Insert_Counter_Handler \ 9.301 - typedef void (*CounterHandler) (int,int,int,SlaveVP*,uint64,uint64,uint64); 9.302 - 9.303 - enum eventType { 9.304 - DebugEvt = 0, 9.305 - AppResponderInvocation_start, 9.306 - AppResponder_start, 9.307 - AppResponder_end, 9.308 - AssignerInvocation_start, 9.309 - NextAssigner_start, 9.310 - Assigner_start, 9.311 - Assigner_end, 9.312 - Work_start, 9.313 - Work_end, 9.314 - HwResponderInvocation_start, 9.315 - Timestamp_start, 9.316 - Timestamp_end 9.317 - }; 9.318 - 9.319 - #define saveCyclesAndInstrs(core,cycles,instrs,cachem) do{ \ 9.320 - int cycles_fd = _PRTopEnv->cycles_counter_fd[core]; \ 9.321 - int instrs_fd = _PRTopEnv->instrs_counter_fd[core]; \ 9.322 - int cachem_fd = _PRTopEnv->cachem_counter_fd[core]; \ 9.323 - int nread; \ 9.324 - \ 9.325 - nread = read(cycles_fd,&(cycles),sizeof(cycles)); \ 9.326 - if(nread<0){ \ 9.327 - perror("Error reading cycles counter"); \ 9.328 - cycles = 0; \ 9.329 - } \ 9.330 - \ 9.331 - nread = read(instrs_fd,&(instrs),sizeof(instrs)); \ 9.332 - if(nread<0){ \ 9.333 - perror("Error reading cycles counter"); \ 9.334 - instrs = 0; \ 9.335 - } \ 9.336 - nread = read(cachem_fd,&(cachem),sizeof(cachem)); \ 9.337 - if(nread<0){ \ 9.338 - perror("Error reading last level cache miss counter"); \ 9.339 - cachem = 0; \ 9.340 - } \ 9.341 - } while (0) 9.342 - 9.343 - #define MEAS__Insert_Counter_Meas_Fields_into_MasterEnv \ 9.344 - int cycles_counter_fd[NUM_CORES]; \ 9.345 - int instrs_counter_fd[NUM_CORES]; \ 9.346 - int cachem_counter_fd[NUM_CORES]; \ 9.347 - uint64 start_master_lock[NUM_CORES][3]; \ 9.348 - CounterHandler counterHandler; 9.349 - 9.350 - #define HOLISTIC__Setup_Perf_Counters setup_perf_counters(); 9.351 - 9.352 - 9.353 - #define HOLISTIC__CoreCtrl_Setup \ 9.354 - CounterHandler counterHandler = _PRTopEnv->counterHandler; \ 9.355 - SlaveVP *lastVPBeforeMaster = NULL; \ 9.356 - /*if(thisCoresThdParams->coreNum == 0){ \ 9.357 - uint64 initval = tsc_offset_send(thisCoresThdParams,0); \ 9.358 - while(!coreCtlrThdParams[NUM_CORES - 2]->ret_tsc); \ 9.359 - } \ 9.360 - if(0 < (thisCoresThdParams->coreNum) && (thisCoresThdParams->coreNum) < (NUM_CORES - 1)){ \ 9.361 - ThdParams* sendCoresThdParams = coreCtlrThdParams[thisCoresThdParams->coreNum - 1]; \ 9.362 - int sndctr = tsc_offset_resp(sendCoresThdParams, 0); \ 9.363 - uint64 initval = tsc_offset_send(thisCoresThdParams,0); \ 9.364 - while(!coreCtlrThdParams[NUM_CORES - 2]->ret_tsc); \ 9.365 - } \ 9.366 - if(thisCoresThdParams->coreNum == (NUM_CORES - 1)){ \ 9.367 - ThdParams* sendCoresThdParams = coreCtlrThdParams[thisCoresThdParams->coreNum - 1]; \ 9.368 - int sndctr = tsc_offset_resp(sendCoresThdParams,0); \ 9.369 - }*/ 9.370 - 9.371 - 9.372 - #define HOLISTIC__Insert_Master_Global_Vars \ 9.373 - int vpid,task; \ 9.374 - CounterHandler counterHandler = _PRTopEnv->counterHandler; 9.375 - 9.376 - #define HOLISTIC__Record_last_work lastVPBeforeMaster = currVP; 9.377 - 9.378 - #define HOLISTIC__Record_AppResponderInvocation_start \ 9.379 - uint64 cycles,instrs,cachem; \ 9.380 - saveCyclesAndInstrs(thisCoresIdx,cycles, instrs,cachem); \ 9.381 - if(lastVPBeforeMaster){ \ 9.382 - (*counterHandler)(AppResponderInvocation_start,lastVPBeforeMaster->slaveNum,lastVPBeforeMaster->numTimesAssignedToASlot,lastVPBeforeMaster,cycles,instrs,cachem); \ 9.383 - lastVPBeforeMaster = NULL; \ 9.384 - } else { \ 9.385 - _PRTopEnv->start_master_lock[thisCoresIdx][0] = cycles; \ 9.386 - _PRTopEnv->start_master_lock[thisCoresIdx][1] = instrs; \ 9.387 - _PRTopEnv->start_master_lock[thisCoresIdx][2] = cachem; \ 9.388 - } 9.389 - 9.390 - /* Request Handler may call resume() on the VP, but we want to 9.391 - * account the whole interval to the same task. Therefore, need 9.392 - * to save task ID at the beginning. 9.393 - * 9.394 - * Using this value as "end of AppResponder Invocation Time" 9.395 - * is possible if there is only one SchedSlot per core - 9.396 - * invoking processor is last to be treated here! If more than 9.397 - * one slot, MasterLoop processing time for all but the last VP 9.398 - * would be erroneously counted as invocation time. 9.399 - */ 9.400 - #define HOLISTIC__Record_AppResponder_start \ 9.401 - vpid = currSlot->slaveAssignedToSlot->slaveNum; \ 9.402 - task = currSlot->slaveAssignedToSlot->numTimesAssignedToASlot; \ 9.403 - uint64 cycles, instrs, cachem; \ 9.404 - saveCyclesAndInstrs(thisCoresIdx,cycles, instrs,cachem); \ 9.405 - (*counterHandler)(AppResponder_start,vpid,task,currSlot->slaveAssignedToSlot,cycles,instrs,cachem); 9.406 - 9.407 - #define HOLISTIC__Record_AppResponder_end \ 9.408 - uint64 cycles2,instrs2,cachem2; \ 9.409 - saveCyclesAndInstrs(thisCoresIdx,cycles2, instrs2,cachem2); \ 9.410 - (*counterHandler)(AppResponder_end,vpid,task,currSlot->slaveAssignedToSlot,cycles2,instrs2,cachem2); \ 9.411 - (*counterHandler)(Timestamp_end,vpid,task,currSlot->slaveAssignedToSlot,rdtsc(),0,0); 9.412 - 9.413 - 9.414 - /* Don't know who to account time to yet - goes to assigned VP 9.415 - * after the call. 9.416 - */ 9.417 - #define HOLISTIC__Record_Assigner_start \ 9.418 - int empty = FALSE; \ 9.419 - if(currSlot->slaveAssignedToSlot == NULL){ \ 9.420 - empty= TRUE; \ 9.421 - } \ 9.422 - uint64 tmp_cycles, tmp_instrs, tmp_cachem; \ 9.423 - saveCyclesAndInstrs(thisCoresIdx,tmp_cycles,tmp_instrs,tmp_cachem); \ 9.424 - uint64 tsc = rdtsc(); \ 9.425 - if(vpid > 0) { \ 9.426 - (*counterHandler)(NextAssigner_start,vpid,task,currSlot->slaveAssignedToSlot,tmp_cycles,tmp_instrs,tmp_cachem); \ 9.427 - vpid = 0; \ 9.428 - task = 0; \ 9.429 - } 9.430 - 9.431 - #define HOLISTIC__Record_Assigner_end \ 9.432 - uint64 cycles,instrs,cachem; \ 9.433 - saveCyclesAndInstrs(thisCoresIdx,cycles,instrs,cachem); \ 9.434 - if(empty){ \ 9.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]); \ 9.436 - } \ 9.437 - (*counterHandler)(Timestamp_start,assignedSlaveVP->slaveNum,assignedSlaveVP->numTimesAssignedToASlot,assignedSlaveVP,tsc,0,0); \ 9.438 - (*counterHandler)(Assigner_start,assignedSlaveVP->slaveNum,assignedSlaveVP->numTimesAssignedToASlot,assignedSlaveVP,tmp_cycles,tmp_instrs,tmp_cachem); \ 9.439 - (*counterHandler)(Assigner_end,assignedSlaveVP->slaveNum,assignedSlaveVP->numTimesAssignedToASlot,assignedSlaveVP,cycles,instrs,tmp_cachem); 9.440 - 9.441 - #define HOLISTIC__Record_Work_start \ 9.442 - if(currVP){ \ 9.443 - uint64 cycles,instrs,cachem; \ 9.444 - saveCyclesAndInstrs(thisCoresIdx,cycles, instrs,cachem); \ 9.445 - (*counterHandler)(Work_start,currVP->slaveNum,currVP->numTimesAssignedToASlot,currVP,cycles,instrs,cachem); \ 9.446 - } 9.447 - 9.448 - #define HOLISTIC__Record_Work_end \ 9.449 - if(currVP){ \ 9.450 - uint64 cycles,instrs,cachem; \ 9.451 - saveCyclesAndInstrs(thisCoresIdx,cycles, instrs,cachem); \ 9.452 - (*counterHandler)(Work_end,currVP->slaveNum,currVP->numTimesAssignedToASlot,currVP,cycles,instrs,cachem); \ 9.453 - } 9.454 - 9.455 - #define HOLISTIC__Record_HwResponderInvocation_start \ 9.456 - uint64 cycles,instrs,cachem; \ 9.457 - saveCyclesAndInstrs(animatingSlv->coreAnimatedBy,cycles, instrs,cachem); \ 9.458 - (*(_PRTopEnv->counterHandler))(HwResponderInvocation_start,animatingSlv->slaveNum,animatingSlv->numTimesAssignedToASlot,animatingSlv,cycles,instrs,cachem); 9.459 - 9.460 - 9.461 - #define getReturnAddressBeforeLibraryCall(vp_ptr, res_ptr) do{ \ 9.462 -void* frame_ptr0 = vp_ptr->framePtr; \ 9.463 -void* frame_ptr1 = *((void**)frame_ptr0); \ 9.464 -void* frame_ptr2 = *((void**)frame_ptr1); \ 9.465 -void* frame_ptr3 = *((void**)frame_ptr2); \ 9.466 -void* ret_addr = *((void**)frame_ptr3 + 1); \ 9.467 -*res_ptr = ret_addr; \ 9.468 -} while (0) 9.469 - 9.470 -#else 9.471 - #define MEAS__Insert_Counter_Handler 9.472 - #define MEAS__Insert_Counter_Meas_Fields_into_MasterEnv 9.473 - #define HOLISTIC__Setup_Perf_Counters 9.474 - #define HOLISTIC__CoreCtrl_Setup 9.475 - #define HOLISTIC__Insert_Master_Global_Vars 9.476 - #define HOLISTIC__Record_last_work 9.477 - #define HOLISTIC__Record_AppResponderInvocation_start 9.478 - #define HOLISTIC__Record_AppResponder_start 9.479 - #define HOLISTIC__Record_AppResponder_end 9.480 - #define HOLISTIC__Record_Assigner_start 9.481 - #define HOLISTIC__Record_Assigner_end 9.482 - #define HOLISTIC__Record_Work_start 9.483 - #define HOLISTIC__Record_Work_end 9.484 - #define HOLISTIC__Record_HwResponderInvocation_start 9.485 - #define getReturnAddressBeforeLibraryCall(vp_ptr, res_ptr) 9.486 -#endif 9.487 - 9.488 -//Experiment in two-step macros -- if doesn't work, insert each separately 9.489 -#define MEAS__Insert_Meas_Fields_into_Slave \ 9.490 - MEAS__Insert_Susp_Meas_Fields_into_Slave \ 9.491 - MEAS__Insert_Master_Meas_Fields_into_Slave \ 9.492 - MEAS__Insert_System_Meas_Fields_into_Slave 9.493 - 9.494 - 9.495 -//====================== Histogram Macros -- Create ======================== 9.496 -// 9.497 -// 9.498 - 9.499 -//The language implementation should include a definition of this macro, 9.500 -// which creates all the histograms the language uses to collect measurements 9.501 -// of plugin operation -- so, if the language didn't define it, must 9.502 -// define it here (as empty), to avoid compile error 9.503 -#ifndef MEAS__Make_Meas_Hists_for_Language 9.504 -#define MEAS__Make_Meas_Hists_for_Language 9.505 -#endif 9.506 - 9.507 -#define makeAMeasHist( histInfo, idx, name, numBins, startVal, binWidth ) \ 9.508 - makeHighestDynArrayIndexBeAtLeast( _PRTopEnv->measHistsInfo, idx ); \ 9.509 - _PRTopEnv->measHists[idx] = \ 9.510 - makeFixedBinHist( numBins, startVal, binWidth, name ); 9.511 - 9.512 -//============================== Probes =================================== 9.513 - 9.514 - 9.515 -//=========================================================================== 9.516 -#endif /* _PR_DEFS_MEAS_H */ 9.517 - 9.518 +/* 9.519 + * Copyright 2009 OpenSourceResearchInstitute.org 9.520 + * Licensed under GNU General Public License version 2 9.521 + * 9.522 + * Author: seanhalle@yahoo.com 9.523 + * 9.524 + */ 9.525 + 9.526 +#ifndef _MEAS_MACROS_H 9.527 +#define _MEAS_MACROS_H 9.528 +#define _GNU_SOURCE 9.529 + 9.530 +//================== Macros define types of meas want ===================== 9.531 +// 9.532 +/*Generic measurement macro -- has name-space collision potential, which 9.533 + * compiler will catch.. so only use one pair inside a given set of 9.534 + * curly braces. 9.535 + */ 9.536 +//TODO: finish generic capture interval in hist 9.537 +enum histograms 9.538 + { generic1 9.539 + }; 9.540 + #define MEAS__Capture_Pre_Point \ 9.541 + int32 startStamp, endStamp; \ 9.542 + saveLowTimeStampCountInto( startStamp ); 9.543 + 9.544 + #define MEAS__Capture_Post_Point( histName ) \ 9.545 + saveLowTimeStampCountInto( endStamp ); \ 9.546 + addIntervalToHist( startStamp, endStamp, _PRTopEnv->histName ); 9.547 + 9.548 + 9.549 + 9.550 + 9.551 +//================== Macros define types of meas want ===================== 9.552 + 9.553 +#ifdef MEAS__TURN_ON_SUSP_MEAS 9.554 + #define MEAS__Insert_Susp_Meas_Fields_into_Slave \ 9.555 + uint32 preSuspTSCLow; \ 9.556 + uint32 postSuspTSCLow; 9.557 + 9.558 + #define MEAS__Insert_Susp_Meas_Fields_into_MasterEnv \ 9.559 + Histogram *suspLowTimeHist; \ 9.560 + Histogram *suspHighTimeHist; 9.561 + 9.562 + #define MEAS__Make_Meas_Hists_for_Susp_Meas \ 9.563 + _PRTopEnv->suspLowTimeHist = makeFixedBinHistExt( 100, 0, 200,\ 9.564 + "master_low_time_hist");\ 9.565 + _PRTopEnv->suspHighTimeHist = makeFixedBinHistExt( 100, 0, 200,\ 9.566 + "master_high_time_hist"); 9.567 + 9.568 + //record time stamp: compare to time-stamp recorded below 9.569 + #define MEAS__Capture_Pre_Susp_Point \ 9.570 + saveLowTimeStampCountInto( animatingSlv->preSuspTSCLow ); 9.571 + 9.572 + //NOTE: only take low part of count -- do sanity check when take diff 9.573 + #define MEAS__Capture_Post_Susp_Point \ 9.574 + saveLowTimeStampCountInto( animatingSlv->postSuspTSCLow );\ 9.575 + addIntervalToHist( preSuspTSCLow, postSuspTSCLow,\ 9.576 + _PRTopEnv->suspLowTimeHist ); \ 9.577 + addIntervalToHist( preSuspTSCLow, postSuspTSCLow,\ 9.578 + _PRTopEnv->suspHighTimeHist ); 9.579 + 9.580 + #define MEAS__Print_Hists_for_Susp_Meas \ 9.581 + printHist( _PRTopEnv->pluginTimeHist ); 9.582 + 9.583 +#else 9.584 + #define MEAS__Insert_Susp_Meas_Fields_into_Slave 9.585 + #define MEAS__Insert_Susp_Meas_Fields_into_MasterEnv 9.586 + #define MEAS__Make_Meas_Hists_for_Susp_Meas 9.587 + #define MEAS__Capture_Pre_Susp_Point 9.588 + #define MEAS__Capture_Post_Susp_Point 9.589 + #define MEAS__Print_Hists_for_Susp_Meas 9.590 +#endif 9.591 + 9.592 +#ifdef MEAS__TURN_ON_MASTER_MEAS 9.593 + #define MEAS__Insert_Master_Meas_Fields_into_Slave \ 9.594 + uint32 startMasterTSCLow; \ 9.595 + uint32 endMasterTSCLow; 9.596 + 9.597 + #define MEAS__Insert_Master_Meas_Fields_into_MasterEnv \ 9.598 + Histogram *masterLowTimeHist; \ 9.599 + Histogram *masterHighTimeHist; 9.600 + 9.601 + #define MEAS__Make_Meas_Hists_for_Master_Meas \ 9.602 + _PRTopEnv->masterLowTimeHist = makeFixedBinHistExt( 100, 0, 200,\ 9.603 + "master_low_time_hist");\ 9.604 + _PRTopEnv->masterHighTimeHist = makeFixedBinHistExt( 100, 0, 200,\ 9.605 + "master_high_time_hist"); 9.606 + 9.607 + //Total Master time includes one coreloop time -- just assume the core 9.608 + // loop time is same for Master as for AppSlvs, even though it may be 9.609 + // smaller due to higher predictability of the fixed jmp. 9.610 + #define MEAS__Capture_Pre_Master_Point\ 9.611 + saveLowTimeStampCountInto( masterVP->startMasterTSCLow ); 9.612 + 9.613 + #define MEAS__Capture_Post_Master_Point \ 9.614 + saveLowTimeStampCountInto( masterVP->endMasterTSCLow );\ 9.615 + addIntervalToHist( startMasterTSCLow, endMasterTSCLow,\ 9.616 + _PRTopEnv->masterLowTimeHist ); \ 9.617 + addIntervalToHist( startMasterTSCLow, endMasterTSCLow,\ 9.618 + _PRTopEnv->masterHighTimeHist ); 9.619 + 9.620 + #define MEAS__Print_Hists_for_Master_Meas \ 9.621 + printHist( _PRTopEnv->pluginTimeHist ); 9.622 + 9.623 +#else 9.624 + #define MEAS__Insert_Master_Meas_Fields_into_Slave 9.625 + #define MEAS__Insert_Master_Meas_Fields_into_MasterEnv 9.626 + #define MEAS__Make_Meas_Hists_for_Master_Meas 9.627 + #define MEAS__Capture_Pre_Master_Point 9.628 + #define MEAS__Capture_Post_Master_Point 9.629 + #define MEAS__Print_Hists_for_Master_Meas 9.630 +#endif 9.631 + 9.632 + 9.633 +#ifdef MEAS__TURN_ON_MASTER_LOCK_MEAS 9.634 + #define MEAS__Insert_Master_Lock_Meas_Fields_into_MasterEnv \ 9.635 + Histogram *masterLockLowTimeHist; \ 9.636 + Histogram *masterLockHighTimeHist; 9.637 + 9.638 + #define MEAS__Make_Meas_Hists_for_Master_Lock_Meas \ 9.639 + _PRTopEnv->masterLockLowTimeHist = makeFixedBinHist( 50, 0, 2, \ 9.640 + "master lock low time hist");\ 9.641 + _PRTopEnv->masterLockHighTimeHist = makeFixedBinHist( 50, 0, 100,\ 9.642 + "master lock high time hist"); 9.643 + 9.644 + #define MEAS__Capture_Pre_Master_Lock_Point \ 9.645 + int32 startStamp, endStamp; \ 9.646 + saveLowTimeStampCountInto( startStamp ); 9.647 + 9.648 + #define MEAS__Capture_Post_Master_Lock_Point \ 9.649 + saveLowTimeStampCountInto( endStamp ); \ 9.650 + addIntervalToHist( startStamp, endStamp,\ 9.651 + _PRTopEnv->masterLockLowTimeHist ); \ 9.652 + addIntervalToHist( startStamp, endStamp,\ 9.653 + _PRTopEnv->masterLockHighTimeHist ); 9.654 + 9.655 + #define MEAS__Print_Hists_for_Master_Lock_Meas \ 9.656 + printHist( _PRTopEnv->masterLockLowTimeHist ); \ 9.657 + printHist( _PRTopEnv->masterLockHighTimeHist ); 9.658 + 9.659 +#else 9.660 + #define MEAS__Insert_Master_Lock_Meas_Fields_into_MasterEnv 9.661 + #define MEAS__Make_Meas_Hists_for_Master_Lock_Meas 9.662 + #define MEAS__Capture_Pre_Master_Lock_Point 9.663 + #define MEAS__Capture_Post_Master_Lock_Point 9.664 + #define MEAS__Print_Hists_for_Master_Lock_Meas 9.665 +#endif 9.666 + 9.667 + 9.668 +#ifdef MEAS__TURN_ON_MALLOC_MEAS 9.669 + #define MEAS__Insert_Malloc_Meas_Fields_into_MasterEnv\ 9.670 + Histogram *mallocTimeHist; \ 9.671 + Histogram *freeTimeHist; 9.672 + 9.673 + #define MEAS__Make_Meas_Hists_for_Malloc_Meas \ 9.674 + _PRTopEnv->mallocTimeHist = makeFixedBinHistExt( 100, 0, 30,\ 9.675 + "malloc_time_hist");\ 9.676 + _PRTopEnv->freeTimeHist = makeFixedBinHistExt( 100, 0, 30,\ 9.677 + "free_time_hist"); 9.678 + 9.679 + #define MEAS__Capture_Pre_Malloc_Point \ 9.680 + int32 startStamp, endStamp; \ 9.681 + saveLowTimeStampCountInto( startStamp ); 9.682 + 9.683 + #define MEAS__Capture_Post_Malloc_Point \ 9.684 + saveLowTimeStampCountInto( endStamp ); \ 9.685 + addIntervalToHist( startStamp, endStamp,\ 9.686 + _PRTopEnv->mallocTimeHist ); 9.687 + 9.688 + #define MEAS__Capture_Pre_Free_Point \ 9.689 + int32 startStamp, endStamp; \ 9.690 + saveLowTimeStampCountInto( startStamp ); 9.691 + 9.692 + #define MEAS__Capture_Post_Free_Point \ 9.693 + saveLowTimeStampCountInto( endStamp ); \ 9.694 + addIntervalToHist( startStamp, endStamp,\ 9.695 + _PRTopEnv->freeTimeHist ); 9.696 + 9.697 + #define MEAS__Print_Hists_for_Malloc_Meas \ 9.698 + printHist( _PRTopEnv->mallocTimeHist ); \ 9.699 + saveHistToFile( _PRTopEnv->mallocTimeHist ); \ 9.700 + printHist( _PRTopEnv->freeTimeHist ); \ 9.701 + saveHistToFile( _PRTopEnv->freeTimeHist ); \ 9.702 + freeHistExt( _PRTopEnv->mallocTimeHist ); \ 9.703 + freeHistExt( _PRTopEnv->freeTimeHist ); 9.704 + 9.705 +#else 9.706 + #define MEAS__Insert_Malloc_Meas_Fields_into_MasterEnv 9.707 + #define MEAS__Make_Meas_Hists_for_Malloc_Meas 9.708 + #define MEAS__Capture_Pre_Malloc_Point 9.709 + #define MEAS__Capture_Post_Malloc_Point 9.710 + #define MEAS__Capture_Pre_Free_Point 9.711 + #define MEAS__Capture_Post_Free_Point 9.712 + #define MEAS__Print_Hists_for_Malloc_Meas 9.713 +#endif 9.714 + 9.715 + 9.716 + 9.717 +#ifdef MEAS__TURN_ON_PLUGIN_MEAS 9.718 + #define MEAS__Insert_Plugin_Meas_Fields_into_MasterEnv \ 9.719 + Histogram *reqHdlrLowTimeHist; \ 9.720 + Histogram *reqHdlrHighTimeHist; 9.721 + 9.722 + #define MEAS__Make_Meas_Hists_for_Plugin_Meas \ 9.723 + _PRTopEnv->reqHdlrLowTimeHist = makeFixedBinHistExt( 100, 0, 200,\ 9.724 + "plugin_low_time_hist");\ 9.725 + _PRTopEnv->reqHdlrHighTimeHist = makeFixedBinHistExt( 100, 0, 200,\ 9.726 + "plugin_high_time_hist"); 9.727 + 9.728 + #define MEAS__startReqHdlr \ 9.729 + int32 startStamp1, endStamp1; \ 9.730 + saveLowTimeStampCountInto( startStamp1 ); 9.731 + 9.732 + #define MEAS__endReqHdlr \ 9.733 + saveLowTimeStampCountInto( endStamp1 ); \ 9.734 + addIntervalToHist( startStamp1, endStamp1, \ 9.735 + _PRTopEnv->reqHdlrLowTimeHist ); \ 9.736 + addIntervalToHist( startStamp1, endStamp1, \ 9.737 + _PRTopEnv->reqHdlrHighTimeHist ); 9.738 + 9.739 + #define MEAS__Print_Hists_for_Plugin_Meas \ 9.740 + printHist( _PRTopEnv->reqHdlrLowTimeHist ); \ 9.741 + saveHistToFile( _PRTopEnv->reqHdlrLowTimeHist ); \ 9.742 + printHist( _PRTopEnv->reqHdlrHighTimeHist ); \ 9.743 + saveHistToFile( _PRTopEnv->reqHdlrHighTimeHist ); \ 9.744 + freeHistExt( _PRTopEnv->reqHdlrLowTimeHist ); \ 9.745 + freeHistExt( _PRTopEnv->reqHdlrHighTimeHist ); 9.746 +#else 9.747 + #define MEAS__Insert_Plugin_Meas_Fields_into_MasterEnv 9.748 + #define MEAS__Make_Meas_Hists_for_Plugin_Meas 9.749 + #define MEAS__startReqHdlr 9.750 + #define MEAS__endReqHdlr 9.751 + #define MEAS__Print_Hists_for_Plugin_Meas 9.752 + 9.753 +#endif 9.754 + 9.755 + 9.756 +#ifdef MEAS__TURN_ON_SYSTEM_MEAS 9.757 + #define MEAS__Insert_System_Meas_Fields_into_Slave \ 9.758 + TSCountLowHigh startSusp; \ 9.759 + uint64 totalSuspCycles; \ 9.760 + uint32 numGoodSusp; 9.761 + 9.762 + #define MEAS__Insert_System_Meas_Fields_into_MasterEnv \ 9.763 + TSCountLowHigh startMaster; \ 9.764 + uint64 totalMasterCycles; \ 9.765 + uint32 numMasterAnimations; \ 9.766 + TSCountLowHigh startReqHdlr; \ 9.767 + uint64 totalPluginCycles; \ 9.768 + uint32 numPluginAnimations; \ 9.769 + uint64 cyclesTillStartAnimationMaster; \ 9.770 + TSCountLowHigh endAnimationMaster; 9.771 + 9.772 + #define MEAS__startAnimationMaster_forSys \ 9.773 + TSCountLowHigh startStamp1, endStamp1; \ 9.774 + saveTSCLowHigh( endStamp1 ); \ 9.775 + _PRTopEnv->cyclesTillStartAnimationMaster = \ 9.776 + endStamp1.longVal - masterVP->startSusp.longVal; 9.777 + 9.778 + #define Meas_startReqHdlr_forSys \ 9.779 + saveTSCLowHigh( startStamp1 ); \ 9.780 + _PRTopEnv->startReqHdlr.longVal = startStamp1.longVal; 9.781 + 9.782 + #define MEAS__endAnimationMaster_forSys \ 9.783 + saveTSCLowHigh( startStamp1 ); \ 9.784 + _PRTopEnv->endAnimationMaster.longVal = startStamp1.longVal; 9.785 + 9.786 + /*A TSC is stored in VP first thing inside wrapper-lib 9.787 + * Now, measures cycles from there to here 9.788 + * Master and Plugin will add this value to other trace-seg measures 9.789 + */ 9.790 + #define MEAS__Capture_End_Susp_in_CoreCtlr_ForSys\ 9.791 + saveTSCLowHigh(endSusp); \ 9.792 + numCycles = endSusp.longVal - currVP->startSusp.longVal; \ 9.793 + /*sanity check (400K is about 20K iters)*/ \ 9.794 + if( numCycles < 400000 ) \ 9.795 + { currVP->totalSuspCycles += numCycles; \ 9.796 + currVP->numGoodSusp++; \ 9.797 + } \ 9.798 + /*recorded every time, but only read if currVP == MasterVP*/ \ 9.799 + _PRTopEnv->startMaster.longVal = endSusp.longVal; 9.800 + 9.801 +#else 9.802 + #define MEAS__Insert_System_Meas_Fields_into_Slave 9.803 + #define MEAS__Insert_System_Meas_Fields_into_MasterEnv 9.804 + #define MEAS__Make_Meas_Hists_for_System_Meas 9.805 + #define MEAS__startAnimationMaster_forSys 9.806 + #define MEAS__startReqHdlr_forSys 9.807 + #define MEAS__endAnimationMaster_forSys 9.808 + #define MEAS__Capture_End_Susp_in_CoreCtlr_ForSys 9.809 + #define MEAS__Print_Hists_for_System_Meas 9.810 +#endif 9.811 + 9.812 +#ifdef HOLISTIC__TURN_ON_PERF_COUNTERS 9.813 + 9.814 + #define MEAS__Insert_Counter_Handler \ 9.815 + typedef void (*CounterHandler) (int,int,int,SlaveVP*,uint64,uint64,uint64); 9.816 + 9.817 + enum eventType { 9.818 + DebugEvt = 0, 9.819 + AppResponderInvocation_start, 9.820 + AppResponder_start, 9.821 + AppResponder_end, 9.822 + AssignerInvocation_start, 9.823 + NextAssigner_start, 9.824 + Assigner_start, 9.825 + Assigner_end, 9.826 + Work_start, 9.827 + Work_end, 9.828 + HwResponderInvocation_start, 9.829 + Timestamp_start, 9.830 + Timestamp_end 9.831 + }; 9.832 + 9.833 + #define saveCyclesAndInstrs(core,cycles,instrs,cachem) do{ \ 9.834 + int cycles_fd = _PRTopEnv->cycles_counter_fd[core]; \ 9.835 + int instrs_fd = _PRTopEnv->instrs_counter_fd[core]; \ 9.836 + int cachem_fd = _PRTopEnv->cachem_counter_fd[core]; \ 9.837 + int nread; \ 9.838 + \ 9.839 + nread = read(cycles_fd,&(cycles),sizeof(cycles)); \ 9.840 + if(nread<0){ \ 9.841 + perror("Error reading cycles counter"); \ 9.842 + cycles = 0; \ 9.843 + } \ 9.844 + \ 9.845 + nread = read(instrs_fd,&(instrs),sizeof(instrs)); \ 9.846 + if(nread<0){ \ 9.847 + perror("Error reading cycles counter"); \ 9.848 + instrs = 0; \ 9.849 + } \ 9.850 + nread = read(cachem_fd,&(cachem),sizeof(cachem)); \ 9.851 + if(nread<0){ \ 9.852 + perror("Error reading last level cache miss counter"); \ 9.853 + cachem = 0; \ 9.854 + } \ 9.855 + } while (0) 9.856 + 9.857 + #define MEAS__Insert_Counter_Meas_Fields_into_MasterEnv \ 9.858 + int cycles_counter_fd[NUM_CORES]; \ 9.859 + int instrs_counter_fd[NUM_CORES]; \ 9.860 + int cachem_counter_fd[NUM_CORES]; \ 9.861 + uint64 start_master_lock[NUM_CORES][3]; \ 9.862 + CounterHandler counterHandler; 9.863 + 9.864 + #define HOLISTIC__Setup_Perf_Counters setup_perf_counters(); 9.865 + 9.866 + 9.867 + #define HOLISTIC__CoreCtrl_Setup \ 9.868 + CounterHandler counterHandler = _PRTopEnv->counterHandler; \ 9.869 + SlaveVP *lastVPBeforeMaster = NULL; \ 9.870 + /*if(thisCoresThdParams->coreNum == 0){ \ 9.871 + uint64 initval = tsc_offset_send(thisCoresThdParams,0); \ 9.872 + while(!coreCtlrThdParams[NUM_CORES - 2]->ret_tsc); \ 9.873 + } \ 9.874 + if(0 < (thisCoresThdParams->coreNum) && (thisCoresThdParams->coreNum) < (NUM_CORES - 1)){ \ 9.875 + ThdParams* sendCoresThdParams = coreCtlrThdParams[thisCoresThdParams->coreNum - 1]; \ 9.876 + int sndctr = tsc_offset_resp(sendCoresThdParams, 0); \ 9.877 + uint64 initval = tsc_offset_send(thisCoresThdParams,0); \ 9.878 + while(!coreCtlrThdParams[NUM_CORES - 2]->ret_tsc); \ 9.879 + } \ 9.880 + if(thisCoresThdParams->coreNum == (NUM_CORES - 1)){ \ 9.881 + ThdParams* sendCoresThdParams = coreCtlrThdParams[thisCoresThdParams->coreNum - 1]; \ 9.882 + int sndctr = tsc_offset_resp(sendCoresThdParams,0); \ 9.883 + }*/ 9.884 + 9.885 + 9.886 + #define HOLISTIC__Insert_Master_Global_Vars \ 9.887 + int vpid,task; \ 9.888 + CounterHandler counterHandler = _PRTopEnv->counterHandler; 9.889 + 9.890 + #define HOLISTIC__Record_last_work lastVPBeforeMaster = currVP; 9.891 + 9.892 + #define HOLISTIC__Record_AppResponderInvocation_start \ 9.893 + uint64 cycles,instrs,cachem; \ 9.894 + saveCyclesAndInstrs(thisCoresIdx,cycles, instrs,cachem); \ 9.895 + if(lastVPBeforeMaster){ \ 9.896 + (*counterHandler)(AppResponderInvocation_start,lastVPBeforeMaster->slaveNum,lastVPBeforeMaster->numTimesAssignedToASlot,lastVPBeforeMaster,cycles,instrs,cachem); \ 9.897 + lastVPBeforeMaster = NULL; \ 9.898 + } else { \ 9.899 + _PRTopEnv->start_master_lock[thisCoresIdx][0] = cycles; \ 9.900 + _PRTopEnv->start_master_lock[thisCoresIdx][1] = instrs; \ 9.901 + _PRTopEnv->start_master_lock[thisCoresIdx][2] = cachem; \ 9.902 + } 9.903 + 9.904 + /* Request Handler may call resume() on the VP, but we want to 9.905 + * account the whole interval to the same task. Therefore, need 9.906 + * to save task ID at the beginning. 9.907 + * 9.908 + * Using this value as "end of AppResponder Invocation Time" 9.909 + * is possible if there is only one SchedSlot per core - 9.910 + * invoking processor is last to be treated here! If more than 9.911 + * one slot, MasterLoop processing time for all but the last VP 9.912 + * would be erroneously counted as invocation time. 9.913 + */ 9.914 + #define HOLISTIC__Record_AppResponder_start \ 9.915 + vpid = currSlot->slaveAssignedToSlot->slaveNum; \ 9.916 + task = currSlot->slaveAssignedToSlot->numTimesAssignedToASlot; \ 9.917 + uint64 cycles, instrs, cachem; \ 9.918 + saveCyclesAndInstrs(thisCoresIdx,cycles, instrs,cachem); \ 9.919 + (*counterHandler)(AppResponder_start,vpid,task,currSlot->slaveAssignedToSlot,cycles,instrs,cachem); 9.920 + 9.921 + #define HOLISTIC__Record_AppResponder_end \ 9.922 + uint64 cycles2,instrs2,cachem2; \ 9.923 + saveCyclesAndInstrs(thisCoresIdx,cycles2, instrs2,cachem2); \ 9.924 + (*counterHandler)(AppResponder_end,vpid,task,currSlot->slaveAssignedToSlot,cycles2,instrs2,cachem2); \ 9.925 + (*counterHandler)(Timestamp_end,vpid,task,currSlot->slaveAssignedToSlot,rdtsc(),0,0); 9.926 + 9.927 + 9.928 + /* Don't know who to account time to yet - goes to assigned VP 9.929 + * after the call. 9.930 + */ 9.931 + #define HOLISTIC__Record_Assigner_start \ 9.932 + int empty = FALSE; \ 9.933 + if(currSlot->slaveAssignedToSlot == NULL){ \ 9.934 + empty= TRUE; \ 9.935 + } \ 9.936 + uint64 tmp_cycles, tmp_instrs, tmp_cachem; \ 9.937 + saveCyclesAndInstrs(thisCoresIdx,tmp_cycles,tmp_instrs,tmp_cachem); \ 9.938 + uint64 tsc = rdtsc(); \ 9.939 + if(vpid > 0) { \ 9.940 + (*counterHandler)(NextAssigner_start,vpid,task,currSlot->slaveAssignedToSlot,tmp_cycles,tmp_instrs,tmp_cachem); \ 9.941 + vpid = 0; \ 9.942 + task = 0; \ 9.943 + } 9.944 + 9.945 + #define HOLISTIC__Record_Assigner_end \ 9.946 + uint64 cycles,instrs,cachem; \ 9.947 + saveCyclesAndInstrs(thisCoresIdx,cycles,instrs,cachem); \ 9.948 + if(empty){ \ 9.949 + (*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]); \ 9.950 + } \ 9.951 + (*counterHandler)(Timestamp_start,assignedSlaveVP->slaveNum,assignedSlaveVP->numTimesAssignedToASlot,assignedSlaveVP,tsc,0,0); \ 9.952 + (*counterHandler)(Assigner_start,assignedSlaveVP->slaveNum,assignedSlaveVP->numTimesAssignedToASlot,assignedSlaveVP,tmp_cycles,tmp_instrs,tmp_cachem); \ 9.953 + (*counterHandler)(Assigner_end,assignedSlaveVP->slaveNum,assignedSlaveVP->numTimesAssignedToASlot,assignedSlaveVP,cycles,instrs,tmp_cachem); 9.954 + 9.955 + #define HOLISTIC__Record_Work_start \ 9.956 + if(currVP){ \ 9.957 + uint64 cycles,instrs,cachem; \ 9.958 + saveCyclesAndInstrs(thisCoresIdx,cycles, instrs,cachem); \ 9.959 + (*counterHandler)(Work_start,currVP->slaveNum,currVP->numTimesAssignedToASlot,currVP,cycles,instrs,cachem); \ 9.960 + } 9.961 + 9.962 + #define HOLISTIC__Record_Work_end \ 9.963 + if(currVP){ \ 9.964 + uint64 cycles,instrs,cachem; \ 9.965 + saveCyclesAndInstrs(thisCoresIdx,cycles, instrs,cachem); \ 9.966 + (*counterHandler)(Work_end,currVP->slaveNum,currVP->numTimesAssignedToASlot,currVP,cycles,instrs,cachem); \ 9.967 + } 9.968 + 9.969 + #define HOLISTIC__Record_HwResponderInvocation_start \ 9.970 + uint64 cycles,instrs,cachem; \ 9.971 + saveCyclesAndInstrs(animatingSlv->coreAnimatedBy,cycles, instrs,cachem); \ 9.972 + (*(_PRTopEnv->counterHandler))(HwResponderInvocation_start,animatingSlv->slaveNum,animatingSlv->numTimesAssignedToASlot,animatingSlv,cycles,instrs,cachem); 9.973 + 9.974 + 9.975 + #define getReturnAddressBeforeLibraryCall(vp_ptr, res_ptr) do{ \ 9.976 +void* frame_ptr0 = vp_ptr->framePtr; \ 9.977 +void* frame_ptr1 = *((void**)frame_ptr0); \ 9.978 +void* frame_ptr2 = *((void**)frame_ptr1); \ 9.979 +void* frame_ptr3 = *((void**)frame_ptr2); \ 9.980 +void* ret_addr = *((void**)frame_ptr3 + 1); \ 9.981 +*res_ptr = ret_addr; \ 9.982 +} while (0) 9.983 + 9.984 +#else 9.985 + #define MEAS__Insert_Counter_Handler 9.986 + #define MEAS__Insert_Counter_Meas_Fields_into_MasterEnv 9.987 + #define HOLISTIC__Setup_Perf_Counters 9.988 + #define HOLISTIC__CoreCtrl_Setup 9.989 + #define HOLISTIC__Insert_Master_Global_Vars 9.990 + #define HOLISTIC__Record_last_work 9.991 + #define HOLISTIC__Record_AppResponderInvocation_start 9.992 + #define HOLISTIC__Record_AppResponder_start 9.993 + #define HOLISTIC__Record_AppResponder_end 9.994 + #define HOLISTIC__Record_Assigner_start 9.995 + #define HOLISTIC__Record_Assigner_end 9.996 + #define HOLISTIC__Record_Work_start 9.997 + #define HOLISTIC__Record_Work_end 9.998 + #define HOLISTIC__Record_HwResponderInvocation_start 9.999 + #define getReturnAddressBeforeLibraryCall(vp_ptr, res_ptr) 9.1000 +#endif 9.1001 + 9.1002 +//Experiment in two-step macros -- if doesn't work, insert each separately 9.1003 +#define MEAS__Insert_Meas_Fields_into_Slave \ 9.1004 + MEAS__Insert_Susp_Meas_Fields_into_Slave \ 9.1005 + MEAS__Insert_Master_Meas_Fields_into_Slave \ 9.1006 + MEAS__Insert_System_Meas_Fields_into_Slave 9.1007 + 9.1008 + 9.1009 +//====================== Histogram Macros -- Create ======================== 9.1010 +// 9.1011 +// 9.1012 + 9.1013 +//The language implementation should include a definition of this macro, 9.1014 +// which creates all the histograms the language uses to collect measurements 9.1015 +// of plugin operation -- so, if the language didn't define it, must 9.1016 +// define it here (as empty), to avoid compile error 9.1017 +#ifndef MEAS__Make_Meas_Hists_for_Language 9.1018 +#define MEAS__Make_Meas_Hists_for_Language 9.1019 +#endif 9.1020 + 9.1021 +#define makeAMeasHist( histInfo, idx, name, numBins, startVal, binWidth ) \ 9.1022 + makeHighestDynArrayIndexBeAtLeast( _PRTopEnv->measHistsInfo, idx ); \ 9.1023 + _PRTopEnv->measHists[idx] = \ 9.1024 + makeFixedBinHist( numBins, startVal, binWidth, name ); 9.1025 + 9.1026 +//============================== Probes =================================== 9.1027 + 9.1028 + 9.1029 +//=========================================================================== 9.1030 +#endif /* _PR_DEFS_MEAS_H */ 9.1031 +
10.1 --- a/Services_offered_by_PR/prdependency.h Thu Aug 08 02:39:56 2013 -0700 10.2 +++ b/Services_offered_by_PR/prdependency.h Thu Aug 08 03:00:36 2013 -0700 10.3 @@ -1,57 +1,57 @@ 10.4 -/* 10.5 - * Copyright 2011 OpenSourceResearchInstitute.org 10.6 - * Licensed under GNU General Public License version 2 10.7 - * 10.8 - * Author: Nina Engelhardt 10.9 - * 10.10 - */ 10.11 - 10.12 -#ifndef _PRDEPENDENCY_H 10.13 -#define _PRDEPENDENCY_H 10.14 - 10.15 - 10.16 -#include <stdio.h> 10.17 -#include <PR__include/prlistofarrays.h> 10.18 - 10.19 -typedef struct { 10.20 - int vp; 10.21 - int task; 10.22 -} Unit; 10.23 - 10.24 -typedef struct { 10.25 - int from_vp; 10.26 - int from_task; 10.27 - int to_vp; 10.28 - int to_task; 10.29 -} Dependency; 10.30 - 10.31 -typedef struct { 10.32 - int32 id; 10.33 - ListOfArrays* senders; 10.34 - ListOfArrays* receivers; 10.35 -} NtoN; 10.36 - 10.37 -FILE* dependency_file; 10.38 - 10.39 -Dependency* new_dependency(int from_vp, int from_task, int to_vp, int to_task); 10.40 - 10.41 -NtoN* new_NtoN(int id); 10.42 - 10.43 -int set_dependency_file(FILE* file); 10.44 - 10.45 -void print_ctl_dependency_to_file(void* _dep); 10.46 - 10.47 -void print_comm_dependency_to_file(void* _dep); 10.48 - 10.49 -void print_dyn_dependency_to_file(void* _dep); 10.50 - 10.51 -void print_hw_dependency_to_file(void* _dep); 10.52 - 10.53 -void print_dependency_to_file(void* dep); 10.54 - 10.55 -void print_unit_to_file(void* unit); 10.56 - 10.57 -void print_nton_to_file(void* _nton); 10.58 - 10.59 -#endif /* DEPENDENCY_H */ 10.60 - 10.61 +/* 10.62 + * Copyright 2011 OpenSourceResearchInstitute.org 10.63 + * Licensed under GNU General Public License version 2 10.64 + * 10.65 + * Author: Nina Engelhardt 10.66 + * 10.67 + */ 10.68 + 10.69 +#ifndef _PRDEPENDENCY_H 10.70 +#define _PRDEPENDENCY_H 10.71 + 10.72 + 10.73 +#include <stdio.h> 10.74 +#include <PR__include/prlistofarrays.h> 10.75 + 10.76 +typedef struct { 10.77 + int vp; 10.78 + int task; 10.79 +} Unit; 10.80 + 10.81 +typedef struct { 10.82 + int from_vp; 10.83 + int from_task; 10.84 + int to_vp; 10.85 + int to_task; 10.86 +} Dependency; 10.87 + 10.88 +typedef struct { 10.89 + int32 id; 10.90 + ListOfArrays* senders; 10.91 + ListOfArrays* receivers; 10.92 +} NtoN; 10.93 + 10.94 +FILE* dependency_file; 10.95 + 10.96 +Dependency* new_dependency(int from_vp, int from_task, int to_vp, int to_task); 10.97 + 10.98 +NtoN* new_NtoN(int id); 10.99 + 10.100 +int set_dependency_file(FILE* file); 10.101 + 10.102 +void print_ctl_dependency_to_file(void* _dep); 10.103 + 10.104 +void print_comm_dependency_to_file(void* _dep); 10.105 + 10.106 +void print_dyn_dependency_to_file(void* _dep); 10.107 + 10.108 +void print_hw_dependency_to_file(void* _dep); 10.109 + 10.110 +void print_dependency_to_file(void* dep); 10.111 + 10.112 +void print_unit_to_file(void* unit); 10.113 + 10.114 +void print_nton_to_file(void* _nton); 10.115 + 10.116 +#endif /* DEPENDENCY_H */ 10.117 +
11.1 --- a/Services_offered_by_PR/probes__wrapper_library.h Thu Aug 08 02:39:56 2013 -0700 11.2 +++ b/Services_offered_by_PR/probes__wrapper_library.h Thu Aug 08 03:00:36 2013 -0700 11.3 @@ -1,44 +1,44 @@ 11.4 -/* 11.5 - * Copyright 2009 OpenSourceStewardshipFoundation.org 11.6 - * Licensed under GNU General Public License version 2 11.7 - * 11.8 - * Author: seanhalle@yahoo.com 11.9 - * 11.10 - */ 11.11 - 11.12 -/*NOTE: this file should only be included AFTER some other 11.13 - * file has defined which kind of probe to use, and whether 11.14 - * probes are turned on or off.. 11.15 - * 11.16 - *In other words, this is a static library that uses macros, 11.17 - * and there are multiple versions of the same macro.. which 11.18 - * version gets used depends on #define statements in a 11.19 - * DIFFERENT file.. (traditionally PR_defs__turn_on_and_off.h) 11.20 - * 11.21 - *So, this file relies on #defines that appear in other files, 11.22 - * which must come first in the sequence of #includes that 11.23 - * include this one.. 11.24 - */ 11.25 - 11.26 -#ifndef _PROBES_wrapper_library_H 11.27 -#define _PROBES_wrapper_library_H 11.28 -#define _GNU_SOURCE 11.29 - 11.30 -//========================================================= 11.31 -// Use only these aliases within application code 11.32 -//========================================================= 11.33 - 11.34 - 11.35 -#define PR_App__record_time_point_into_new_probe PR_WL__record_time_point_into_new_probe 11.36 -#define PR_App__create_single_interval_probe PR_WL__create_single_interval_probe 11.37 -#define PR_App__create_histogram_probe PR_WL__create_histogram_probe 11.38 -#define PR_App__index_probe_by_its_name PR_WL__index_probe_by_its_name 11.39 -#define PR_App__get_probe_by_name PR_WL__get_probe_by_name 11.40 -#define PR_App__record_sched_choice_into_probe PR_WL__record_sched_choice_into_probe 11.41 -#define PR_App__record_interval_start_in_probe PR_WL__record_interval_start_in_probe 11.42 -#define PR_App__record_interval_end_in_probe PR_WL__record_interval_end_in_probe 11.43 -#define PR_App__print_stats_of_probe PR_WL__print_stats_of_probe 11.44 -#define PR_App__print_stats_of_all_probes PR_WL__print_stats_of_all_probes 11.45 - 11.46 -#endif /* top ifndef */ 11.47 - 11.48 +/* 11.49 + * Copyright 2009 OpenSourceStewardshipFoundation.org 11.50 + * Licensed under GNU General Public License version 2 11.51 + * 11.52 + * Author: seanhalle@yahoo.com 11.53 + * 11.54 + */ 11.55 + 11.56 +/*NOTE: this file should only be included AFTER some other 11.57 + * file has defined which kind of probe to use, and whether 11.58 + * probes are turned on or off.. 11.59 + * 11.60 + *In other words, this is a static library that uses macros, 11.61 + * and there are multiple versions of the same macro.. which 11.62 + * version gets used depends on #define statements in a 11.63 + * DIFFERENT file.. (traditionally PR_defs__turn_on_and_off.h) 11.64 + * 11.65 + *So, this file relies on #defines that appear in other files, 11.66 + * which must come first in the sequence of #includes that 11.67 + * include this one.. 11.68 + */ 11.69 + 11.70 +#ifndef _PROBES_wrapper_library_H 11.71 +#define _PROBES_wrapper_library_H 11.72 +#define _GNU_SOURCE 11.73 + 11.74 +//========================================================= 11.75 +// Use only these aliases within application code 11.76 +//========================================================= 11.77 + 11.78 + 11.79 +#define PR_App__record_time_point_into_new_probe PR_WL__record_time_point_into_new_probe 11.80 +#define PR_App__create_single_interval_probe PR_WL__create_single_interval_probe 11.81 +#define PR_App__create_histogram_probe PR_WL__create_histogram_probe 11.82 +#define PR_App__index_probe_by_its_name PR_WL__index_probe_by_its_name 11.83 +#define PR_App__get_probe_by_name PR_WL__get_probe_by_name 11.84 +#define PR_App__record_sched_choice_into_probe PR_WL__record_sched_choice_into_probe 11.85 +#define PR_App__record_interval_start_in_probe PR_WL__record_interval_start_in_probe 11.86 +#define PR_App__record_interval_end_in_probe PR_WL__record_interval_end_in_probe 11.87 +#define PR_App__print_stats_of_probe PR_WL__print_stats_of_probe 11.88 +#define PR_App__print_stats_of_all_probes PR_WL__print_stats_of_all_probes 11.89 + 11.90 +#endif /* top ifndef */ 11.91 +
12.1 --- a/__README__about_dir.txt Thu Aug 08 02:39:56 2013 -0700 12.2 +++ b/__README__about_dir.txt Thu Aug 08 03:00:36 2013 -0700 12.3 @@ -1,7 +1,7 @@ 12.4 - 12.5 -This directory is a copy of /usr/include/PR__include 12.6 - 12.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). 12.8 - 12.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. 12.10 - 12.11 + 12.12 +This directory is a copy of /usr/include/PR__include 12.13 + 12.14 +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). 12.15 + 12.16 +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. 12.17 +
13.1 --- a/langlets/vreo_wrapper_library.h Thu Aug 08 02:39:56 2013 -0700 13.2 +++ b/langlets/vreo_wrapper_library.h Thu Aug 08 03:00:36 2013 -0700 13.3 @@ -1,264 +1,264 @@ 13.4 -/* 13.5 - * Copyright 2009 OpenSourceResearchInstitute.org 13.6 - * Licensed under GNU General Public License version 2 13.7 - * 13.8 - * Author: seanhalle@yahoo.com 13.9 - * 13.10 - */ 13.11 - 13.12 -#ifndef _VREO_WRAPPER_H 13.13 -#define _VREO_WRAPPER_H 13.14 - 13.15 -#include <PR__include/PR__structs__common.h> 13.16 -//#include <PR__include/prqueue.h> 13.17 -//#include <PR__include/prhash.h> 13.18 -//#include "Measurement/dependency.h" 13.19 - 13.20 - //uniquely identifies VSs -- should be a jenkins char-hash of "VSs" to int32 13.21 -#define VReo_MAGIC_NUMBER 0000000003 13.22 - 13.23 -//=========================================================================== 13.24 -/* 13.25 - //uniquely identifies VSs -- should be a jenkins char-hash of "VSs" to int32 13.26 -#define VReo_MAGIC_NUMBER 0000000003 13.27 - 13.28 -#define NUM_STRUCS_IN_LANG_ENV 1000 13.29 - 13.30 - //This is hardware dependent -- it's the number of cycles of scheduling 13.31 - // overhead -- if a work unit is fewer than this, it is better being 13.32 - // combined sequentially with other work 13.33 - //This value depends on both PR overhead and VSs's plugin. At some point 13.34 - // it will be derived by perf-counter measurements during init of VSs 13.35 -#define MIN_WORK_UNIT_CYCLES 20000 13.36 -*/ 13.37 - 13.38 -//=========================================================================== 13.39 -/*This header defines everything specific to the VReo semantic plug-in 13.40 - */ 13.41 -typedef struct _VReoIsland VReoIsland; 13.42 - 13.43 -//typedef struct _VReoLangReq VReoLangReq; 13.44 -//typedef struct _VReoTaskStub VReoTaskStub; 13.45 -//typedef void (*VReoTaskFnPtr ) ( void *, SlaveVP *); 13.46 -typedef bool32 (*VReoCheckerFn ) ( VReoIsland * ); 13.47 -typedef void (*VReoDoerFn ) ( VReoIsland * ); 13.48 -//=========================================================================== 13.49 - 13.50 -/* 13.51 -#define IS_A_VP NULL 13.52 -#define IS_ENDED NULL 13.53 -#define SEED_SLV NULL 13.54 - 13.55 -#define NO_ID NULL 13.56 -#define ANY_CORE -1 13.57 -*/ 13.58 - 13.59 -//=========================================================================== 13.60 - 13.61 -typedef struct 13.62 - { 13.63 - void *buffer; 13.64 - bool32 portIsFull; 13.65 - SlaveVP *waitingReaderVP; //doubles as flag 13.66 - SlaveVP *waitingWriterVP; 13.67 - 13.68 - void *reader; //either island or VP 13.69 - void *writer; //either island or VP 13.70 - 13.71 - int32 numReaderCheckerFns; 13.72 - VReoCheckerFn *readerCheckerFns; //checkers triggered when port state changes 13.73 - VReoDoerFn *readerDoerFns; //corresponding doer functions 13.74 - 13.75 - int32 numWriterCheckerFns; 13.76 - VReoCheckerFn *writerCheckerFns; //checkers triggered when port state changes 13.77 - VReoDoerFn *writerDoerFns; //corresponding doer functions 13.78 - } 13.79 -VReoPort; 13.80 - 13.81 -struct _VReoIsland 13.82 - { 13.83 - int32 numPorts; 13.84 - VReoPort **ports; //array of pointers to port structs 13.85 - 13.86 - int32 numCheckerFns; 13.87 - VReoCheckerFn *checkerFns; //checkers triggered when state changes 13.88 - VReoDoerFn *doerFns; //corresponding doer functions 13.89 - 13.90 - int32 lastCheckerToSucceed; 13.91 - }; 13.92 -//VReoIsland 13.93 - 13.94 -typedef struct _VReoListElem VReoListElem; 13.95 - 13.96 -struct _VReoListElem 13.97 - { 13.98 - void *payload; 13.99 - VReoListElem *next; 13.100 - }; 13.101 -//VReoListElem 13.102 - 13.103 -typedef struct 13.104 - { 13.105 - int32 numPorts; // 13.106 - VReoPort *ports; //array of port structs 13.107 - VReoPort **boundaryPorts; 13.108 - 13.109 - int32 numIslands; 13.110 - VReoIsland *islands; //array of island structs -- no pointers 13.111 - 13.112 - int32 numVPs; 13.113 - VReoListElem *VPs; 13.114 - 13.115 - int32 suspendScope; //given to PR -- VPs created suspended 13.116 - } 13.117 -VReoCircuit; 13.118 - 13.119 -//Every application-defined birth param struct must have a pointer to a 13.120 -// circuit as its first field. An instance of one of those app-defined 13.121 -// structs is then cast to be a VReoBirthParams, in order for VReo to 13.122 -// access the circuit field without knowing anything about the app-specific 13.123 -// part of the structure 13.124 -typedef struct 13.125 - { 13.126 - VReoCircuit *circuit; 13.127 - } 13.128 -VReoBirthParams; 13.129 - 13.130 -/*This is VReo's "lang meta task" 13.131 - *See the proto-runtime wiki entry to learn about "lang meta task" 13.132 - *In essence, this holds all the meta information that VReo needs about a task 13.133 - */ 13.134 -/* 13.135 -struct _VReoTaskStub 13.136 - { 13.137 - VReoTaskStub *parentTaskStub; //for liveness, for the wait construct 13.138 - int32 numLiveChildTasks; 13.139 - int32 numLiveChildVPs; 13.140 - bool32 isWaitingForChildTasksToEnd; 13.141 - bool32 isWaitingForChildVPsToEnd; 13.142 - bool32 isEnded; 13.143 - }; 13.144 -*/ 13.145 - 13.146 - 13.147 -/*Semantic-layer-specific data sent inside a request from lib call in app 13.148 - * to request handler called in AnimationMaster 13.149 - */ 13.150 -/* 13.151 -struct _VReoLangReq 13.152 - { 13.153 - SlaveVP *callingVP; 13.154 - 13.155 - BirthFnPtr fnPtr; 13.156 - void *initData; 13.157 - int32 coreToAssignOnto; 13.158 - int32 createSuspendedGroup; 13.159 - 13.160 - VReoCircuit *circuit; 13.161 - VReoPort *port; 13.162 - void *itemToPut; 13.163 - } 13.164 -*/ 13.165 -/* VReoLangReq */; 13.166 - 13.167 - 13.168 -/* 13.169 -typedef struct 13.170 - { 13.171 - PrivQueueStruc *slaveReadyQ; //Shared (slaves not pinned) 13.172 - PrivQueueStruc *taskReadyQ; //Shared (tasks not pinned) 13.173 - 13.174 - int32 nextCoreToGetNewSlv; 13.175 - int32 primitiveStartTime; 13.176 - 13.177 - VReoCircuit *circuit; //used during debugging, to get access when no work 13.178 - 13.179 - #ifdef HOLISTIC__TURN_ON_OBSERVE_UCC 13.180 - ListOfArrays* unitList; 13.181 - ListOfArrays* ctlDependenciesList; 13.182 - ListOfArrays* commDependenciesList; 13.183 - NtoN** ntonGroups; 13.184 - PrivDynArrayInfo* ntonGroupsInfo; 13.185 - ListOfArrays* dynDependenciesList; 13.186 - Unit last_in_slot[NUM_CORES * NUM_ANIM_SLOTS]; 13.187 - ListOfArrays* hwArcs; 13.188 - #endif 13.189 - 13.190 - #ifdef HOLISTIC__TURN_ON_PERF_COUNTERS 13.191 - ListOfArrays* counterList[NUM_CORES]; 13.192 - #endif 13.193 - } 13.194 -VReoLangEnv; 13.195 - 13.196 - 13.197 -typedef struct 13.198 - { 13.199 - VReoCircuit *circuit; 13.200 - int32 numPorts; 13.201 - int32 *ports; 13.202 - } 13.203 -VReoVPParams; 13.204 - 13.205 -typedef struct 13.206 - { 13.207 - VReoVPParams *params; //keep here, so can free when end VP 13.208 - } 13.209 -VReoLangData; 13.210 -*/ 13.211 - 13.212 -//=========================================================================== 13.213 - 13.214 -//======================= 13.215 - 13.216 -void 13.217 -VReo__start( SlaveVP *seedVP ); 13.218 - 13.219 -void 13.220 -VReo__shutdown( SlaveVP *seedVP ); 13.221 - 13.222 -void 13.223 -VReo__wait_for_all_VReo_created_work_to_end( SlaveVP *seedVP ); 13.224 - 13.225 -//======================= 13.226 - 13.227 -void 13.228 -VReo__put_into_port( void *itemToPut, VReoPort *port, SlaveVP *callingVP ); 13.229 - 13.230 -void * 13.231 -VReo__get_from_port( VReoPort *port, SlaveVP *callingVP ); 13.232 - 13.233 - 13.234 - 13.235 -SlaveVP * 13.236 -VReo__create_VP( BirthFnPtr fnPtr, void *_params, 13.237 - VReoCircuit *circuit, SlaveVP *creatingVP ); 13.238 - 13.239 -void 13.240 -VReo__end_VP( SlaveVP *VPToEnd ); 13.241 - 13.242 - 13.243 -//======================= 13.244 - 13.245 - 13.246 -//========================= Internal use only ============================= 13.247 -/* 13.248 -bool32 13.249 -VReo__assign_work_to_slot( void *_langEnv, AnimSlot *slot ); 13.250 - 13.251 -SlaveVP * 13.252 -VReo__create_slave_with_affinity( BirthFnPtr fnPtr, void *initData, 13.253 - SlaveVP *creatingSlv, int32 coreToAssignOnto); 13.254 - 13.255 -void 13.256 -VReo__cleanup_after_shutdown(); 13.257 - 13.258 -//===================== ===================== 13.259 - 13.260 -#include "VReo_Request_Handlers.h" 13.261 - 13.262 -//===================== Measurement of Lang Overheads ===================== 13.263 -#include "Measurement/VReo_Measurement.h" 13.264 -*/ 13.265 -//=========================================================================== 13.266 -#endif /* _VReo_H */ 13.267 - 13.268 +/* 13.269 + * Copyright 2009 OpenSourceResearchInstitute.org 13.270 + * Licensed under GNU General Public License version 2 13.271 + * 13.272 + * Author: seanhalle@yahoo.com 13.273 + * 13.274 + */ 13.275 + 13.276 +#ifndef _VREO_WRAPPER_H 13.277 +#define _VREO_WRAPPER_H 13.278 + 13.279 +#include <PR__include/PR__structs__common.h> 13.280 +//#include <PR__include/prqueue.h> 13.281 +//#include <PR__include/prhash.h> 13.282 +//#include "Measurement/dependency.h" 13.283 + 13.284 + //uniquely identifies VSs -- should be a jenkins char-hash of "VSs" to int32 13.285 +#define VReo_MAGIC_NUMBER 0000000003 13.286 + 13.287 +//=========================================================================== 13.288 +/* 13.289 + //uniquely identifies VSs -- should be a jenkins char-hash of "VSs" to int32 13.290 +#define VReo_MAGIC_NUMBER 0000000003 13.291 + 13.292 +#define NUM_STRUCS_IN_LANG_ENV 1000 13.293 + 13.294 + //This is hardware dependent -- it's the number of cycles of scheduling 13.295 + // overhead -- if a work unit is fewer than this, it is better being 13.296 + // combined sequentially with other work 13.297 + //This value depends on both PR overhead and VSs's plugin. At some point 13.298 + // it will be derived by perf-counter measurements during init of VSs 13.299 +#define MIN_WORK_UNIT_CYCLES 20000 13.300 +*/ 13.301 + 13.302 +//=========================================================================== 13.303 +/*This header defines everything specific to the VReo semantic plug-in 13.304 + */ 13.305 +typedef struct _VReoIsland VReoIsland; 13.306 + 13.307 +//typedef struct _VReoLangReq VReoLangReq; 13.308 +//typedef struct _VReoTaskStub VReoTaskStub; 13.309 +//typedef void (*VReoTaskFnPtr ) ( void *, SlaveVP *); 13.310 +typedef bool32 (*VReoCheckerFn ) ( VReoIsland * ); 13.311 +typedef void (*VReoDoerFn ) ( VReoIsland * ); 13.312 +//=========================================================================== 13.313 + 13.314 +/* 13.315 +#define IS_A_VP NULL 13.316 +#define IS_ENDED NULL 13.317 +#define SEED_SLV NULL 13.318 + 13.319 +#define NO_ID NULL 13.320 +#define ANY_CORE -1 13.321 +*/ 13.322 + 13.323 +//=========================================================================== 13.324 + 13.325 +typedef struct 13.326 + { 13.327 + void *buffer; 13.328 + bool32 portIsFull; 13.329 + SlaveVP *waitingReaderVP; //doubles as flag 13.330 + SlaveVP *waitingWriterVP; 13.331 + 13.332 + void *reader; //either island or VP 13.333 + void *writer; //either island or VP 13.334 + 13.335 + int32 numReaderCheckerFns; 13.336 + VReoCheckerFn *readerCheckerFns; //checkers triggered when port state changes 13.337 + VReoDoerFn *readerDoerFns; //corresponding doer functions 13.338 + 13.339 + int32 numWriterCheckerFns; 13.340 + VReoCheckerFn *writerCheckerFns; //checkers triggered when port state changes 13.341 + VReoDoerFn *writerDoerFns; //corresponding doer functions 13.342 + } 13.343 +VReoPort; 13.344 + 13.345 +struct _VReoIsland 13.346 + { 13.347 + int32 numPorts; 13.348 + VReoPort **ports; //array of pointers to port structs 13.349 + 13.350 + int32 numCheckerFns; 13.351 + VReoCheckerFn *checkerFns; //checkers triggered when state changes 13.352 + VReoDoerFn *doerFns; //corresponding doer functions 13.353 + 13.354 + int32 lastCheckerToSucceed; 13.355 + }; 13.356 +//VReoIsland 13.357 + 13.358 +typedef struct _VReoListElem VReoListElem; 13.359 + 13.360 +struct _VReoListElem 13.361 + { 13.362 + void *payload; 13.363 + VReoListElem *next; 13.364 + }; 13.365 +//VReoListElem 13.366 + 13.367 +typedef struct 13.368 + { 13.369 + int32 numPorts; // 13.370 + VReoPort *ports; //array of port structs 13.371 + VReoPort **boundaryPorts; 13.372 + 13.373 + int32 numIslands; 13.374 + VReoIsland *islands; //array of island structs -- no pointers 13.375 + 13.376 + int32 numVPs; 13.377 + VReoListElem *VPs; 13.378 + 13.379 + int32 suspendScope; //given to PR -- VPs created suspended 13.380 + } 13.381 +VReoCircuit; 13.382 + 13.383 +//Every application-defined birth param struct must have a pointer to a 13.384 +// circuit as its first field. An instance of one of those app-defined 13.385 +// structs is then cast to be a VReoBirthParams, in order for VReo to 13.386 +// access the circuit field without knowing anything about the app-specific 13.387 +// part of the structure 13.388 +typedef struct 13.389 + { 13.390 + VReoCircuit *circuit; 13.391 + } 13.392 +VReoBirthParams; 13.393 + 13.394 +/*This is VReo's "lang meta task" 13.395 + *See the proto-runtime wiki entry to learn about "lang meta task" 13.396 + *In essence, this holds all the meta information that VReo needs about a task 13.397 + */ 13.398 +/* 13.399 +struct _VReoTaskStub 13.400 + { 13.401 + VReoTaskStub *parentTaskStub; //for liveness, for the wait construct 13.402 + int32 numLiveChildTasks; 13.403 + int32 numLiveChildVPs; 13.404 + bool32 isWaitingForChildTasksToEnd; 13.405 + bool32 isWaitingForChildVPsToEnd; 13.406 + bool32 isEnded; 13.407 + }; 13.408 +*/ 13.409 + 13.410 + 13.411 +/*Semantic-layer-specific data sent inside a request from lib call in app 13.412 + * to request handler called in AnimationMaster 13.413 + */ 13.414 +/* 13.415 +struct _VReoLangReq 13.416 + { 13.417 + SlaveVP *callingVP; 13.418 + 13.419 + BirthFnPtr fnPtr; 13.420 + void *initData; 13.421 + int32 coreToAssignOnto; 13.422 + int32 createSuspendedGroup; 13.423 + 13.424 + VReoCircuit *circuit; 13.425 + VReoPort *port; 13.426 + void *itemToPut; 13.427 + } 13.428 +*/ 13.429 +/* VReoLangReq */; 13.430 + 13.431 + 13.432 +/* 13.433 +typedef struct 13.434 + { 13.435 + PrivQueueStruc *slaveReadyQ; //Shared (slaves not pinned) 13.436 + PrivQueueStruc *taskReadyQ; //Shared (tasks not pinned) 13.437 + 13.438 + int32 nextCoreToGetNewSlv; 13.439 + int32 primitiveStartTime; 13.440 + 13.441 + VReoCircuit *circuit; //used during debugging, to get access when no work 13.442 + 13.443 + #ifdef HOLISTIC__TURN_ON_OBSERVE_UCC 13.444 + ListOfArrays* unitList; 13.445 + ListOfArrays* ctlDependenciesList; 13.446 + ListOfArrays* commDependenciesList; 13.447 + NtoN** ntonGroups; 13.448 + PrivDynArrayInfo* ntonGroupsInfo; 13.449 + ListOfArrays* dynDependenciesList; 13.450 + Unit last_in_slot[NUM_CORES * NUM_ANIM_SLOTS]; 13.451 + ListOfArrays* hwArcs; 13.452 + #endif 13.453 + 13.454 + #ifdef HOLISTIC__TURN_ON_PERF_COUNTERS 13.455 + ListOfArrays* counterList[NUM_CORES]; 13.456 + #endif 13.457 + } 13.458 +VReoLangEnv; 13.459 + 13.460 + 13.461 +typedef struct 13.462 + { 13.463 + VReoCircuit *circuit; 13.464 + int32 numPorts; 13.465 + int32 *ports; 13.466 + } 13.467 +VReoVPParams; 13.468 + 13.469 +typedef struct 13.470 + { 13.471 + VReoVPParams *params; //keep here, so can free when end VP 13.472 + } 13.473 +VReoLangData; 13.474 +*/ 13.475 + 13.476 +//=========================================================================== 13.477 + 13.478 +//======================= 13.479 + 13.480 +void 13.481 +VReo__start( SlaveVP *seedVP ); 13.482 + 13.483 +void 13.484 +VReo__shutdown( SlaveVP *seedVP ); 13.485 + 13.486 +void 13.487 +VReo__wait_for_all_VReo_created_work_to_end( SlaveVP *seedVP ); 13.488 + 13.489 +//======================= 13.490 + 13.491 +void 13.492 +VReo__put_into_port( void *itemToPut, VReoPort *port, SlaveVP *callingVP ); 13.493 + 13.494 +void * 13.495 +VReo__get_from_port( VReoPort *port, SlaveVP *callingVP ); 13.496 + 13.497 + 13.498 + 13.499 +SlaveVP * 13.500 +VReo__create_VP( BirthFnPtr fnPtr, void *_params, 13.501 + VReoCircuit *circuit, SlaveVP *creatingVP ); 13.502 + 13.503 +void 13.504 +VReo__end_VP( SlaveVP *VPToEnd ); 13.505 + 13.506 + 13.507 +//======================= 13.508 + 13.509 + 13.510 +//========================= Internal use only ============================= 13.511 +/* 13.512 +bool32 13.513 +VReo__assign_work_to_slot( void *_langEnv, AnimSlot *slot ); 13.514 + 13.515 +SlaveVP * 13.516 +VReo__create_slave_with_affinity( BirthFnPtr fnPtr, void *initData, 13.517 + SlaveVP *creatingSlv, int32 coreToAssignOnto); 13.518 + 13.519 +void 13.520 +VReo__cleanup_after_shutdown(); 13.521 + 13.522 +//===================== ===================== 13.523 + 13.524 +#include "VReo_Request_Handlers.h" 13.525 + 13.526 +//===================== Measurement of Lang Overheads ===================== 13.527 +#include "Measurement/VReo_Measurement.h" 13.528 +*/ 13.529 +//=========================================================================== 13.530 +#endif /* _VReo_H */ 13.531 +
14.1 --- a/prdynarray.h Thu Aug 08 02:39:56 2013 -0700 14.2 +++ b/prdynarray.h Thu Aug 08 03:00:36 2013 -0700 14.3 @@ -1,91 +1,91 @@ 14.4 -/* 14.5 - * File: Vector.h 14.6 - * Author: Me 14.7 - * 14.8 - * Created on May 14, 2010, 3:08 PM 14.9 - */ 14.10 - 14.11 -#ifndef _DYNARRAY_H 14.12 -#define _DYNARRAY_H 14.13 - 14.14 -#include <PR__include/PR__primitive_data_types.h> 14.15 - 14.16 - 14.17 - 14.18 -/*WARNING: Passing a DynArray as a param is dangerous if add to the DynArray 14.19 - * inside the function called! After adding or other operation that might 14.20 - * change the size, must re-read the addr of the chunk of memory that is the 14.21 - * array, via the DynArrayInfo. 14.22 - *Here's why: An array variable is a location, either on the stack 14.23 - * or in a field of a struct, whose contents is an addr. That addr is of the 14.24 - * first location of a chunk of locations. The DynArray works by changing 14.25 - * the chunk of locations, then modifying the contents of the original 14.26 - * array variable. It overwrites the addr of the old chunk of locations 14.27 - * with the addr of the new chunk. 14.28 - *But when the array variable is passed as a parameter, such as 14.29 - * in this: "foo( myDynArray )", then there are now two locations that hold 14.30 - * the addr of the same chunk of locations. So when a call is made that 14.31 - * adds to the DynArray, and inside the DynArray expands, it only updates 14.32 - * the original location with the new addr. Hence, the function will begin 14.33 - * overwriting memory past the end of the old chunk, because it still has 14.34 - * the pointer to the old chunk of locations. 14.35 - * 14.36 - *A dynamic array is accessed same as any other array. However, must use 14.37 - * dyn array calls, defined in here, in order to add or increase the size. 14.38 - * Must re-read the original array variable after any size-changing calls. 14.39 - *To pass a DynArray as a parameter to a function, can only pass the 14.40 - * DynArrayInfo, then inside the function, to read the addr of the first 14.41 - * location in the chunk of locations that is the array, do this: 14.42 - * "localArrayCopy = *(myDynArrayInfo->addrOfPtrToArray). After that, can 14.43 - * treat localArrayCopy as a normal array, as long as don't make any calls 14.44 - * that add or otherwise could increase the size of the array. If do make 14.45 - * such a call, then re-copy the array via the above. Can then use the 14.46 - * copy up until another add to the array. 14.47 - * 14.48 - */ 14.49 -typedef struct 14.50 - { 14.51 - void ***addrOfPtrToArray; //addr of var that is array of ptrs == triple * 14.52 - int32 numInArray; //num entries added 14.53 - int32 sizeOfArray; //num elems alloc'd 14.54 - int32 sizeOfElem; //num bytes in one elem of array -- used in 2nd version 14.55 - } 14.56 -PrivDynArrayInfo; 14.57 - 14.58 -PrivDynArrayInfo * 14.59 -makePrivDynArrayInfoFrom( void ***addrOfPtrToArray, int32 sizeOfArray ); 14.60 - 14.61 -PrivDynArrayInfo * 14.62 -makePrivDynArrayOfSize( void ***addrOfPtrToArray, int32 sizeOfArray ); 14.63 - 14.64 -PrivDynArrayInfo * 14.65 -makePrivDynArrayOfSize_Ext( void ***addrOfPtrToArray, int32 sizeOfArray ); 14.66 - 14.67 -int32 14.68 -addToDynArray( void *value, PrivDynArrayInfo *info ); 14.69 - 14.70 -void 14.71 -makeHighestDynArrayIndexBe( PrivDynArrayInfo *info, int32 highestIndex ); 14.72 - 14.73 -void 14.74 -makeHighestDynArrayIndexBeAtLeast(PrivDynArrayInfo *info,int32 highestIndex); 14.75 - 14.76 -void 14.77 -increaseSizeOfDynArrayTo( PrivDynArrayInfo *info, int32 newSize ); 14.78 - 14.79 -typedef void (*FreeFnPtr) ( void * ); //fn has to cast void * to whatever 14.80 - 14.81 -void 14.82 -freeDynArrayDeep( PrivDynArrayInfo *info, FreeFnPtr freeFnPtr ); 14.83 - 14.84 -void 14.85 -freeDynArrayFlat( PrivDynArrayInfo *info ); 14.86 - 14.87 - 14.88 -typedef void (*DynArrayFnPtr) ( void * ); //fn has to cast void * 14.89 - 14.90 -void 14.91 -forAllInDynArrayDo( PrivDynArrayInfo *info, DynArrayFnPtr fnPtr ); 14.92 - 14.93 -#endif /* _DYNARRAY_H */ 14.94 - 14.95 +/* 14.96 + * File: Vector.h 14.97 + * Author: Me 14.98 + * 14.99 + * Created on May 14, 2010, 3:08 PM 14.100 + */ 14.101 + 14.102 +#ifndef _DYNARRAY_H 14.103 +#define _DYNARRAY_H 14.104 + 14.105 +#include <PR__include/PR__primitive_data_types.h> 14.106 + 14.107 + 14.108 + 14.109 +/*WARNING: Passing a DynArray as a param is dangerous if add to the DynArray 14.110 + * inside the function called! After adding or other operation that might 14.111 + * change the size, must re-read the addr of the chunk of memory that is the 14.112 + * array, via the DynArrayInfo. 14.113 + *Here's why: An array variable is a location, either on the stack 14.114 + * or in a field of a struct, whose contents is an addr. That addr is of the 14.115 + * first location of a chunk of locations. The DynArray works by changing 14.116 + * the chunk of locations, then modifying the contents of the original 14.117 + * array variable. It overwrites the addr of the old chunk of locations 14.118 + * with the addr of the new chunk. 14.119 + *But when the array variable is passed as a parameter, such as 14.120 + * in this: "foo( myDynArray )", then there are now two locations that hold 14.121 + * the addr of the same chunk of locations. So when a call is made that 14.122 + * adds to the DynArray, and inside the DynArray expands, it only updates 14.123 + * the original location with the new addr. Hence, the function will begin 14.124 + * overwriting memory past the end of the old chunk, because it still has 14.125 + * the pointer to the old chunk of locations. 14.126 + * 14.127 + *A dynamic array is accessed same as any other array. However, must use 14.128 + * dyn array calls, defined in here, in order to add or increase the size. 14.129 + * Must re-read the original array variable after any size-changing calls. 14.130 + *To pass a DynArray as a parameter to a function, can only pass the 14.131 + * DynArrayInfo, then inside the function, to read the addr of the first 14.132 + * location in the chunk of locations that is the array, do this: 14.133 + * "localArrayCopy = *(myDynArrayInfo->addrOfPtrToArray). After that, can 14.134 + * treat localArrayCopy as a normal array, as long as don't make any calls 14.135 + * that add or otherwise could increase the size of the array. If do make 14.136 + * such a call, then re-copy the array via the above. Can then use the 14.137 + * copy up until another add to the array. 14.138 + * 14.139 + */ 14.140 +typedef struct 14.141 + { 14.142 + void ***addrOfPtrToArray; //addr of var that is array of ptrs == triple * 14.143 + int32 numInArray; //num entries added 14.144 + int32 sizeOfArray; //num elems alloc'd 14.145 + int32 sizeOfElem; //num bytes in one elem of array -- used in 2nd version 14.146 + } 14.147 +PrivDynArrayInfo; 14.148 + 14.149 +PrivDynArrayInfo * 14.150 +makePrivDynArrayInfoFrom( void ***addrOfPtrToArray, int32 sizeOfArray ); 14.151 + 14.152 +PrivDynArrayInfo * 14.153 +makePrivDynArrayOfSize( void ***addrOfPtrToArray, int32 sizeOfArray ); 14.154 + 14.155 +PrivDynArrayInfo * 14.156 +makePrivDynArrayOfSize_Ext( void ***addrOfPtrToArray, int32 sizeOfArray ); 14.157 + 14.158 +int32 14.159 +addToDynArray( void *value, PrivDynArrayInfo *info ); 14.160 + 14.161 +void 14.162 +makeHighestDynArrayIndexBe( PrivDynArrayInfo *info, int32 highestIndex ); 14.163 + 14.164 +void 14.165 +makeHighestDynArrayIndexBeAtLeast(PrivDynArrayInfo *info,int32 highestIndex); 14.166 + 14.167 +void 14.168 +increaseSizeOfDynArrayTo( PrivDynArrayInfo *info, int32 newSize ); 14.169 + 14.170 +typedef void (*FreeFnPtr) ( void * ); //fn has to cast void * to whatever 14.171 + 14.172 +void 14.173 +freeDynArrayDeep( PrivDynArrayInfo *info, FreeFnPtr freeFnPtr ); 14.174 + 14.175 +void 14.176 +freeDynArrayFlat( PrivDynArrayInfo *info ); 14.177 + 14.178 + 14.179 +typedef void (*DynArrayFnPtr) ( void * ); //fn has to cast void * 14.180 + 14.181 +void 14.182 +forAllInDynArrayDo( PrivDynArrayInfo *info, DynArrayFnPtr fnPtr ); 14.183 + 14.184 +#endif /* _DYNARRAY_H */ 14.185 +
15.1 --- a/prhash.h Thu Aug 08 02:39:56 2013 -0700 15.2 +++ b/prhash.h Thu Aug 08 03:00:36 2013 -0700 15.3 @@ -1,96 +1,96 @@ 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 -#ifndef _PRHASH_H 15.12 -#define _PRHASH_H 15.13 - 15.14 -#include <stdio.h> 15.15 -#include <string.h> 15.16 -#include <errno.h> 15.17 -#include <stdlib.h> 15.18 - 15.19 -#include <PR__include/PR__primitive_data_types.h> 15.20 - 15.21 -//===================== defines ===================== 15.22 -#define TRUE 1 15.23 -#define FALSE 0 15.24 - 15.25 -#define DEFAULT_HASH_TABLE_SIZE 1 << 10 15.26 -#define DEFAULT_POWER_OF_2_TABLE_SIZE 10 15.27 - 15.28 - 15.29 -//===================== structs ===================== 15.30 -union hashkey_t{ 15.31 - char hashable[8]; 15.32 - int32 parts[2]; 15.33 -}; 15.34 - 15.35 -typedef union hashkey_t hashkey_t; 15.36 - 15.37 -typedef struct _HashEntry HashEntry; 15.38 - 15.39 -struct _HashEntry 15.40 - { 15.41 - char *key; 15.42 - void *content; 15.43 - HashEntry *next; 15.44 - }; 15.45 - 15.46 -typedef void (*FreeEntryContentFnPtr) ( void * ); 15.47 - 15.48 -typedef struct 15.49 - { int32 tableSz; 15.50 - int32 numEntries; 15.51 - HashEntry* *entries; 15.52 - int32 hashMask; 15.53 - int32 prevHash; 15.54 - FreeEntryContentFnPtr freeEntryContentFn; 15.55 - } 15.56 -HashTable; 15.57 - 15.58 - 15.59 -//=========================================================================== 15.60 -// Public functions 15.61 -HashTable *makeHashTable( int numHashSlots, FreeEntryContentFnPtr freeFn ); 15.62 - 15.63 -int32 putEntryIntoTable( HashEntry *entry, HashTable *table); 15.64 -int32 addValueIntoTable( char* key, void *value, HashTable *table); 15.65 -HashEntry *getEntryFromTable( char *key, HashTable *table ); 15.66 -void *getValueFromTable( char *key, HashTable *table ); 15.67 - 15.68 -bool8 deleteEntryFromTable( char *key, HashTable *table ); 15.69 -bool8 deleteThisEntryFromTable( HashEntry *entry, HashTable *table ); 15.70 -bool8 deleteEntrysValueInTable( char *key, HashTable *table ); 15.71 -bool8 deleteEntryFromTableAndFreeValue( char *key, HashTable *table ); 15.72 -void freeHashTable( HashTable *table ); 15.73 -//char *paramBagToString( ParamBag * bag ) 15.74 - 15.75 -//================= Same Fns, but for 32b array key hash fn ================ 15.76 -HashTable *makeHashTable32(int32 powerOf2OfSz, FreeEntryContentFnPtr freeFn); 15.77 -HashTable *makeDefaultSizeHashTable32( FreeEntryContentFnPtr freeFn ); 15.78 - 15.79 -int32 putEntryIntoTable32( HashEntry *entry, HashTable *table); 15.80 -HashEntry *addValueIntoTable32( uint32 key[], void *value, HashTable *table); 15.81 -HashEntry *getEntryFromTable32( uint32 key[], HashTable *table ); 15.82 -void *getValueFromTable32( uint32 key[], HashTable *table ); 15.83 - 15.84 -bool32 deleteEntryFromTable32( uint32 key[], HashTable *table ); 15.85 - 15.86 -//=========================================================================== 15.87 -// Internal functions 15.88 -void freeHashEntryUsing( HashEntry *entry, HashTable *table ); 15.89 -unsigned int hashThisKey( char *s, int hashSz ); 15.90 -void nullOutTablesArray( HashTable *table ); 15.91 -void doubleTableSize( HashTable *table ); 15.92 -void freeHashEntryButNotContent( HashEntry *entry ); 15.93 - 15.94 -uint32 15.95 -jenkHash32( const uint32 *key, /* array of uint32 values */ 15.96 - int32 length); /* num uint32 in the key */ 15.97 - 15.98 -#endif /* _PRIVATE_HASH_H */ 15.99 - 15.100 +/* 15.101 + * Copyright 2009 OpenSourceResearchInstitute.org 15.102 + * Licensed under GNU General Public License version 2 15.103 + * 15.104 + * Author: seanhalle@yahoo.com 15.105 + */ 15.106 + 15.107 +#ifndef _PRHASH_H 15.108 +#define _PRHASH_H 15.109 + 15.110 +#include <stdio.h> 15.111 +#include <string.h> 15.112 +#include <errno.h> 15.113 +#include <stdlib.h> 15.114 + 15.115 +#include <PR__include/PR__primitive_data_types.h> 15.116 + 15.117 +//===================== defines ===================== 15.118 +#define TRUE 1 15.119 +#define FALSE 0 15.120 + 15.121 +#define DEFAULT_HASH_TABLE_SIZE 1 << 10 15.122 +#define DEFAULT_POWER_OF_2_TABLE_SIZE 10 15.123 + 15.124 + 15.125 +//===================== structs ===================== 15.126 +union hashkey_t{ 15.127 + char hashable[8]; 15.128 + int32 parts[2]; 15.129 +}; 15.130 + 15.131 +typedef union hashkey_t hashkey_t; 15.132 + 15.133 +typedef struct _HashEntry HashEntry; 15.134 + 15.135 +struct _HashEntry 15.136 + { 15.137 + char *key; 15.138 + void *content; 15.139 + HashEntry *next; 15.140 + }; 15.141 + 15.142 +typedef void (*FreeEntryContentFnPtr) ( void * ); 15.143 + 15.144 +typedef struct 15.145 + { int32 tableSz; 15.146 + int32 numEntries; 15.147 + HashEntry* *entries; 15.148 + int32 hashMask; 15.149 + int32 prevHash; 15.150 + FreeEntryContentFnPtr freeEntryContentFn; 15.151 + } 15.152 +HashTable; 15.153 + 15.154 + 15.155 +//=========================================================================== 15.156 +// Public functions 15.157 +HashTable *makeHashTable( int numHashSlots, FreeEntryContentFnPtr freeFn ); 15.158 + 15.159 +int32 putEntryIntoTable( HashEntry *entry, HashTable *table); 15.160 +int32 addValueIntoTable( char* key, void *value, HashTable *table); 15.161 +HashEntry *getEntryFromTable( char *key, HashTable *table ); 15.162 +void *getValueFromTable( char *key, HashTable *table ); 15.163 + 15.164 +bool8 deleteEntryFromTable( char *key, HashTable *table ); 15.165 +bool8 deleteThisEntryFromTable( HashEntry *entry, HashTable *table ); 15.166 +bool8 deleteEntrysValueInTable( char *key, HashTable *table ); 15.167 +bool8 deleteEntryFromTableAndFreeValue( char *key, HashTable *table ); 15.168 +void freeHashTable( HashTable *table ); 15.169 +//char *paramBagToString( ParamBag * bag ) 15.170 + 15.171 +//================= Same Fns, but for 32b array key hash fn ================ 15.172 +HashTable *makeHashTable32(int32 powerOf2OfSz, FreeEntryContentFnPtr freeFn); 15.173 +HashTable *makeDefaultSizeHashTable32( FreeEntryContentFnPtr freeFn ); 15.174 + 15.175 +int32 putEntryIntoTable32( HashEntry *entry, HashTable *table); 15.176 +HashEntry *addValueIntoTable32( uint32 key[], void *value, HashTable *table); 15.177 +HashEntry *getEntryFromTable32( uint32 key[], HashTable *table ); 15.178 +void *getValueFromTable32( uint32 key[], HashTable *table ); 15.179 + 15.180 +bool32 deleteEntryFromTable32( uint32 key[], HashTable *table ); 15.181 + 15.182 +//=========================================================================== 15.183 +// Internal functions 15.184 +void freeHashEntryUsing( HashEntry *entry, HashTable *table ); 15.185 +unsigned int hashThisKey( char *s, int hashSz ); 15.186 +void nullOutTablesArray( HashTable *table ); 15.187 +void doubleTableSize( HashTable *table ); 15.188 +void freeHashEntryButNotContent( HashEntry *entry ); 15.189 + 15.190 +uint32 15.191 +jenkHash32( const uint32 *key, /* array of uint32 values */ 15.192 + int32 length); /* num uint32 in the key */ 15.193 + 15.194 +#endif /* _PRIVATE_HASH_H */ 15.195 +
16.1 --- a/prhistogram.h Thu Aug 08 02:39:56 2013 -0700 16.2 +++ b/prhistogram.h Thu Aug 08 03:00:36 2013 -0700 16.3 @@ -1,102 +1,102 @@ 16.4 -/* 16.5 - * Copyright 2010 OpenSourceResearchInstitute.org 16.6 - * Licensed under GNU General Public License version 2 16.7 - * 16.8 - * Author: seanhalle@yahoo.com 16.9 - * 16.10 - */ 16.11 - 16.12 - 16.13 -#ifndef _PRHISTOGRAM_H 16.14 -#define _PRHISTOGRAM_H 16.15 - 16.16 -#include <PR__include/prmalloc.h> 16.17 -#include <PR__include/PR__primitive_data_types.h> 16.18 - 16.19 - 16.20 -typedef struct 16.21 - { 16.22 - char *name; 16.23 - int32 startOfRange; 16.24 - int32 endOfRange; 16.25 - int32 numBins; 16.26 - int32 binWidth; 16.27 - int32 *bins; 16.28 - } 16.29 -Histogram; 16.30 - 16.31 -typedef struct 16.32 - { 16.33 - float32 startOfRange; 16.34 - float32 endOfRange; 16.35 - int32 numBins; 16.36 - float32 binWidth; 16.37 - int32 *bins; 16.38 - } 16.39 -FloatHist; 16.40 - 16.41 -typedef struct 16.42 - { 16.43 - float64 startOfRange; 16.44 - float64 endOfRange; 16.45 - int32 numBins; 16.46 - float64 binWidth; 16.47 - int32 *bins; 16.48 - } 16.49 -DblHist; 16.50 - 16.51 -Histogram * 16.52 -makeHistogram( int32 numBins, int32 startOfRange, int32 endOfRange ); 16.53 - 16.54 -Histogram * 16.55 -makeFixedBinHist( int32 numBins, int32 startOfRange, int32 binWidth, 16.56 - char *name ); 16.57 - 16.58 -Histogram * 16.59 -makeFixedBinHistExt( int32 numBins, int32 startOfRange, int32 binWidth, 16.60 - char *name ); 16.61 - 16.62 -void inline 16.63 -addToHist( int32 value, Histogram *hist ); 16.64 - 16.65 -void inline 16.66 -addIntervalToHist( uint32 startIntvl, uint32 endIntvl, Histogram *hist ); 16.67 - 16.68 -void inline 16.69 -subIntervalFromHist( int32 startIntvl, int32 endIntvl, Histogram *hist ); 16.70 - 16.71 -void 16.72 -saveHistToFile(Histogram *hist); 16.73 - 16.74 -void 16.75 -printHist( Histogram *hist ); 16.76 - 16.77 -FloatHist * 16.78 -makeFloatHistogram( int numBins, float32 startOfRange, float32 binWidth ); 16.79 - 16.80 -void 16.81 -addToFloatHist( float32 value, FloatHist *hist ); 16.82 - 16.83 -void 16.84 -printFloatHist( FloatHist *hist ); 16.85 - 16.86 -void 16.87 -freeHistExt( Histogram *hist ); 16.88 - 16.89 -void 16.90 -freeHist( Histogram *hist ); 16.91 - 16.92 -DblHist * 16.93 -makeDblHistogram( int numBins, float64 startOfRange, float64 binWidth ); 16.94 - 16.95 -void 16.96 -addToDblHist( float64 value, DblHist *hist ); 16.97 - 16.98 -void 16.99 -printDblHist( DblHist *hist ); 16.100 - 16.101 -void 16.102 -freeDblHist( DblHist *hist ); 16.103 - 16.104 -#endif /* _HISTOGRAM_H */ 16.105 - 16.106 +/* 16.107 + * Copyright 2010 OpenSourceResearchInstitute.org 16.108 + * Licensed under GNU General Public License version 2 16.109 + * 16.110 + * Author: seanhalle@yahoo.com 16.111 + * 16.112 + */ 16.113 + 16.114 + 16.115 +#ifndef _PRHISTOGRAM_H 16.116 +#define _PRHISTOGRAM_H 16.117 + 16.118 +#include <PR__include/prmalloc.h> 16.119 +#include <PR__include/PR__primitive_data_types.h> 16.120 + 16.121 + 16.122 +typedef struct 16.123 + { 16.124 + char *name; 16.125 + int32 startOfRange; 16.126 + int32 endOfRange; 16.127 + int32 numBins; 16.128 + int32 binWidth; 16.129 + int32 *bins; 16.130 + } 16.131 +Histogram; 16.132 + 16.133 +typedef struct 16.134 + { 16.135 + float32 startOfRange; 16.136 + float32 endOfRange; 16.137 + int32 numBins; 16.138 + float32 binWidth; 16.139 + int32 *bins; 16.140 + } 16.141 +FloatHist; 16.142 + 16.143 +typedef struct 16.144 + { 16.145 + float64 startOfRange; 16.146 + float64 endOfRange; 16.147 + int32 numBins; 16.148 + float64 binWidth; 16.149 + int32 *bins; 16.150 + } 16.151 +DblHist; 16.152 + 16.153 +Histogram * 16.154 +makeHistogram( int32 numBins, int32 startOfRange, int32 endOfRange ); 16.155 + 16.156 +Histogram * 16.157 +makeFixedBinHist( int32 numBins, int32 startOfRange, int32 binWidth, 16.158 + char *name ); 16.159 + 16.160 +Histogram * 16.161 +makeFixedBinHistExt( int32 numBins, int32 startOfRange, int32 binWidth, 16.162 + char *name ); 16.163 + 16.164 +void inline 16.165 +addToHist( int32 value, Histogram *hist ); 16.166 + 16.167 +void inline 16.168 +addIntervalToHist( uint32 startIntvl, uint32 endIntvl, Histogram *hist ); 16.169 + 16.170 +void inline 16.171 +subIntervalFromHist( int32 startIntvl, int32 endIntvl, Histogram *hist ); 16.172 + 16.173 +void 16.174 +saveHistToFile(Histogram *hist); 16.175 + 16.176 +void 16.177 +printHist( Histogram *hist ); 16.178 + 16.179 +FloatHist * 16.180 +makeFloatHistogram( int numBins, float32 startOfRange, float32 binWidth ); 16.181 + 16.182 +void 16.183 +addToFloatHist( float32 value, FloatHist *hist ); 16.184 + 16.185 +void 16.186 +printFloatHist( FloatHist *hist ); 16.187 + 16.188 +void 16.189 +freeHistExt( Histogram *hist ); 16.190 + 16.191 +void 16.192 +freeHist( Histogram *hist ); 16.193 + 16.194 +DblHist * 16.195 +makeDblHistogram( int numBins, float64 startOfRange, float64 binWidth ); 16.196 + 16.197 +void 16.198 +addToDblHist( float64 value, DblHist *hist ); 16.199 + 16.200 +void 16.201 +printDblHist( DblHist *hist ); 16.202 + 16.203 +void 16.204 +freeDblHist( DblHist *hist ); 16.205 + 16.206 +#endif /* _HISTOGRAM_H */ 16.207 +
17.1 --- a/prmalloc.h Thu Aug 08 02:39:56 2013 -0700 17.2 +++ b/prmalloc.h Thu Aug 08 03:00:36 2013 -0700 17.3 @@ -1,52 +1,52 @@ 17.4 -/* 17.5 - * Copyright 2009 OpenSourceCodeStewardshipFoundation.org 17.6 - * Licensed under GNU General Public License version 2 17.7 - * 17.8 - * Author: seanhalle@yahoo.com 17.9 - * 17.10 - * Created on November 14, 2009, 9:07 PM 17.11 - */ 17.12 - 17.13 -#ifndef _PRMALLOC_H 17.14 -#define _PRMALLOC_H 17.15 - 17.16 -#include <malloc.h> 17.17 -#include <inttypes.h> 17.18 -#include <math.h> 17.19 -#include <PR__include/PR__primitive_data_types.h> 17.20 - 17.21 -void * 17.22 -PR_int__malloc( size_t sizeRequested ); 17.23 - 17.24 -void * 17.25 -PR_int__malloc_aligned( size_t sizeRequested ); 17.26 - 17.27 -void 17.28 -PR_int__free( void *ptrToFree ); 17.29 - 17.30 -//Use these in application code directly 17.31 -#define \ 17.32 -PR__malloc PR_WL__malloc 17.33 - 17.34 -#define \ 17.35 -PR__free PR_WL__free 17.36 - 17.37 -//these are implemented in the PR leaf implementation 17.38 -void * 17.39 -PR_WL__malloc( int32 sizeRequested ); 17.40 - 17.41 -void 17.42 -PR_WL__free( void *ptrToFree ); 17.43 - 17.44 - 17.45 -/*Allocates memory from the external system -- higher overhead 17.46 - */ 17.47 -void * 17.48 -PR_ext__malloc_in_ext( size_t sizeRequested ); 17.49 - 17.50 -/*Frees memory that was allocated in the external system -- higher overhead 17.51 - */ 17.52 -void 17.53 -PR_ext__free_in_ext( void *ptrToFree ); 17.54 - 17.55 +/* 17.56 + * Copyright 2009 OpenSourceCodeStewardshipFoundation.org 17.57 + * Licensed under GNU General Public License version 2 17.58 + * 17.59 + * Author: seanhalle@yahoo.com 17.60 + * 17.61 + * Created on November 14, 2009, 9:07 PM 17.62 + */ 17.63 + 17.64 +#ifndef _PRMALLOC_H 17.65 +#define _PRMALLOC_H 17.66 + 17.67 +#include <malloc.h> 17.68 +#include <inttypes.h> 17.69 +#include <math.h> 17.70 +#include <PR__include/PR__primitive_data_types.h> 17.71 + 17.72 +void * 17.73 +PR_int__malloc( size_t sizeRequested ); 17.74 + 17.75 +void * 17.76 +PR_int__malloc_aligned( size_t sizeRequested ); 17.77 + 17.78 +void 17.79 +PR_int__free( void *ptrToFree ); 17.80 + 17.81 +//Use these in application code directly 17.82 +#define \ 17.83 +PR__malloc PR_WL__malloc 17.84 + 17.85 +#define \ 17.86 +PR__free PR_WL__free 17.87 + 17.88 +//these are implemented in the PR leaf implementation 17.89 +void * 17.90 +PR_WL__malloc( int32 sizeRequested ); 17.91 + 17.92 +void 17.93 +PR_WL__free( void *ptrToFree ); 17.94 + 17.95 + 17.96 +/*Allocates memory from the external system -- higher overhead 17.97 + */ 17.98 +void * 17.99 +PR_ext__malloc_in_ext( size_t sizeRequested ); 17.100 + 17.101 +/*Frees memory that was allocated in the external system -- higher overhead 17.102 + */ 17.103 +void 17.104 +PR_ext__free_in_ext( void *ptrToFree ); 17.105 + 17.106 #endif 17.107 \ No newline at end of file
18.1 --- a/prqueue.h Thu Aug 08 02:39:56 2013 -0700 18.2 +++ b/prqueue.h Thu Aug 08 03:00:36 2013 -0700 18.3 @@ -1,114 +1,114 @@ 18.4 -/* 18.5 - * Copyright 2009 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 -#ifndef _PRQUEUE_H 18.12 -#define _PRQUEUE_H 18.13 - 18.14 -#include <PR__include/PR__primitive_data_types.h> 18.15 -#include <pthread.h> 18.16 - 18.17 -#define TRUE 1 18.18 -#define FALSE 0 18.19 - 18.20 -//================== Private Queue stuff =================== 18.21 -/* It is the data that is shared so only need one mutex. */ 18.22 -typedef struct 18.23 - { void **insertPos; 18.24 - void **extractPos; 18.25 - void **startOfData; //data is pointers 18.26 - void **endOfData; //set when alloc data 18.27 - } 18.28 -PrivQueueStruc; 18.29 - 18.30 -typedef void (*DynArrayFnPtr) ( void * ); //fn has to cast void * 18.31 - 18.32 -PrivQueueStruc* makePrivQ ( ); 18.33 -bool32 isEmptyPrivQ ( PrivQueueStruc *Q ); //ret TRUE if empty 18.34 -void* peekPrivQ ( PrivQueueStruc *Q ); //ret NULL if empty 18.35 -void* readPrivQ ( PrivQueueStruc *Q ); //ret NULL if empty 18.36 -void writePrivQ( void *in, PrivQueueStruc *Q ); 18.37 - //return false when full 18.38 -bool32 writeIfSpacePrivQ( void * in, PrivQueueStruc* Q ); 18.39 -int32 numInPrivQ( PrivQueueStruc *Q ); 18.40 -void pushPrivQ( void * in, PrivQueueStruc* Q ); 18.41 -void freePrivQ( PrivQueueStruc *Q ); 18.42 - 18.43 - 18.44 -//====================== Parallel Queue Stuff ==================== 18.45 - 18.46 -//========== pThreads based queue ========== 18.47 -/* It is the data that is shared so only need one mutex. */ 18.48 -typedef 18.49 -struct 18.50 - { pthread_mutex_t mutex_t; 18.51 - pthread_cond_t cond_w_t; 18.52 - pthread_cond_t cond_r_t; 18.53 - int32 count; 18.54 - int32 readPos; 18.55 - int32 writePos; 18.56 - void* data[1024]; //an array of pointers 18.57 - int w_empty; 18.58 - int w_full; 18.59 - } 18.60 -PThdQueueStruc; 18.61 - 18.62 -PThdQueueStruc* makePThdQ(); 18.63 -void* readPThdQ( PThdQueueStruc *Q ); 18.64 -void writePThdQ( void *in, PThdQueueStruc *Q ); 18.65 - 18.66 - 18.67 -//========== CAS based queue ========== 18.68 -typedef 18.69 -struct 18.70 - { volatile int32 insertLock; 18.71 - volatile int32 extractLock; 18.72 - volatile void* *insertPos; 18.73 - volatile void* *extractPos; 18.74 - void* startOfData[1024]; //data is pointers 18.75 - void* *endOfData; //set when make queue 18.76 - } 18.77 -CASQueueStruc; 18.78 - 18.79 -CASQueueStruc* makeCASQ(); 18.80 -void* readCASQ( CASQueueStruc *Q ); 18.81 -void writeCASQ( void *in, CASQueueStruc *Q ); 18.82 - 18.83 - 18.84 -//========= non-atomic instr based queue =========== 18.85 -typedef 18.86 -struct 18.87 - { void* *insertPos; 18.88 - void* *extractPos; 18.89 - void* startOfData[1024]; //data is pointers 18.90 - void* *endOfData; //set when make queue 18.91 - } 18.92 -SRSWQueueStruc; 18.93 - 18.94 -SRSWQueueStruc* makeSRSWQ(); 18.95 -void freeSRSWQ( SRSWQueueStruc* Q ); 18.96 -void* readSRSWQ( SRSWQueueStruc *Q ); 18.97 -void writeSRSWQ( void *in, SRSWQueueStruc *Q ); 18.98 - 18.99 - 18.100 -//========= non-atomic instr S R M W queue =========== 18.101 -typedef 18.102 -struct 18.103 - { int32 lastQReadFrom; 18.104 - int32 numInternalQs; 18.105 - int32 internalQsSz; 18.106 - SRSWQueueStruc* *internalQs; 18.107 - } 18.108 -SRMWQueueStruc; 18.109 - 18.110 -SRMWQueueStruc* makeSRMWQ(); 18.111 -int addWriterToSRMWQ( SRMWQueueStruc *Q ); 18.112 -void* readSRMWQ( SRMWQueueStruc *Q ); 18.113 -void writeSRMWQ( void *in, SRMWQueueStruc *Q, int writerID ); 18.114 - 18.115 - 18.116 -#endif /* _PRIVATE_QUEUE_H */ 18.117 - 18.118 +/* 18.119 + * Copyright 2009 OpenSourceResearchInstitute.org 18.120 + * Licensed under GNU General Public License version 2 18.121 + * 18.122 + * Author: seanhalle@yahoo.com 18.123 + */ 18.124 + 18.125 +#ifndef _PRQUEUE_H 18.126 +#define _PRQUEUE_H 18.127 + 18.128 +#include <PR__include/PR__primitive_data_types.h> 18.129 +#include <pthread.h> 18.130 + 18.131 +#define TRUE 1 18.132 +#define FALSE 0 18.133 + 18.134 +//================== Private Queue stuff =================== 18.135 +/* It is the data that is shared so only need one mutex. */ 18.136 +typedef struct 18.137 + { void **insertPos; 18.138 + void **extractPos; 18.139 + void **startOfData; //data is pointers 18.140 + void **endOfData; //set when alloc data 18.141 + } 18.142 +PrivQueueStruc; 18.143 + 18.144 +typedef void (*DynArrayFnPtr) ( void * ); //fn has to cast void * 18.145 + 18.146 +PrivQueueStruc* makePrivQ ( ); 18.147 +bool32 isEmptyPrivQ ( PrivQueueStruc *Q ); //ret TRUE if empty 18.148 +void* peekPrivQ ( PrivQueueStruc *Q ); //ret NULL if empty 18.149 +void* readPrivQ ( PrivQueueStruc *Q ); //ret NULL if empty 18.150 +void writePrivQ( void *in, PrivQueueStruc *Q ); 18.151 + //return false when full 18.152 +bool32 writeIfSpacePrivQ( void * in, PrivQueueStruc* Q ); 18.153 +int32 numInPrivQ( PrivQueueStruc *Q ); 18.154 +void pushPrivQ( void * in, PrivQueueStruc* Q ); 18.155 +void freePrivQ( PrivQueueStruc *Q ); 18.156 + 18.157 + 18.158 +//====================== Parallel Queue Stuff ==================== 18.159 + 18.160 +//========== pThreads based queue ========== 18.161 +/* It is the data that is shared so only need one mutex. */ 18.162 +typedef 18.163 +struct 18.164 + { pthread_mutex_t mutex_t; 18.165 + pthread_cond_t cond_w_t; 18.166 + pthread_cond_t cond_r_t; 18.167 + int32 count; 18.168 + int32 readPos; 18.169 + int32 writePos; 18.170 + void* data[1024]; //an array of pointers 18.171 + int w_empty; 18.172 + int w_full; 18.173 + } 18.174 +PThdQueueStruc; 18.175 + 18.176 +PThdQueueStruc* makePThdQ(); 18.177 +void* readPThdQ( PThdQueueStruc *Q ); 18.178 +void writePThdQ( void *in, PThdQueueStruc *Q ); 18.179 + 18.180 + 18.181 +//========== CAS based queue ========== 18.182 +typedef 18.183 +struct 18.184 + { volatile int32 insertLock; 18.185 + volatile int32 extractLock; 18.186 + volatile void* *insertPos; 18.187 + volatile void* *extractPos; 18.188 + void* startOfData[1024]; //data is pointers 18.189 + void* *endOfData; //set when make queue 18.190 + } 18.191 +CASQueueStruc; 18.192 + 18.193 +CASQueueStruc* makeCASQ(); 18.194 +void* readCASQ( CASQueueStruc *Q ); 18.195 +void writeCASQ( void *in, CASQueueStruc *Q ); 18.196 + 18.197 + 18.198 +//========= non-atomic instr based queue =========== 18.199 +typedef 18.200 +struct 18.201 + { void* *insertPos; 18.202 + void* *extractPos; 18.203 + void* startOfData[1024]; //data is pointers 18.204 + void* *endOfData; //set when make queue 18.205 + } 18.206 +SRSWQueueStruc; 18.207 + 18.208 +SRSWQueueStruc* makeSRSWQ(); 18.209 +void freeSRSWQ( SRSWQueueStruc* Q ); 18.210 +void* readSRSWQ( SRSWQueueStruc *Q ); 18.211 +void writeSRSWQ( void *in, SRSWQueueStruc *Q ); 18.212 + 18.213 + 18.214 +//========= non-atomic instr S R M W queue =========== 18.215 +typedef 18.216 +struct 18.217 + { int32 lastQReadFrom; 18.218 + int32 numInternalQs; 18.219 + int32 internalQsSz; 18.220 + SRSWQueueStruc* *internalQs; 18.221 + } 18.222 +SRMWQueueStruc; 18.223 + 18.224 +SRMWQueueStruc* makeSRMWQ(); 18.225 +int addWriterToSRMWQ( SRMWQueueStruc *Q ); 18.226 +void* readSRMWQ( SRMWQueueStruc *Q ); 18.227 +void writeSRMWQ( void *in, SRMWQueueStruc *Q, int writerID ); 18.228 + 18.229 + 18.230 +#endif /* _PRIVATE_QUEUE_H */ 18.231 +
