changeset 20:f3cb11baf791 ML_lib_longjmp

Fully working longjmp, get_sched based. Also OS Portability work included. Related library_proto-runtime commit: 45dc6d5afb2d
author Philipe Louchtch
date Fri, 09 May 2014 11:19:53 +0200
parents 45f7cf8a80eb
children c05370bd62dd
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__ML_lib_longjmp langlets/PRServ__wrapper_library.h langlets/prdsl_wrapper_library.h langlets/vreo_wrapper_library.h osportability.h prdynarray.h prhash.h prhistogram.h prlistofarrays.h prmalloc.h prparam.h prqueue.h
diffstat 23 files changed, 1961 insertions(+), 1820 deletions(-) [+]
line diff
     1.1 --- a/PR__PI.h	Tue Mar 04 12:45:08 2014 -0800
     1.2 +++ b/PR__PI.h	Fri May 09 11:19:53 2014 +0200
     1.3 @@ -37,10 +37,16 @@
     1.4  
     1.5  //#define PR_PI__get_fresh_slaveVP   PR_int__create_slaveVP_helper
     1.6  
     1.7 -inline
     1.8 +__inline
     1.9  SlaveVP*
    1.10  PR_PI__get_fresh_slaveVP( BirthFnPtr fnPtr, void *dataParam, SlaveVP* requestingSlv );
    1.11  
    1.12 +void
    1.13 +PR_PI__make_slave_ready( SlaveVP *slave, void *_langEnv );
    1.14 +
    1.15 +void
    1.16 +PR_PI__make_task_ready(void *_task, void *_langEnv);
    1.17 +
    1.18  //==============
    1.19  //=== Lang Data
    1.20  //=
    1.21 @@ -111,6 +117,9 @@
    1.22  void
    1.23  PR_PI__resume_slave_in_PRServ( SlaveVP *slave );
    1.24  
    1.25 +void
    1.26 +PR_PI__set_task_properties(int32 *ID, BirthFnPtr birthFn, void *initData, void *task, SlaveVP *slave, int32 magicNum);
    1.27 +
    1.28  #define \
    1.29  PR_PI__malloc   PR_int__malloc
    1.30  #define \
     2.1 --- a/PR__SS.h	Tue Mar 04 12:45:08 2014 -0800
     2.2 +++ b/PR__SS.h	Fri May 09 11:19:53 2014 +0200
     2.3 @@ -1,128 +1,128 @@
     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_slot( int32 coreSlotsAreOn );
    2.82 -
    2.83 -void
    2.84 -PR_SS__create_the_coreCtlr_OS_threads();
    2.85 -
    2.86 -int
    2.87 -PR_SS__give_num_cores();
    2.88 -
    2.89 -//===================
    2.90 -
    2.91 -void
    2.92 -PR_SS__end_process_normally( PRProcess *process );
    2.93 -
    2.94 -void
    2.95 -PR_SS__shutdown_OS_threads();
    2.96 -
    2.97 -SlaveVP* 
    2.98 -PR_SS__create_shutdown_slave();
    2.99 -
   2.100 -void
   2.101 -PR_SS__cleanup_at_end_of_shutdown();
   2.102 - 
   2.103 -void
   2.104 -PR_SS__print_out_measurements();
   2.105 -
   2.106 -void
   2.107 -PR_SS__wait_for_PR_to_shutdown();
   2.108 -
   2.109 -//=============================
   2.110 -//===
   2.111 -//=
   2.112 -
   2.113 -#define \
   2.114 -PR_SS__give_lang_data_from_slave   PR_int__give_lang_data_from_slave
   2.115 -#define \
   2.116 -PR_SS__give_lang_meta_task_from_slave   PR_int__give_lang_meta_task_from_slave
   2.117 -#define \
   2.118 -PR_SS__give_proto_lang_env_for_slave   PR_int__give_proto_lang_env_for_slave
   2.119 -#define \
   2.120 -PR_SS__give_lang_env_for_slave   PR_int__give_lang_env_for_slave
   2.121 -#define \
   2.122 -PR_SS__give_lang_env_from_process   PR_int__give_lang_env_from_process
   2.123 -
   2.124 -#define \
   2.125 -PR_SS__malloc  PR_WL__malloc /*SS happens outside the Master*/
   2.126 -#define \
   2.127 -PR_SS__free    PR_WL__free
   2.128 -
   2.129 -//================================================
   2.130 -#endif	/*  */
   2.131 -
   2.132 +/*
   2.133 + *  Copyright 2009 OpenSourceResearchInstitute.org
   2.134 + *  Licensed under GNU General Public License version 2
   2.135 + *
   2.136 + * Author: seanhalle@yahoo.com
   2.137 + * 
   2.138 + */
   2.139 +
   2.140 +#ifndef _PR__SS_H
   2.141 +#define	_PR__SS_H
   2.142 +#define _GNU_SOURCE
   2.143 +
   2.144 +#include <PR__include/PR__structs__common.h>
   2.145 +
   2.146 +//=========================  Function Prototypes  ===========================
   2.147 +/* MEANING OF   WL  PI  SS  int PROS
   2.148 + * These indicate which places the function is safe to use.  They stand for:
   2.149 + * 
   2.150 + * WL   Wrapper Library -- wrapper lib code should only use these
   2.151 + * PI   Plugin          -- plugin code should only use these
   2.152 + * SS   Startup and Shutdown -- designates these relate to startup & shutdown
   2.153 + * int32internal to PR -- should not be used in wrapper lib or plugin
   2.154 + * PROS means "OS functions for applications to use"
   2.155 + * 
   2.156 + * PR_int__ functions touch internal PR data structs and are only safe
   2.157 + *  to be used inside the master lock.  However, occasionally, they appear
   2.158 + * in wrapper-lib or plugin code.  In those cases, very careful analysis
   2.159 + * has been done to be sure no concurrency issues could arise.
   2.160 + * 
   2.161 + * PR_WL__ functions are all safe for use outside the master lock.
   2.162 + * 
   2.163 + * PROS are only safe for applications to use -- they're like a second
   2.164 + * language mixed in -- but they can't be used inside plugin code, and
   2.165 + * aren't meant for use in wrapper libraries, because they are themselves
   2.166 + * wrapper-library calls!
   2.167 + */
   2.168 +
   2.169 +//===============  Startup and Shutdown  ================
   2.170 +//===
   2.171 +//=    Some of these are for PR internal use only, others for langlet use
   2.172 +
   2.173 +
   2.174 +#define \
   2.175 +PR_SS__malloc  PR_WL__malloc /*SS happens outside the Master*/
   2.176 +#define \
   2.177 +PR_SS__free    PR_WL__free
   2.178 +
   2.179 +//===================
   2.180 +void *
   2.181 +PR_SS__create_lang_env( int32 size, SlaveVP *slave, int32 magicNum );
   2.182 +
   2.183 +void
   2.184 +PR_SS__register_assigner( SlaveAssigner assigner, SlaveVP *seedVP, int32 magicNum );
   2.185 +void
   2.186 +PR_SS__register_lang_shutdown_handler( LangShutdownHdlr shutdownHdlr, SlaveVP *seedVP,
   2.187 +                                  int32 magicNum );
   2.188 +void
   2.189 +PR_SS__register_lang_data_creator( LangDataCreator langDataCreator, 
   2.190 +                                              SlaveVP *seedVP, int32 magicNum );
   2.191 +void
   2.192 +PR_SS__register_lang_meta_task_creator( LangDataCreator langMetaTaskCreator, 
   2.193 +                                              SlaveVP *seedVP, int32 magicNum );
   2.194 +void
   2.195 +PR_SS__register_make_slave_ready_fn( MakeSlaveReadyFn fn, SlaveVP *seedVP,
   2.196 +                                                               int32 magicNum );
   2.197 +void
   2.198 +PR_SS__register_make_task_ready_fn( MakeTaskReadyFn fn, SlaveVP *seedVP,
   2.199 +                                    int32 magicNum );
   2.200 +
   2.201 +
   2.202 +//================================
   2.203 +//===
   2.204 +//=       PR internal use only
   2.205 +void
   2.206 +PR_SS__create_topEnv();
   2.207 +
   2.208 +AnimSlot *
   2.209 +PR_SS__create_anim_slot( int32 coreSlotsAreOn );
   2.210 +
   2.211 +void
   2.212 +PR_SS__create_the_coreCtlr_OS_threads();
   2.213 +
   2.214 +int
   2.215 +PR_SS__give_num_cores();
   2.216 +
   2.217 +//===================
   2.218 +
   2.219 +void
   2.220 +PR_SS__end_process_normally( PRProcess *process );
   2.221 +
   2.222 +void
   2.223 +PR_SS__shutdown_OS_threads();
   2.224 +
   2.225 +SlaveVP* 
   2.226 +PR_SS__create_shutdown_slave(int32 coreNum);
   2.227 +
   2.228 +void
   2.229 +PR_SS__cleanup_at_end_of_shutdown();
   2.230 + 
   2.231 +void
   2.232 +PR_SS__print_out_measurements();
   2.233 +
   2.234 +void
   2.235 +PR_SS__wait_for_PR_to_shutdown();
   2.236 +
   2.237 +//=============================
   2.238 +//===
   2.239 +//=
   2.240 +
   2.241 +#define \
   2.242 +PR_SS__give_lang_data_from_slave   PR_int__give_lang_data_from_slave
   2.243 +#define \
   2.244 +PR_SS__give_lang_meta_task_from_slave   PR_int__give_lang_meta_task_from_slave
   2.245 +#define \
   2.246 +PR_SS__give_proto_lang_env_for_slave   PR_int__give_proto_lang_env_for_slave
   2.247 +#define \
   2.248 +PR_SS__give_lang_env_for_slave   PR_int__give_lang_env_for_slave
   2.249 +#define \
   2.250 +PR_SS__give_lang_env_from_process   PR_int__give_lang_env_from_process
   2.251 +
   2.252 +#define \
   2.253 +PR_SS__malloc  PR_WL__malloc /*SS happens outside the Master*/
   2.254 +#define \
   2.255 +PR_SS__free    PR_WL__free
   2.256 +
   2.257 +//================================================
   2.258 +#endif	/*  */
   2.259 +
     3.1 --- a/PR__WL.h	Tue Mar 04 12:45:08 2014 -0800
     3.2 +++ b/PR__WL.h	Fri May 09 11:19:53 2014 +0200
     3.3 @@ -63,11 +63,11 @@
     3.4  #define \
     3.5  PR__create_taskID_of_size   PR_WL__create_taskID_of_size
     3.6  
     3.7 -inline
     3.8 +__inline
     3.9  int32 *
    3.10  PR__give_ID_from_slave( SlaveVP *animSlv, int32 magicNumber );
    3.11  
    3.12 -inline
    3.13 +__inline
    3.14  int32 *
    3.15  PR__give_ID_from_lang_meta_task( void *_task );
    3.16  
    3.17 @@ -91,11 +91,11 @@
    3.18  void
    3.19  PR_WL__suspend_slaveVP_and_send_req( SlaveVP *callingSlv );
    3.20  
    3.21 -inline void
    3.22 +__inline void
    3.23  PR_WL__add_lang_request_in_mallocd_PRReqst( void *langReqData, 
    3.24                                                            SlaveVP *callingSlv );
    3.25  
    3.26 -inline void
    3.27 +__inline void
    3.28  PR_WL__send_lang_request( void *langReq, RequestHandler handler, 
    3.29                                            SlaveVP *callingSlv, int32 magicNum );
    3.30  
    3.31 @@ -103,17 +103,17 @@
    3.32  PR_WL__send_create_slaveVP_req( void *langReq, int32 *ID, CreateHandler handler, 
    3.33                                  SlaveVP *reqstingSlv, int32 magicNum );
    3.34  
    3.35 -void inline
    3.36 +void __inline
    3.37  PR_WL__send_end_slave_req( void *langReq, RequestHandler handler, 
    3.38                                         SlaveVP *slvToDissipate, int32 magicNum );
    3.39  
    3.40 -inline void
    3.41 +__inline void
    3.42  PR_WL__send_service_request( void *langReqData, SlaveVP *callingSlv );
    3.43  
    3.44 -inline void
    3.45 +__inline void
    3.46  PR_WL__send_lang_shutdown_request( SlaveVP *callingSlv, int32 magicNum );
    3.47  
    3.48 -inline 
    3.49 +__inline 
    3.50  int32 *
    3.51  PR_WL__create_taskID_of_size( int32 numInts );
    3.52  
     4.1 --- a/PR__int.h	Tue Mar 04 12:45:08 2014 -0800
     4.2 +++ b/PR__int.h	Fri May 09 11:19:53 2014 +0200
     4.3 @@ -22,17 +22,17 @@
     4.4   * int: internal to the PR implementation
     4.5   */
     4.6  
     4.7 -inline
     4.8 +__inline
     4.9  void
    4.10  PR_int__reset_slaveVP_to_BirthFn( SlaveVP *slaveVP, BirthFnPtr fnPtr,
    4.11                                void    *dataParam);
    4.12  
    4.13 -inline
    4.14 +__inline
    4.15  void
    4.16  PR_int__point_slaveVP_to_OneParamFn( SlaveVP *slaveVP, void *fnPtr,
    4.17                                void    *param);
    4.18  
    4.19 -inline
    4.20 +__inline
    4.21  void
    4.22  PR_int__point_slaveVP_to_TwoParamFn( SlaveVP *slaveVP, void *fnPtr,
    4.23                               void    *param1, void *param2);
    4.24 @@ -40,13 +40,17 @@
    4.25  //===========================================================================
    4.26  //
    4.27  //===========================================================================
    4.28 -inline
    4.29 +__inline
    4.30  SlaveVP *
    4.31  PR_int__create_slaveVP_struct( BirthFnPtr fnPtr, void *dataParam );
    4.32  
    4.33 -inline
    4.34 +__inline
    4.35 +void
    4.36 +PR_int__create_slaveVP_finalize( SlaveVP* newSlv );
    4.37 +
    4.38 +__inline
    4.39  SlaveVP *
    4.40 -PR_int__create_slaveVP( BirthFnPtr fnPtr, void *dataParam, int32 coreNum );
    4.41 +PR_int__create_slaveVP( BirthFnPtr fnPtr, void *dataParam );
    4.42  
    4.43  SlaveVP *
    4.44  PR_int__get_recycled_slot_slave( int32 coreNum );
    4.45 @@ -54,22 +58,22 @@
    4.46  SlaveVP *
    4.47  PR_int__create_slot_slave( int32 coreNum );
    4.48  
    4.49 -inline 
    4.50 +__inline 
    4.51  void
    4.52  PR_int__replace_with_new_slot_slv( SlaveVP *slave );
    4.53  
    4.54  void 
    4.55  idle_fn(void* data, SlaveVP *animatingSlv);
    4.56  
    4.57 -inline
    4.58 +__inline
    4.59  void
    4.60  PR_int__put_task_into_slot( void *task, AnimSlot *slot );
    4.61  
    4.62 -inline
    4.63 +__inline
    4.64  void
    4.65  PR_int__put_slave_into_slot( SlaveVP *slave, AnimSlot *slot );
    4.66  
    4.67 -void inline
    4.68 +__inline void
    4.69  PRHandle__ServiceReq(  SlaveVP *requestingSlv );
    4.70  
    4.71  void
    4.72 @@ -89,11 +93,11 @@
    4.73  //=============================
    4.74  //=== Lange Env
    4.75  //=
    4.76 -inline 
    4.77 +__inline 
    4.78  void *
    4.79  PR_int__give_lang_env( PRLangEnv *protoLangEnv );
    4.80  
    4.81 -inline 
    4.82 +__inline 
    4.83  PRLangEnv *
    4.84  PR_int__give_proto_lang_env( void *langEnv );
    4.85  
    4.86 @@ -101,89 +105,89 @@
    4.87  void *
    4.88  PR_int__create_lang_env_in_process( int32 size, PRProcess *process, int32 magicNum );
    4.89  
    4.90 -inline
    4.91 +__inline
    4.92  void *
    4.93  PR_int__remove_lang_env_from_process_and_free( void *langEnv );
    4.94  
    4.95 -inline
    4.96 +__inline
    4.97  void *
    4.98  PR_int__give_lang_env_of_req( PRReqst *req, SlaveVP *requestingSlv );
    4.99  
   4.100 -inline
   4.101 +__inline
   4.102  void *
   4.103  PR_int__give_lang_env_for_slave( SlaveVP *slave, int32 magicNum );
   4.104  //No WL version -- not safe!  if use env in WL, be sure data rd & wr is stable
   4.105  
   4.106 -inline
   4.107 +__inline
   4.108  PRLangEnv *
   4.109  PR_int__give_proto_lang_env_for_slave( SlaveVP *slave, int32 magicNumber );
   4.110  //No WL version -- not safe!  if use env in WL, be sure data rd & wr is stable
   4.111  
   4.112 -inline
   4.113 +__inline
   4.114  void *
   4.115  PR_int__give_lang_env_from_process( PRProcess *process, int32 magicNum );
   4.116  //No WL version -- not safe!  if use env in WL, be sure data rd & wr is stable
   4.117  
   4.118 -inline
   4.119 +__inline
   4.120  PRLangEnv *
   4.121  PR_int__give_proto_lang_env_from_process( PRProcess *process, int32 magicNum );
   4.122  
   4.123  //=======================
   4.124  //=== Meta Task
   4.125  //=
   4.126 -inline 
   4.127 +__inline 
   4.128  PRMetaTask *
   4.129  PR_int__give_prolog_of_lang_meta_task( void *task );
   4.130  
   4.131 -inline
   4.132 +__inline
   4.133  void *
   4.134  PR_int__give_lang_meta_task_of_prolog( PRMetaTask *metaTask);
   4.135  
   4.136 -inline
   4.137 +__inline
   4.138  void *
   4.139  PR_int__create_lang_meta_task( int32 size, LangMetaTaskFreer freer, int32 magicNum );
   4.140  
   4.141 -inline
   4.142 +__inline
   4.143  void *
   4.144  PR_int__create_lang_meta_task_in_slave( int32 size, LangMetaTaskFreer freer,
   4.145                                          SlaveVP *slave, int32 magicNum );
   4.146  
   4.147 -inline
   4.148 +__inline
   4.149  PRMetaTask *
   4.150  PR_int__create_generic_slave_meta_task( void *initData );
   4.151  
   4.152  void
   4.153  PR_int__free_lang_meta_task_and_remove_from_coll( void *langMetaTask );
   4.154  
   4.155 -inline
   4.156 +__inline
   4.157  void
   4.158  PR_int__insert_meta_task_into_slave( PRMetaTask *task, SlaveVP *slave );
   4.159  
   4.160 -inline
   4.161 +__inline
   4.162  void
   4.163  PR_int__insert_lang_meta_task_into_slave__ML( void *langMetaTask, SlaveVP *slave );
   4.164  
   4.165 -inline
   4.166 +__inline
   4.167  void *
   4.168  PR_int__give_lang_meta_task_from_slave( SlaveVP *slave, int32 magicNumer );
   4.169  
   4.170 -inline
   4.171 +__inline
   4.172  SlaveVP *
   4.173  PR_PI__give_slave_lang_meta_task_is_assigned_to( void *langMetaTask );
   4.174  
   4.175  //==============
   4.176  //=== Lang Data
   4.177  //=
   4.178 -inline
   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 +__inline
   4.186  void *
   4.187  PR_int__give_lang_data_from_slave( SlaveVP *slave, int32 magicNumer );
   4.188  
   4.189 -inline
   4.190 +__inline
   4.191  void *
   4.192  PR_int__give_lang_data_of_prolog( PRLangData *langData);
   4.193  
   4.194 @@ -193,29 +197,29 @@
   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 +__inline
   4.200  void
   4.201  PR_int__insert_elem_into_collection( PRCollElem *elem, PRCollElem **coll, int32 hash );
   4.202  
   4.203 -inline
   4.204 +__inline
   4.205  void
   4.206  PR_int__replace_or_insert_elem_into_collection( PRCollElem *elem, 
   4.207                                                  PRCollElem **coll, 
   4.208                                                  int32 hash );
   4.209  
   4.210 -inline
   4.211 +__inline
   4.212  void *
   4.213  PR_int__lookup_elem_in_collection( int32 hash, PRCollElem **coll );
   4.214  
   4.215 -inline
   4.216 +__inline
   4.217  void
   4.218  PR_int__remove_elem_from_collection( int32 hash, PRCollElem **coll );
   4.219  
   4.220 -inline
   4.221 +__inline
   4.222  void
   4.223  PR_int__set_collection_to_empty( PRCollElem **coll );
   4.224  
   4.225 -inline
   4.226 +__inline
   4.227  void
   4.228  PR_int__apply_Fn_to_all_in_collection( void (*Fn)(void *), PRCollElem **coll );
   4.229  
   4.230 @@ -245,28 +249,32 @@
   4.231  char *
   4.232  PR_int__strDup( char *str );
   4.233  
   4.234 -inline void
   4.235 +__inline void
   4.236  PR_int__get_wrapper_lock();
   4.237  
   4.238 -inline void
   4.239 +__inline void
   4.240  PR_int__get_master_lock();
   4.241  
   4.242 -inline void
   4.243 +__inline void
   4.244  PR_int__get_malloc_lock();
   4.245  
   4.246 -inline void
   4.247 +__inline void
   4.248  PR_int__pthread_wait_for_condition(int32* condVar);
   4.249  
   4.250 +__inline void
   4.251 +PR_int__aquire_masterLock();
   4.252 +
   4.253  #define PR_int__release_master_lock()  _PRTopEnv->masterLock  = UNLOCKED
   4.254  
   4.255  #define PR_int__release_wrapper_lock() _PRTopEnv->wrapperLock = UNLOCKED
   4.256  
   4.257  #define PR_int__release_malloc_lock()  _PRTopEnv->mallocLock  = UNLOCKED
   4.258  
   4.259 -inline uint32_t
   4.260 +__inline
   4.261 +uint32_t
   4.262  PR_int__randomNumber();
   4.263  
   4.264 -inline void
   4.265 +__inline void
   4.266  PR_int__backoff_for_TooLongToGetLock( int32 numTriesToGetLock );
   4.267  
   4.268  #endif	/* _PR_INT_H */
     5.1 --- a/PR__primitive_data_types.h	Tue Mar 04 12:45:08 2014 -0800
     5.2 +++ b/PR__primitive_data_types.h	Fri May 09 11:19:53 2014 +0200
     5.3 @@ -1,42 +1,61 @@
     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 +#ifdef _WIN32
    5.69 +
    5.70 +#define bool8   char              
    5.71 +#define int8    char              
    5.72 +#define uint8   char              
    5.73 +#define int16   short             
    5.74 +#define uint16  unsigned short    
    5.75 +#define int32   int               
    5.76 +#define uint32  unsigned int      
    5.77 +#define bool32  unsigned int      
    5.78 +#define uint64  unsigned long long
    5.79 +#define float32 float             
    5.80 +#define float64 double  
    5.81 +
    5.82 +#else
    5.83 +
    5.84 +typedef char               bool8;
    5.85 +typedef char               int8;
    5.86 +typedef char               uint8;
    5.87 +typedef short              int16;
    5.88 +typedef unsigned short     uint16;
    5.89 +typedef int                int32;
    5.90 +typedef unsigned int       uint32;
    5.91 +typedef unsigned int       bool32;
    5.92 +typedef long long          int64;
    5.93 +typedef unsigned long long uint64;
    5.94 +typedef float              float32;
    5.95 +typedef double             float64;
    5.96 +
    5.97 +#endif
    5.98 +
    5.99 +//typedef double double      float128;  //GCC doesn't like this
   5.100 +#define float128 double double
   5.101 +
   5.102 +#define TRUE  1
   5.103 +#define FALSE 0
   5.104 +
   5.105 +#endif	/* _PRIMITIVE_DATA_TYPES_H */
   5.106 +
     6.1 --- a/PR__structs__common.h	Tue Mar 04 12:45:08 2014 -0800
     6.2 +++ b/PR__structs__common.h	Fri May 09 11:19:53 2014 +0200
     6.3 @@ -11,7 +11,13 @@
     6.4  #define _GNU_SOURCE
     6.5  
     6.6  #include <setjmp.h>
     6.7 +#ifdef _WIN32
     6.8 +    #define WIN32__LEAN_AND_MEAN
     6.9 +    #include <Windows.h>
    6.10 +#else
    6.11 +#endif
    6.12  #include <pthread.h>
    6.13 +
    6.14  #include <sys/time.h>
    6.15  
    6.16  //#include "PR_defs__turn_on_and_off.h"
    6.17 @@ -108,13 +114,13 @@
    6.18         float64           createPtInSecs; //real-clock time PR initialized
    6.19         Histogram       **measHists;
    6.20         PrivDynArrayInfo *measHistsInfo;
    6.21 -       MEAS__Insert_Susp_Meas_Fields_into_MasterEnv;
    6.22 -       MEAS__Insert_Master_Meas_Fields_into_MasterEnv;
    6.23 -       MEAS__Insert_Master_Lock_Meas_Fields_into_MasterEnv;
    6.24 -       MEAS__Insert_Malloc_Meas_Fields_into_MasterEnv;
    6.25 -       MEAS__Insert_Plugin_Meas_Fields_into_MasterEnv;
    6.26 -       MEAS__Insert_System_Meas_Fields_into_MasterEnv;
    6.27 -       MEAS__Insert_Counter_Meas_Fields_into_MasterEnv;
    6.28 +       MEAS__Insert_Susp_Meas_Fields_into_MasterEnv
    6.29 +       MEAS__Insert_Master_Meas_Fields_into_MasterEnv
    6.30 +       MEAS__Insert_Master_Lock_Meas_Fields_into_MasterEnv
    6.31 +       MEAS__Insert_System_Meas_Fields_into_MasterEnv
    6.32 +       MEAS__Insert_Malloc_Meas_Fields_into_MasterEnv
    6.33 +       MEAS__Insert_Plugin_Meas_Fields_into_MasterEnv
    6.34 +       MEAS__Insert_Counter_Meas_Fields_into_MasterEnv
    6.35        //==========================================
    6.36   }
    6.37  PRProcess;
    6.38 @@ -186,6 +192,7 @@
    6.39  typedef struct
    6.40   {
    6.41     //for future expansion
    6.42 +    void* undefined;
    6.43   }
    6.44  SlotPerfInfo;
    6.45  
    6.46 @@ -253,7 +260,7 @@
    6.47  //   PRGhostInfo  *ghostInfo;
    6.48     
    6.49          //=========== MEASUREMENT STUFF ==========
    6.50 -         MEAS__Insert_Meas_Fields_into_Slave;
    6.51 +         MEAS__Insert_Meas_Fields_into_Slave
    6.52           float64     createPtInSecs;  //time VP created, in seconds
    6.53          //========================================
    6.54           
    6.55 @@ -346,10 +353,9 @@
    6.56  //=========================  Extra Stuff Data Strucs  =======================
    6.57  typedef struct
    6.58   {
    6.59 -
    6.60 +    void* undefined;
    6.61   }
    6.62  PRExcp; //exception
    6.63  
    6.64 -
    6.65  #endif	/* _PR__structs_H */
    6.66  
     7.1 --- a/Services_offered_by_PR/DEBUG__macros.h	Tue Mar 04 12:45:08 2014 -0800
     7.2 +++ b/Services_offered_by_PR/DEBUG__macros.h	Fri May 09 11:19:53 2014 +0200
     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:%d\n", __FUNCTION__, __LINE__);\
    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	Tue Mar 04 12:45:08 2014 -0800
     8.2 +++ b/Services_offered_by_PR/MEAS__Counter_Recording.h	Fri May 09 11:19:53 2014 +0200
     8.3 @@ -1,37 +1,37 @@
     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 -
    8.15 -#include <PR__include/PR__structs__common.h>
    8.16 -
    8.17 -typedef struct 
    8.18 - {
    8.19 -   int event_type;
    8.20 -   int coreID;
    8.21 -   AnimSlot* slot;
    8.22 -   int vp;
    8.23 -   int task;
    8.24 -   uint64 cycles;
    8.25 -   uint64 instrs;
    8.26 - } 
    8.27 -CounterEvent;
    8.28 -
    8.29 -FILE* counterfile; //pass file handle via side effect because
    8.30 -                   // doAllInListOfArrays only takes Fns with a single input
    8.31 -
    8.32 -void MEAS__init_counter_data_structs_for_lang( SlaveVP *slv, int32 magicNum );
    8.33 -
    8.34 -void MEAS__counter_handler(int evt_type, int vpid, int task, SlaveVP* pr, uint64 cycles, uint64 instrs);
    8.35 -
    8.36 -void MEAS__set_counter_file(FILE* f);
    8.37 -
    8.38 -void MEAS__print_counter_event_to_file( void* _e );
    8.39 -#endif	/* PRServ_COUNTER_RECORDING_H */
    8.40 -
    8.41 +/* 
    8.42 + * File:   MEAS__Counter_Recording.h
    8.43 + * Author: nengel
    8.44 + *
    8.45 + * Created on January 11, 2012, 3:03 PM
    8.46 + */
    8.47 +
    8.48 +#ifndef MEAS__COUNTER_RECORDING_H
    8.49 +#define	MEAS__COUNTER_RECORDING_H
    8.50 +
    8.51 +
    8.52 +#include <PR__include/PR__structs__common.h>
    8.53 +
    8.54 +typedef struct 
    8.55 + {
    8.56 +   int event_type;
    8.57 +   int coreID;
    8.58 +   AnimSlot* slot;
    8.59 +   int vp;
    8.60 +   int task;
    8.61 +   uint64 cycles;
    8.62 +   uint64 instrs;
    8.63 + } 
    8.64 +CounterEvent;
    8.65 +
    8.66 +FILE* counterfile; //pass file handle via side effect because
    8.67 +                   // doAllInListOfArrays only takes Fns with a single input
    8.68 +
    8.69 +void MEAS__init_counter_data_structs_for_lang( SlaveVP *slv, int32 magicNum );
    8.70 +
    8.71 +void MEAS__counter_handler(int evt_type, int vpid, int task, SlaveVP* pr, uint64 cycles, uint64 instrs);
    8.72 +
    8.73 +void MEAS__set_counter_file(FILE* f);
    8.74 +
    8.75 +void MEAS__print_counter_event_to_file( void* _e );
    8.76 +#endif	/* PRServ_COUNTER_RECORDING_H */
    8.77 +
     9.1 --- a/Services_offered_by_PR/MEAS__macros.h	Tue Mar 04 12:45:08 2014 -0800
     9.2 +++ b/Services_offered_by_PR/MEAS__macros.h	Fri May 09 11:19:53 2014 +0200
     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	Tue Mar 04 12:45:08 2014 -0800
    10.2 +++ b/Services_offered_by_PR/prdependency.h	Fri May 09 11:19:53 2014 +0200
    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	Tue Mar 04 12:45:08 2014 -0800
    11.2 +++ b/Services_offered_by_PR/probes__wrapper_library.h	Fri May 09 11:19:53 2014 +0200
    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	Tue Mar 04 12:45:08 2014 -0800
    12.2 +++ b/__README__about_dir.txt	Fri May 09 11:19:53 2014 +0200
    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/PRServ__wrapper_library.h	Tue Mar 04 12:45:08 2014 -0800
    13.2 +++ b/langlets/PRServ__wrapper_library.h	Fri May 09 11:19:53 2014 +0200
    13.3 @@ -1,173 +1,173 @@
    13.4 -/*
    13.5 - *  Copyright 2009-2013 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 _PRServ_wrapper_library_H
   13.13 -#define	_PRServ_wrapper_library_H
   13.14 -
   13.15 -#include <PR__include/PR__structs__common.h>
   13.16 -
   13.17 -
   13.18 -//===========================================================================
   13.19 -typedef void (*PtrToAtomicFn )   ( void * ); //executed atomically in master
   13.20 -
   13.21 -typedef struct _DKUPiece DKUPiece;
   13.22 -typedef struct _DKUInstance DKUInstance;
   13.23 -
   13.24 -typedef void (*DKUKernel )       ( void *, SlaveVP * ); //used as task birth Fn
   13.25 -typedef void (*DKUSerialKernel ) ( void *, SlaveVP * ); //used as task birth Fn
   13.26 -typedef void (*DKUDivider )      ( DKUPiece * ); 
   13.27 -typedef void (*DKUUndivider )    ( DKUPiece * );
   13.28 -
   13.29 -typedef DKUPiece *  (*DKURootPieceMaker) ( void *, DKUInstance * ); 
   13.30 -
   13.31 -struct _DKUInstance
   13.32 - { 
   13.33 -   DKURootPieceMaker rootPieceMaker;
   13.34 -   DKUKernel         kernel;
   13.35 -   DKUSerialKernel   serialKernel;
   13.36 -   DKUDivider        divider;
   13.37 -   DKUUndivider      undivider;
   13.38 - };
   13.39 -
   13.40 -struct _DKUPiece
   13.41 - {
   13.42 -   void        *payload;
   13.43 -   int32        dataFootprint; //Kbytes of cache space used by piece -- set by root piece maker and then by divider
   13.44 -   DKUPiece    *parent;
   13.45 -   DKUPiece   **children;
   13.46 -   int32        childFootprint; //set as suggestion by PR, reset by divider
   13.47 -   int32        numChildren; //set as suggestion by PR, reset by divider
   13.48 -   int32        numUnfinishedChildren;
   13.49 -   DKUInstance *dkuInstance;   //to get kernel and undivider
   13.50 -   void        *undividerInfo; //divider communicates to undivider
   13.51 -   SlaveVP     *waitingVP;
   13.52 -   bool32       wasRecursivelyDivided;
   13.53 - };
   13.54 - 
   13.55 -
   13.56 -   
   13.57 -   
   13.58 -   
   13.59 -   
   13.60 -   
   13.61 -
   13.62 -/*WARNING: assembly hard-codes position of endInstrAddr as first field
   13.63 - */
   13.64 -typedef struct
   13.65 - {
   13.66 -   void           *endInstrAddr;
   13.67 -   int32           hasBeenStarted;
   13.68 -   int32           hasFinished;
   13.69 -   PrivQueueStruc *waitQ;
   13.70 - }
   13.71 -PRServSingleton;
   13.72 -
   13.73 - 
   13.74 -//===========================================================================
   13.75 -
   13.76 -int32
   13.77 -PRServ__giveMinWorkUnitCycles( float32 percentOverhead );
   13.78 -
   13.79 -void
   13.80 -PRServ__begin_primitive();
   13.81 -
   13.82 -int32
   13.83 -PRServ__end_primitive_and_give_cycles();
   13.84 -
   13.85 -int32
   13.86 -PRServ__giveIdealNumWorkUnits();
   13.87 -
   13.88 -int32
   13.89 -PRServ__give_number_of_cores_to_schedule_onto();
   13.90 -
   13.91 -char *
   13.92 -PRServ___give_environment_string();
   13.93 -
   13.94 -//=======================
   13.95 -
   13.96 -void
   13.97 -PRServ__end_seedVP( SlaveVP *seedSlv );
   13.98 -//=======================
   13.99 -
  13.100 -inline int32 *
  13.101 -PRServ__create_taskID_of_size( int32 numInts, SlaveVP *animSlv );
  13.102 -
  13.103 -//=========================
  13.104 -void
  13.105 -PRServ__taskwait(SlaveVP *animSlv);
  13.106 -
  13.107 -inline int32 *
  13.108 -PRServ__give_self_taskID( SlaveVP *animSlv );
  13.109 -
  13.110 -//======================= Concurrency Stuff ======================
  13.111 -void
  13.112 -PRServ__start_fn_singleton( int32 singletonID, SlaveVP *animSlv );
  13.113 -
  13.114 -void
  13.115 -PRServ__end_fn_singleton( int32 singletonID, SlaveVP *animSlv );
  13.116 -
  13.117 -void
  13.118 -PRServ__start_data_singleton( PRServSingleton **singeltonAddr, SlaveVP *animSlv );
  13.119 -
  13.120 -void
  13.121 -PRServ__end_data_singleton( PRServSingleton **singletonAddr, SlaveVP *animSlv );
  13.122 -
  13.123 -void
  13.124 -PRServ__animate_short_fn_in_isolation( PtrToAtomicFn ptrToFnToExecInMaster,
  13.125 -                                    void *data, SlaveVP *animSlv );
  13.126 -
  13.127 -void
  13.128 -PRServ__start_transaction( int32 transactionID, SlaveVP *animSlv );
  13.129 -
  13.130 -void
  13.131 -PRServ__end_transaction( int32 transactionID, SlaveVP *animSlv );
  13.132 -
  13.133 -//==============================  DKU  =============================
  13.134 -DKUInstance *
  13.135 -PRServ__DKU_make_empty_DKU_instance( SlaveVP *animSlv );
  13.136 -
  13.137 -DKUPiece *
  13.138 -PRServ__DKU_make_empty_DKU_piece();
  13.139 -
  13.140 -DKUPiece *
  13.141 -PRServ__DKU_make_child_piece_from( DKUPiece *pieceToDivide );
  13.142 -
  13.143 -void
  13.144 -PRServ__DKU_set_root_piece_maker( DKUInstance *dkuInstance, 
  13.145 -                                  DKURootPieceMaker rootPieceMakerFn, 
  13.146 -                                  SlaveVP *animSlv );
  13.147 -void
  13.148 -PRServ__DKU_set_kernel( DKUInstance *dkuInstance, 
  13.149 -                        DKUKernel kernelFn, 
  13.150 -                        SlaveVP *animSlv );
  13.151 -void
  13.152 -PRServ__DKU_set_serial_kernel( DKUInstance *dkuInstance, 
  13.153 -                               DKUSerialKernel serialKernelFn, 
  13.154 -                               SlaveVP *animSlv );
  13.155 -void
  13.156 -PRServ__DKU_set_divider( DKUInstance *dkuInstance, 
  13.157 -                         DKUDivider dividerFn, 
  13.158 -                         SlaveVP *animSlv );
  13.159 -void
  13.160 -PRServ__DKU_set_undivider( DKUInstance *dkuInstance, 
  13.161 -                           DKUUndivider undividerFn, 
  13.162 -                           SlaveVP *animSlv );
  13.163 -DKUPiece *
  13.164 -PRServ__DKU_make_root_piece( DKUInstance *dkuInstance, 
  13.165 -                             void *data, 
  13.166 -                             SlaveVP *animSlv );
  13.167 -void
  13.168 -PRServ__DKU_perform_work_on( DKUPiece *rootPiece, 
  13.169 -                             SlaveVP *animSlv );
  13.170 -void
  13.171 -PRServ__DKU_wait_for_result_to_be_complete( DKUPiece *rootPiece, 
  13.172 -                                            SlaveVP  *animSlv );
  13.173 -
  13.174 -//===========================================================================
  13.175 -#endif	/* _PRServ_H */
  13.176 -
  13.177 +/*
  13.178 + *  Copyright 2009-2013 OpenSourceResearchInstitute.org
  13.179 + *  Licensed under GNU General Public License version 2
  13.180 + *
  13.181 + * Author: seanhalle@yahoo.com
  13.182 + *
  13.183 + */
  13.184 +
  13.185 +#ifndef _PRServ_wrapper_library_H
  13.186 +#define	_PRServ_wrapper_library_H
  13.187 +
  13.188 +#include <PR__include/PR__structs__common.h>
  13.189 +
  13.190 +
  13.191 +//===========================================================================
  13.192 +typedef void (*PtrToAtomicFn )   ( void * ); //executed atomically in master
  13.193 +
  13.194 +typedef struct _DKUPiece DKUPiece;
  13.195 +typedef struct _DKUInstance DKUInstance;
  13.196 +
  13.197 +typedef void (*DKUKernel )       ( void *, SlaveVP * ); //used as task birth Fn
  13.198 +typedef void (*DKUSerialKernel ) ( void *, SlaveVP * ); //used as task birth Fn
  13.199 +typedef void (*DKUDivider )      ( DKUPiece * ); 
  13.200 +typedef void (*DKUUndivider )    ( DKUPiece * );
  13.201 +
  13.202 +typedef DKUPiece *  (*DKURootPieceMaker) ( void *, DKUInstance * ); 
  13.203 +
  13.204 +struct _DKUInstance
  13.205 + { 
  13.206 +   DKURootPieceMaker rootPieceMaker;
  13.207 +   DKUKernel         kernel;
  13.208 +   DKUSerialKernel   serialKernel;
  13.209 +   DKUDivider        divider;
  13.210 +   DKUUndivider      undivider;
  13.211 + };
  13.212 +
  13.213 +struct _DKUPiece
  13.214 + {
  13.215 +   void        *payload;
  13.216 +   int32        dataFootprint; //Kbytes of cache space used by piece -- set by root piece maker and then by divider
  13.217 +   DKUPiece    *parent;
  13.218 +   DKUPiece   **children;
  13.219 +   int32        childFootprint; //set as suggestion by PR, reset by divider
  13.220 +   int32        numChildren; //set as suggestion by PR, reset by divider
  13.221 +   int32        numUnfinishedChildren;
  13.222 +   DKUInstance *dkuInstance;   //to get kernel and undivider
  13.223 +   void        *undividerInfo; //divider communicates to undivider
  13.224 +   SlaveVP     *waitingVP;
  13.225 +   bool32       wasRecursivelyDivided;
  13.226 + };
  13.227 + 
  13.228 +
  13.229 +   
  13.230 +   
  13.231 +   
  13.232 +   
  13.233 +   
  13.234 +
  13.235 +/*WARNING: assembly hard-codes position of endInstrAddr as first field
  13.236 + */
  13.237 +typedef struct
  13.238 + {
  13.239 +   void           *endInstrAddr;
  13.240 +   int32           hasBeenStarted;
  13.241 +   int32           hasFinished;
  13.242 +   PrivQueueStruc *waitQ;
  13.243 + }
  13.244 +PRServSingleton;
  13.245 +
  13.246 + 
  13.247 +//===========================================================================
  13.248 +
  13.249 +int32
  13.250 +PRServ__giveMinWorkUnitCycles( float32 percentOverhead );
  13.251 +
  13.252 +void
  13.253 +PRServ__begin_primitive();
  13.254 +
  13.255 +int32
  13.256 +PRServ__end_primitive_and_give_cycles();
  13.257 +
  13.258 +int32
  13.259 +PRServ__giveIdealNumWorkUnits();
  13.260 +
  13.261 +int32
  13.262 +PRServ__give_number_of_cores_to_schedule_onto();
  13.263 +
  13.264 +char *
  13.265 +PRServ___give_environment_string();
  13.266 +
  13.267 +//=======================
  13.268 +
  13.269 +void
  13.270 +PRServ__end_seedVP( SlaveVP *seedSlv );
  13.271 +//=======================
  13.272 +
  13.273 +__inline int32 *
  13.274 +PRServ__create_taskID_of_size( int32 numInts, SlaveVP *animSlv );
  13.275 +
  13.276 +//=========================
  13.277 +void
  13.278 +PRServ__taskwait(SlaveVP *animSlv);
  13.279 +
  13.280 +__inline int32 *
  13.281 +PRServ__give_self_taskID( SlaveVP *animSlv );
  13.282 +
  13.283 +//======================= Concurrency Stuff ======================
  13.284 +void
  13.285 +PRServ__start_fn_singleton( int32 singletonID, SlaveVP *animSlv );
  13.286 +
  13.287 +void
  13.288 +PRServ__end_fn_singleton( int32 singletonID, SlaveVP *animSlv );
  13.289 +
  13.290 +void
  13.291 +PRServ__start_data_singleton( PRServSingleton **singeltonAddr, SlaveVP *animSlv );
  13.292 +
  13.293 +void
  13.294 +PRServ__end_data_singleton( PRServSingleton **singletonAddr, SlaveVP *animSlv );
  13.295 +
  13.296 +void
  13.297 +PRServ__animate_short_fn_in_isolation( PtrToAtomicFn ptrToFnToExecInMaster,
  13.298 +                                    void *data, SlaveVP *animSlv );
  13.299 +
  13.300 +void
  13.301 +PRServ__start_transaction( int32 transactionID, SlaveVP *animSlv );
  13.302 +
  13.303 +void
  13.304 +PRServ__end_transaction( int32 transactionID, SlaveVP *animSlv );
  13.305 +
  13.306 +//==============================  DKU  =============================
  13.307 +DKUInstance *
  13.308 +PRServ__DKU_make_empty_DKU_instance( SlaveVP *animSlv );
  13.309 +
  13.310 +DKUPiece *
  13.311 +PRServ__DKU_make_empty_DKU_piece();
  13.312 +
  13.313 +DKUPiece *
  13.314 +PRServ__DKU_make_child_piece_from( DKUPiece *pieceToDivide );
  13.315 +
  13.316 +void
  13.317 +PRServ__DKU_set_root_piece_maker( DKUInstance *dkuInstance, 
  13.318 +                                  DKURootPieceMaker rootPieceMakerFn, 
  13.319 +                                  SlaveVP *animSlv );
  13.320 +void
  13.321 +PRServ__DKU_set_kernel( DKUInstance *dkuInstance, 
  13.322 +                        DKUKernel kernelFn, 
  13.323 +                        SlaveVP *animSlv );
  13.324 +void
  13.325 +PRServ__DKU_set_serial_kernel( DKUInstance *dkuInstance, 
  13.326 +                               DKUSerialKernel serialKernelFn, 
  13.327 +                               SlaveVP *animSlv );
  13.328 +void
  13.329 +PRServ__DKU_set_divider( DKUInstance *dkuInstance, 
  13.330 +                         DKUDivider dividerFn, 
  13.331 +                         SlaveVP *animSlv );
  13.332 +void
  13.333 +PRServ__DKU_set_undivider( DKUInstance *dkuInstance, 
  13.334 +                           DKUUndivider undividerFn, 
  13.335 +                           SlaveVP *animSlv );
  13.336 +DKUPiece *
  13.337 +PRServ__DKU_make_root_piece( DKUInstance *dkuInstance, 
  13.338 +                             void *data, 
  13.339 +                             SlaveVP *animSlv );
  13.340 +void
  13.341 +PRServ__DKU_perform_work_on( DKUPiece *rootPiece, 
  13.342 +                             SlaveVP *animSlv );
  13.343 +void
  13.344 +PRServ__DKU_wait_for_result_to_be_complete( DKUPiece *rootPiece, 
  13.345 +                                            SlaveVP  *animSlv );
  13.346 +
  13.347 +//===========================================================================
  13.348 +#endif	/* _PRServ_H */
  13.349 +
    14.1 --- a/langlets/prdsl_wrapper_library.h	Tue Mar 04 12:45:08 2014 -0800
    14.2 +++ b/langlets/prdsl_wrapper_library.h	Fri May 09 11:19:53 2014 +0200
    14.3 @@ -1,93 +1,93 @@
    14.4 -/*
    14.5 - *  Copyright 2009 OpenSourceResearchInstitute.org
    14.6 - *  Licensed under GNU General Public License version 2
    14.7 - *
    14.8 - * Author: seanhalle@yahoo.com
    14.9 - *
   14.10 - */
   14.11 -
   14.12 -#ifndef _PRDSL_WRAPPER_H
   14.13 -#define	_PRDSL_WRAPPER_H
   14.14 -
   14.15 -#include <PR__include/PR__structs__common.h>
   14.16 -
   14.17 -//===========================================================================
   14.18 -   //uniquely identifies PRDSL -- should be a jenkins char-hash of "PRDSL" to int32
   14.19 -#define PRDSL_MAGIC_NUMBER 0000000004
   14.20 -
   14.21 -typedef struct _PRDSLTaskStub  PRDSLTaskStub;
   14.22 -
   14.23 -//===========================================================================
   14.24 -
   14.25 -/*This is PRDSL's "lang meta task"
   14.26 - *See the proto-runtime wiki entry to learn about "lang meta task"
   14.27 - *In essence, this holds all the meta information that PRDSL needs about a task
   14.28 - */
   14.29 -struct _PRDSLTaskStub
   14.30 - {
   14.31 -   void           **args;            //given to the birth Fn
   14.32 -   int32            numBlockingProp;
   14.33 -   PrivQueueStruc  *dependentTasksQ;
   14.34 -   bool32           isActive; //active after done adding propendents
   14.35 -   bool32           canBeAProp;
   14.36 -   
   14.37 -   PRDSLTaskStub *parentTaskStub; //for liveness, for the wait construct
   14.38 -   int32          numLiveChildTasks;
   14.39 -   int32          numLiveChildVPs;
   14.40 -   bool32         isWaitingForChildTasksToEnd;
   14.41 -   bool32         isWaitingForChildThreadsToEnd;
   14.42 -   bool32         isEnded;
   14.43 -   
   14.44 -//   int32         *taskID; //is in PRMetaTask, in prolog
   14.45 - };
   14.46 -
   14.47 -
   14.48 -//=======================
   14.49 -
   14.50 -void
   14.51 -PRDSL__start( SlaveVP *seedSlv );
   14.52 -
   14.53 -void
   14.54 -PRDSL__shutdown( SlaveVP *seedSlv );
   14.55 -
   14.56 -void
   14.57 -PRDSL__wait_for_all_PRDSL_created_work_to_end( SlaveVP *seedSlv );
   14.58 -
   14.59 -//=======================
   14.60 -
   14.61 -SlaveVP *
   14.62 -PRDSL__create_thread( BirthFnPtr fnPtr,   void *initData,
   14.63 -                                               SlaveVP *creatingThd );
   14.64 -
   14.65 -void
   14.66 -PRDSL__end_thread( SlaveVP *thdToEnd );
   14.67 -
   14.68 -//=======================
   14.69 -
   14.70 -#define PRDSL__malloc( numBytes, callingSlave ) PR_App__malloc( numBytes, callingSlave)
   14.71 -
   14.72 -#define PRDSL__free(ptrToFree, callingSlave ) PR_App__free( ptrToFree, callingSlave )
   14.73 -
   14.74 -
   14.75 -//=======================
   14.76 -PRDSLTaskStub *
   14.77 -PRDSL__create_task_ready_to_run( BirthFnPtr birthFn, void *args, SlaveVP *animSlv);
   14.78 -
   14.79 -//inline int32 *
   14.80 -//PRDSL__create_taskID_of_size( int32 numInts, SlaveVP *animSlv );
   14.81 -
   14.82 -
   14.83 -void
   14.84 -PRDSL__end_task( SlaveVP *animSlv );
   14.85 -
   14.86 -//=========================
   14.87 -void
   14.88 -PRDSL__taskwait(SlaveVP *animSlv);
   14.89 -
   14.90 -
   14.91 -inline int32 *
   14.92 -PRDSL__give_self_taskID( SlaveVP *animSlv );
   14.93 -
   14.94 -//===========================================================================
   14.95 -#endif	
   14.96 -
   14.97 +/*
   14.98 + *  Copyright 2009 OpenSourceResearchInstitute.org
   14.99 + *  Licensed under GNU General Public License version 2
  14.100 + *
  14.101 + * Author: seanhalle@yahoo.com
  14.102 + *
  14.103 + */
  14.104 +
  14.105 +#ifndef _PRDSL_WRAPPER_H
  14.106 +#define	_PRDSL_WRAPPER_H
  14.107 +
  14.108 +#include <PR__include/PR__structs__common.h>
  14.109 +
  14.110 +//===========================================================================
  14.111 +   //uniquely identifies PRDSL -- should be a jenkins char-hash of "PRDSL" to int32
  14.112 +#define PRDSL_MAGIC_NUMBER 0000000004
  14.113 +
  14.114 +typedef struct _PRDSLTaskStub  PRDSLTaskStub;
  14.115 +
  14.116 +//===========================================================================
  14.117 +
  14.118 +/*This is PRDSL's "lang meta task"
  14.119 + *See the proto-runtime wiki entry to learn about "lang meta task"
  14.120 + *In essence, this holds all the meta information that PRDSL needs about a task
  14.121 + */
  14.122 +struct _PRDSLTaskStub
  14.123 + {
  14.124 +   void           **args;            //given to the birth Fn
  14.125 +   int32            numBlockingProp;
  14.126 +   PrivQueueStruc  *dependentTasksQ;
  14.127 +   bool32           isActive; //active after done adding propendents
  14.128 +   bool32           canBeAProp;
  14.129 +   
  14.130 +   PRDSLTaskStub *parentTaskStub; //for liveness, for the wait construct
  14.131 +   int32          numLiveChildTasks;
  14.132 +   int32          numLiveChildVPs;
  14.133 +   bool32         isWaitingForChildTasksToEnd;
  14.134 +   bool32         isWaitingForChildThreadsToEnd;
  14.135 +   bool32         isEnded;
  14.136 +   
  14.137 +//   int32         *taskID; //is in PRMetaTask, in prolog
  14.138 + };
  14.139 +
  14.140 +
  14.141 +//=======================
  14.142 +
  14.143 +void
  14.144 +PRDSL__start( SlaveVP *seedSlv );
  14.145 +
  14.146 +void
  14.147 +PRDSL__shutdown( SlaveVP *seedSlv );
  14.148 +
  14.149 +void
  14.150 +PRDSL__wait_for_all_PRDSL_created_work_to_end( SlaveVP *seedSlv );
  14.151 +
  14.152 +//=======================
  14.153 +
  14.154 +SlaveVP *
  14.155 +PRDSL__create_thread( BirthFnPtr fnPtr,   void *initData,
  14.156 +                                               SlaveVP *creatingThd );
  14.157 +
  14.158 +void
  14.159 +PRDSL__end_thread( SlaveVP *thdToEnd );
  14.160 +
  14.161 +//=======================
  14.162 +
  14.163 +#define PRDSL__malloc( numBytes, callingSlave ) PR_App__malloc( numBytes, callingSlave)
  14.164 +
  14.165 +#define PRDSL__free(ptrToFree, callingSlave ) PR_App__free( ptrToFree, callingSlave )
  14.166 +
  14.167 +
  14.168 +//=======================
  14.169 +PRDSLTaskStub *
  14.170 +PRDSL__create_task_ready_to_run( BirthFnPtr birthFn, void *args, SlaveVP *animSlv);
  14.171 +
  14.172 +//inline int32 *
  14.173 +//PRDSL__create_taskID_of_size( int32 numInts, SlaveVP *animSlv );
  14.174 +
  14.175 +
  14.176 +void
  14.177 +PRDSL__end_task( SlaveVP *animSlv );
  14.178 +
  14.179 +//=========================
  14.180 +void
  14.181 +PRDSL__taskwait(SlaveVP *animSlv);
  14.182 +
  14.183 +
  14.184 +inline int32 *
  14.185 +PRDSL__give_self_taskID( SlaveVP *animSlv );
  14.186 +
  14.187 +//===========================================================================
  14.188 +#endif	
  14.189 +
    15.1 --- a/langlets/vreo_wrapper_library.h	Tue Mar 04 12:45:08 2014 -0800
    15.2 +++ b/langlets/vreo_wrapper_library.h	Fri May 09 11:19:53 2014 +0200
    15.3 @@ -10,41 +10,63 @@
    15.4  #define	_VREO_WRAPPER_H
    15.5  
    15.6  #include <PR__include/PR__structs__common.h>
    15.7 -
    15.8 +#include <PR__include/prqueue.h>
    15.9     //uniquely identifies VSs -- should be a jenkins char-hash of "VSs" to int32
   15.10  #define VReo_MAGIC_NUMBER 0000000003
   15.11  
   15.12  //===========================================================================
   15.13  typedef struct _VReoIsland VReoIsland;
   15.14 +typedef struct _VReoO1island VReoO1island;
   15.15 +typedef struct _VReoBridge   VReoBridge;
   15.16 +typedef struct _VReoPartnerQStruct VReoPartnerQStruct;
   15.17  
   15.18  typedef bool32 (*VReoCheckerFn ) ( VReoIsland * );
   15.19  typedef void   (*VReoDoerFn )    ( VReoIsland * );
   15.20 +typedef void   (*VReoO1islandDoerFn) (VReoO1island *, VReoBridge*, VReoBridge*); //chg to list of bridges
   15.21  //===========================================================================
   15.22 +typedef enum
   15.23 + { None = 0,
   15.24 +   Island,
   15.25 +   O1island,
   15.26 +   VP
   15.27 + }
   15.28 +VReoRWType;
   15.29  
   15.30 -typedef struct
   15.31 +struct _VReoBridge
   15.32   {
   15.33     void          *buffer;
   15.34 -   bool32         portIsFull;
   15.35 +   bool32         bridgeIsFull;
   15.36     SlaveVP       *waitingReaderVP;   //doubles as flag
   15.37     SlaveVP       *waitingWriterVP;
   15.38     
   15.39 -   void          *reader;  //either island or VP
   15.40 -   void          *writer;  //either island or VP
   15.41 -   
   15.42 +   void          *reader;  //island, o1island, or VP
   15.43 +   VReoRWType     readerType;
   15.44 +   void          *writer;  //island, o1island, or VP
   15.45 +   VReoRWType     writerType;
   15.46 +
   15.47 +   //============  For Islands  =============
   15.48     int32          numReaderCheckerFns;  
   15.49 -   VReoCheckerFn *readerCheckerFns;     //checkers triggered when port state changes
   15.50 +   VReoCheckerFn *readerCheckerFns;     //checkers triggered when bridge state changes
   15.51     VReoDoerFn    *readerDoerFns;        //corresponding doer functions   
   15.52  
   15.53     int32          numWriterCheckerFns;  
   15.54 -   VReoCheckerFn *writerCheckerFns;     //checkers triggered when port state changes
   15.55 -   VReoDoerFn    *writerDoerFns;        //corresponding doer functions   
   15.56 - }
   15.57 -VReoPort;
   15.58 -
   15.59 +   VReoCheckerFn *writerCheckerFns;     //checkers triggered when bridge state changes
   15.60 +   VReoDoerFn    *writerDoerFns;        //corresponding doer functions
   15.61 +   
   15.62 +   //============  For O1islands  =============
   15.63 +   VReoPartnerQStruct *readerPartnerQStruct;
   15.64 +   VReoPartnerQStruct *writerPartnerQStruct;
   15.65 +      //these queues are pointed to by partnerQStructs in other bridges
   15.66 +      //the bridge is placed into these queues when no partner is found
   15.67 +   PrivQueueStruc     *readerOfferQ; 
   15.68 +   PrivQueueStruc     *writerOfferQ;
   15.69 + };
   15.70 +//VReoBridge
   15.71 + 
   15.72  struct _VReoIsland
   15.73   {
   15.74 -   int32          numPorts;
   15.75 -   VReoPort     **ports;          //array of pointers to port structs
   15.76 +   int32          numBridges;
   15.77 +   VReoBridge     **bridges;          //array of pointers to bridge structs
   15.78     
   15.79     int32          numCheckerFns;
   15.80     VReoCheckerFn *checkerFns;     //checkers triggered when state changes
   15.81 @@ -54,6 +76,33 @@
   15.82   };
   15.83  //VReoIsland
   15.84  
   15.85 +
   15.86 +struct _VReoO1island
   15.87 + {
   15.88 +   int32          numBridges;
   15.89 +   VReoBridge     **bridges;          //array of pointers to bridge structs
   15.90 +   
   15.91 +//   VReoO1islandCheckerFn  checkerFn; //checker triggered when state changes
   15.92 +//   VReoO1islandDoerFn    *doerFns;        //corresponding doer functions   
   15.93 +   
   15.94 +   //During search, have to save last Q checked inside each node of 
   15.95 +   // Qstruct..
   15.96 + };
   15.97 +//VReoO1island
   15.98 +
   15.99 +/*This is expected to change in future..  just quick and simple to get
  15.100 + * first version of optimization working.  In particular, the way the
  15.101 + * doer functions are handled should change.  Not clear how to handle them
  15.102 + * at this point.
  15.103 + */
  15.104 +struct _VReoPartnerQStruct
  15.105 + {
  15.106 +   int32             numQs;
  15.107 +   PrivQueueStruc  **partnerQs;   //array of partner Qs, hold bridge ptrs
  15.108 +   VReoO1islandDoerFn *doerFns;     //array of ptrs to doer Fns
  15.109 +  };
  15.110 +//VReoPartnerQStruct
  15.111 + 
  15.112  typedef struct _VReoListElem VReoListElem;
  15.113   
  15.114  struct _VReoListElem
  15.115 @@ -65,13 +114,16 @@
  15.116   
  15.117  typedef struct
  15.118   {
  15.119 -   int32        numPorts; //
  15.120 -   VReoPort    *ports;    //array of port structs
  15.121 -   VReoPort   **boundaryPorts;
  15.122 +   int32        numBridges; //
  15.123 +   VReoBridge    *bridges;    //array of bridge structs
  15.124 +   VReoBridge   **boundaryBridges;
  15.125     
  15.126     int32        numIslands;
  15.127     VReoIsland  *islands;  //array of island structs -- no pointers
  15.128     
  15.129 +   int32        numO1islands;
  15.130 +   VReoO1island  *o1islands;  //array of O1island structs -- no pointers
  15.131 +   
  15.132     int32        numVPs;
  15.133     VReoListElem *VPs;
  15.134     
  15.135 @@ -106,10 +158,10 @@
  15.136  //=======================
  15.137  
  15.138  void
  15.139 -VReo__put_into_port( void *itemToPut, VReoPort *port, SlaveVP *callingVP );
  15.140 +VReo__put_into_bridge( void *itemToPut, VReoBridge *bridge, SlaveVP *callingVP );
  15.141  
  15.142  void *
  15.143 -VReo__get_from_port( VReoPort *port, SlaveVP *callingVP );
  15.144 +VReo__get_from_bridge( VReoBridge *bridge, SlaveVP *callingVP );
  15.145  
  15.146  
  15.147  
  15.148 @@ -120,6 +172,12 @@
  15.149  void
  15.150  VReo__end_VP( SlaveVP *VPToEnd );
  15.151  
  15.152 +//================  For use by generated circuit code  =================
  15.153 +void
  15.154 +o1islandReadBridgeToWrittenBridgeDoer( VReoO1island *o1island, 
  15.155 +                      VReoBridge *readBridge, VReoBridge *writtenBridge );
  15.156 +
  15.157 +
  15.158  //===========================================================================
  15.159  #endif	/* _VReo_H */
  15.160  
    16.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.2 +++ b/osportability.h	Fri May 09 11:19:53 2014 +0200
    16.3 @@ -0,0 +1,39 @@
    16.4 +#ifndef __OS_PORTABILITY_H__
    16.5 +#define __OS_PORTABILITY_H__
    16.6 +
    16.7 +#ifdef _WIN32
    16.8 +
    16.9 +#define VC_EXTRALEAN
   16.10 +#define WIN32_LEAN_AND_MEAN
   16.11 +
   16.12 +#include <Windows.h>
   16.13 +#include <wintime.h>
   16.14 +
   16.15 +#include <PR__include/PR__primitive_data_types.h>
   16.16 +#include <malloc.h>
   16.17 +
   16.18 +#define cpu_set_t DWORD_PTR
   16.19 +#define PR_int__malloc malloc
   16.20 +#define PR_int__free free
   16.21 +
   16.22 +__inline int32 __sync_bool_compare_and_swap(volatile int32* destination, int32 newval, int32 oldval)
   16.23 +{
   16.24 +    /*
   16.25 +    #ifdef _WIN32
   16.26 +        gotLock = (int)(UNLOCKED && InterlockedCompareExchange((volatile unsigned long long*) addrOfMasterLock, (long long)LOCKED, (long long)UNLOCKED));
   16.27 +    #else
   16.28 +    */
   16.29 +    return (int32)(oldval == InterlockedCompareExchange((volatile unsigned long long*) destination, (long long)newval, (long long)oldval));
   16.30 +}
   16.31 +
   16.32 +#define pthread_yield sched_yield
   16.33 +
   16.34 +
   16.35 +
   16.36 +#else // GNU
   16.37 +
   16.38 +#include <sys/time.h>
   16.39 +#include <alloca.h>
   16.40 +
   16.41 +#endif // _WIN32
   16.42 +#endif // __OS_PORTABILITY_H__
   16.43 \ No newline at end of file
    17.1 --- a/prdynarray.h	Tue Mar 04 12:45:08 2014 -0800
    17.2 +++ b/prdynarray.h	Fri May 09 11:19:53 2014 +0200
    17.3 @@ -1,91 +1,91 @@
    17.4 -/* 
    17.5 - * File:   Vector.h
    17.6 - * Author: Me
    17.7 - *
    17.8 - * Created on May 14, 2010, 3:08 PM
    17.9 - */
   17.10 -
   17.11 -#ifndef _DYNARRAY_H
   17.12 -#define	_DYNARRAY_H
   17.13 -
   17.14 -#include <PR__include/PR__primitive_data_types.h>
   17.15 -
   17.16 -
   17.17 -
   17.18 -/*WARNING: Passing a DynArray as a param is dangerous if add to the DynArray
   17.19 - * inside the function called!   After adding or other operation that might
   17.20 - * change the size, must re-read the addr of the chunk of memory that is the
   17.21 - * array, via the DynArrayInfo.
   17.22 - *Here's why: An array variable is a location, either on the stack
   17.23 - * or in a field of a struct, whose contents is an addr.  That addr is of the
   17.24 - * first location of a chunk of locations.  The DynArray works by changing
   17.25 - * the chunk of locations, then modifying the contents of the original 
   17.26 - * array variable.  It overwrites the addr of the old chunk of locations
   17.27 - * with the addr of the new chunk.
   17.28 - *But when the array variable is passed as a parameter, such as 
   17.29 - * in this: "foo( myDynArray )", then there are now two locations that hold
   17.30 - * the addr of the same chunk of locations.  So when a call is made that
   17.31 - * adds to the DynArray, and inside the DynArray expands, it only updates
   17.32 - * the original location with  the new addr.  Hence, the function will begin
   17.33 - * overwriting memory past the end of the old chunk, because it still has 
   17.34 - * the pointer to the old chunk of locations.
   17.35 - *
   17.36 - *A dynamic array is accessed same as any other array.  However, must use
   17.37 - * dyn array calls, defined in here, in order to add or increase the size.
   17.38 - * Must re-read the original array variable after any size-changing calls.
   17.39 - *To pass a DynArray as a parameter to a function, can only pass the 
   17.40 - * DynArrayInfo, then inside the function, to read the addr of the first 
   17.41 - * location in the chunk of locations that is the array, do this:
   17.42 - * "localArrayCopy = *(myDynArrayInfo->addrOfPtrToArray).  After that, can 
   17.43 - * treat localArrayCopy as a normal array, as long as don't make any calls
   17.44 - * that add or otherwise could increase the size of the array.  If do make
   17.45 - * such a call, then re-copy the array via the above.  Can then use the
   17.46 - * copy up until another add to the array.
   17.47 - * 
   17.48 - */
   17.49 -typedef struct
   17.50 - {
   17.51 -   void ***addrOfPtrToArray; //addr of var that is array of ptrs == triple *
   17.52 -   int32   numInArray;  //num entries added
   17.53 -   int32   sizeOfArray; //num elems alloc'd
   17.54 -   int32   sizeOfElem;  //num bytes in one elem of array -- used in 2nd version
   17.55 - }
   17.56 -PrivDynArrayInfo;
   17.57 -
   17.58 -PrivDynArrayInfo *
   17.59 -makePrivDynArrayInfoFrom( void ***addrOfPtrToArray, int32 sizeOfArray );
   17.60 -
   17.61 -PrivDynArrayInfo *
   17.62 -makePrivDynArrayOfSize( void ***addrOfPtrToArray, int32 sizeOfArray );
   17.63 -
   17.64 -PrivDynArrayInfo *
   17.65 -makePrivDynArrayOfSize_Ext( void ***addrOfPtrToArray, int32 sizeOfArray );
   17.66 -
   17.67 -int32
   17.68 -addToDynArray( void *value, PrivDynArrayInfo *info );
   17.69 -
   17.70 -void
   17.71 -makeHighestDynArrayIndexBe( PrivDynArrayInfo *info, int32 highestIndex );
   17.72 -
   17.73 -void
   17.74 -makeHighestDynArrayIndexBeAtLeast(PrivDynArrayInfo *info,int32 highestIndex);
   17.75 -
   17.76 -void
   17.77 -increaseSizeOfDynArrayTo( PrivDynArrayInfo *info, int32 newSize );
   17.78 -
   17.79 -typedef void  (*FreeFnPtr)  ( void * ); //fn has to cast void * to whatever
   17.80 -
   17.81 -void
   17.82 -freeDynArrayDeep( PrivDynArrayInfo *info, FreeFnPtr freeFnPtr );
   17.83 -
   17.84 -void
   17.85 -freeDynArrayFlat( PrivDynArrayInfo *info );
   17.86 -
   17.87 -
   17.88 -typedef void  (*DynArrayFnPtr)  ( void * );  //fn has to cast void *
   17.89 -
   17.90 -void
   17.91 -forAllInDynArrayDo( PrivDynArrayInfo *info, DynArrayFnPtr fnPtr );
   17.92 -
   17.93 -#endif	/* _DYNARRAY_H */
   17.94 -
   17.95 +/* 
   17.96 + * File:   Vector.h
   17.97 + * Author: Me
   17.98 + *
   17.99 + * Created on May 14, 2010, 3:08 PM
  17.100 + */
  17.101 +
  17.102 +#ifndef _DYNARRAY_H
  17.103 +#define	_DYNARRAY_H
  17.104 +
  17.105 +#include <PR__include/PR__primitive_data_types.h>
  17.106 +
  17.107 +
  17.108 +
  17.109 +/*WARNING: Passing a DynArray as a param is dangerous if add to the DynArray
  17.110 + * inside the function called!   After adding or other operation that might
  17.111 + * change the size, must re-read the addr of the chunk of memory that is the
  17.112 + * array, via the DynArrayInfo.
  17.113 + *Here's why: An array variable is a location, either on the stack
  17.114 + * or in a field of a struct, whose contents is an addr.  That addr is of the
  17.115 + * first location of a chunk of locations.  The DynArray works by changing
  17.116 + * the chunk of locations, then modifying the contents of the original 
  17.117 + * array variable.  It overwrites the addr of the old chunk of locations
  17.118 + * with the addr of the new chunk.
  17.119 + *But when the array variable is passed as a parameter, such as 
  17.120 + * in this: "foo( myDynArray )", then there are now two locations that hold
  17.121 + * the addr of the same chunk of locations.  So when a call is made that
  17.122 + * adds to the DynArray, and inside the DynArray expands, it only updates
  17.123 + * the original location with  the new addr.  Hence, the function will begin
  17.124 + * overwriting memory past the end of the old chunk, because it still has 
  17.125 + * the pointer to the old chunk of locations.
  17.126 + *
  17.127 + *A dynamic array is accessed same as any other array.  However, must use
  17.128 + * dyn array calls, defined in here, in order to add or increase the size.
  17.129 + * Must re-read the original array variable after any size-changing calls.
  17.130 + *To pass a DynArray as a parameter to a function, can only pass the 
  17.131 + * DynArrayInfo, then inside the function, to read the addr of the first 
  17.132 + * location in the chunk of locations that is the array, do this:
  17.133 + * "localArrayCopy = *(myDynArrayInfo->addrOfPtrToArray).  After that, can 
  17.134 + * treat localArrayCopy as a normal array, as long as don't make any calls
  17.135 + * that add or otherwise could increase the size of the array.  If do make
  17.136 + * such a call, then re-copy the array via the above.  Can then use the
  17.137 + * copy up until another add to the array.
  17.138 + * 
  17.139 + */
  17.140 +typedef struct
  17.141 + {
  17.142 +   void ***addrOfPtrToArray; //addr of var that is array of ptrs == triple *
  17.143 +   int32   numInArray;  //num entries added
  17.144 +   int32   sizeOfArray; //num elems alloc'd
  17.145 +   int32   sizeOfElem;  //num bytes in one elem of array -- used in 2nd version
  17.146 + }
  17.147 +PrivDynArrayInfo;
  17.148 +
  17.149 +PrivDynArrayInfo *
  17.150 +makePrivDynArrayInfoFrom( void ***addrOfPtrToArray, int32 sizeOfArray );
  17.151 +
  17.152 +PrivDynArrayInfo *
  17.153 +makePrivDynArrayOfSize( void ***addrOfPtrToArray, int32 sizeOfArray );
  17.154 +
  17.155 +PrivDynArrayInfo *
  17.156 +makePrivDynArrayOfSize_Ext( void ***addrOfPtrToArray, int32 sizeOfArray );
  17.157 +
  17.158 +int32
  17.159 +addToDynArray( void *value, PrivDynArrayInfo *info );
  17.160 +
  17.161 +void
  17.162 +makeHighestDynArrayIndexBe( PrivDynArrayInfo *info, int32 highestIndex );
  17.163 +
  17.164 +void
  17.165 +makeHighestDynArrayIndexBeAtLeast(PrivDynArrayInfo *info,int32 highestIndex);
  17.166 +
  17.167 +void
  17.168 +increaseSizeOfDynArrayTo( PrivDynArrayInfo *info, int32 newSize );
  17.169 +
  17.170 +typedef void  (*FreeFnPtr)  ( void * ); //fn has to cast void * to whatever
  17.171 +
  17.172 +void
  17.173 +freeDynArrayDeep( PrivDynArrayInfo *info, FreeFnPtr freeFnPtr );
  17.174 +
  17.175 +void
  17.176 +freeDynArrayFlat( PrivDynArrayInfo *info );
  17.177 +
  17.178 +
  17.179 +typedef void  (*DynArrayFnPtr)  ( void * );  //fn has to cast void *
  17.180 +
  17.181 +void
  17.182 +forAllInDynArrayDo( PrivDynArrayInfo *info, DynArrayFnPtr fnPtr );
  17.183 +
  17.184 +#endif	/* _DYNARRAY_H */
  17.185 +
    18.1 --- a/prhash.h	Tue Mar 04 12:45:08 2014 -0800
    18.2 +++ b/prhash.h	Fri May 09 11:19:53 2014 +0200
    18.3 @@ -1,96 +1,96 @@
    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 _PRHASH_H
   18.12 -#define	_PRHASH_H
   18.13 -
   18.14 -#include <stdio.h>
   18.15 -#include <string.h>
   18.16 -#include <errno.h>
   18.17 -#include <stdlib.h>
   18.18 -
   18.19 -#include <PR__include/PR__primitive_data_types.h>
   18.20 -
   18.21 -//=====================  defines  =====================
   18.22 -#define TRUE     1
   18.23 -#define FALSE    0
   18.24 -
   18.25 -#define DEFAULT_HASH_TABLE_SIZE 1 << 10
   18.26 -#define DEFAULT_POWER_OF_2_TABLE_SIZE 10
   18.27 -
   18.28 -
   18.29 -//=====================  structs  =====================
   18.30 -union hashkey_t{
   18.31 -    char hashable[8];
   18.32 -    int32 parts[2];
   18.33 -};
   18.34 -
   18.35 -typedef union hashkey_t hashkey_t;
   18.36 -
   18.37 -typedef struct _HashEntry HashEntry;
   18.38 -
   18.39 -struct _HashEntry
   18.40 - {
   18.41 -   char       *key;
   18.42 -   void       *content;
   18.43 -   HashEntry  *next;
   18.44 - };
   18.45 -
   18.46 -typedef void (*FreeEntryContentFnPtr)    ( void * );
   18.47 -
   18.48 -typedef struct
   18.49 - { int32       tableSz;
   18.50 -   int32       numEntries;
   18.51 -   HashEntry* *entries;
   18.52 -   int32       hashMask;
   18.53 -   int32       prevHash;
   18.54 -   FreeEntryContentFnPtr freeEntryContentFn;
   18.55 - }
   18.56 -HashTable;
   18.57 -
   18.58 -
   18.59 -//===========================================================================
   18.60 -//   Public functions
   18.61 -HashTable   *makeHashTable( int numHashSlots, FreeEntryContentFnPtr freeFn );
   18.62 -
   18.63 -int32        putEntryIntoTable( HashEntry *entry, HashTable *table);
   18.64 -int32        addValueIntoTable( char* key, void *value, HashTable *table);
   18.65 -HashEntry   *getEntryFromTable( char *key, HashTable *table );
   18.66 -void        *getValueFromTable( char *key, HashTable *table );
   18.67 -
   18.68 -bool8        deleteEntryFromTable( char *key, HashTable *table );
   18.69 -bool8        deleteThisEntryFromTable( HashEntry *entry, HashTable *table );
   18.70 -bool8        deleteEntrysValueInTable( char *key, HashTable *table );
   18.71 -bool8        deleteEntryFromTableAndFreeValue( char *key, HashTable *table );
   18.72 -void         freeHashTable( HashTable *table );
   18.73 -//char        *paramBagToString( ParamBag * bag )
   18.74 -
   18.75 -//================= Same Fns, but for 32b array key hash fn ================
   18.76 -HashTable *makeHashTable32(int32 powerOf2OfSz, FreeEntryContentFnPtr freeFn);
   18.77 -HashTable *makeDefaultSizeHashTable32( FreeEntryContentFnPtr freeFn );
   18.78 -
   18.79 -int32      putEntryIntoTable32( HashEntry *entry, HashTable *table);
   18.80 -HashEntry *addValueIntoTable32( uint32 key[], void *value, HashTable *table);
   18.81 -HashEntry *getEntryFromTable32( uint32 key[], HashTable *table );
   18.82 -void      *getValueFromTable32( uint32 key[], HashTable *table );
   18.83 -
   18.84 -bool32     deleteEntryFromTable32( uint32 key[], HashTable *table );
   18.85 -
   18.86 -//===========================================================================
   18.87 -//   Internal functions
   18.88 -void         freeHashEntryUsing( HashEntry *entry, HashTable *table );
   18.89 -unsigned int hashThisKey( char *s, int hashSz );
   18.90 -void         nullOutTablesArray( HashTable *table );
   18.91 -void         doubleTableSize( HashTable *table );
   18.92 -void         freeHashEntryButNotContent( HashEntry *entry );
   18.93 -
   18.94 -uint32 
   18.95 -jenkHash32( const uint32  *key,     /* array of uint32 values */
   18.96 -                   int32   length);  /* num uint32 in the key */
   18.97 -        
   18.98 -#endif	/* _PRIVATE_HASH_H */
   18.99 -
  18.100 +/*
  18.101 + *  Copyright 2009 OpenSourceResearchInstitute.org
  18.102 + *  Licensed under GNU General Public License version 2
  18.103 + *
  18.104 + * Author: seanhalle@yahoo.com
  18.105 + */
  18.106 +
  18.107 +#ifndef _PRHASH_H
  18.108 +#define	_PRHASH_H
  18.109 +
  18.110 +#include <stdio.h>
  18.111 +#include <string.h>
  18.112 +#include <errno.h>
  18.113 +#include <stdlib.h>
  18.114 +
  18.115 +#include <PR__include/PR__primitive_data_types.h>
  18.116 +
  18.117 +//=====================  defines  =====================
  18.118 +#define TRUE     1
  18.119 +#define FALSE    0
  18.120 +
  18.121 +#define DEFAULT_HASH_TABLE_SIZE 1 << 10
  18.122 +#define DEFAULT_POWER_OF_2_TABLE_SIZE 10
  18.123 +
  18.124 +
  18.125 +//=====================  structs  =====================
  18.126 +union hashkey_t{
  18.127 +    char hashable[8];
  18.128 +    int32 parts[2];
  18.129 +};
  18.130 +
  18.131 +typedef union hashkey_t hashkey_t;
  18.132 +
  18.133 +typedef struct _HashEntry HashEntry;
  18.134 +
  18.135 +struct _HashEntry
  18.136 + {
  18.137 +   char       *key;
  18.138 +   void       *content;
  18.139 +   HashEntry  *next;
  18.140 + };
  18.141 +
  18.142 +typedef void (*FreeEntryContentFnPtr)    ( void * );
  18.143 +
  18.144 +typedef struct
  18.145 + { int32       tableSz;
  18.146 +   int32       numEntries;
  18.147 +   HashEntry* *entries;
  18.148 +   int32       hashMask;
  18.149 +   int32       prevHash;
  18.150 +   FreeEntryContentFnPtr freeEntryContentFn;
  18.151 + }
  18.152 +HashTable;
  18.153 +
  18.154 +
  18.155 +//===========================================================================
  18.156 +//   Public functions
  18.157 +HashTable   *makeHashTable( int numHashSlots, FreeEntryContentFnPtr freeFn );
  18.158 +
  18.159 +int32        putEntryIntoTable( HashEntry *entry, HashTable *table);
  18.160 +int32        addValueIntoTable( char* key, void *value, HashTable *table);
  18.161 +HashEntry   *getEntryFromTable( char *key, HashTable *table );
  18.162 +void        *getValueFromTable( char *key, HashTable *table );
  18.163 +
  18.164 +bool8        deleteEntryFromTable( char *key, HashTable *table );
  18.165 +bool8        deleteThisEntryFromTable( HashEntry *entry, HashTable *table );
  18.166 +bool8        deleteEntrysValueInTable( char *key, HashTable *table );
  18.167 +bool8        deleteEntryFromTableAndFreeValue( char *key, HashTable *table );
  18.168 +void         freeHashTable( HashTable *table );
  18.169 +//char        *paramBagToString( ParamBag * bag )
  18.170 +
  18.171 +//================= Same Fns, but for 32b array key hash fn ================
  18.172 +HashTable *makeHashTable32(int32 powerOf2OfSz, FreeEntryContentFnPtr freeFn);
  18.173 +HashTable *makeDefaultSizeHashTable32( FreeEntryContentFnPtr freeFn );
  18.174 +
  18.175 +int32      putEntryIntoTable32( HashEntry *entry, HashTable *table);
  18.176 +HashEntry *addValueIntoTable32( uint32 key[], void *value, HashTable *table);
  18.177 +HashEntry *getEntryFromTable32( uint32 key[], HashTable *table );
  18.178 +void      *getValueFromTable32( uint32 key[], HashTable *table );
  18.179 +
  18.180 +bool32     deleteEntryFromTable32( uint32 key[], HashTable *table );
  18.181 +
  18.182 +//===========================================================================
  18.183 +//   Internal functions
  18.184 +void         freeHashEntryUsing( HashEntry *entry, HashTable *table );
  18.185 +unsigned int hashThisKey( char *s, int hashSz );
  18.186 +void         nullOutTablesArray( HashTable *table );
  18.187 +void         doubleTableSize( HashTable *table );
  18.188 +void         freeHashEntryButNotContent( HashEntry *entry );
  18.189 +
  18.190 +uint32 
  18.191 +jenkHash32( const uint32  *key,     /* array of uint32 values */
  18.192 +                   int32   length);  /* num uint32 in the key */
  18.193 +        
  18.194 +#endif	/* _PRIVATE_HASH_H */
  18.195 +
    19.1 --- a/prhistogram.h	Tue Mar 04 12:45:08 2014 -0800
    19.2 +++ b/prhistogram.h	Fri May 09 11:19:53 2014 +0200
    19.3 @@ -1,102 +1,102 @@
    19.4 -/*
    19.5 - *  Copyright 2010 OpenSourceResearchInstitute.org
    19.6 - *  Licensed under GNU General Public License version 2
    19.7 - *
    19.8 - * Author: seanhalle@yahoo.com
    19.9 - * 
   19.10 - */
   19.11 -
   19.12 -
   19.13 -#ifndef _PRHISTOGRAM_H
   19.14 -#define	_PRHISTOGRAM_H
   19.15 -
   19.16 -#include <PR__include/prmalloc.h>
   19.17 -#include <PR__include/PR__primitive_data_types.h>
   19.18 -
   19.19 -
   19.20 -typedef struct
   19.21 - {
   19.22 -   char  *name;
   19.23 -   int32  startOfRange;
   19.24 -   int32  endOfRange;
   19.25 -   int32  numBins;
   19.26 -   int32  binWidth;
   19.27 -   int32 *bins;
   19.28 - }
   19.29 -Histogram;
   19.30 -
   19.31 -typedef struct
   19.32 - {
   19.33 -   float32  startOfRange;
   19.34 -   float32  endOfRange;
   19.35 -   int32    numBins;
   19.36 -   float32  binWidth;
   19.37 -   int32   *bins;
   19.38 - }
   19.39 -FloatHist;
   19.40 -
   19.41 -typedef struct
   19.42 - {
   19.43 -   float64 startOfRange;
   19.44 -   float64  endOfRange;
   19.45 -   int32    numBins;
   19.46 -   float64  binWidth;
   19.47 -   int32   *bins;
   19.48 - }
   19.49 -DblHist;
   19.50 -
   19.51 -Histogram *
   19.52 -makeHistogram( int32 numBins, int32 startOfRange, int32 endOfRange );
   19.53 -
   19.54 -Histogram *
   19.55 -makeFixedBinHist( int32 numBins, int32 startOfRange, int32 binWidth,
   19.56 -                  char *name );
   19.57 -
   19.58 -Histogram *
   19.59 -makeFixedBinHistExt( int32 numBins, int32 startOfRange, int32 binWidth,
   19.60 -                     char *name );
   19.61 -
   19.62 -void inline
   19.63 -addToHist( int32 value, Histogram *hist );
   19.64 -
   19.65 -void inline
   19.66 -addIntervalToHist( uint32 startIntvl, uint32 endIntvl, Histogram *hist );
   19.67 -
   19.68 -void inline
   19.69 -subIntervalFromHist( int32 startIntvl, int32 endIntvl, Histogram *hist );
   19.70 -
   19.71 -void
   19.72 -saveHistToFile(Histogram *hist);
   19.73 -
   19.74 -void
   19.75 -printHist( Histogram *hist );
   19.76 -
   19.77 -FloatHist *
   19.78 -makeFloatHistogram( int numBins, float32 startOfRange, float32 binWidth );
   19.79 -
   19.80 -void
   19.81 -addToFloatHist( float32 value, FloatHist *hist );
   19.82 -
   19.83 -void
   19.84 -printFloatHist( FloatHist *hist );
   19.85 -
   19.86 -void
   19.87 -freeHistExt( Histogram *hist );
   19.88 -
   19.89 -void
   19.90 -freeHist( Histogram *hist );
   19.91 -
   19.92 -DblHist *
   19.93 -makeDblHistogram( int numBins, float64 startOfRange, float64 binWidth );
   19.94 -
   19.95 -void
   19.96 -addToDblHist( float64 value, DblHist *hist );
   19.97 -
   19.98 -void
   19.99 -printDblHist( DblHist *hist );
  19.100 -
  19.101 -void
  19.102 -freeDblHist( DblHist *hist );
  19.103 -
  19.104 -#endif	/* _HISTOGRAM_H */
  19.105 -
  19.106 +/*
  19.107 + *  Copyright 2010 OpenSourceResearchInstitute.org
  19.108 + *  Licensed under GNU General Public License version 2
  19.109 + *
  19.110 + * Author: seanhalle@yahoo.com
  19.111 + * 
  19.112 + */
  19.113 +
  19.114 +
  19.115 +#ifndef _PRHISTOGRAM_H
  19.116 +#define	_PRHISTOGRAM_H
  19.117 +
  19.118 +#include <PR__include/prmalloc.h>
  19.119 +#include <PR__include/PR__primitive_data_types.h>
  19.120 +
  19.121 +
  19.122 +typedef struct
  19.123 + {
  19.124 +   char  *name;
  19.125 +   int32  startOfRange;
  19.126 +   int32  endOfRange;
  19.127 +   int32  numBins;
  19.128 +   int32  binWidth;
  19.129 +   int32 *bins;
  19.130 + }
  19.131 +Histogram;
  19.132 +
  19.133 +typedef struct
  19.134 + {
  19.135 +   float32  startOfRange;
  19.136 +   float32  endOfRange;
  19.137 +   int32    numBins;
  19.138 +   float32  binWidth;
  19.139 +   int32   *bins;
  19.140 + }
  19.141 +FloatHist;
  19.142 +
  19.143 +typedef struct
  19.144 + {
  19.145 +   float64 startOfRange;
  19.146 +   float64  endOfRange;
  19.147 +   int32    numBins;
  19.148 +   float64  binWidth;
  19.149 +   int32   *bins;
  19.150 + }
  19.151 +DblHist;
  19.152 +
  19.153 +Histogram *
  19.154 +makeHistogram( int32 numBins, int32 startOfRange, int32 endOfRange );
  19.155 +
  19.156 +Histogram *
  19.157 +makeFixedBinHist( int32 numBins, int32 startOfRange, int32 binWidth,
  19.158 +                  char *name );
  19.159 +
  19.160 +Histogram *
  19.161 +makeFixedBinHistExt( int32 numBins, int32 startOfRange, int32 binWidth,
  19.162 +                     char *name );
  19.163 +
  19.164 +__inline void
  19.165 +addToHist( int32 value, Histogram *hist );
  19.166 +
  19.167 +__inline void
  19.168 +addIntervalToHist( uint32 startIntvl, uint32 endIntvl, Histogram *hist );
  19.169 +
  19.170 +__inline void
  19.171 +subIntervalFromHist( int32 startIntvl, int32 endIntvl, Histogram *hist );
  19.172 +
  19.173 +void
  19.174 +saveHistToFile(Histogram *hist);
  19.175 +
  19.176 +void
  19.177 +printHist( Histogram *hist );
  19.178 +
  19.179 +FloatHist *
  19.180 +makeFloatHistogram( int numBins, float32 startOfRange, float32 binWidth );
  19.181 +
  19.182 +void
  19.183 +addToFloatHist( float32 value, FloatHist *hist );
  19.184 +
  19.185 +void
  19.186 +printFloatHist( FloatHist *hist );
  19.187 +
  19.188 +void
  19.189 +freeHistExt( Histogram *hist );
  19.190 +
  19.191 +void
  19.192 +freeHist( Histogram *hist );
  19.193 +
  19.194 +DblHist *
  19.195 +makeDblHistogram( int numBins, float64 startOfRange, float64 binWidth );
  19.196 +
  19.197 +void
  19.198 +addToDblHist( float64 value, DblHist *hist );
  19.199 +
  19.200 +void
  19.201 +printDblHist( DblHist *hist );
  19.202 +
  19.203 +void
  19.204 +freeDblHist( DblHist *hist );
  19.205 +
  19.206 +#endif	/* _HISTOGRAM_H */
  19.207 +
    20.1 --- a/prlistofarrays.h	Tue Mar 04 12:45:08 2014 -0800
    20.2 +++ b/prlistofarrays.h	Fri May 09 11:19:53 2014 +0200
    20.3 @@ -1,67 +1,67 @@
    20.4 -/* 
    20.5 - * File:   ListOfArrays.h
    20.6 - * Author: Nina Engelhardt
    20.7 - *
    20.8 - * Created on December 16, 2011, 2:06 PM
    20.9 - */
   20.10 -
   20.11 -#ifndef  _LISTOFARRAYS_H
   20.12 -#define	_LISTOFARRAYS_H
   20.13 -
   20.14 -#include<stddef.h>
   20.15 -#include <inttypes.h>
   20.16 -
   20.17 -#include <PR__include/PR__primitive_data_types.h>
   20.18 -#include <PR__include/prdynarray.h>
   20.19 -
   20.20 -
   20.21 -typedef struct {
   20.22 -    void* next;
   20.23 -    void* data;
   20.24 -} ArrayFragment;
   20.25 -
   20.26 -typedef struct {
   20.27 -    void** dim1;
   20.28 -    PrivDynArrayInfo* dim1info;
   20.29 -    //ArrayFragment* last;
   20.30 -    size_t entry_size;
   20.31 -    int num_entries_per_fragment;
   20.32 -    int next_free_index;
   20.33 -} ListOfArrays;
   20.34 -
   20.35 -ListOfArrays* makeListOfArrays(size_t entry_size, int num_entries_per_block);
   20.36 -
   20.37 -#define addToListOfArrays(type,value,list) do { \
   20.38 -    int offset_in_fragment = list->next_free_index % list->num_entries_per_fragment; \
   20.39 -    if(offset_in_fragment == 0){ \
   20.40 -        void* newBlock = PR__malloc(list->entry_size * list->num_entries_per_fragment); \
   20.41 -        addToDynArray(newBlock,list->dim1info); \
   20.42 -    } \
   20.43 -    type* typedFragment = (type*) ((list->dim1)[list->dim1info->numInArray -1]); \
   20.44 -    typedFragment[offset_in_fragment] = value; \
   20.45 -    list->next_free_index++; \
   20.46 -} while (0)
   20.47 -
   20.48 -#define addToListOfArrays_ext(type,value,list) do { \
   20.49 -    int offset_in_fragment = list->next_free_index % list->num_entries_per_fragment; \
   20.50 -    if(offset_in_fragment == 0){ \
   20.51 -        void* newBlock = malloc(list->entry_size * list->num_entries_per_fragment); \
   20.52 -        addToDynArray(newBlock,list->dim1info); \
   20.53 -    } \
   20.54 -    type* typedFragment = (type*) ((list->dim1)[list->dim1info->numInArray -1]); \
   20.55 -    typedFragment[offset_in_fragment] = value; \
   20.56 -    list->next_free_index++; \
   20.57 -} while (0)
   20.58 -
   20.59 -typedef void  (*ListOfArraysFnPtr)  ( void * );  //fn has to cast void *
   20.60 -
   20.61 -void forAllInListOfArraysDo(ListOfArrays* list, ListOfArraysFnPtr fnPtr);
   20.62 -
   20.63 -#define valueInListOfArrays(type,index,list) ((type*)((list->dim1)[index / list->num_entries_per_fragment]))[index % list->num_entries_per_fragment]
   20.64 -
   20.65 -#define setValueInListOfArrays(type,index,value,list) ((type*)((list->dim1)[index / list->num_entries_per_fragment]))[index % list->num_entries_per_fragment] = value
   20.66 -
   20.67 -void freeListOfArrays(ListOfArrays* list);
   20.68 -
   20.69 -#endif	/* LISTOFARRAYS_H */
   20.70 -
   20.71 +/* 
   20.72 + * File:   ListOfArrays.h
   20.73 + * Author: Nina Engelhardt
   20.74 + *
   20.75 + * Created on December 16, 2011, 2:06 PM
   20.76 + */
   20.77 +
   20.78 +#ifndef  _LISTOFARRAYS_H
   20.79 +#define	_LISTOFARRAYS_H
   20.80 +
   20.81 +#include<stddef.h>
   20.82 +#include <inttypes.h>
   20.83 +
   20.84 +#include <PR__include/PR__primitive_data_types.h>
   20.85 +#include <PR__include/prdynarray.h>
   20.86 +
   20.87 +
   20.88 +typedef struct {
   20.89 +    void* next;
   20.90 +    void* data;
   20.91 +} ArrayFragment;
   20.92 +
   20.93 +typedef struct {
   20.94 +    void** dim1;
   20.95 +    PrivDynArrayInfo* dim1info;
   20.96 +    //ArrayFragment* last;
   20.97 +    size_t entry_size;
   20.98 +    int num_entries_per_fragment;
   20.99 +    int next_free_index;
  20.100 +} ListOfArrays;
  20.101 +
  20.102 +ListOfArrays* makeListOfArrays(size_t entry_size, int num_entries_per_block);
  20.103 +
  20.104 +#define addToListOfArrays(type,value,list) do { \
  20.105 +    int offset_in_fragment = list->next_free_index % list->num_entries_per_fragment; \
  20.106 +    if(offset_in_fragment == 0){ \
  20.107 +        void* newBlock = PR__malloc(list->entry_size * list->num_entries_per_fragment); \
  20.108 +        addToDynArray(newBlock,list->dim1info); \
  20.109 +    } \
  20.110 +    type* typedFragment = (type*) ((list->dim1)[list->dim1info->numInArray -1]); \
  20.111 +    typedFragment[offset_in_fragment] = value; \
  20.112 +    list->next_free_index++; \
  20.113 +} while (0)
  20.114 +
  20.115 +#define addToListOfArrays_ext(type,value,list) do { \
  20.116 +    int offset_in_fragment = list->next_free_index % list->num_entries_per_fragment; \
  20.117 +    if(offset_in_fragment == 0){ \
  20.118 +        void* newBlock = malloc(list->entry_size * list->num_entries_per_fragment); \
  20.119 +        addToDynArray(newBlock,list->dim1info); \
  20.120 +    } \
  20.121 +    type* typedFragment = (type*) ((list->dim1)[list->dim1info->numInArray -1]); \
  20.122 +    typedFragment[offset_in_fragment] = value; \
  20.123 +    list->next_free_index++; \
  20.124 +} while (0)
  20.125 +
  20.126 +typedef void  (*ListOfArraysFnPtr)  ( void * );  //fn has to cast void *
  20.127 +
  20.128 +void forAllInListOfArraysDo(ListOfArrays* list, ListOfArraysFnPtr fnPtr);
  20.129 +
  20.130 +#define valueInListOfArrays(type,index,list) ((type*)((list->dim1)[index / list->num_entries_per_fragment]))[index % list->num_entries_per_fragment]
  20.131 +
  20.132 +#define setValueInListOfArrays(type,index,value,list) ((type*)((list->dim1)[index / list->num_entries_per_fragment]))[index % list->num_entries_per_fragment] = value
  20.133 +
  20.134 +void freeListOfArrays(ListOfArrays* list);
  20.135 +
  20.136 +#endif	/* LISTOFARRAYS_H */
  20.137 +
    21.1 --- a/prmalloc.h	Tue Mar 04 12:45:08 2014 -0800
    21.2 +++ b/prmalloc.h	Fri May 09 11:19:53 2014 +0200
    21.3 @@ -1,52 +1,52 @@
    21.4 -/*
    21.5 - *  Copyright 2009 OpenSourceCodeStewardshipFoundation.org
    21.6 - *  Licensed under GNU General Public License version 2
    21.7 - *
    21.8 - * Author: seanhalle@yahoo.com
    21.9 - *
   21.10 - * Created on November 14, 2009, 9:07 PM
   21.11 - */
   21.12 -
   21.13 -#ifndef _PRMALLOC_H
   21.14 -#define	_PRMALLOC_H
   21.15 -
   21.16 -#include <malloc.h>
   21.17 -#include <inttypes.h>
   21.18 -#include <math.h>
   21.19 -#include <PR__include/PR__primitive_data_types.h>
   21.20 -
   21.21 -void *
   21.22 -PR_int__malloc( size_t sizeRequested );
   21.23 -
   21.24 -void *
   21.25 -PR_int__malloc_aligned( size_t sizeRequested );
   21.26 -
   21.27 -void
   21.28 -PR_int__free( void *ptrToFree );
   21.29 -
   21.30 -//Use these in application code directly
   21.31 -#define \
   21.32 -PR__malloc  PR_WL__malloc
   21.33 -
   21.34 -#define \
   21.35 -PR__free    PR_WL__free
   21.36 -
   21.37 -//these are implemented in the PR leaf implementation
   21.38 -void *
   21.39 -PR_WL__malloc( int32  sizeRequested ); 
   21.40 -
   21.41 -void
   21.42 -PR_WL__free( void *ptrToFree );
   21.43 -
   21.44 -
   21.45 -/*Allocates memory from the external system -- higher overhead
   21.46 - */
   21.47 -void *
   21.48 -PR_ext__malloc_in_ext( size_t sizeRequested );
   21.49 -
   21.50 -/*Frees memory that was allocated in the external system -- higher overhead
   21.51 - */
   21.52 -void
   21.53 -PR_ext__free_in_ext( void *ptrToFree );
   21.54 -
   21.55 +/*
   21.56 + *  Copyright 2009 OpenSourceCodeStewardshipFoundation.org
   21.57 + *  Licensed under GNU General Public License version 2
   21.58 + *
   21.59 + * Author: seanhalle@yahoo.com
   21.60 + *
   21.61 + * Created on November 14, 2009, 9:07 PM
   21.62 + */
   21.63 +
   21.64 +#ifndef _PRMALLOC_H
   21.65 +#define	_PRMALLOC_H
   21.66 +
   21.67 +#include <malloc.h>
   21.68 +#include <inttypes.h>
   21.69 +#include <math.h>
   21.70 +#include <PR__include/PR__primitive_data_types.h>
   21.71 +
   21.72 +void *
   21.73 +PR_int__malloc( size_t sizeRequested );
   21.74 +
   21.75 +void *
   21.76 +PR_int__malloc_aligned( size_t sizeRequested );
   21.77 +
   21.78 +void
   21.79 +PR_int__free( void *ptrToFree );
   21.80 +
   21.81 +//Use these in application code directly
   21.82 +#define \
   21.83 +PR__malloc  PR_WL__malloc
   21.84 +
   21.85 +#define \
   21.86 +PR__free    PR_WL__free
   21.87 +
   21.88 +//these are implemented in the PR leaf implementation
   21.89 +void *
   21.90 +PR_WL__malloc( int32  sizeRequested ); 
   21.91 +
   21.92 +void
   21.93 +PR_WL__free( void *ptrToFree );
   21.94 +
   21.95 +
   21.96 +/*Allocates memory from the external system -- higher overhead
   21.97 + */
   21.98 +void *
   21.99 +PR_ext__malloc_in_ext( size_t sizeRequested );
  21.100 +
  21.101 +/*Frees memory that was allocated in the external system -- higher overhead
  21.102 + */
  21.103 +void
  21.104 +PR_ext__free_in_ext( void *ptrToFree );
  21.105 +
  21.106  #endif
  21.107 \ No newline at end of file
    22.1 --- a/prparam.h	Tue Mar 04 12:45:08 2014 -0800
    22.2 +++ b/prparam.h	Fri May 09 11:19:53 2014 +0200
    22.3 @@ -1,59 +1,59 @@
    22.4 -/* 
    22.5 - * 
    22.6 - * Author: SeanHalle@yahoo.com
    22.7 - *
    22.8 - * Created on November 19, 2009, 6:30 PM
    22.9 - */
   22.10 -
   22.11 -#ifndef _PARAM_H
   22.12 -#define	_PARAM_H
   22.13 -
   22.14 -#include <PR__include/PR__primitive_data_types.h>
   22.15 -
   22.16 -
   22.17 -typedef
   22.18 -struct
   22.19 - { int type;
   22.20 -   int intValue;
   22.21 -   char * strValue;
   22.22 -   float floatValue;
   22.23 - }
   22.24 -ParamStruc;
   22.25 -
   22.26 -#define INT_PARAM_TYPE    0
   22.27 -#define STRING_PARAM_TYPE 1
   22.28 -#define FLOAT_PARAM_TYPE  2
   22.29 -
   22.30 -#define PARAM_BAG_HASHSIZE 1024
   22.31 -
   22.32 -typedef struct _ParamBagHashEntry ParamBagHashEntry;
   22.33 -
   22.34 -struct _ParamBagHashEntry
   22.35 - {
   22.36 -   char       *key;
   22.37 -   ParamStruc *param;
   22.38 -   struct _ParamBagHashEntry *next;
   22.39 - }
   22.40 -/*ParamBagHashEntry*/;
   22.41 -
   22.42 -
   22.43 -typedef
   22.44 -struct
   22.45 - { int bagSz;
   22.46 -   ParamBagHashEntry* *entries;
   22.47 - }
   22.48 -ParamBag;
   22.49 -
   22.50 -
   22.51 -ParamBag    *makeParamBag();
   22.52 -void         readParamFileIntoBag( char *paramFileName, ParamBag * bag );
   22.53 -ParamStruc  *getParamFromBag( char *key, ParamBag * bag );
   22.54 -int          addParamToBag( char* key, ParamStruc *param, ParamBag *bag );
   22.55 -void         freeParamBag( ParamBag *bag );
   22.56 -//char        *paramBagToString( ParamBag * bag );
   22.57 -ParamStruc  *makeParamStruc();
   22.58 -ParamStruc  *makeParamFromStrs( char * type, char *value );
   22.59 -ssize_t      getline( char **lineptr, size_t *n, FILE *stream );
   22.60 -
   22.61 -#endif	/* _PARAM_H */
   22.62 -
   22.63 +/* 
   22.64 + * 
   22.65 + * Author: SeanHalle@yahoo.com
   22.66 + *
   22.67 + * Created on November 19, 2009, 6:30 PM
   22.68 + */
   22.69 +
   22.70 +#ifndef _PARAM_H
   22.71 +#define	_PARAM_H
   22.72 +
   22.73 +#include <PR__include/PR__primitive_data_types.h>
   22.74 +
   22.75 +
   22.76 +typedef
   22.77 +struct
   22.78 + { int type;
   22.79 +   int intValue;
   22.80 +   char * strValue;
   22.81 +   float floatValue;
   22.82 + }
   22.83 +ParamStruc;
   22.84 +
   22.85 +#define INT_PARAM_TYPE    0
   22.86 +#define STRING_PARAM_TYPE 1
   22.87 +#define FLOAT_PARAM_TYPE  2
   22.88 +
   22.89 +#define PARAM_BAG_HASHSIZE 1024
   22.90 +
   22.91 +typedef struct _ParamBagHashEntry ParamBagHashEntry;
   22.92 +
   22.93 +struct _ParamBagHashEntry
   22.94 + {
   22.95 +   char       *key;
   22.96 +   ParamStruc *param;
   22.97 +   struct _ParamBagHashEntry *next;
   22.98 + }
   22.99 +/*ParamBagHashEntry*/;
  22.100 +
  22.101 +
  22.102 +typedef
  22.103 +struct
  22.104 + { int bagSz;
  22.105 +   ParamBagHashEntry* *entries;
  22.106 + }
  22.107 +ParamBag;
  22.108 +
  22.109 +
  22.110 +ParamBag    *makeParamBag();
  22.111 +void         readParamFileIntoBag( char *paramFileName, ParamBag * bag );
  22.112 +ParamStruc  *getParamFromBag( char *key, ParamBag * bag );
  22.113 +int          addParamToBag( char* key, ParamStruc *param, ParamBag *bag );
  22.114 +void         freeParamBag( ParamBag *bag );
  22.115 +//char        *paramBagToString( ParamBag * bag );
  22.116 +ParamStruc  *makeParamStruc();
  22.117 +ParamStruc  *makeParamFromStrs( char * type, char *value );
  22.118 +ssize_t      getline( char **lineptr, size_t *n, FILE *stream );
  22.119 +
  22.120 +#endif	/* _PARAM_H */
  22.121 +
    23.1 --- a/prqueue.h	Tue Mar 04 12:45:08 2014 -0800
    23.2 +++ b/prqueue.h	Fri May 09 11:19:53 2014 +0200
    23.3 @@ -1,114 +1,116 @@
    23.4 -/*
    23.5 - *  Copyright 2009 OpenSourceResearchInstitute.org
    23.6 - *  Licensed under GNU General Public License version 2
    23.7 - *
    23.8 - * Author: seanhalle@yahoo.com
    23.9 - */
   23.10 -
   23.11 -#ifndef _PRQUEUE_H
   23.12 -#define	_PRQUEUE_H
   23.13 -
   23.14 -#include <PR__include/PR__primitive_data_types.h>
   23.15 -#include <pthread.h>
   23.16 -
   23.17 -#define TRUE     1
   23.18 -#define FALSE    0
   23.19 -
   23.20 -//==================  Private Queue stuff ===================
   23.21 -/* It is the data that is shared so only need one mutex. */
   23.22 -typedef struct
   23.23 - { void      **insertPos;
   23.24 -   void      **extractPos;
   23.25 -   void      **startOfData;  //data is pointers
   23.26 -   void      **endOfData;    //set when alloc data
   23.27 - }
   23.28 -PrivQueueStruc;
   23.29 -
   23.30 -typedef void  (*DynArrayFnPtr)  ( void * );  //fn has to cast void *
   23.31 -
   23.32 -PrivQueueStruc*  makePrivQ ( );
   23.33 -bool32           isEmptyPrivQ ( PrivQueueStruc *Q ); //ret TRUE if empty
   23.34 -void*            peekPrivQ ( PrivQueueStruc *Q ); //ret NULL if empty
   23.35 -void*            readPrivQ ( PrivQueueStruc *Q ); //ret NULL if empty
   23.36 -void             writePrivQ( void *in, PrivQueueStruc *Q );
   23.37 -                    //return false when full
   23.38 -bool32           writeIfSpacePrivQ( void * in, PrivQueueStruc* Q );
   23.39 -int32            numInPrivQ( PrivQueueStruc *Q );
   23.40 -void             pushPrivQ( void * in, PrivQueueStruc* Q );
   23.41 -void             freePrivQ( PrivQueueStruc *Q );
   23.42 -
   23.43 -
   23.44 -//====================== Parallel Queue Stuff ====================
   23.45 -
   23.46 -//========== pThreads based queue ==========
   23.47 -/* It is the data that is shared so only need one mutex. */
   23.48 -typedef
   23.49 -struct
   23.50 - { pthread_mutex_t  mutex_t;
   23.51 -   pthread_cond_t   cond_w_t;
   23.52 -   pthread_cond_t   cond_r_t;
   23.53 -   int32            count;
   23.54 -   int32            readPos;
   23.55 -   int32            writePos;
   23.56 -   void*            data[1024];  //an array of pointers
   23.57 -   int w_empty;
   23.58 -   int w_full;
   23.59 - }
   23.60 -PThdQueueStruc;
   23.61 -
   23.62 -PThdQueueStruc*     makePThdQ();
   23.63 -void* readPThdQ( PThdQueueStruc *Q );
   23.64 -void writePThdQ( void *in, PThdQueueStruc *Q );
   23.65 -
   23.66 -
   23.67 -//========== CAS based queue ==========
   23.68 -typedef
   23.69 -struct
   23.70 - { volatile int32   insertLock;
   23.71 -   volatile int32   extractLock;
   23.72 -   volatile void*  *insertPos;
   23.73 -   volatile void*  *extractPos;
   23.74 -   void*   startOfData[1024];  //data is pointers
   23.75 -   void*  *endOfData;          //set when make queue
   23.76 - }
   23.77 -CASQueueStruc;
   23.78 -
   23.79 -CASQueueStruc*  makeCASQ();
   23.80 -void* readCASQ( CASQueueStruc *Q );
   23.81 -void writeCASQ( void *in, CASQueueStruc *Q );
   23.82 -
   23.83 -
   23.84 -//========= non-atomic instr based queue ===========
   23.85 -typedef
   23.86 -struct
   23.87 - { void*  *insertPos;
   23.88 -   void*  *extractPos;
   23.89 -   void*   startOfData[1024];  //data is pointers
   23.90 -   void*  *endOfData;          //set when make queue
   23.91 - }
   23.92 -SRSWQueueStruc;
   23.93 -
   23.94 -SRSWQueueStruc* makeSRSWQ();
   23.95 -void  freeSRSWQ( SRSWQueueStruc* Q );
   23.96 -void* readSRSWQ( SRSWQueueStruc *Q );
   23.97 -void  writeSRSWQ( void *in, SRSWQueueStruc *Q );
   23.98 -
   23.99 -
  23.100 -//========= non-atomic instr S R M W queue ===========
  23.101 -typedef
  23.102 -struct
  23.103 - { int32            lastQReadFrom;
  23.104 -   int32            numInternalQs;
  23.105 -   int32            internalQsSz;
  23.106 -   SRSWQueueStruc* *internalQs;
  23.107 - }
  23.108 -SRMWQueueStruc;
  23.109 -
  23.110 -SRMWQueueStruc* makeSRMWQ();
  23.111 -int addWriterToSRMWQ( SRMWQueueStruc *Q );
  23.112 -void* readSRMWQ( SRMWQueueStruc *Q );
  23.113 -void writeSRMWQ( void *in, SRMWQueueStruc *Q, int writerID );
  23.114 -
  23.115 -
  23.116 -#endif	/* _PRIVATE_QUEUE_H */
  23.117 -
  23.118 +/*
  23.119 + *  Copyright 2009 OpenSourceResearchInstitute.org
  23.120 + *  Licensed under GNU General Public License version 2
  23.121 + *
  23.122 + * Author: seanhalle@yahoo.com
  23.123 + */
  23.124 +
  23.125 +#ifndef _PRQUEUE_H
  23.126 +#define	_PRQUEUE_H
  23.127 +
  23.128 +#include <PR__include/PR__primitive_data_types.h>
  23.129 +//#include <pthreads/implement.h> //Part of pthreads-win32, needed for type definitions
  23.130 +#include <PR__include/osportability.h>
  23.131 +
  23.132 +#define TRUE     1
  23.133 +#define FALSE    0
  23.134 +
  23.135 +//==================  Private Queue stuff ===================
  23.136 +/* It is the data that is shared so only need one mutex. */
  23.137 +typedef struct _PrivQueueStruc
  23.138 + { void      **insertPos;
  23.139 +   void      **extractPos;
  23.140 +   void      **startOfData;  //data is pointers
  23.141 +   void      **endOfData;    //set when alloc data
  23.142 + }
  23.143 +PrivQueueStruc;
  23.144 +
  23.145 +typedef void  (*DynArrayFnPtr)  ( void * );  //fn has to cast void *
  23.146 +
  23.147 +PrivQueueStruc*  makePrivQ ( );
  23.148 +bool32           isEmptyPrivQ ( PrivQueueStruc *Q ); //ret TRUE if empty
  23.149 +void*            peekPrivQ ( PrivQueueStruc *Q ); //ret NULL if empty
  23.150 +void*            readPrivQ ( PrivQueueStruc *Q ); //ret NULL if empty
  23.151 +void             writePrivQ( void *in, PrivQueueStruc *Q );
  23.152 +                    //return false when full
  23.153 +bool32           writeIfSpacePrivQ( void * in, PrivQueueStruc* Q );
  23.154 +int32            numInPrivQ( PrivQueueStruc *Q );
  23.155 +void             pushPrivQ( void * in, PrivQueueStruc* Q );
  23.156 +void             freePrivQ( PrivQueueStruc *Q );
  23.157 +
  23.158 +
  23.159 +//====================== Parallel Queue Stuff ====================
  23.160 +
  23.161 +//========== pThreads based queue ==========
  23.162 +/* It is the data that is shared so only need one mutex. */
  23.163 +typedef
  23.164 +struct _PThdQueueStruc
  23.165 + { 
  23.166 +   pthread_mutex_t  mutex_t;
  23.167 +   pthread_cond_t   cond_w_t;
  23.168 +   pthread_cond_t   cond_r_t;
  23.169 +   int32            count;
  23.170 +   int32            readPos;
  23.171 +   int32            writePos;
  23.172 +   void*            data[1024];  //an array of pointers
  23.173 +   int w_empty;
  23.174 +   int w_full;
  23.175 + }
  23.176 +PThdQueueStruc;
  23.177 +
  23.178 +PThdQueueStruc*     makePThdQ();
  23.179 +void* readPThdQ( PThdQueueStruc *Q );
  23.180 +void writePThdQ( void *in, PThdQueueStruc *Q );
  23.181 +
  23.182 +
  23.183 +//========== CAS based queue ==========
  23.184 +typedef
  23.185 +struct _CASQueueStruc
  23.186 + { volatile int32   insertLock;
  23.187 +   volatile int32   extractLock;
  23.188 +   volatile void*  *insertPos;
  23.189 +   volatile void*  *extractPos;
  23.190 +   void*   startOfData[1024];  //data is pointers
  23.191 +   void*  *endOfData;          //set when make queue
  23.192 + }
  23.193 +CASQueueStruc;
  23.194 +
  23.195 +CASQueueStruc*  makeCASQ();
  23.196 +void* readCASQ( CASQueueStruc *Q );
  23.197 +void writeCASQ( void *in, CASQueueStruc *Q );
  23.198 +
  23.199 +
  23.200 +//========= non-atomic instr based queue ===========
  23.201 +typedef
  23.202 +struct _SRSWQueueStruc
  23.203 + { void*  *insertPos;
  23.204 +   void*  *extractPos;
  23.205 +   void*   startOfData[1024];  //data is pointers
  23.206 +   void*  *endOfData;          //set when make queue
  23.207 + }
  23.208 +SRSWQueueStruc;
  23.209 +
  23.210 +SRSWQueueStruc* makeSRSWQ();
  23.211 +void  freeSRSWQ( SRSWQueueStruc* Q );
  23.212 +void* readSRSWQ( SRSWQueueStruc *Q );
  23.213 +void  writeSRSWQ( void *in, SRSWQueueStruc *Q );
  23.214 +
  23.215 +
  23.216 +//========= non-atomic instr S R M W queue ===========
  23.217 +typedef
  23.218 +struct _SRMWQueueStruc
  23.219 + { int32            lastQReadFrom;
  23.220 +   int32            numInternalQs;
  23.221 +   int32            internalQsSz;
  23.222 +   SRSWQueueStruc* *internalQs;
  23.223 + }
  23.224 +SRMWQueueStruc;
  23.225 +
  23.226 +SRMWQueueStruc* makeSRMWQ();
  23.227 +int addWriterToSRMWQ( SRMWQueueStruc *Q );
  23.228 +void* readSRMWQ( SRMWQueueStruc *Q );
  23.229 +void writeSRMWQ( void *in, SRMWQueueStruc *Q, int writerID );
  23.230 +
  23.231 +
  23.232 +#endif	/* _PRIVATE_QUEUE_H */
  23.233 +