# HG changeset patch # User Sean Halle # Date 1375956036 25200 # Node ID 14241f07f742e69ca2c5d183bbe96e377d8917e5 # Parent d460a47ed2d6b02df6741933a7ebdbf65244ea06 committing files from /usr/include/PR__include directly.. test.. diff -r d460a47ed2d6 -r 14241f07f742 PR__PI.h --- a/PR__PI.h Thu Aug 08 02:39:56 2013 -0700 +++ b/PR__PI.h Thu Aug 08 03:00:36 2013 -0700 @@ -1,196 +1,196 @@ -/* - * Copyright 2009 OpenSourceResearchInstitute.org - * Licensed under GNU General Public License version 2 - * - * Author: seanhalle@yahoo.com - * - */ - -#ifndef _PR__PI_H -#define _PR__PI_H -#define _GNU_SOURCE - -#include - -//========================= Function Prototypes =========================== -/* MEANING OF WL PI SS int PROS - * These indicate which places the function is safe to use. They stand for: - * - * WL Wrapper Library -- wrapper lib code should only use these - * PI Plugin -- plugin code should only use these - * SS Startup and Shutdown -- designates these relate to startup & shutdown - * int32internal to PR -- should not be used in wrapper lib or plugin - * PROS means "OS functions for applications to use" - * - * PR_int__ functions touch internal PR data structs and are only safe - * to be used inside the master lock. However, occasionally, they appear - * in wrapper-lib or plugin code. In those cases, very careful analysis - * has been done to be sure no concurrency issues could arise. - * - * PR_WL__ functions are all safe for use outside the master lock. - * - * PROS are only safe for applications to use -- they're like a second - * language mixed in -- but they can't be used inside plugin code, and - * aren't meant for use in wrapper libraries, because they are themselves - * wrapper-library calls! - */ - -#define \ -PR_PI__create_slaveVP PR_int__create_slaveVP_helper - -//============== -//=== Lang Data -//= -#define \ -PR_PI__give_lang_data_from_slave PR_int__give_lang_data_from_slave -#define \ -PR_SS__give_lang_data_from_slave PR_int__give_lang_data_from_slave - -int32 -PR_PI__give_num_cores(); - -//============ -//=== Lang Env -//= -#define \ -PR_PI__give_proto_lang_env_for_slave PR_int__give_proto_lang_env_for_slave -#define \ -PR_PI__give_lang_env_for_slave PR_int__give_lang_env_for_slave -#define \ -PR_PI__give_lang_env_from_process PR_int__give_lang_env_from_process - - -//========= -//=== Meta Task -//= -#define \ -PR_PI__give_lang_meta_task_from_slave PR_int__give_lang_meta_task_from_slave -#define \ -PR_PI__give_prolog_of_lang_meta_task PR_int__give_prolog_of_lang_meta_task - -SlaveVP * -PR_PI__give_slave_lang_meta_task_is_assigned_to( void *langMetaTask ); - -#define \ -PR_PI__free_lang_meta_task_and_remove_from_slave PR_int__free_lang_meta_task_and_remove_from_coll - -#define \ -PR_PI__free_lang_meta_task PR_int__free_lang_meta_task - -void -PR_PI__set_no_del_flag_in_lang_meta_task( void *langMetaTask ); -void -PR_PI__clear_no_del_flag_in_lang_meta_task( void *langMetaTask ); - -//========== -//=== -//= -#define \ -PR_PI__give_ID_from_lang_meta_task PR__give_ID_from_lang_meta_task -#define \ -PR_PI__give_ID_from_slave PR__give_ID_from_slave - -//============= -//=== -//= -#define \ -PR_PI__put_slave_into_slot PR_int__put_slave_into_slot -#define \ -PR_PI__put_task_into_slot PR_int__put_task_into_slot - -PRReqst * -PR_PI__take_next_request_out_of( SlaveVP *slaveWithReq ); - -#define \ -PR_PI__take_lang_reqst_from( req ) req->langReq - -void -PR_PI__resume_slave_in_PRServ( SlaveVP *slave ); - -#define \ -PR_PI__malloc PR_int__malloc -#define \ -PR_PI__malloc_aligned PR_int__malloc_aligned -#define \ -PR_PI__free PR_int__free - - -#define \ -PR_PI__throw_exception PR_int__throw_exception - -//=============== Startup and Shutdown ================ -//=== -//= -void -PR_SS__create_topEnv(); - -AnimSlot ** -PR_SS__create_anim_slots( int32 coreSlotsAreOn ); - -void -PR_SS__create_the_coreCtlr_OS_threads(); - -//=================== -void * -PR_SS__create_lang_env( int32 size, SlaveVP *slave, int32 magicNum ); - -void -PR_SS__register_assigner( SlaveAssigner assigner, SlaveVP *seedVP, int32 magicNum ); -void -PR_SS__register_lang_shutdown_handler( LangShutdownHdlr shutdownHdlr, SlaveVP *seedVP, - int32 magicNum ); -void -PR_SS__register_lang_data_creator( LangDataCreator langDataCreator, - SlaveVP *seedVP, int32 magicNum ); -void -PR_SS__register_lang_meta_task_creator( LangDataCreator langMetaTaskCreator, - SlaveVP *seedVP, int32 magicNum ); -void -PR_SS__register_make_slave_ready_fn( MakeSlaveReadyFn fn, SlaveVP *seedVP, - int32 magicNum ); -void -PR_SS__register_make_task_ready_fn( MakeTaskReadyFn fn, SlaveVP *seedVP, - int32 magicNum ); -//=================== - -void -PR_SS__end_process_normally( PRProcess *process ); - -void -PR_SS__shutdown_OS_threads(); - -SlaveVP* -PR_SS__create_shutdown_slave(); - -void -PR_SS__cleanup_at_end_of_shutdown(); - -void -PR_SS__print_out_measurements(); - -void -PR_SS__wait_for_PR_to_shutdown(); - - -//============================= -//=== -//= - -#define \ -PR_SS__give_proto_lang_env_for_slave PR_int__give_proto_lang_env_for_slave - -#define \ -PR_SS__give_lang_meta_task_from_slave PR_int__give_lang_meta_task_from_slave -#define \ -PR_SS__give_lang_env_for_slave PR_int__give_lang_env_for_slave -#define \ -PR_SS__give_lang_env_from_process PR_int__give_lang_env_from_process - -#define \ -PR_SS__malloc PR_WL__malloc /*SS happens outside the Master*/ -#define \ -PR_SS__free PR_WL__free - -//================================================ -#endif /* _PR__PI_H */ - +/* + * Copyright 2009 OpenSourceResearchInstitute.org + * Licensed under GNU General Public License version 2 + * + * Author: seanhalle@yahoo.com + * + */ + +#ifndef _PR__PI_H +#define _PR__PI_H +#define _GNU_SOURCE + +#include + +//========================= Function Prototypes =========================== +/* MEANING OF WL PI SS int PROS + * These indicate which places the function is safe to use. They stand for: + * + * WL Wrapper Library -- wrapper lib code should only use these + * PI Plugin -- plugin code should only use these + * SS Startup and Shutdown -- designates these relate to startup & shutdown + * int32internal to PR -- should not be used in wrapper lib or plugin + * PROS means "OS functions for applications to use" + * + * PR_int__ functions touch internal PR data structs and are only safe + * to be used inside the master lock. However, occasionally, they appear + * in wrapper-lib or plugin code. In those cases, very careful analysis + * has been done to be sure no concurrency issues could arise. + * + * PR_WL__ functions are all safe for use outside the master lock. + * + * PROS are only safe for applications to use -- they're like a second + * language mixed in -- but they can't be used inside plugin code, and + * aren't meant for use in wrapper libraries, because they are themselves + * wrapper-library calls! + */ + +#define \ +PR_PI__create_slaveVP PR_int__create_slaveVP_helper + +//============== +//=== Lang Data +//= +#define \ +PR_PI__give_lang_data_from_slave PR_int__give_lang_data_from_slave +#define \ +PR_SS__give_lang_data_from_slave PR_int__give_lang_data_from_slave + +int32 +PR_PI__give_num_cores(); + +//============ +//=== Lang Env +//= +#define \ +PR_PI__give_proto_lang_env_for_slave PR_int__give_proto_lang_env_for_slave +#define \ +PR_PI__give_lang_env_for_slave PR_int__give_lang_env_for_slave +#define \ +PR_PI__give_lang_env_from_process PR_int__give_lang_env_from_process + + +//========= +//=== Meta Task +//= +#define \ +PR_PI__give_lang_meta_task_from_slave PR_int__give_lang_meta_task_from_slave +#define \ +PR_PI__give_prolog_of_lang_meta_task PR_int__give_prolog_of_lang_meta_task + +SlaveVP * +PR_PI__give_slave_lang_meta_task_is_assigned_to( void *langMetaTask ); + +#define \ +PR_PI__free_lang_meta_task_and_remove_from_slave PR_int__free_lang_meta_task_and_remove_from_coll + +#define \ +PR_PI__free_lang_meta_task PR_int__free_lang_meta_task + +void +PR_PI__set_no_del_flag_in_lang_meta_task( void *langMetaTask ); +void +PR_PI__clear_no_del_flag_in_lang_meta_task( void *langMetaTask ); + +//========== +//=== +//= +#define \ +PR_PI__give_ID_from_lang_meta_task PR__give_ID_from_lang_meta_task +#define \ +PR_PI__give_ID_from_slave PR__give_ID_from_slave + +//============= +//=== +//= +#define \ +PR_PI__put_slave_into_slot PR_int__put_slave_into_slot +#define \ +PR_PI__put_task_into_slot PR_int__put_task_into_slot + +PRReqst * +PR_PI__take_next_request_out_of( SlaveVP *slaveWithReq ); + +#define \ +PR_PI__take_lang_reqst_from( req ) req->langReq + +void +PR_PI__resume_slave_in_PRServ( SlaveVP *slave ); + +#define \ +PR_PI__malloc PR_int__malloc +#define \ +PR_PI__malloc_aligned PR_int__malloc_aligned +#define \ +PR_PI__free PR_int__free + + +#define \ +PR_PI__throw_exception PR_int__throw_exception + +//=============== Startup and Shutdown ================ +//=== +//= +void +PR_SS__create_topEnv(); + +AnimSlot ** +PR_SS__create_anim_slots( int32 coreSlotsAreOn ); + +void +PR_SS__create_the_coreCtlr_OS_threads(); + +//=================== +void * +PR_SS__create_lang_env( int32 size, SlaveVP *slave, int32 magicNum ); + +void +PR_SS__register_assigner( SlaveAssigner assigner, SlaveVP *seedVP, int32 magicNum ); +void +PR_SS__register_lang_shutdown_handler( LangShutdownHdlr shutdownHdlr, SlaveVP *seedVP, + int32 magicNum ); +void +PR_SS__register_lang_data_creator( LangDataCreator langDataCreator, + SlaveVP *seedVP, int32 magicNum ); +void +PR_SS__register_lang_meta_task_creator( LangDataCreator langMetaTaskCreator, + SlaveVP *seedVP, int32 magicNum ); +void +PR_SS__register_make_slave_ready_fn( MakeSlaveReadyFn fn, SlaveVP *seedVP, + int32 magicNum ); +void +PR_SS__register_make_task_ready_fn( MakeTaskReadyFn fn, SlaveVP *seedVP, + int32 magicNum ); +//=================== + +void +PR_SS__end_process_normally( PRProcess *process ); + +void +PR_SS__shutdown_OS_threads(); + +SlaveVP* +PR_SS__create_shutdown_slave(); + +void +PR_SS__cleanup_at_end_of_shutdown(); + +void +PR_SS__print_out_measurements(); + +void +PR_SS__wait_for_PR_to_shutdown(); + + +//============================= +//=== +//= + +#define \ +PR_SS__give_proto_lang_env_for_slave PR_int__give_proto_lang_env_for_slave + +#define \ +PR_SS__give_lang_meta_task_from_slave PR_int__give_lang_meta_task_from_slave +#define \ +PR_SS__give_lang_env_for_slave PR_int__give_lang_env_for_slave +#define \ +PR_SS__give_lang_env_from_process PR_int__give_lang_env_from_process + +#define \ +PR_SS__malloc PR_WL__malloc /*SS happens outside the Master*/ +#define \ +PR_SS__free PR_WL__free + +//================================================ +#endif /* _PR__PI_H */ + diff -r d460a47ed2d6 -r 14241f07f742 PR__SS.h --- a/PR__SS.h Thu Aug 08 02:39:56 2013 -0700 +++ b/PR__SS.h Thu Aug 08 03:00:36 2013 -0700 @@ -1,119 +1,119 @@ -/* - * Copyright 2009 OpenSourceResearchInstitute.org - * Licensed under GNU General Public License version 2 - * - * Author: seanhalle@yahoo.com - * - */ - -#ifndef _PR__SS_H -#define _PR__SS_H -#define _GNU_SOURCE - -#include - -//========================= Function Prototypes =========================== -/* MEANING OF WL PI SS int PROS - * These indicate which places the function is safe to use. They stand for: - * - * WL Wrapper Library -- wrapper lib code should only use these - * PI Plugin -- plugin code should only use these - * SS Startup and Shutdown -- designates these relate to startup & shutdown - * int32internal to PR -- should not be used in wrapper lib or plugin - * PROS means "OS functions for applications to use" - * - * PR_int__ functions touch internal PR data structs and are only safe - * to be used inside the master lock. However, occasionally, they appear - * in wrapper-lib or plugin code. In those cases, very careful analysis - * has been done to be sure no concurrency issues could arise. - * - * PR_WL__ functions are all safe for use outside the master lock. - * - * PROS are only safe for applications to use -- they're like a second - * language mixed in -- but they can't be used inside plugin code, and - * aren't meant for use in wrapper libraries, because they are themselves - * wrapper-library calls! - */ - -//=============== Startup and Shutdown ================ -//=== -//= Some of these are for PR internal use only, others for langlet use - - -#define \ -PR_SS__malloc PR_WL__malloc /*SS happens outside the Master*/ -#define \ -PR_SS__free PR_WL__free - -//=================== -void * -PR_SS__create_lang_env( int32 size, SlaveVP *slave, int32 magicNum ); - -void -PR_SS__register_assigner( SlaveAssigner assigner, SlaveVP *seedVP, int32 magicNum ); -void -PR_SS__register_lang_shutdown_handler( LangShutdownHdlr shutdownHdlr, SlaveVP *seedVP, - int32 magicNum ); -void -PR_SS__register_lang_data_creator( LangDataCreator langDataCreator, - SlaveVP *seedVP, int32 magicNum ); -void -PR_SS__register_lang_meta_task_creator( LangDataCreator langMetaTaskCreator, - SlaveVP *seedVP, int32 magicNum ); -void -PR_SS__register_make_slave_ready_fn( MakeSlaveReadyFn fn, SlaveVP *seedVP, - int32 magicNum ); -void -PR_SS__register_make_task_ready_fn( MakeTaskReadyFn fn, SlaveVP *seedVP, - int32 magicNum ); - - -//================================ -//=== -//= PR internal use only -void -PR_SS__create_topEnv(); - -AnimSlot ** -PR_SS__create_anim_slots( int32 coreSlotsAreOn ); - -void -PR_SS__create_the_coreCtlr_OS_threads(); -//=================== - -void -PR_SS__end_process_normally( PRProcess *process ); - -void -PR_SS__shutdown_OS_threads(); - -SlaveVP* -PR_SS__create_shutdown_slave(); - -void -PR_SS__cleanup_at_end_of_shutdown(); - -void -PR_SS__print_out_measurements(); - -void -PR_SS__wait_for_PR_to_shutdown(); - -//============================= -//=== -//= - -#define \ -PR_SS__give_lang_data_from_slave PR_int__give_lang_data_from_slave -#define \ -PR_SS__give_lang_meta_task_from_slave PR_int__give_lang_meta_task_from_slave -#define \ -PR_SS__give_proto_lang_env_for_slave PR_int__give_proto_lang_env_for_slave -#define \ -PR_SS__give_lang_env_for_slave PR_int__give_lang_env_for_slave -#define \ -PR_SS__give_lang_env_from_process PR_int__give_lang_env_from_process - -//================================================ -#endif /* */ - +/* + * Copyright 2009 OpenSourceResearchInstitute.org + * Licensed under GNU General Public License version 2 + * + * Author: seanhalle@yahoo.com + * + */ + +#ifndef _PR__SS_H +#define _PR__SS_H +#define _GNU_SOURCE + +#include + +//========================= Function Prototypes =========================== +/* MEANING OF WL PI SS int PROS + * These indicate which places the function is safe to use. They stand for: + * + * WL Wrapper Library -- wrapper lib code should only use these + * PI Plugin -- plugin code should only use these + * SS Startup and Shutdown -- designates these relate to startup & shutdown + * int32internal to PR -- should not be used in wrapper lib or plugin + * PROS means "OS functions for applications to use" + * + * PR_int__ functions touch internal PR data structs and are only safe + * to be used inside the master lock. However, occasionally, they appear + * in wrapper-lib or plugin code. In those cases, very careful analysis + * has been done to be sure no concurrency issues could arise. + * + * PR_WL__ functions are all safe for use outside the master lock. + * + * PROS are only safe for applications to use -- they're like a second + * language mixed in -- but they can't be used inside plugin code, and + * aren't meant for use in wrapper libraries, because they are themselves + * wrapper-library calls! + */ + +//=============== Startup and Shutdown ================ +//=== +//= Some of these are for PR internal use only, others for langlet use + + +#define \ +PR_SS__malloc PR_WL__malloc /*SS happens outside the Master*/ +#define \ +PR_SS__free PR_WL__free + +//=================== +void * +PR_SS__create_lang_env( int32 size, SlaveVP *slave, int32 magicNum ); + +void +PR_SS__register_assigner( SlaveAssigner assigner, SlaveVP *seedVP, int32 magicNum ); +void +PR_SS__register_lang_shutdown_handler( LangShutdownHdlr shutdownHdlr, SlaveVP *seedVP, + int32 magicNum ); +void +PR_SS__register_lang_data_creator( LangDataCreator langDataCreator, + SlaveVP *seedVP, int32 magicNum ); +void +PR_SS__register_lang_meta_task_creator( LangDataCreator langMetaTaskCreator, + SlaveVP *seedVP, int32 magicNum ); +void +PR_SS__register_make_slave_ready_fn( MakeSlaveReadyFn fn, SlaveVP *seedVP, + int32 magicNum ); +void +PR_SS__register_make_task_ready_fn( MakeTaskReadyFn fn, SlaveVP *seedVP, + int32 magicNum ); + + +//================================ +//=== +//= PR internal use only +void +PR_SS__create_topEnv(); + +AnimSlot ** +PR_SS__create_anim_slots( int32 coreSlotsAreOn ); + +void +PR_SS__create_the_coreCtlr_OS_threads(); +//=================== + +void +PR_SS__end_process_normally( PRProcess *process ); + +void +PR_SS__shutdown_OS_threads(); + +SlaveVP* +PR_SS__create_shutdown_slave(); + +void +PR_SS__cleanup_at_end_of_shutdown(); + +void +PR_SS__print_out_measurements(); + +void +PR_SS__wait_for_PR_to_shutdown(); + +//============================= +//=== +//= + +#define \ +PR_SS__give_lang_data_from_slave PR_int__give_lang_data_from_slave +#define \ +PR_SS__give_lang_meta_task_from_slave PR_int__give_lang_meta_task_from_slave +#define \ +PR_SS__give_proto_lang_env_for_slave PR_int__give_proto_lang_env_for_slave +#define \ +PR_SS__give_lang_env_for_slave PR_int__give_lang_env_for_slave +#define \ +PR_SS__give_lang_env_from_process PR_int__give_lang_env_from_process + +//================================================ +#endif /* */ + diff -r d460a47ed2d6 -r 14241f07f742 PR__WL.h --- a/PR__WL.h Thu Aug 08 02:39:56 2013 -0700 +++ b/PR__WL.h Thu Aug 08 03:00:36 2013 -0700 @@ -1,142 +1,142 @@ -/* - * Copyright 2009 OpenSourceResearchInstitute.org - * Licensed under GNU General Public License version 2 - * - * Author: seanhalle@yahoo.com - * - */ - -#ifndef _PR__WL_H -#define _PR__WL_H -#define _GNU_SOURCE - -#include -#include -//========================= Function Prototypes =========================== -/* MEANING OF WL PI SS int PROS - * These indicate which places the function is safe to use. They stand for: - * - * WL Wrapper Library -- wrapper lib code should only use these - * PI Plugin -- plugin code should only use these - * SS Startup and Shutdown -- designates these relate to startup & shutdown - * int32internal to PR -- should not be used in wrapper lib or plugin - * PROS means "OS functions for applications to use" - * - * PR_int__ functions touch internal PR data structs and are only safe - * to be used inside the master lock. However, occasionally, they appear - * in wrapper-lib or plugin code. In those cases, very careful analysis - * has been done to be sure no concurrency issues could arise. - * - * PR_WL__ functions are all safe for use outside the master lock. - * - * PROS are only safe for applications to use -- they're like a second - * language mixed in -- but they can't be used inside plugin code, and - * aren't meant for use in wrapper libraries, because they are themselves - * wrapper-library calls! - */ - -//============== Top level Fns called from main =============== -void -PR__start(); - -PRProcess * -PR__create_process( BirthFnPtr seed_Fn, void *seedData ); - -void -PR__end_seedVP( SlaveVP *seedSlv ); - -void -PR__end_process_from_inside( SlaveVP *seedSlv ); - -void * -PR__give_results_from_process_when_ready( PRProcess *process ); - -void -PR__wait_for_process_to_end( PRProcess *process ); - -void -PR__wait_for_all_activity_to_end(); - -void -PR__shutdown(); - -#define \ -PR__create_taskID_of_size PR_WL__create_taskID_of_size - -inline -int32 * -PR__give_ID_from_slave( SlaveVP *animSlv, int32 magicNumber ); - -inline -int32 * -PR__give_ID_from_lang_meta_task( void *_task ); - - -//============== include internally used fn prototypes ================ -#include "PR__int.h" - -#define PR_WL__give_lang_data PR_int__give_lang_data_from_slave - -#define \ -PR_WL__create_slaveVP PR_int__create_slaveVP_helper - -#define \ -PR_WL__give_lang_meta_task_from_slave PR_int__give_lang_meta_task_from_slave - -#define \ -PR_WL__give_prolog_of_lang_meta_task PR_int__give_prolog_of_lang_meta_task - -//============== Request Related =============== - -void -PR_WL__suspend_slaveVP_and_send_req( SlaveVP *callingSlv ); - -inline void -PR_WL__add_lang_request_in_mallocd_PRReqst( void *langReqData, - SlaveVP *callingSlv ); - -inline void -PR_WL__send_lang_request( void *langReq, RequestHandler handler, - SlaveVP *callingSlv, int32 magicNum ); - -void -PR_WL__send_create_slaveVP_req( void *langReq, int32 *ID, CreateHandler handler, - SlaveVP *reqstingSlv, int32 magicNum ); - -void inline -PR_WL__send_end_slave_req( void *langReq, RequestHandler handler, - SlaveVP *slvToDissipate, int32 magicNum ); - -inline void -PR_WL__send_service_request( void *langReqData, SlaveVP *callingSlv ); - -inline void -PR_WL__send_lang_shutdown_request( SlaveVP *callingSlv, int32 magicNum ); - -inline -int32 * -PR_WL__create_taskID_of_size( int32 numInts ); - -//======================== MEASUREMENT ====================== -uint64 -PR_WL__give_num_plugin_cycles(); -uint32 -PR_WL__give_num_plugin_animations(); - - -//========================= Utilities ======================= -void -PR_WL__throw_exception( char *msgStr, SlaveVP *reqstSlv, PRExcp *excpData ); -#define PR_App__throw_exception PR_WL__throw_exception - - -//======================================================================= - -//========================= Services ======================= -//#include "Services_Offered_by_PR/Measurement_and_Stats/probes.h" -//#include "Services_Offered_by_PR/Services_Language/PRServ.h" -//#include "Services_Offered_by_PR/Services_Language/libPRServ.h" - -//================================================ -#endif /* _PR_H */ - +/* + * Copyright 2009 OpenSourceResearchInstitute.org + * Licensed under GNU General Public License version 2 + * + * Author: seanhalle@yahoo.com + * + */ + +#ifndef _PR__WL_H +#define _PR__WL_H +#define _GNU_SOURCE + +#include +#include +//========================= Function Prototypes =========================== +/* MEANING OF WL PI SS int PROS + * These indicate which places the function is safe to use. They stand for: + * + * WL Wrapper Library -- wrapper lib code should only use these + * PI Plugin -- plugin code should only use these + * SS Startup and Shutdown -- designates these relate to startup & shutdown + * int32internal to PR -- should not be used in wrapper lib or plugin + * PROS means "OS functions for applications to use" + * + * PR_int__ functions touch internal PR data structs and are only safe + * to be used inside the master lock. However, occasionally, they appear + * in wrapper-lib or plugin code. In those cases, very careful analysis + * has been done to be sure no concurrency issues could arise. + * + * PR_WL__ functions are all safe for use outside the master lock. + * + * PROS are only safe for applications to use -- they're like a second + * language mixed in -- but they can't be used inside plugin code, and + * aren't meant for use in wrapper libraries, because they are themselves + * wrapper-library calls! + */ + +//============== Top level Fns called from main =============== +void +PR__start(); + +PRProcess * +PR__create_process( BirthFnPtr seed_Fn, void *seedData ); + +void +PR__end_seedVP( SlaveVP *seedSlv ); + +void +PR__end_process_from_inside( SlaveVP *seedSlv ); + +void * +PR__give_results_from_process_when_ready( PRProcess *process ); + +void +PR__wait_for_process_to_end( PRProcess *process ); + +void +PR__wait_for_all_activity_to_end(); + +void +PR__shutdown(); + +#define \ +PR__create_taskID_of_size PR_WL__create_taskID_of_size + +inline +int32 * +PR__give_ID_from_slave( SlaveVP *animSlv, int32 magicNumber ); + +inline +int32 * +PR__give_ID_from_lang_meta_task( void *_task ); + + +//============== include internally used fn prototypes ================ +#include "PR__int.h" + +#define PR_WL__give_lang_data PR_int__give_lang_data_from_slave + +#define \ +PR_WL__create_slaveVP PR_int__create_slaveVP_helper + +#define \ +PR_WL__give_lang_meta_task_from_slave PR_int__give_lang_meta_task_from_slave + +#define \ +PR_WL__give_prolog_of_lang_meta_task PR_int__give_prolog_of_lang_meta_task + +//============== Request Related =============== + +void +PR_WL__suspend_slaveVP_and_send_req( SlaveVP *callingSlv ); + +inline void +PR_WL__add_lang_request_in_mallocd_PRReqst( void *langReqData, + SlaveVP *callingSlv ); + +inline void +PR_WL__send_lang_request( void *langReq, RequestHandler handler, + SlaveVP *callingSlv, int32 magicNum ); + +void +PR_WL__send_create_slaveVP_req( void *langReq, int32 *ID, CreateHandler handler, + SlaveVP *reqstingSlv, int32 magicNum ); + +void inline +PR_WL__send_end_slave_req( void *langReq, RequestHandler handler, + SlaveVP *slvToDissipate, int32 magicNum ); + +inline void +PR_WL__send_service_request( void *langReqData, SlaveVP *callingSlv ); + +inline void +PR_WL__send_lang_shutdown_request( SlaveVP *callingSlv, int32 magicNum ); + +inline +int32 * +PR_WL__create_taskID_of_size( int32 numInts ); + +//======================== MEASUREMENT ====================== +uint64 +PR_WL__give_num_plugin_cycles(); +uint32 +PR_WL__give_num_plugin_animations(); + + +//========================= Utilities ======================= +void +PR_WL__throw_exception( char *msgStr, SlaveVP *reqstSlv, PRExcp *excpData ); +#define PR_App__throw_exception PR_WL__throw_exception + + +//======================================================================= + +//========================= Services ======================= +//#include "Services_Offered_by_PR/Measurement_and_Stats/probes.h" +//#include "Services_Offered_by_PR/Services_Language/PRServ.h" +//#include "Services_Offered_by_PR/Services_Language/libPRServ.h" + +//================================================ +#endif /* _PR_H */ + diff -r d460a47ed2d6 -r 14241f07f742 PR__int.h --- a/PR__int.h Thu Aug 08 02:39:56 2013 -0700 +++ b/PR__int.h Thu Aug 08 03:00:36 2013 -0700 @@ -1,246 +1,246 @@ -/* - * Copyright 2009 OpenSourceResearchInstitute.org - * Licensed under GNU General Public License version 2 - * - * Author: seanhalle@yahoo.com - * - */ - -#ifndef _PR_INT_H -#define _PR_INT_H -#define _GNU_SOURCE - - -#define LOCKED 1 -#define UNLOCKED 0 - -/* MEANING OF WL PI SS int - * These indicate which places the function is safe to use. They stand for: - * WL: Wrapper Library - * PI: Plugin - * SS: Startup and Shutdown - * int: internal to the PR implementation - */ - -inline -void -PR_int__reset_slaveVP_to_BirthFn( SlaveVP *slaveVP, BirthFnPtr fnPtr, - void *dataParam); - -inline -void -PR_int__point_slaveVP_to_OneParamFn( SlaveVP *slaveVP, void *fnPtr, - void *param); - -inline -void -PR_int__point_slaveVP_to_TwoParamFn( SlaveVP *slaveVP, void *fnPtr, - void *param1, void *param2); - -//=========================================================================== -// -//=========================================================================== -inline -SlaveVP * -PR_int__create_slaveVP_helper( BirthFnPtr fnPtr, void *dataParam ); - -inline -SlaveVP * -PR_int__create_slaveVP( BirthFnPtr fnPtr, void *dataParam, PRProcess *process ); - -SlaveVP * -PR_int__get_recycled_slot_slave( ); - -SlaveVP * -PR_int__create_slot_slave( ); - -inline -void -PR_int__replace_with_new_slot_slv( SlaveVP *slave ); - -void -idle_fn(void* data, SlaveVP *animatingSlv); - -inline -void -PR_int__put_task_into_slot( void *task, AnimSlot *slot ); - -inline -void -PR_int__put_slave_into_slot( SlaveVP *slave, AnimSlot *slot ); - -void inline -PRHandle__ServiceReq( SlaveVP *requestingSlv ); - -void -PR_int__free_slaveVP( SlaveVP *slave ); - -void -PR_int__recycle_slaveVP( SlaveVP *slave ); - -void -freeLangDataAsElem( void *elem ); - -void -freeMetaTaskAsElem( void *elem ); - - -//============================= -//=== Lange Env -//= -inline -void * -PR_int__give_lang_env( PRLangEnv *protoLangEnv ); - -inline -PRLangEnv * -PR_int__give_proto_lang_env( void *langEnv ); - -//inline -void * -PR_int__create_lang_env_in_process( int32 size, PRProcess *process, int32 magicNum ); - -inline -void * -PR_int__remove_lang_env_from_process_and_free( void *langEnv ); - -inline -void * -PR_int__give_lang_env_of_req( PRReqst *req, SlaveVP *requestingSlv ); - -inline -void * -PR_int__give_lang_env_for_slave( SlaveVP *slave, int32 magicNum ); -//No WL version -- not safe! if use env in WL, be sure data rd & wr is stable - -inline -PRLangEnv * -PR_int__give_proto_lang_env_for_slave( SlaveVP *slave, int32 magicNumber ); -//No WL version -- not safe! if use env in WL, be sure data rd & wr is stable - -inline -void * -PR_int__give_lang_env_from_process( PRProcess *process, int32 magicNum ); -//No WL version -- not safe! if use env in WL, be sure data rd & wr is stable - -inline -PRLangEnv * -PR_int__give_proto_lang_env_from_process( PRProcess *process, int32 magicNum ); - -//======================= -//=== Meta Task -//= -inline -PRMetaTask * -PR_int__give_prolog_of_lang_meta_task( void *task ); - -inline -void * -PR_int__give_lang_meta_task_of_prolog( PRMetaTask *metaTask); - -inline -void * -PR_int__create_lang_meta_task( int32 size, LangMetaTaskFreer freer, int32 magicNum ); - -inline -void * -PR_int__create_lang_meta_task_in_slave( int32 size, LangMetaTaskFreer freer, - SlaveVP *slave, int32 magicNum ); - -inline -PRMetaTask * -PR_int__create_generic_slave_meta_task( void *initData ); - -void -PR_int__free_lang_meta_task_and_remove_from_coll( void *langMetaTask ); - -inline -void -PR_int__insert_meta_task_into_slave( PRMetaTask *task, SlaveVP *slave ); - -inline -void -PR_int__insert_lang_meta_task_into_slave__ML( void *langMetaTask, SlaveVP *slave ); - -inline -void * -PR_int__give_lang_meta_task_from_slave( SlaveVP *slave, int32 magicNumer ); - -inline -SlaveVP * -PR_PI__give_slave_lang_meta_task_is_assigned_to( void *langMetaTask ); - -//============== -//=== Lang Data -//= -inline -void * -PR_PI__create_lang_data_in_slave( int32 size, LangDataFreer freer, - SlaveVP *slave, int32 magicNum ); - -inline -void * -PR_int__give_lang_data_from_slave( SlaveVP *slave, int32 magicNumer ); - -inline -void * -PR_int__give_lang_data_of_prolog( PRLangData *langData); - -//================================================== -//=== Collection -//= -PRCollElem ** //return an array of pointers -PR_int__make_collection_of_size( int32 numInColl ); - -inline -void -PR_int__insert_elem_into_collection( PRCollElem *elem, PRCollElem **coll, int32 hash ); - -inline -void * -PR_int__lookup_elem_in_collection( int32 hash, PRCollElem **coll ); - -inline -void -PR_int__remove_elem_from_collection( int32 hash, PRCollElem **coll ); - -inline -void -PR_int__set_collection_to_empty( PRCollElem **coll ); - -inline -void -PR_int__apply_Fn_to_all_in_collection( void (*Fn)(void *), PRCollElem **coll ); - -//=========== -//=== -//= -void -PR_int__error( char *msgStr ); - -void -PR_int__throw_exception( char *msgStr, SlaveVP *reqstSlv, PRExcp *excpData ); - -char * -PR_int__strDup( char *str ); - -inline void -PR_int__get_wrapper_lock(); - -inline void -PR_int__get_malloc_lock(); - -#define PR_int__release_master_lock() _PRTopEnv->masterLock = UNLOCKED - -#define PR_int__release_wrapper_lock() _PRTopEnv->wrapperLock = UNLOCKED - -#define PR_int__release_malloc_lock() _PRTopEnv->mallocLock = UNLOCKED - -inline uint32_t -PR_int__randomNumber(); - -inline void -PR_int__backoff_for_TooLongToGetLock( int32 numTriesToGetLock ); - -#endif /* _PR_INT_H */ - +/* + * Copyright 2009 OpenSourceResearchInstitute.org + * Licensed under GNU General Public License version 2 + * + * Author: seanhalle@yahoo.com + * + */ + +#ifndef _PR_INT_H +#define _PR_INT_H +#define _GNU_SOURCE + + +#define LOCKED 1 +#define UNLOCKED 0 + +/* MEANING OF WL PI SS int + * These indicate which places the function is safe to use. They stand for: + * WL: Wrapper Library + * PI: Plugin + * SS: Startup and Shutdown + * int: internal to the PR implementation + */ + +inline +void +PR_int__reset_slaveVP_to_BirthFn( SlaveVP *slaveVP, BirthFnPtr fnPtr, + void *dataParam); + +inline +void +PR_int__point_slaveVP_to_OneParamFn( SlaveVP *slaveVP, void *fnPtr, + void *param); + +inline +void +PR_int__point_slaveVP_to_TwoParamFn( SlaveVP *slaveVP, void *fnPtr, + void *param1, void *param2); + +//=========================================================================== +// +//=========================================================================== +inline +SlaveVP * +PR_int__create_slaveVP_helper( BirthFnPtr fnPtr, void *dataParam ); + +inline +SlaveVP * +PR_int__create_slaveVP( BirthFnPtr fnPtr, void *dataParam, PRProcess *process ); + +SlaveVP * +PR_int__get_recycled_slot_slave( ); + +SlaveVP * +PR_int__create_slot_slave( ); + +inline +void +PR_int__replace_with_new_slot_slv( SlaveVP *slave ); + +void +idle_fn(void* data, SlaveVP *animatingSlv); + +inline +void +PR_int__put_task_into_slot( void *task, AnimSlot *slot ); + +inline +void +PR_int__put_slave_into_slot( SlaveVP *slave, AnimSlot *slot ); + +void inline +PRHandle__ServiceReq( SlaveVP *requestingSlv ); + +void +PR_int__free_slaveVP( SlaveVP *slave ); + +void +PR_int__recycle_slaveVP( SlaveVP *slave ); + +void +freeLangDataAsElem( void *elem ); + +void +freeMetaTaskAsElem( void *elem ); + + +//============================= +//=== Lange Env +//= +inline +void * +PR_int__give_lang_env( PRLangEnv *protoLangEnv ); + +inline +PRLangEnv * +PR_int__give_proto_lang_env( void *langEnv ); + +//inline +void * +PR_int__create_lang_env_in_process( int32 size, PRProcess *process, int32 magicNum ); + +inline +void * +PR_int__remove_lang_env_from_process_and_free( void *langEnv ); + +inline +void * +PR_int__give_lang_env_of_req( PRReqst *req, SlaveVP *requestingSlv ); + +inline +void * +PR_int__give_lang_env_for_slave( SlaveVP *slave, int32 magicNum ); +//No WL version -- not safe! if use env in WL, be sure data rd & wr is stable + +inline +PRLangEnv * +PR_int__give_proto_lang_env_for_slave( SlaveVP *slave, int32 magicNumber ); +//No WL version -- not safe! if use env in WL, be sure data rd & wr is stable + +inline +void * +PR_int__give_lang_env_from_process( PRProcess *process, int32 magicNum ); +//No WL version -- not safe! if use env in WL, be sure data rd & wr is stable + +inline +PRLangEnv * +PR_int__give_proto_lang_env_from_process( PRProcess *process, int32 magicNum ); + +//======================= +//=== Meta Task +//= +inline +PRMetaTask * +PR_int__give_prolog_of_lang_meta_task( void *task ); + +inline +void * +PR_int__give_lang_meta_task_of_prolog( PRMetaTask *metaTask); + +inline +void * +PR_int__create_lang_meta_task( int32 size, LangMetaTaskFreer freer, int32 magicNum ); + +inline +void * +PR_int__create_lang_meta_task_in_slave( int32 size, LangMetaTaskFreer freer, + SlaveVP *slave, int32 magicNum ); + +inline +PRMetaTask * +PR_int__create_generic_slave_meta_task( void *initData ); + +void +PR_int__free_lang_meta_task_and_remove_from_coll( void *langMetaTask ); + +inline +void +PR_int__insert_meta_task_into_slave( PRMetaTask *task, SlaveVP *slave ); + +inline +void +PR_int__insert_lang_meta_task_into_slave__ML( void *langMetaTask, SlaveVP *slave ); + +inline +void * +PR_int__give_lang_meta_task_from_slave( SlaveVP *slave, int32 magicNumer ); + +inline +SlaveVP * +PR_PI__give_slave_lang_meta_task_is_assigned_to( void *langMetaTask ); + +//============== +//=== Lang Data +//= +inline +void * +PR_PI__create_lang_data_in_slave( int32 size, LangDataFreer freer, + SlaveVP *slave, int32 magicNum ); + +inline +void * +PR_int__give_lang_data_from_slave( SlaveVP *slave, int32 magicNumer ); + +inline +void * +PR_int__give_lang_data_of_prolog( PRLangData *langData); + +//================================================== +//=== Collection +//= +PRCollElem ** //return an array of pointers +PR_int__make_collection_of_size( int32 numInColl ); + +inline +void +PR_int__insert_elem_into_collection( PRCollElem *elem, PRCollElem **coll, int32 hash ); + +inline +void * +PR_int__lookup_elem_in_collection( int32 hash, PRCollElem **coll ); + +inline +void +PR_int__remove_elem_from_collection( int32 hash, PRCollElem **coll ); + +inline +void +PR_int__set_collection_to_empty( PRCollElem **coll ); + +inline +void +PR_int__apply_Fn_to_all_in_collection( void (*Fn)(void *), PRCollElem **coll ); + +//=========== +//=== +//= +void +PR_int__error( char *msgStr ); + +void +PR_int__throw_exception( char *msgStr, SlaveVP *reqstSlv, PRExcp *excpData ); + +char * +PR_int__strDup( char *str ); + +inline void +PR_int__get_wrapper_lock(); + +inline void +PR_int__get_malloc_lock(); + +#define PR_int__release_master_lock() _PRTopEnv->masterLock = UNLOCKED + +#define PR_int__release_wrapper_lock() _PRTopEnv->wrapperLock = UNLOCKED + +#define PR_int__release_malloc_lock() _PRTopEnv->mallocLock = UNLOCKED + +inline uint32_t +PR_int__randomNumber(); + +inline void +PR_int__backoff_for_TooLongToGetLock( int32 numTriesToGetLock ); + +#endif /* _PR_INT_H */ + diff -r d460a47ed2d6 -r 14241f07f742 PR__primitive_data_types.h --- a/PR__primitive_data_types.h Thu Aug 08 02:39:56 2013 -0700 +++ b/PR__primitive_data_types.h Thu Aug 08 03:00:36 2013 -0700 @@ -1,42 +1,42 @@ -/* - * Copyright 2009 OpenSourceResearchInstitute.org - * Licensed under GNU General Public License version 2 - * - * Author: seanhalle@yahoo.com - * - - */ - -#ifndef _PRIMITIVE_DATA_TYPES_H -#define _PRIMITIVE_DATA_TYPES_H - - -/*For portability, need primitive data types that have a well defined - * size, and well-defined layout into bytes - *To do this, provide standard aliases for all primitive data types - *These aliases must be used in all functions instead of the ANSI types - * - *When PR is used together with BLIS, these definitions will be replaced - * inside each specialization module according to the compiler used in - * that module and the hardware being specialized to. - */ -typedef char bool8; -typedef char int8; -typedef char uint8; -typedef short int16; -typedef unsigned short uint16; -typedef int int32; -typedef unsigned int uint32; -typedef unsigned int bool32; -typedef long long int64; -typedef unsigned long long uint64; -typedef float float32; -typedef double float64; -//typedef double double float128; //GCC doesn't like this -#define float128 double double - -#define TRUE 1 -#define FALSE 0 - -#endif /* _PRIMITIVE_DATA_TYPES_H */ - +/* + * Copyright 2009 OpenSourceResearchInstitute.org + * Licensed under GNU General Public License version 2 + * + * Author: seanhalle@yahoo.com + * + + */ + +#ifndef _PRIMITIVE_DATA_TYPES_H +#define _PRIMITIVE_DATA_TYPES_H + + +/*For portability, need primitive data types that have a well defined + * size, and well-defined layout into bytes + *To do this, provide standard aliases for all primitive data types + *These aliases must be used in all functions instead of the ANSI types + * + *When PR is used together with BLIS, these definitions will be replaced + * inside each specialization module according to the compiler used in + * that module and the hardware being specialized to. + */ +typedef char bool8; +typedef char int8; +typedef char uint8; +typedef short int16; +typedef unsigned short uint16; +typedef int int32; +typedef unsigned int uint32; +typedef unsigned int bool32; +typedef long long int64; +typedef unsigned long long uint64; +typedef float float32; +typedef double float64; +//typedef double double float128; //GCC doesn't like this +#define float128 double double + +#define TRUE 1 +#define FALSE 0 + +#endif /* _PRIMITIVE_DATA_TYPES_H */ + diff -r d460a47ed2d6 -r 14241f07f742 PR__structs__common.h --- a/PR__structs__common.h Thu Aug 08 02:39:56 2013 -0700 +++ b/PR__structs__common.h Thu Aug 08 03:00:36 2013 -0700 @@ -1,346 +1,346 @@ -/* - * Copyright 2009 OpenSourceResearchInstitute.org - * Licensed under GNU General Public License version 2 - * - * Author: seanhalle@yahoo.com - * - */ - -#ifndef _PR__structs__common_H -#define _PR__structs__common_H -#define _GNU_SOURCE - -#include -#include - -//#include "PR_defs__turn_on_and_off.h" -#include -#include -#include - -#include //reqd by PRProcess -#include //reqd by PRProcess -#include //reqd by PRProcess -#include //reqd by PRLangEnv, in turn reqd by PRProcess - -//================================ Typedefs ================================= -//=== -//= -#define ZERO 0 - -//typedef unsigned long long TSCount; - -typedef struct _AnimSlot AnimSlot; -typedef struct _PRReqst PRReqst; -typedef struct _SlaveVP SlaveVP; -//typedef struct _MasterVP MasterVP; -typedef struct _IntervalProbe IntervalProbe; -typedef struct _PRLangEnv PRLangEnv; //a prolog -typedef struct _PRMetaTask PRMetaTask; //a prolog -typedef struct _PRLangData PRLangData; //a prolog -typedef struct _PRCollElem PRCollElem; //generic form of the prologs - -typedef bool32 (*SlaveAssigner) ( void *, AnimSlot* ); //langEnv, slot for HW info -typedef void (*RequestHandler) ( void *, SlaveVP *, void * ); //req, slv, langEnv -typedef void *(*CreateHandler) ( void *, SlaveVP *, void * ); //req, slv, langEnv -typedef void (*LangShutdownHdlr) ( void * ); //langEnv -typedef void *(*LangDataCreator) ( SlaveVP * ); -typedef void (*LangDataFreer) ( void * ); //lang data to free -typedef void *(*LangMetaTaskCreator)( SlaveVP * ); //when slave has no meta task for magic num -typedef void (*LangMetaTaskFreer) ( void * ); //lang meta task to free -typedef void (*MakeSlaveReadyFn) ( SlaveVP *, void * ); //slave and langEnv -typedef void (*MakeTaskReadyFn) ( void *, void * ); //langTask and langEnv -typedef void (*BirthFnPtr) ( void *, SlaveVP * ); //initData, animSlv -typedef void BirthFn ( void *, SlaveVP * ); //initData, animSlv -typedef void (*ResumeSlvFnPtr) ( SlaveVP *, void * ); - //=========== MEASUREMENT STUFF ========== - MEAS__Insert_Counter_Handler - //======================================== - - -typedef struct - { //These are set by the plugin during startup and the application - char *assignerInfo; - char *appInfo; - char *inputInfo; - } -PRSysMetaInfo; - -//===================== Process Data Struct ====================== - -/*This structure holds all the information PR needs to manage a program. PR - * stores information about what percent of CPU time the program is getting, - * - */ - -typedef struct - { - int32 numEnvsWithWork; - void *resultToReturn; - - PRLangEnv **langEnvs; //used as a hash table - PRLangEnv **protoLangEnvsList; //for fast linear scan of envs - int32 numLangEnvs; //for fast linear scan of envs - - SlaveVP *seedSlv; - - int32 numLiveGenericSlvs; - int32 numLiveTasks; - - SlaveAssigner overrideAssigner; - - - - //These are used to coord with an OS thread waiting for process to end - bool32 hasWaitingToEnd; - bool32 executionIsComplete; - pthread_mutex_t doneLock; - pthread_cond_t doneCond; - pthread_mutex_t doneAckLock; //waiter gets, then releases when done waiting - - //=========== MEASUREMENT STUFF ============= - IntervalProbe **intervalProbes; - PrivDynArrayInfo *dynIntervalProbesInfo; - HashTable *probeNameHashTbl; - int32 masterCreateProbeID; - float64 createPtInSecs; //real-clock time PR initialized - Histogram **measHists; - PrivDynArrayInfo *measHistsInfo; - MEAS__Insert_Susp_Meas_Fields_into_MasterEnv; - MEAS__Insert_Master_Meas_Fields_into_MasterEnv; - MEAS__Insert_Master_Lock_Meas_Fields_into_MasterEnv; - MEAS__Insert_Malloc_Meas_Fields_into_MasterEnv; - MEAS__Insert_Plugin_Meas_Fields_into_MasterEnv; - MEAS__Insert_System_Meas_Fields_into_MasterEnv; - MEAS__Insert_Counter_Meas_Fields_into_MasterEnv; - //========================================== - } -PRProcess; - - -//============= Request Related =========== -// - -enum PRReqstType //avoid starting enums at 0, for debug reasons - { - TaskCreate = 1, - TaskEnd, - SlvCreate, - SlvDissipate, - Language, - Service, //To invoke a PR provided equivalent of a language request (ex: probe) - Hardware, - IO, - OSCall, - LangShutdown, - ProcessEnd, - PRShutdown - }; - - -struct _PRReqst - { - enum PRReqstType reqType;//used for special forms that have PR behavior - void *langReq; - PRProcess *processReqIsIn; - int32 langMagicNumber; - SlaveVP *requestingSlave; - - BirthFnPtr topLevelFn; - void *initData; - int32 *ID; - - //The request handling structure is a bit messy.. for special forms, - // such as create and dissipate, the language inserts pointer to handler - // fn directly into the request.. might change to this for all requests - RequestHandler handler; //pointer to handler fn - CreateHandler createHdlr; //special because returns something - int32 createSuspendedGroup; //must be non-zero - - PRReqst *nextReqst; - }; -//PRReqst - -enum PRServiceReqType //These are equivalent to lang requests, but for - { // PR's services available directly to app, like OS - make_probe = 1, // and probe services -- like a PR-wide built-in lang - throw_excp, - openFile, - otherIO - }; - -typedef struct - { enum PRServiceReqType reqType; - SlaveVP *requestingSlv; - char *nameStr; //for create probe - char *msgStr; //for exception - void *exceptionData; - } -PRServiceReq; - - -//==================== Core data structures =================== - -typedef struct - { - //for future expansion - } -SlotPerfInfo; - -struct _AnimSlot - { - int32 workIsDone; - int32 needsWorkAssigned; - SlaveVP *slaveAssignedToSlot; - - int32 slotIdx; //needed by Holistic Model's data gathering - int32 coreSlotIsOn; - SlotPerfInfo *perfInfo; //used by assigner to pick best slave for core - }; -//AnimSlot - -enum VPtype - { SlotTaskSlv = 1,//Slave tied to an anim slot, only animates tasks - FreeTaskSlv, //When a suspended task ends, the slave becomes this - GenericSlv, //the VP is explicitly seen in the app code, or task suspends - SeedSlv, - Master_VP, - ShutdownVP, - IdleVP - }; - -/*This structure embodies the state of a slaveVP. It is reused for masterVP - * and shutdownVPs. - */ -struct _SlaveVP - { //The offsets of these fields are hard-coded into assembly - void *stackPtr; //save the core's stack ptr when suspend - void *framePtr; //save core's frame ptr when suspend - void *resumeInstrPtr; //save core's program-counter when suspend - void *coreCtlrFramePtr; //restore before jmp back to core controller - void *coreCtlrStackPtr; //restore before jmp back to core controller - - //============ below this, no fields are used in asm ============= - - void *startOfStack; //used to free, and to point slave to Fn - PRProcess *processSlaveIsIn; - enum VPtype typeOfVP; //Slave vs Master vs Shutdown.. - int32 slaveNum; //each slave given it's seq in creation - int32 *ID; //App defines meaning of each int in array - int32 coreAnimatedBy; - int32 numTimesAssignedToASlot; //Each assign is for one work-unit, so is an ID - //note, a scheduling decision is uniquely identified by the triple: - // -- used in record & replay - - //for comm -- between master and coreCtlr & btwn wrapper lib and plugin - AnimSlot *animSlotAssignedTo; - PRReqst *request; //wrapper lib puts in requests, plugin takes out - void *dataRetFromReq;//Return vals from plugin to Wrapper Lib - - //For language specific data that needs to be in the slave - //These are accessed directly for single-lang, but multi-lang places - // a holder here instead, then uses magic num to get lang's version - PRLangData **langDatas; //Lang saves lang-specific things in slave here - PRMetaTask **metaTasks; - - //=========== MEASUREMENT STUFF ========== - MEAS__Insert_Meas_Fields_into_Slave; - float64 createPtInSecs; //time VP created, in seconds - //======================================== - -// int8 cacheLinePad[512 - sizeof(contents)]; //for false sharing - }; -//SlaveVP - - -enum PRMode - { SingleLang = 1, - StandaloneWTasks, - MultiLang - }; - - -//===================== These are prologs ==================== -//===A prolog is data immediately before pointer returned by a create function. -//= -struct _PRLangEnv - { //============== First two must match PRCollElem ============== - int32 langMagicNumber; //indexes into hash array of langEnvs in PRProcess - PRLangEnv *chainedLangEnv; //chains to langEnvs with same hash - //============================================================= - - SlaveAssigner workAssigner; - LangShutdownHdlr shutdownHdlr; //called when lang ended or process shutdown - LangDataCreator langDataCreator; - LangMetaTaskCreator langMetaTaskCreator; - MakeSlaveReadyFn makeSlaveReadyFn; - MakeTaskReadyFn makeTaskReadyFn; - - //when multi-lang, master polls lang env's to find one with work in it.. - // in single-lang case, flag ignored, master always asks lang for work - int32 hasWork; - PRProcess *processEnvIsIn; - - int32 idxInProcess; //index into array of langEnvs in the process - - int32 numReadyWork; - - int32 numLiveWork; - PrivQueueStruc *waitingForWorkToEndQ; - }; -//PRLangEnv -- this is the prolog of every lang's lang env - -enum PRTaskType - { GenericSlave = 1, - SlotTask, - FreeTask - }; - -struct _PRMetaTask - { //============== First two must match PRCollElem ============== - int32 langMagicNumber; - PRMetaTask *chainedMetaTask; - //============================================================= - enum PRTaskType taskType; - int32 *ID; //is standard PR ID - PRProcess *processTaskIsIn; - SlaveVP *slaveAssignedTo; //not valid until task animated - BirthFnPtr topLevelFn; //This is the Fn executes as the task - void *initData; //The data taken by the function - LangMetaTaskFreer freer; - bool32 goAheadAndFree; - - //NOTE: info needed for "wait" functionality is inside lang's metaTask - }; -//PRMetaTask -- prolog of every lang's meta task - -struct _PRLangData - { //============== First two must match PRCollElem ============== - int32 langMagicNumber; - PRLangData *chainedLangData; - //============================================================= - LangDataFreer freer; - bool32 goAheadAndFree; - SlaveVP *slaveAssignedTo; - }; -//PRLangData -- this is the prolog of each lang's lang data - -struct _PRCollElem - { - int32 hash; - PRCollElem *chained; - }; -//PRCollElem -- this is generic form of all the prologs - - - -//========================= Extra Stuff Data Strucs ======================= -typedef struct - { - - } -PRExcp; //exception - - -#endif /* _PR__structs_H */ - +/* + * Copyright 2009 OpenSourceResearchInstitute.org + * Licensed under GNU General Public License version 2 + * + * Author: seanhalle@yahoo.com + * + */ + +#ifndef _PR__structs__common_H +#define _PR__structs__common_H +#define _GNU_SOURCE + +#include +#include + +//#include "PR_defs__turn_on_and_off.h" +#include +#include +#include + +#include //reqd by PRProcess +#include //reqd by PRProcess +#include //reqd by PRProcess +#include //reqd by PRLangEnv, in turn reqd by PRProcess + +//================================ Typedefs ================================= +//=== +//= +#define ZERO 0 + +//typedef unsigned long long TSCount; + +typedef struct _AnimSlot AnimSlot; +typedef struct _PRReqst PRReqst; +typedef struct _SlaveVP SlaveVP; +//typedef struct _MasterVP MasterVP; +typedef struct _IntervalProbe IntervalProbe; +typedef struct _PRLangEnv PRLangEnv; //a prolog +typedef struct _PRMetaTask PRMetaTask; //a prolog +typedef struct _PRLangData PRLangData; //a prolog +typedef struct _PRCollElem PRCollElem; //generic form of the prologs + +typedef bool32 (*SlaveAssigner) ( void *, AnimSlot* ); //langEnv, slot for HW info +typedef void (*RequestHandler) ( void *, SlaveVP *, void * ); //req, slv, langEnv +typedef void *(*CreateHandler) ( void *, SlaveVP *, void * ); //req, slv, langEnv +typedef void (*LangShutdownHdlr) ( void * ); //langEnv +typedef void *(*LangDataCreator) ( SlaveVP * ); +typedef void (*LangDataFreer) ( void * ); //lang data to free +typedef void *(*LangMetaTaskCreator)( SlaveVP * ); //when slave has no meta task for magic num +typedef void (*LangMetaTaskFreer) ( void * ); //lang meta task to free +typedef void (*MakeSlaveReadyFn) ( SlaveVP *, void * ); //slave and langEnv +typedef void (*MakeTaskReadyFn) ( void *, void * ); //langTask and langEnv +typedef void (*BirthFnPtr) ( void *, SlaveVP * ); //initData, animSlv +typedef void BirthFn ( void *, SlaveVP * ); //initData, animSlv +typedef void (*ResumeSlvFnPtr) ( SlaveVP *, void * ); + //=========== MEASUREMENT STUFF ========== + MEAS__Insert_Counter_Handler + //======================================== + + +typedef struct + { //These are set by the plugin during startup and the application + char *assignerInfo; + char *appInfo; + char *inputInfo; + } +PRSysMetaInfo; + +//===================== Process Data Struct ====================== + +/*This structure holds all the information PR needs to manage a program. PR + * stores information about what percent of CPU time the program is getting, + * + */ + +typedef struct + { + int32 numEnvsWithWork; + void *resultToReturn; + + PRLangEnv **langEnvs; //used as a hash table + PRLangEnv **protoLangEnvsList; //for fast linear scan of envs + int32 numLangEnvs; //for fast linear scan of envs + + SlaveVP *seedSlv; + + int32 numLiveGenericSlvs; + int32 numLiveTasks; + + SlaveAssigner overrideAssigner; + + + + //These are used to coord with an OS thread waiting for process to end + bool32 hasWaitingToEnd; + bool32 executionIsComplete; + pthread_mutex_t doneLock; + pthread_cond_t doneCond; + pthread_mutex_t doneAckLock; //waiter gets, then releases when done waiting + + //=========== MEASUREMENT STUFF ============= + IntervalProbe **intervalProbes; + PrivDynArrayInfo *dynIntervalProbesInfo; + HashTable *probeNameHashTbl; + int32 masterCreateProbeID; + float64 createPtInSecs; //real-clock time PR initialized + Histogram **measHists; + PrivDynArrayInfo *measHistsInfo; + MEAS__Insert_Susp_Meas_Fields_into_MasterEnv; + MEAS__Insert_Master_Meas_Fields_into_MasterEnv; + MEAS__Insert_Master_Lock_Meas_Fields_into_MasterEnv; + MEAS__Insert_Malloc_Meas_Fields_into_MasterEnv; + MEAS__Insert_Plugin_Meas_Fields_into_MasterEnv; + MEAS__Insert_System_Meas_Fields_into_MasterEnv; + MEAS__Insert_Counter_Meas_Fields_into_MasterEnv; + //========================================== + } +PRProcess; + + +//============= Request Related =========== +// + +enum PRReqstType //avoid starting enums at 0, for debug reasons + { + TaskCreate = 1, + TaskEnd, + SlvCreate, + SlvDissipate, + Language, + Service, //To invoke a PR provided equivalent of a language request (ex: probe) + Hardware, + IO, + OSCall, + LangShutdown, + ProcessEnd, + PRShutdown + }; + + +struct _PRReqst + { + enum PRReqstType reqType;//used for special forms that have PR behavior + void *langReq; + PRProcess *processReqIsIn; + int32 langMagicNumber; + SlaveVP *requestingSlave; + + BirthFnPtr topLevelFn; + void *initData; + int32 *ID; + + //The request handling structure is a bit messy.. for special forms, + // such as create and dissipate, the language inserts pointer to handler + // fn directly into the request.. might change to this for all requests + RequestHandler handler; //pointer to handler fn + CreateHandler createHdlr; //special because returns something + int32 createSuspendedGroup; //must be non-zero + + PRReqst *nextReqst; + }; +//PRReqst + +enum PRServiceReqType //These are equivalent to lang requests, but for + { // PR's services available directly to app, like OS + make_probe = 1, // and probe services -- like a PR-wide built-in lang + throw_excp, + openFile, + otherIO + }; + +typedef struct + { enum PRServiceReqType reqType; + SlaveVP *requestingSlv; + char *nameStr; //for create probe + char *msgStr; //for exception + void *exceptionData; + } +PRServiceReq; + + +//==================== Core data structures =================== + +typedef struct + { + //for future expansion + } +SlotPerfInfo; + +struct _AnimSlot + { + int32 workIsDone; + int32 needsWorkAssigned; + SlaveVP *slaveAssignedToSlot; + + int32 slotIdx; //needed by Holistic Model's data gathering + int32 coreSlotIsOn; + SlotPerfInfo *perfInfo; //used by assigner to pick best slave for core + }; +//AnimSlot + +enum VPtype + { SlotTaskSlv = 1,//Slave tied to an anim slot, only animates tasks + FreeTaskSlv, //When a suspended task ends, the slave becomes this + GenericSlv, //the VP is explicitly seen in the app code, or task suspends + SeedSlv, + Master_VP, + ShutdownVP, + IdleVP + }; + +/*This structure embodies the state of a slaveVP. It is reused for masterVP + * and shutdownVPs. + */ +struct _SlaveVP + { //The offsets of these fields are hard-coded into assembly + void *stackPtr; //save the core's stack ptr when suspend + void *framePtr; //save core's frame ptr when suspend + void *resumeInstrPtr; //save core's program-counter when suspend + void *coreCtlrFramePtr; //restore before jmp back to core controller + void *coreCtlrStackPtr; //restore before jmp back to core controller + + //============ below this, no fields are used in asm ============= + + void *startOfStack; //used to free, and to point slave to Fn + PRProcess *processSlaveIsIn; + enum VPtype typeOfVP; //Slave vs Master vs Shutdown.. + int32 slaveNum; //each slave given it's seq in creation + int32 *ID; //App defines meaning of each int in array + int32 coreAnimatedBy; + int32 numTimesAssignedToASlot; //Each assign is for one work-unit, so is an ID + //note, a scheduling decision is uniquely identified by the triple: + // -- used in record & replay + + //for comm -- between master and coreCtlr & btwn wrapper lib and plugin + AnimSlot *animSlotAssignedTo; + PRReqst *request; //wrapper lib puts in requests, plugin takes out + void *dataRetFromReq;//Return vals from plugin to Wrapper Lib + + //For language specific data that needs to be in the slave + //These are accessed directly for single-lang, but multi-lang places + // a holder here instead, then uses magic num to get lang's version + PRLangData **langDatas; //Lang saves lang-specific things in slave here + PRMetaTask **metaTasks; + + //=========== MEASUREMENT STUFF ========== + MEAS__Insert_Meas_Fields_into_Slave; + float64 createPtInSecs; //time VP created, in seconds + //======================================== + +// int8 cacheLinePad[512 - sizeof(contents)]; //for false sharing + }; +//SlaveVP + + +enum PRMode + { SingleLang = 1, + StandaloneWTasks, + MultiLang + }; + + +//===================== These are prologs ==================== +//===A prolog is data immediately before pointer returned by a create function. +//= +struct _PRLangEnv + { //============== First two must match PRCollElem ============== + int32 langMagicNumber; //indexes into hash array of langEnvs in PRProcess + PRLangEnv *chainedLangEnv; //chains to langEnvs with same hash + //============================================================= + + SlaveAssigner workAssigner; + LangShutdownHdlr shutdownHdlr; //called when lang ended or process shutdown + LangDataCreator langDataCreator; + LangMetaTaskCreator langMetaTaskCreator; + MakeSlaveReadyFn makeSlaveReadyFn; + MakeTaskReadyFn makeTaskReadyFn; + + //when multi-lang, master polls lang env's to find one with work in it.. + // in single-lang case, flag ignored, master always asks lang for work + int32 hasWork; + PRProcess *processEnvIsIn; + + int32 idxInProcess; //index into array of langEnvs in the process + + int32 numReadyWork; + + int32 numLiveWork; + PrivQueueStruc *waitingForWorkToEndQ; + }; +//PRLangEnv -- this is the prolog of every lang's lang env + +enum PRTaskType + { GenericSlave = 1, + SlotTask, + FreeTask + }; + +struct _PRMetaTask + { //============== First two must match PRCollElem ============== + int32 langMagicNumber; + PRMetaTask *chainedMetaTask; + //============================================================= + enum PRTaskType taskType; + int32 *ID; //is standard PR ID + PRProcess *processTaskIsIn; + SlaveVP *slaveAssignedTo; //not valid until task animated + BirthFnPtr topLevelFn; //This is the Fn executes as the task + void *initData; //The data taken by the function + LangMetaTaskFreer freer; + bool32 goAheadAndFree; + + //NOTE: info needed for "wait" functionality is inside lang's metaTask + }; +//PRMetaTask -- prolog of every lang's meta task + +struct _PRLangData + { //============== First two must match PRCollElem ============== + int32 langMagicNumber; + PRLangData *chainedLangData; + //============================================================= + LangDataFreer freer; + bool32 goAheadAndFree; + SlaveVP *slaveAssignedTo; + }; +//PRLangData -- this is the prolog of each lang's lang data + +struct _PRCollElem + { + int32 hash; + PRCollElem *chained; + }; +//PRCollElem -- this is generic form of all the prologs + + + +//========================= Extra Stuff Data Strucs ======================= +typedef struct + { + + } +PRExcp; //exception + + +#endif /* _PR__structs_H */ + diff -r d460a47ed2d6 -r 14241f07f742 Services_offered_by_PR/DEBUG__macros.h --- a/Services_offered_by_PR/DEBUG__macros.h Thu Aug 08 02:39:56 2013 -0700 +++ b/Services_offered_by_PR/DEBUG__macros.h Thu Aug 08 03:00:36 2013 -0700 @@ -1,65 +1,65 @@ -/* - * Copyright 2009 OpenSourceResearchInstitute.org - * Licensed under GNU General Public License version 2 - * - * Author: seanhalle@yahoo.com - * - */ - -#ifndef _DEBUG__macros_H -#define _DEBUG__macros_H -#define _GNU_SOURCE - -/* - */ -#ifdef DEBUG__TURN_ON_DEBUG_PRINT - #define DEBUG__printf( bool, ...) \ - do{\ - if(bool)\ - { printf(__VA_ARGS__);\ - printf(" | function: %s\n", __FUNCTION__);\ - fflush(stdin);\ - }\ - }while(0);/*macro magic to isolate var-names*/ - - #define DEBUG__printf1( bool, msg, param) \ - do{\ - if(bool)\ - { printf(msg, param);\ - printf(" | function: %s\n", __FUNCTION__);\ - fflush(stdin);\ - }\ - }while(0);/*macro magic to isolate var-names*/ - - #define DEBUG__printf2( bool, msg, p1, p2) \ - do{\ - if(bool)\ - { printf(msg, p1, p2); \ - printf(" | function: %s\n", __FUNCTION__);\ - fflush(stdin);\ - }\ - }while(0);/*macro magic to isolate var-names*/ - - #define DEBUG__printf3( bool, msg, p1, p2, p3) \ - do{\ - if(bool)\ - { printf(msg, p1, p2, p3); \ - printf(" | function: %s\n", __FUNCTION__);\ - fflush(stdin);\ - }\ - }while(0);/*macro magic to isolate var-names*/ - -#else - #define DEBUG__printf( bool, ...) - #define DEBUG__printf1( bool, msg, param) - #define DEBUG__printf2( bool, msg, p1, p2) -#endif - -//============================= ERROR MSGs ============================ -#define ERROR(msg) printf(msg); -#define ERROR1(msg, param) printf(msg, param); -#define ERROR2(msg, p1, p2) printf(msg, p1, p2); - -//=========================================================================== -#endif /* _PR_DEFS_H */ - +/* + * Copyright 2009 OpenSourceResearchInstitute.org + * Licensed under GNU General Public License version 2 + * + * Author: seanhalle@yahoo.com + * + */ + +#ifndef _DEBUG__macros_H +#define _DEBUG__macros_H +#define _GNU_SOURCE + +/* + */ +#ifdef DEBUG__TURN_ON_DEBUG_PRINT + #define DEBUG__printf( bool, ...) \ + do{\ + if(bool)\ + { printf(__VA_ARGS__);\ + printf(" | function: %s\n", __FUNCTION__);\ + fflush(stdin);\ + }\ + }while(0);/*macro magic to isolate var-names*/ + + #define DEBUG__printf1( bool, msg, param) \ + do{\ + if(bool)\ + { printf(msg, param);\ + printf(" | function: %s\n", __FUNCTION__);\ + fflush(stdin);\ + }\ + }while(0);/*macro magic to isolate var-names*/ + + #define DEBUG__printf2( bool, msg, p1, p2) \ + do{\ + if(bool)\ + { printf(msg, p1, p2); \ + printf(" | function: %s\n", __FUNCTION__);\ + fflush(stdin);\ + }\ + }while(0);/*macro magic to isolate var-names*/ + + #define DEBUG__printf3( bool, msg, p1, p2, p3) \ + do{\ + if(bool)\ + { printf(msg, p1, p2, p3); \ + printf(" | function: %s\n", __FUNCTION__);\ + fflush(stdin);\ + }\ + }while(0);/*macro magic to isolate var-names*/ + +#else + #define DEBUG__printf( bool, ...) + #define DEBUG__printf1( bool, msg, param) + #define DEBUG__printf2( bool, msg, p1, p2) +#endif + +//============================= ERROR MSGs ============================ +#define ERROR(msg) printf(msg); +#define ERROR1(msg, param) printf(msg, param); +#define ERROR2(msg, p1, p2) printf(msg, p1, p2); + +//=========================================================================== +#endif /* _PR_DEFS_H */ + diff -r d460a47ed2d6 -r 14241f07f742 Services_offered_by_PR/MEAS__Counter_Recording.h --- a/Services_offered_by_PR/MEAS__Counter_Recording.h Thu Aug 08 02:39:56 2013 -0700 +++ b/Services_offered_by_PR/MEAS__Counter_Recording.h Thu Aug 08 03:00:36 2013 -0700 @@ -1,36 +1,36 @@ -/* - * File: MEAS__Counter_Recording.h - * Author: nengel - * - * Created on January 11, 2012, 3:03 PM - */ - -#ifndef MEAS__COUNTER_RECORDING_H -#define MEAS__COUNTER_RECORDING_H - -#include "PR__common_includes/PR__common_structs.h" - -typedef struct - { - int event_type; - int coreID; - AnimSlot* slot; - int vp; - int task; - uint64 cycles; - uint64 instrs; - } -CounterEvent; - -FILE* counterfile; //pass file handle via side effect because - // doAllInListOfArrays only takes Fns with a single input - -void MEAS__init_counter_data_structs_for_lang( SlaveVP *slv, int32 magicNum ); - -void MEAS__counter_handler(int evt_type, int vpid, int task, SlaveVP* pr, uint64 cycles, uint64 instrs); - -void MEAS__set_counter_file(FILE* f); - -void MEAS__print_counter_event_to_file( void* _e ); -#endif /* PRServ_COUNTER_RECORDING_H */ - +/* + * File: MEAS__Counter_Recording.h + * Author: nengel + * + * Created on January 11, 2012, 3:03 PM + */ + +#ifndef MEAS__COUNTER_RECORDING_H +#define MEAS__COUNTER_RECORDING_H + +#include "PR__common_includes/PR__common_structs.h" + +typedef struct + { + int event_type; + int coreID; + AnimSlot* slot; + int vp; + int task; + uint64 cycles; + uint64 instrs; + } +CounterEvent; + +FILE* counterfile; //pass file handle via side effect because + // doAllInListOfArrays only takes Fns with a single input + +void MEAS__init_counter_data_structs_for_lang( SlaveVP *slv, int32 magicNum ); + +void MEAS__counter_handler(int evt_type, int vpid, int task, SlaveVP* pr, uint64 cycles, uint64 instrs); + +void MEAS__set_counter_file(FILE* f); + +void MEAS__print_counter_event_to_file( void* _e ); +#endif /* PRServ_COUNTER_RECORDING_H */ + diff -r d460a47ed2d6 -r 14241f07f742 Services_offered_by_PR/MEAS__macros.h --- a/Services_offered_by_PR/MEAS__macros.h Thu Aug 08 02:39:56 2013 -0700 +++ b/Services_offered_by_PR/MEAS__macros.h Thu Aug 08 03:00:36 2013 -0700 @@ -1,514 +1,514 @@ -/* - * Copyright 2009 OpenSourceResearchInstitute.org - * Licensed under GNU General Public License version 2 - * - * Author: seanhalle@yahoo.com - * - */ - -#ifndef _MEAS_MACROS_H -#define _MEAS_MACROS_H -#define _GNU_SOURCE - -//================== Macros define types of meas want ===================== -// -/*Generic measurement macro -- has name-space collision potential, which - * compiler will catch.. so only use one pair inside a given set of - * curly braces. - */ -//TODO: finish generic capture interval in hist -enum histograms - { generic1 - }; - #define MEAS__Capture_Pre_Point \ - int32 startStamp, endStamp; \ - saveLowTimeStampCountInto( startStamp ); - - #define MEAS__Capture_Post_Point( histName ) \ - saveLowTimeStampCountInto( endStamp ); \ - addIntervalToHist( startStamp, endStamp, _PRTopEnv->histName ); - - - - -//================== Macros define types of meas want ===================== - -#ifdef MEAS__TURN_ON_SUSP_MEAS - #define MEAS__Insert_Susp_Meas_Fields_into_Slave \ - uint32 preSuspTSCLow; \ - uint32 postSuspTSCLow; - - #define MEAS__Insert_Susp_Meas_Fields_into_MasterEnv \ - Histogram *suspLowTimeHist; \ - Histogram *suspHighTimeHist; - - #define MEAS__Make_Meas_Hists_for_Susp_Meas \ - _PRTopEnv->suspLowTimeHist = makeFixedBinHistExt( 100, 0, 200,\ - "master_low_time_hist");\ - _PRTopEnv->suspHighTimeHist = makeFixedBinHistExt( 100, 0, 200,\ - "master_high_time_hist"); - - //record time stamp: compare to time-stamp recorded below - #define MEAS__Capture_Pre_Susp_Point \ - saveLowTimeStampCountInto( animatingSlv->preSuspTSCLow ); - - //NOTE: only take low part of count -- do sanity check when take diff - #define MEAS__Capture_Post_Susp_Point \ - saveLowTimeStampCountInto( animatingSlv->postSuspTSCLow );\ - addIntervalToHist( preSuspTSCLow, postSuspTSCLow,\ - _PRTopEnv->suspLowTimeHist ); \ - addIntervalToHist( preSuspTSCLow, postSuspTSCLow,\ - _PRTopEnv->suspHighTimeHist ); - - #define MEAS__Print_Hists_for_Susp_Meas \ - printHist( _PRTopEnv->pluginTimeHist ); - -#else - #define MEAS__Insert_Susp_Meas_Fields_into_Slave - #define MEAS__Insert_Susp_Meas_Fields_into_MasterEnv - #define MEAS__Make_Meas_Hists_for_Susp_Meas - #define MEAS__Capture_Pre_Susp_Point - #define MEAS__Capture_Post_Susp_Point - #define MEAS__Print_Hists_for_Susp_Meas -#endif - -#ifdef MEAS__TURN_ON_MASTER_MEAS - #define MEAS__Insert_Master_Meas_Fields_into_Slave \ - uint32 startMasterTSCLow; \ - uint32 endMasterTSCLow; - - #define MEAS__Insert_Master_Meas_Fields_into_MasterEnv \ - Histogram *masterLowTimeHist; \ - Histogram *masterHighTimeHist; - - #define MEAS__Make_Meas_Hists_for_Master_Meas \ - _PRTopEnv->masterLowTimeHist = makeFixedBinHistExt( 100, 0, 200,\ - "master_low_time_hist");\ - _PRTopEnv->masterHighTimeHist = makeFixedBinHistExt( 100, 0, 200,\ - "master_high_time_hist"); - - //Total Master time includes one coreloop time -- just assume the core - // loop time is same for Master as for AppSlvs, even though it may be - // smaller due to higher predictability of the fixed jmp. - #define MEAS__Capture_Pre_Master_Point\ - saveLowTimeStampCountInto( masterVP->startMasterTSCLow ); - - #define MEAS__Capture_Post_Master_Point \ - saveLowTimeStampCountInto( masterVP->endMasterTSCLow );\ - addIntervalToHist( startMasterTSCLow, endMasterTSCLow,\ - _PRTopEnv->masterLowTimeHist ); \ - addIntervalToHist( startMasterTSCLow, endMasterTSCLow,\ - _PRTopEnv->masterHighTimeHist ); - - #define MEAS__Print_Hists_for_Master_Meas \ - printHist( _PRTopEnv->pluginTimeHist ); - -#else - #define MEAS__Insert_Master_Meas_Fields_into_Slave - #define MEAS__Insert_Master_Meas_Fields_into_MasterEnv - #define MEAS__Make_Meas_Hists_for_Master_Meas - #define MEAS__Capture_Pre_Master_Point - #define MEAS__Capture_Post_Master_Point - #define MEAS__Print_Hists_for_Master_Meas -#endif - - -#ifdef MEAS__TURN_ON_MASTER_LOCK_MEAS - #define MEAS__Insert_Master_Lock_Meas_Fields_into_MasterEnv \ - Histogram *masterLockLowTimeHist; \ - Histogram *masterLockHighTimeHist; - - #define MEAS__Make_Meas_Hists_for_Master_Lock_Meas \ - _PRTopEnv->masterLockLowTimeHist = makeFixedBinHist( 50, 0, 2, \ - "master lock low time hist");\ - _PRTopEnv->masterLockHighTimeHist = makeFixedBinHist( 50, 0, 100,\ - "master lock high time hist"); - - #define MEAS__Capture_Pre_Master_Lock_Point \ - int32 startStamp, endStamp; \ - saveLowTimeStampCountInto( startStamp ); - - #define MEAS__Capture_Post_Master_Lock_Point \ - saveLowTimeStampCountInto( endStamp ); \ - addIntervalToHist( startStamp, endStamp,\ - _PRTopEnv->masterLockLowTimeHist ); \ - addIntervalToHist( startStamp, endStamp,\ - _PRTopEnv->masterLockHighTimeHist ); - - #define MEAS__Print_Hists_for_Master_Lock_Meas \ - printHist( _PRTopEnv->masterLockLowTimeHist ); \ - printHist( _PRTopEnv->masterLockHighTimeHist ); - -#else - #define MEAS__Insert_Master_Lock_Meas_Fields_into_MasterEnv - #define MEAS__Make_Meas_Hists_for_Master_Lock_Meas - #define MEAS__Capture_Pre_Master_Lock_Point - #define MEAS__Capture_Post_Master_Lock_Point - #define MEAS__Print_Hists_for_Master_Lock_Meas -#endif - - -#ifdef MEAS__TURN_ON_MALLOC_MEAS - #define MEAS__Insert_Malloc_Meas_Fields_into_MasterEnv\ - Histogram *mallocTimeHist; \ - Histogram *freeTimeHist; - - #define MEAS__Make_Meas_Hists_for_Malloc_Meas \ - _PRTopEnv->mallocTimeHist = makeFixedBinHistExt( 100, 0, 30,\ - "malloc_time_hist");\ - _PRTopEnv->freeTimeHist = makeFixedBinHistExt( 100, 0, 30,\ - "free_time_hist"); - - #define MEAS__Capture_Pre_Malloc_Point \ - int32 startStamp, endStamp; \ - saveLowTimeStampCountInto( startStamp ); - - #define MEAS__Capture_Post_Malloc_Point \ - saveLowTimeStampCountInto( endStamp ); \ - addIntervalToHist( startStamp, endStamp,\ - _PRTopEnv->mallocTimeHist ); - - #define MEAS__Capture_Pre_Free_Point \ - int32 startStamp, endStamp; \ - saveLowTimeStampCountInto( startStamp ); - - #define MEAS__Capture_Post_Free_Point \ - saveLowTimeStampCountInto( endStamp ); \ - addIntervalToHist( startStamp, endStamp,\ - _PRTopEnv->freeTimeHist ); - - #define MEAS__Print_Hists_for_Malloc_Meas \ - printHist( _PRTopEnv->mallocTimeHist ); \ - saveHistToFile( _PRTopEnv->mallocTimeHist ); \ - printHist( _PRTopEnv->freeTimeHist ); \ - saveHistToFile( _PRTopEnv->freeTimeHist ); \ - freeHistExt( _PRTopEnv->mallocTimeHist ); \ - freeHistExt( _PRTopEnv->freeTimeHist ); - -#else - #define MEAS__Insert_Malloc_Meas_Fields_into_MasterEnv - #define MEAS__Make_Meas_Hists_for_Malloc_Meas - #define MEAS__Capture_Pre_Malloc_Point - #define MEAS__Capture_Post_Malloc_Point - #define MEAS__Capture_Pre_Free_Point - #define MEAS__Capture_Post_Free_Point - #define MEAS__Print_Hists_for_Malloc_Meas -#endif - - - -#ifdef MEAS__TURN_ON_PLUGIN_MEAS - #define MEAS__Insert_Plugin_Meas_Fields_into_MasterEnv \ - Histogram *reqHdlrLowTimeHist; \ - Histogram *reqHdlrHighTimeHist; - - #define MEAS__Make_Meas_Hists_for_Plugin_Meas \ - _PRTopEnv->reqHdlrLowTimeHist = makeFixedBinHistExt( 100, 0, 200,\ - "plugin_low_time_hist");\ - _PRTopEnv->reqHdlrHighTimeHist = makeFixedBinHistExt( 100, 0, 200,\ - "plugin_high_time_hist"); - - #define MEAS__startReqHdlr \ - int32 startStamp1, endStamp1; \ - saveLowTimeStampCountInto( startStamp1 ); - - #define MEAS__endReqHdlr \ - saveLowTimeStampCountInto( endStamp1 ); \ - addIntervalToHist( startStamp1, endStamp1, \ - _PRTopEnv->reqHdlrLowTimeHist ); \ - addIntervalToHist( startStamp1, endStamp1, \ - _PRTopEnv->reqHdlrHighTimeHist ); - - #define MEAS__Print_Hists_for_Plugin_Meas \ - printHist( _PRTopEnv->reqHdlrLowTimeHist ); \ - saveHistToFile( _PRTopEnv->reqHdlrLowTimeHist ); \ - printHist( _PRTopEnv->reqHdlrHighTimeHist ); \ - saveHistToFile( _PRTopEnv->reqHdlrHighTimeHist ); \ - freeHistExt( _PRTopEnv->reqHdlrLowTimeHist ); \ - freeHistExt( _PRTopEnv->reqHdlrHighTimeHist ); -#else - #define MEAS__Insert_Plugin_Meas_Fields_into_MasterEnv - #define MEAS__Make_Meas_Hists_for_Plugin_Meas - #define MEAS__startReqHdlr - #define MEAS__endReqHdlr - #define MEAS__Print_Hists_for_Plugin_Meas - -#endif - - -#ifdef MEAS__TURN_ON_SYSTEM_MEAS - #define MEAS__Insert_System_Meas_Fields_into_Slave \ - TSCountLowHigh startSusp; \ - uint64 totalSuspCycles; \ - uint32 numGoodSusp; - - #define MEAS__Insert_System_Meas_Fields_into_MasterEnv \ - TSCountLowHigh startMaster; \ - uint64 totalMasterCycles; \ - uint32 numMasterAnimations; \ - TSCountLowHigh startReqHdlr; \ - uint64 totalPluginCycles; \ - uint32 numPluginAnimations; \ - uint64 cyclesTillStartAnimationMaster; \ - TSCountLowHigh endAnimationMaster; - - #define MEAS__startAnimationMaster_forSys \ - TSCountLowHigh startStamp1, endStamp1; \ - saveTSCLowHigh( endStamp1 ); \ - _PRTopEnv->cyclesTillStartAnimationMaster = \ - endStamp1.longVal - masterVP->startSusp.longVal; - - #define Meas_startReqHdlr_forSys \ - saveTSCLowHigh( startStamp1 ); \ - _PRTopEnv->startReqHdlr.longVal = startStamp1.longVal; - - #define MEAS__endAnimationMaster_forSys \ - saveTSCLowHigh( startStamp1 ); \ - _PRTopEnv->endAnimationMaster.longVal = startStamp1.longVal; - - /*A TSC is stored in VP first thing inside wrapper-lib - * Now, measures cycles from there to here - * Master and Plugin will add this value to other trace-seg measures - */ - #define MEAS__Capture_End_Susp_in_CoreCtlr_ForSys\ - saveTSCLowHigh(endSusp); \ - numCycles = endSusp.longVal - currVP->startSusp.longVal; \ - /*sanity check (400K is about 20K iters)*/ \ - if( numCycles < 400000 ) \ - { currVP->totalSuspCycles += numCycles; \ - currVP->numGoodSusp++; \ - } \ - /*recorded every time, but only read if currVP == MasterVP*/ \ - _PRTopEnv->startMaster.longVal = endSusp.longVal; - -#else - #define MEAS__Insert_System_Meas_Fields_into_Slave - #define MEAS__Insert_System_Meas_Fields_into_MasterEnv - #define MEAS__Make_Meas_Hists_for_System_Meas - #define MEAS__startAnimationMaster_forSys - #define MEAS__startReqHdlr_forSys - #define MEAS__endAnimationMaster_forSys - #define MEAS__Capture_End_Susp_in_CoreCtlr_ForSys - #define MEAS__Print_Hists_for_System_Meas -#endif - -#ifdef HOLISTIC__TURN_ON_PERF_COUNTERS - - #define MEAS__Insert_Counter_Handler \ - typedef void (*CounterHandler) (int,int,int,SlaveVP*,uint64,uint64,uint64); - - enum eventType { - DebugEvt = 0, - AppResponderInvocation_start, - AppResponder_start, - AppResponder_end, - AssignerInvocation_start, - NextAssigner_start, - Assigner_start, - Assigner_end, - Work_start, - Work_end, - HwResponderInvocation_start, - Timestamp_start, - Timestamp_end - }; - - #define saveCyclesAndInstrs(core,cycles,instrs,cachem) do{ \ - int cycles_fd = _PRTopEnv->cycles_counter_fd[core]; \ - int instrs_fd = _PRTopEnv->instrs_counter_fd[core]; \ - int cachem_fd = _PRTopEnv->cachem_counter_fd[core]; \ - int nread; \ - \ - nread = read(cycles_fd,&(cycles),sizeof(cycles)); \ - if(nread<0){ \ - perror("Error reading cycles counter"); \ - cycles = 0; \ - } \ - \ - nread = read(instrs_fd,&(instrs),sizeof(instrs)); \ - if(nread<0){ \ - perror("Error reading cycles counter"); \ - instrs = 0; \ - } \ - nread = read(cachem_fd,&(cachem),sizeof(cachem)); \ - if(nread<0){ \ - perror("Error reading last level cache miss counter"); \ - cachem = 0; \ - } \ - } while (0) - - #define MEAS__Insert_Counter_Meas_Fields_into_MasterEnv \ - int cycles_counter_fd[NUM_CORES]; \ - int instrs_counter_fd[NUM_CORES]; \ - int cachem_counter_fd[NUM_CORES]; \ - uint64 start_master_lock[NUM_CORES][3]; \ - CounterHandler counterHandler; - - #define HOLISTIC__Setup_Perf_Counters setup_perf_counters(); - - - #define HOLISTIC__CoreCtrl_Setup \ - CounterHandler counterHandler = _PRTopEnv->counterHandler; \ - SlaveVP *lastVPBeforeMaster = NULL; \ - /*if(thisCoresThdParams->coreNum == 0){ \ - uint64 initval = tsc_offset_send(thisCoresThdParams,0); \ - while(!coreCtlrThdParams[NUM_CORES - 2]->ret_tsc); \ - } \ - if(0 < (thisCoresThdParams->coreNum) && (thisCoresThdParams->coreNum) < (NUM_CORES - 1)){ \ - ThdParams* sendCoresThdParams = coreCtlrThdParams[thisCoresThdParams->coreNum - 1]; \ - int sndctr = tsc_offset_resp(sendCoresThdParams, 0); \ - uint64 initval = tsc_offset_send(thisCoresThdParams,0); \ - while(!coreCtlrThdParams[NUM_CORES - 2]->ret_tsc); \ - } \ - if(thisCoresThdParams->coreNum == (NUM_CORES - 1)){ \ - ThdParams* sendCoresThdParams = coreCtlrThdParams[thisCoresThdParams->coreNum - 1]; \ - int sndctr = tsc_offset_resp(sendCoresThdParams,0); \ - }*/ - - - #define HOLISTIC__Insert_Master_Global_Vars \ - int vpid,task; \ - CounterHandler counterHandler = _PRTopEnv->counterHandler; - - #define HOLISTIC__Record_last_work lastVPBeforeMaster = currVP; - - #define HOLISTIC__Record_AppResponderInvocation_start \ - uint64 cycles,instrs,cachem; \ - saveCyclesAndInstrs(thisCoresIdx,cycles, instrs,cachem); \ - if(lastVPBeforeMaster){ \ - (*counterHandler)(AppResponderInvocation_start,lastVPBeforeMaster->slaveNum,lastVPBeforeMaster->numTimesAssignedToASlot,lastVPBeforeMaster,cycles,instrs,cachem); \ - lastVPBeforeMaster = NULL; \ - } else { \ - _PRTopEnv->start_master_lock[thisCoresIdx][0] = cycles; \ - _PRTopEnv->start_master_lock[thisCoresIdx][1] = instrs; \ - _PRTopEnv->start_master_lock[thisCoresIdx][2] = cachem; \ - } - - /* Request Handler may call resume() on the VP, but we want to - * account the whole interval to the same task. Therefore, need - * to save task ID at the beginning. - * - * Using this value as "end of AppResponder Invocation Time" - * is possible if there is only one SchedSlot per core - - * invoking processor is last to be treated here! If more than - * one slot, MasterLoop processing time for all but the last VP - * would be erroneously counted as invocation time. - */ - #define HOLISTIC__Record_AppResponder_start \ - vpid = currSlot->slaveAssignedToSlot->slaveNum; \ - task = currSlot->slaveAssignedToSlot->numTimesAssignedToASlot; \ - uint64 cycles, instrs, cachem; \ - saveCyclesAndInstrs(thisCoresIdx,cycles, instrs,cachem); \ - (*counterHandler)(AppResponder_start,vpid,task,currSlot->slaveAssignedToSlot,cycles,instrs,cachem); - - #define HOLISTIC__Record_AppResponder_end \ - uint64 cycles2,instrs2,cachem2; \ - saveCyclesAndInstrs(thisCoresIdx,cycles2, instrs2,cachem2); \ - (*counterHandler)(AppResponder_end,vpid,task,currSlot->slaveAssignedToSlot,cycles2,instrs2,cachem2); \ - (*counterHandler)(Timestamp_end,vpid,task,currSlot->slaveAssignedToSlot,rdtsc(),0,0); - - - /* Don't know who to account time to yet - goes to assigned VP - * after the call. - */ - #define HOLISTIC__Record_Assigner_start \ - int empty = FALSE; \ - if(currSlot->slaveAssignedToSlot == NULL){ \ - empty= TRUE; \ - } \ - uint64 tmp_cycles, tmp_instrs, tmp_cachem; \ - saveCyclesAndInstrs(thisCoresIdx,tmp_cycles,tmp_instrs,tmp_cachem); \ - uint64 tsc = rdtsc(); \ - if(vpid > 0) { \ - (*counterHandler)(NextAssigner_start,vpid,task,currSlot->slaveAssignedToSlot,tmp_cycles,tmp_instrs,tmp_cachem); \ - vpid = 0; \ - task = 0; \ - } - - #define HOLISTIC__Record_Assigner_end \ - uint64 cycles,instrs,cachem; \ - saveCyclesAndInstrs(thisCoresIdx,cycles,instrs,cachem); \ - if(empty){ \ - (*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]); \ - } \ - (*counterHandler)(Timestamp_start,assignedSlaveVP->slaveNum,assignedSlaveVP->numTimesAssignedToASlot,assignedSlaveVP,tsc,0,0); \ - (*counterHandler)(Assigner_start,assignedSlaveVP->slaveNum,assignedSlaveVP->numTimesAssignedToASlot,assignedSlaveVP,tmp_cycles,tmp_instrs,tmp_cachem); \ - (*counterHandler)(Assigner_end,assignedSlaveVP->slaveNum,assignedSlaveVP->numTimesAssignedToASlot,assignedSlaveVP,cycles,instrs,tmp_cachem); - - #define HOLISTIC__Record_Work_start \ - if(currVP){ \ - uint64 cycles,instrs,cachem; \ - saveCyclesAndInstrs(thisCoresIdx,cycles, instrs,cachem); \ - (*counterHandler)(Work_start,currVP->slaveNum,currVP->numTimesAssignedToASlot,currVP,cycles,instrs,cachem); \ - } - - #define HOLISTIC__Record_Work_end \ - if(currVP){ \ - uint64 cycles,instrs,cachem; \ - saveCyclesAndInstrs(thisCoresIdx,cycles, instrs,cachem); \ - (*counterHandler)(Work_end,currVP->slaveNum,currVP->numTimesAssignedToASlot,currVP,cycles,instrs,cachem); \ - } - - #define HOLISTIC__Record_HwResponderInvocation_start \ - uint64 cycles,instrs,cachem; \ - saveCyclesAndInstrs(animatingSlv->coreAnimatedBy,cycles, instrs,cachem); \ - (*(_PRTopEnv->counterHandler))(HwResponderInvocation_start,animatingSlv->slaveNum,animatingSlv->numTimesAssignedToASlot,animatingSlv,cycles,instrs,cachem); - - - #define getReturnAddressBeforeLibraryCall(vp_ptr, res_ptr) do{ \ -void* frame_ptr0 = vp_ptr->framePtr; \ -void* frame_ptr1 = *((void**)frame_ptr0); \ -void* frame_ptr2 = *((void**)frame_ptr1); \ -void* frame_ptr3 = *((void**)frame_ptr2); \ -void* ret_addr = *((void**)frame_ptr3 + 1); \ -*res_ptr = ret_addr; \ -} while (0) - -#else - #define MEAS__Insert_Counter_Handler - #define MEAS__Insert_Counter_Meas_Fields_into_MasterEnv - #define HOLISTIC__Setup_Perf_Counters - #define HOLISTIC__CoreCtrl_Setup - #define HOLISTIC__Insert_Master_Global_Vars - #define HOLISTIC__Record_last_work - #define HOLISTIC__Record_AppResponderInvocation_start - #define HOLISTIC__Record_AppResponder_start - #define HOLISTIC__Record_AppResponder_end - #define HOLISTIC__Record_Assigner_start - #define HOLISTIC__Record_Assigner_end - #define HOLISTIC__Record_Work_start - #define HOLISTIC__Record_Work_end - #define HOLISTIC__Record_HwResponderInvocation_start - #define getReturnAddressBeforeLibraryCall(vp_ptr, res_ptr) -#endif - -//Experiment in two-step macros -- if doesn't work, insert each separately -#define MEAS__Insert_Meas_Fields_into_Slave \ - MEAS__Insert_Susp_Meas_Fields_into_Slave \ - MEAS__Insert_Master_Meas_Fields_into_Slave \ - MEAS__Insert_System_Meas_Fields_into_Slave - - -//====================== Histogram Macros -- Create ======================== -// -// - -//The language implementation should include a definition of this macro, -// which creates all the histograms the language uses to collect measurements -// of plugin operation -- so, if the language didn't define it, must -// define it here (as empty), to avoid compile error -#ifndef MEAS__Make_Meas_Hists_for_Language -#define MEAS__Make_Meas_Hists_for_Language -#endif - -#define makeAMeasHist( histInfo, idx, name, numBins, startVal, binWidth ) \ - makeHighestDynArrayIndexBeAtLeast( _PRTopEnv->measHistsInfo, idx ); \ - _PRTopEnv->measHists[idx] = \ - makeFixedBinHist( numBins, startVal, binWidth, name ); - -//============================== Probes =================================== - - -//=========================================================================== -#endif /* _PR_DEFS_MEAS_H */ - +/* + * Copyright 2009 OpenSourceResearchInstitute.org + * Licensed under GNU General Public License version 2 + * + * Author: seanhalle@yahoo.com + * + */ + +#ifndef _MEAS_MACROS_H +#define _MEAS_MACROS_H +#define _GNU_SOURCE + +//================== Macros define types of meas want ===================== +// +/*Generic measurement macro -- has name-space collision potential, which + * compiler will catch.. so only use one pair inside a given set of + * curly braces. + */ +//TODO: finish generic capture interval in hist +enum histograms + { generic1 + }; + #define MEAS__Capture_Pre_Point \ + int32 startStamp, endStamp; \ + saveLowTimeStampCountInto( startStamp ); + + #define MEAS__Capture_Post_Point( histName ) \ + saveLowTimeStampCountInto( endStamp ); \ + addIntervalToHist( startStamp, endStamp, _PRTopEnv->histName ); + + + + +//================== Macros define types of meas want ===================== + +#ifdef MEAS__TURN_ON_SUSP_MEAS + #define MEAS__Insert_Susp_Meas_Fields_into_Slave \ + uint32 preSuspTSCLow; \ + uint32 postSuspTSCLow; + + #define MEAS__Insert_Susp_Meas_Fields_into_MasterEnv \ + Histogram *suspLowTimeHist; \ + Histogram *suspHighTimeHist; + + #define MEAS__Make_Meas_Hists_for_Susp_Meas \ + _PRTopEnv->suspLowTimeHist = makeFixedBinHistExt( 100, 0, 200,\ + "master_low_time_hist");\ + _PRTopEnv->suspHighTimeHist = makeFixedBinHistExt( 100, 0, 200,\ + "master_high_time_hist"); + + //record time stamp: compare to time-stamp recorded below + #define MEAS__Capture_Pre_Susp_Point \ + saveLowTimeStampCountInto( animatingSlv->preSuspTSCLow ); + + //NOTE: only take low part of count -- do sanity check when take diff + #define MEAS__Capture_Post_Susp_Point \ + saveLowTimeStampCountInto( animatingSlv->postSuspTSCLow );\ + addIntervalToHist( preSuspTSCLow, postSuspTSCLow,\ + _PRTopEnv->suspLowTimeHist ); \ + addIntervalToHist( preSuspTSCLow, postSuspTSCLow,\ + _PRTopEnv->suspHighTimeHist ); + + #define MEAS__Print_Hists_for_Susp_Meas \ + printHist( _PRTopEnv->pluginTimeHist ); + +#else + #define MEAS__Insert_Susp_Meas_Fields_into_Slave + #define MEAS__Insert_Susp_Meas_Fields_into_MasterEnv + #define MEAS__Make_Meas_Hists_for_Susp_Meas + #define MEAS__Capture_Pre_Susp_Point + #define MEAS__Capture_Post_Susp_Point + #define MEAS__Print_Hists_for_Susp_Meas +#endif + +#ifdef MEAS__TURN_ON_MASTER_MEAS + #define MEAS__Insert_Master_Meas_Fields_into_Slave \ + uint32 startMasterTSCLow; \ + uint32 endMasterTSCLow; + + #define MEAS__Insert_Master_Meas_Fields_into_MasterEnv \ + Histogram *masterLowTimeHist; \ + Histogram *masterHighTimeHist; + + #define MEAS__Make_Meas_Hists_for_Master_Meas \ + _PRTopEnv->masterLowTimeHist = makeFixedBinHistExt( 100, 0, 200,\ + "master_low_time_hist");\ + _PRTopEnv->masterHighTimeHist = makeFixedBinHistExt( 100, 0, 200,\ + "master_high_time_hist"); + + //Total Master time includes one coreloop time -- just assume the core + // loop time is same for Master as for AppSlvs, even though it may be + // smaller due to higher predictability of the fixed jmp. + #define MEAS__Capture_Pre_Master_Point\ + saveLowTimeStampCountInto( masterVP->startMasterTSCLow ); + + #define MEAS__Capture_Post_Master_Point \ + saveLowTimeStampCountInto( masterVP->endMasterTSCLow );\ + addIntervalToHist( startMasterTSCLow, endMasterTSCLow,\ + _PRTopEnv->masterLowTimeHist ); \ + addIntervalToHist( startMasterTSCLow, endMasterTSCLow,\ + _PRTopEnv->masterHighTimeHist ); + + #define MEAS__Print_Hists_for_Master_Meas \ + printHist( _PRTopEnv->pluginTimeHist ); + +#else + #define MEAS__Insert_Master_Meas_Fields_into_Slave + #define MEAS__Insert_Master_Meas_Fields_into_MasterEnv + #define MEAS__Make_Meas_Hists_for_Master_Meas + #define MEAS__Capture_Pre_Master_Point + #define MEAS__Capture_Post_Master_Point + #define MEAS__Print_Hists_for_Master_Meas +#endif + + +#ifdef MEAS__TURN_ON_MASTER_LOCK_MEAS + #define MEAS__Insert_Master_Lock_Meas_Fields_into_MasterEnv \ + Histogram *masterLockLowTimeHist; \ + Histogram *masterLockHighTimeHist; + + #define MEAS__Make_Meas_Hists_for_Master_Lock_Meas \ + _PRTopEnv->masterLockLowTimeHist = makeFixedBinHist( 50, 0, 2, \ + "master lock low time hist");\ + _PRTopEnv->masterLockHighTimeHist = makeFixedBinHist( 50, 0, 100,\ + "master lock high time hist"); + + #define MEAS__Capture_Pre_Master_Lock_Point \ + int32 startStamp, endStamp; \ + saveLowTimeStampCountInto( startStamp ); + + #define MEAS__Capture_Post_Master_Lock_Point \ + saveLowTimeStampCountInto( endStamp ); \ + addIntervalToHist( startStamp, endStamp,\ + _PRTopEnv->masterLockLowTimeHist ); \ + addIntervalToHist( startStamp, endStamp,\ + _PRTopEnv->masterLockHighTimeHist ); + + #define MEAS__Print_Hists_for_Master_Lock_Meas \ + printHist( _PRTopEnv->masterLockLowTimeHist ); \ + printHist( _PRTopEnv->masterLockHighTimeHist ); + +#else + #define MEAS__Insert_Master_Lock_Meas_Fields_into_MasterEnv + #define MEAS__Make_Meas_Hists_for_Master_Lock_Meas + #define MEAS__Capture_Pre_Master_Lock_Point + #define MEAS__Capture_Post_Master_Lock_Point + #define MEAS__Print_Hists_for_Master_Lock_Meas +#endif + + +#ifdef MEAS__TURN_ON_MALLOC_MEAS + #define MEAS__Insert_Malloc_Meas_Fields_into_MasterEnv\ + Histogram *mallocTimeHist; \ + Histogram *freeTimeHist; + + #define MEAS__Make_Meas_Hists_for_Malloc_Meas \ + _PRTopEnv->mallocTimeHist = makeFixedBinHistExt( 100, 0, 30,\ + "malloc_time_hist");\ + _PRTopEnv->freeTimeHist = makeFixedBinHistExt( 100, 0, 30,\ + "free_time_hist"); + + #define MEAS__Capture_Pre_Malloc_Point \ + int32 startStamp, endStamp; \ + saveLowTimeStampCountInto( startStamp ); + + #define MEAS__Capture_Post_Malloc_Point \ + saveLowTimeStampCountInto( endStamp ); \ + addIntervalToHist( startStamp, endStamp,\ + _PRTopEnv->mallocTimeHist ); + + #define MEAS__Capture_Pre_Free_Point \ + int32 startStamp, endStamp; \ + saveLowTimeStampCountInto( startStamp ); + + #define MEAS__Capture_Post_Free_Point \ + saveLowTimeStampCountInto( endStamp ); \ + addIntervalToHist( startStamp, endStamp,\ + _PRTopEnv->freeTimeHist ); + + #define MEAS__Print_Hists_for_Malloc_Meas \ + printHist( _PRTopEnv->mallocTimeHist ); \ + saveHistToFile( _PRTopEnv->mallocTimeHist ); \ + printHist( _PRTopEnv->freeTimeHist ); \ + saveHistToFile( _PRTopEnv->freeTimeHist ); \ + freeHistExt( _PRTopEnv->mallocTimeHist ); \ + freeHistExt( _PRTopEnv->freeTimeHist ); + +#else + #define MEAS__Insert_Malloc_Meas_Fields_into_MasterEnv + #define MEAS__Make_Meas_Hists_for_Malloc_Meas + #define MEAS__Capture_Pre_Malloc_Point + #define MEAS__Capture_Post_Malloc_Point + #define MEAS__Capture_Pre_Free_Point + #define MEAS__Capture_Post_Free_Point + #define MEAS__Print_Hists_for_Malloc_Meas +#endif + + + +#ifdef MEAS__TURN_ON_PLUGIN_MEAS + #define MEAS__Insert_Plugin_Meas_Fields_into_MasterEnv \ + Histogram *reqHdlrLowTimeHist; \ + Histogram *reqHdlrHighTimeHist; + + #define MEAS__Make_Meas_Hists_for_Plugin_Meas \ + _PRTopEnv->reqHdlrLowTimeHist = makeFixedBinHistExt( 100, 0, 200,\ + "plugin_low_time_hist");\ + _PRTopEnv->reqHdlrHighTimeHist = makeFixedBinHistExt( 100, 0, 200,\ + "plugin_high_time_hist"); + + #define MEAS__startReqHdlr \ + int32 startStamp1, endStamp1; \ + saveLowTimeStampCountInto( startStamp1 ); + + #define MEAS__endReqHdlr \ + saveLowTimeStampCountInto( endStamp1 ); \ + addIntervalToHist( startStamp1, endStamp1, \ + _PRTopEnv->reqHdlrLowTimeHist ); \ + addIntervalToHist( startStamp1, endStamp1, \ + _PRTopEnv->reqHdlrHighTimeHist ); + + #define MEAS__Print_Hists_for_Plugin_Meas \ + printHist( _PRTopEnv->reqHdlrLowTimeHist ); \ + saveHistToFile( _PRTopEnv->reqHdlrLowTimeHist ); \ + printHist( _PRTopEnv->reqHdlrHighTimeHist ); \ + saveHistToFile( _PRTopEnv->reqHdlrHighTimeHist ); \ + freeHistExt( _PRTopEnv->reqHdlrLowTimeHist ); \ + freeHistExt( _PRTopEnv->reqHdlrHighTimeHist ); +#else + #define MEAS__Insert_Plugin_Meas_Fields_into_MasterEnv + #define MEAS__Make_Meas_Hists_for_Plugin_Meas + #define MEAS__startReqHdlr + #define MEAS__endReqHdlr + #define MEAS__Print_Hists_for_Plugin_Meas + +#endif + + +#ifdef MEAS__TURN_ON_SYSTEM_MEAS + #define MEAS__Insert_System_Meas_Fields_into_Slave \ + TSCountLowHigh startSusp; \ + uint64 totalSuspCycles; \ + uint32 numGoodSusp; + + #define MEAS__Insert_System_Meas_Fields_into_MasterEnv \ + TSCountLowHigh startMaster; \ + uint64 totalMasterCycles; \ + uint32 numMasterAnimations; \ + TSCountLowHigh startReqHdlr; \ + uint64 totalPluginCycles; \ + uint32 numPluginAnimations; \ + uint64 cyclesTillStartAnimationMaster; \ + TSCountLowHigh endAnimationMaster; + + #define MEAS__startAnimationMaster_forSys \ + TSCountLowHigh startStamp1, endStamp1; \ + saveTSCLowHigh( endStamp1 ); \ + _PRTopEnv->cyclesTillStartAnimationMaster = \ + endStamp1.longVal - masterVP->startSusp.longVal; + + #define Meas_startReqHdlr_forSys \ + saveTSCLowHigh( startStamp1 ); \ + _PRTopEnv->startReqHdlr.longVal = startStamp1.longVal; + + #define MEAS__endAnimationMaster_forSys \ + saveTSCLowHigh( startStamp1 ); \ + _PRTopEnv->endAnimationMaster.longVal = startStamp1.longVal; + + /*A TSC is stored in VP first thing inside wrapper-lib + * Now, measures cycles from there to here + * Master and Plugin will add this value to other trace-seg measures + */ + #define MEAS__Capture_End_Susp_in_CoreCtlr_ForSys\ + saveTSCLowHigh(endSusp); \ + numCycles = endSusp.longVal - currVP->startSusp.longVal; \ + /*sanity check (400K is about 20K iters)*/ \ + if( numCycles < 400000 ) \ + { currVP->totalSuspCycles += numCycles; \ + currVP->numGoodSusp++; \ + } \ + /*recorded every time, but only read if currVP == MasterVP*/ \ + _PRTopEnv->startMaster.longVal = endSusp.longVal; + +#else + #define MEAS__Insert_System_Meas_Fields_into_Slave + #define MEAS__Insert_System_Meas_Fields_into_MasterEnv + #define MEAS__Make_Meas_Hists_for_System_Meas + #define MEAS__startAnimationMaster_forSys + #define MEAS__startReqHdlr_forSys + #define MEAS__endAnimationMaster_forSys + #define MEAS__Capture_End_Susp_in_CoreCtlr_ForSys + #define MEAS__Print_Hists_for_System_Meas +#endif + +#ifdef HOLISTIC__TURN_ON_PERF_COUNTERS + + #define MEAS__Insert_Counter_Handler \ + typedef void (*CounterHandler) (int,int,int,SlaveVP*,uint64,uint64,uint64); + + enum eventType { + DebugEvt = 0, + AppResponderInvocation_start, + AppResponder_start, + AppResponder_end, + AssignerInvocation_start, + NextAssigner_start, + Assigner_start, + Assigner_end, + Work_start, + Work_end, + HwResponderInvocation_start, + Timestamp_start, + Timestamp_end + }; + + #define saveCyclesAndInstrs(core,cycles,instrs,cachem) do{ \ + int cycles_fd = _PRTopEnv->cycles_counter_fd[core]; \ + int instrs_fd = _PRTopEnv->instrs_counter_fd[core]; \ + int cachem_fd = _PRTopEnv->cachem_counter_fd[core]; \ + int nread; \ + \ + nread = read(cycles_fd,&(cycles),sizeof(cycles)); \ + if(nread<0){ \ + perror("Error reading cycles counter"); \ + cycles = 0; \ + } \ + \ + nread = read(instrs_fd,&(instrs),sizeof(instrs)); \ + if(nread<0){ \ + perror("Error reading cycles counter"); \ + instrs = 0; \ + } \ + nread = read(cachem_fd,&(cachem),sizeof(cachem)); \ + if(nread<0){ \ + perror("Error reading last level cache miss counter"); \ + cachem = 0; \ + } \ + } while (0) + + #define MEAS__Insert_Counter_Meas_Fields_into_MasterEnv \ + int cycles_counter_fd[NUM_CORES]; \ + int instrs_counter_fd[NUM_CORES]; \ + int cachem_counter_fd[NUM_CORES]; \ + uint64 start_master_lock[NUM_CORES][3]; \ + CounterHandler counterHandler; + + #define HOLISTIC__Setup_Perf_Counters setup_perf_counters(); + + + #define HOLISTIC__CoreCtrl_Setup \ + CounterHandler counterHandler = _PRTopEnv->counterHandler; \ + SlaveVP *lastVPBeforeMaster = NULL; \ + /*if(thisCoresThdParams->coreNum == 0){ \ + uint64 initval = tsc_offset_send(thisCoresThdParams,0); \ + while(!coreCtlrThdParams[NUM_CORES - 2]->ret_tsc); \ + } \ + if(0 < (thisCoresThdParams->coreNum) && (thisCoresThdParams->coreNum) < (NUM_CORES - 1)){ \ + ThdParams* sendCoresThdParams = coreCtlrThdParams[thisCoresThdParams->coreNum - 1]; \ + int sndctr = tsc_offset_resp(sendCoresThdParams, 0); \ + uint64 initval = tsc_offset_send(thisCoresThdParams,0); \ + while(!coreCtlrThdParams[NUM_CORES - 2]->ret_tsc); \ + } \ + if(thisCoresThdParams->coreNum == (NUM_CORES - 1)){ \ + ThdParams* sendCoresThdParams = coreCtlrThdParams[thisCoresThdParams->coreNum - 1]; \ + int sndctr = tsc_offset_resp(sendCoresThdParams,0); \ + }*/ + + + #define HOLISTIC__Insert_Master_Global_Vars \ + int vpid,task; \ + CounterHandler counterHandler = _PRTopEnv->counterHandler; + + #define HOLISTIC__Record_last_work lastVPBeforeMaster = currVP; + + #define HOLISTIC__Record_AppResponderInvocation_start \ + uint64 cycles,instrs,cachem; \ + saveCyclesAndInstrs(thisCoresIdx,cycles, instrs,cachem); \ + if(lastVPBeforeMaster){ \ + (*counterHandler)(AppResponderInvocation_start,lastVPBeforeMaster->slaveNum,lastVPBeforeMaster->numTimesAssignedToASlot,lastVPBeforeMaster,cycles,instrs,cachem); \ + lastVPBeforeMaster = NULL; \ + } else { \ + _PRTopEnv->start_master_lock[thisCoresIdx][0] = cycles; \ + _PRTopEnv->start_master_lock[thisCoresIdx][1] = instrs; \ + _PRTopEnv->start_master_lock[thisCoresIdx][2] = cachem; \ + } + + /* Request Handler may call resume() on the VP, but we want to + * account the whole interval to the same task. Therefore, need + * to save task ID at the beginning. + * + * Using this value as "end of AppResponder Invocation Time" + * is possible if there is only one SchedSlot per core - + * invoking processor is last to be treated here! If more than + * one slot, MasterLoop processing time for all but the last VP + * would be erroneously counted as invocation time. + */ + #define HOLISTIC__Record_AppResponder_start \ + vpid = currSlot->slaveAssignedToSlot->slaveNum; \ + task = currSlot->slaveAssignedToSlot->numTimesAssignedToASlot; \ + uint64 cycles, instrs, cachem; \ + saveCyclesAndInstrs(thisCoresIdx,cycles, instrs,cachem); \ + (*counterHandler)(AppResponder_start,vpid,task,currSlot->slaveAssignedToSlot,cycles,instrs,cachem); + + #define HOLISTIC__Record_AppResponder_end \ + uint64 cycles2,instrs2,cachem2; \ + saveCyclesAndInstrs(thisCoresIdx,cycles2, instrs2,cachem2); \ + (*counterHandler)(AppResponder_end,vpid,task,currSlot->slaveAssignedToSlot,cycles2,instrs2,cachem2); \ + (*counterHandler)(Timestamp_end,vpid,task,currSlot->slaveAssignedToSlot,rdtsc(),0,0); + + + /* Don't know who to account time to yet - goes to assigned VP + * after the call. + */ + #define HOLISTIC__Record_Assigner_start \ + int empty = FALSE; \ + if(currSlot->slaveAssignedToSlot == NULL){ \ + empty= TRUE; \ + } \ + uint64 tmp_cycles, tmp_instrs, tmp_cachem; \ + saveCyclesAndInstrs(thisCoresIdx,tmp_cycles,tmp_instrs,tmp_cachem); \ + uint64 tsc = rdtsc(); \ + if(vpid > 0) { \ + (*counterHandler)(NextAssigner_start,vpid,task,currSlot->slaveAssignedToSlot,tmp_cycles,tmp_instrs,tmp_cachem); \ + vpid = 0; \ + task = 0; \ + } + + #define HOLISTIC__Record_Assigner_end \ + uint64 cycles,instrs,cachem; \ + saveCyclesAndInstrs(thisCoresIdx,cycles,instrs,cachem); \ + if(empty){ \ + (*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]); \ + } \ + (*counterHandler)(Timestamp_start,assignedSlaveVP->slaveNum,assignedSlaveVP->numTimesAssignedToASlot,assignedSlaveVP,tsc,0,0); \ + (*counterHandler)(Assigner_start,assignedSlaveVP->slaveNum,assignedSlaveVP->numTimesAssignedToASlot,assignedSlaveVP,tmp_cycles,tmp_instrs,tmp_cachem); \ + (*counterHandler)(Assigner_end,assignedSlaveVP->slaveNum,assignedSlaveVP->numTimesAssignedToASlot,assignedSlaveVP,cycles,instrs,tmp_cachem); + + #define HOLISTIC__Record_Work_start \ + if(currVP){ \ + uint64 cycles,instrs,cachem; \ + saveCyclesAndInstrs(thisCoresIdx,cycles, instrs,cachem); \ + (*counterHandler)(Work_start,currVP->slaveNum,currVP->numTimesAssignedToASlot,currVP,cycles,instrs,cachem); \ + } + + #define HOLISTIC__Record_Work_end \ + if(currVP){ \ + uint64 cycles,instrs,cachem; \ + saveCyclesAndInstrs(thisCoresIdx,cycles, instrs,cachem); \ + (*counterHandler)(Work_end,currVP->slaveNum,currVP->numTimesAssignedToASlot,currVP,cycles,instrs,cachem); \ + } + + #define HOLISTIC__Record_HwResponderInvocation_start \ + uint64 cycles,instrs,cachem; \ + saveCyclesAndInstrs(animatingSlv->coreAnimatedBy,cycles, instrs,cachem); \ + (*(_PRTopEnv->counterHandler))(HwResponderInvocation_start,animatingSlv->slaveNum,animatingSlv->numTimesAssignedToASlot,animatingSlv,cycles,instrs,cachem); + + + #define getReturnAddressBeforeLibraryCall(vp_ptr, res_ptr) do{ \ +void* frame_ptr0 = vp_ptr->framePtr; \ +void* frame_ptr1 = *((void**)frame_ptr0); \ +void* frame_ptr2 = *((void**)frame_ptr1); \ +void* frame_ptr3 = *((void**)frame_ptr2); \ +void* ret_addr = *((void**)frame_ptr3 + 1); \ +*res_ptr = ret_addr; \ +} while (0) + +#else + #define MEAS__Insert_Counter_Handler + #define MEAS__Insert_Counter_Meas_Fields_into_MasterEnv + #define HOLISTIC__Setup_Perf_Counters + #define HOLISTIC__CoreCtrl_Setup + #define HOLISTIC__Insert_Master_Global_Vars + #define HOLISTIC__Record_last_work + #define HOLISTIC__Record_AppResponderInvocation_start + #define HOLISTIC__Record_AppResponder_start + #define HOLISTIC__Record_AppResponder_end + #define HOLISTIC__Record_Assigner_start + #define HOLISTIC__Record_Assigner_end + #define HOLISTIC__Record_Work_start + #define HOLISTIC__Record_Work_end + #define HOLISTIC__Record_HwResponderInvocation_start + #define getReturnAddressBeforeLibraryCall(vp_ptr, res_ptr) +#endif + +//Experiment in two-step macros -- if doesn't work, insert each separately +#define MEAS__Insert_Meas_Fields_into_Slave \ + MEAS__Insert_Susp_Meas_Fields_into_Slave \ + MEAS__Insert_Master_Meas_Fields_into_Slave \ + MEAS__Insert_System_Meas_Fields_into_Slave + + +//====================== Histogram Macros -- Create ======================== +// +// + +//The language implementation should include a definition of this macro, +// which creates all the histograms the language uses to collect measurements +// of plugin operation -- so, if the language didn't define it, must +// define it here (as empty), to avoid compile error +#ifndef MEAS__Make_Meas_Hists_for_Language +#define MEAS__Make_Meas_Hists_for_Language +#endif + +#define makeAMeasHist( histInfo, idx, name, numBins, startVal, binWidth ) \ + makeHighestDynArrayIndexBeAtLeast( _PRTopEnv->measHistsInfo, idx ); \ + _PRTopEnv->measHists[idx] = \ + makeFixedBinHist( numBins, startVal, binWidth, name ); + +//============================== Probes =================================== + + +//=========================================================================== +#endif /* _PR_DEFS_MEAS_H */ + diff -r d460a47ed2d6 -r 14241f07f742 Services_offered_by_PR/prdependency.h --- a/Services_offered_by_PR/prdependency.h Thu Aug 08 02:39:56 2013 -0700 +++ b/Services_offered_by_PR/prdependency.h Thu Aug 08 03:00:36 2013 -0700 @@ -1,57 +1,57 @@ -/* - * Copyright 2011 OpenSourceResearchInstitute.org - * Licensed under GNU General Public License version 2 - * - * Author: Nina Engelhardt - * - */ - -#ifndef _PRDEPENDENCY_H -#define _PRDEPENDENCY_H - - -#include -#include - -typedef struct { - int vp; - int task; -} Unit; - -typedef struct { - int from_vp; - int from_task; - int to_vp; - int to_task; -} Dependency; - -typedef struct { - int32 id; - ListOfArrays* senders; - ListOfArrays* receivers; -} NtoN; - -FILE* dependency_file; - -Dependency* new_dependency(int from_vp, int from_task, int to_vp, int to_task); - -NtoN* new_NtoN(int id); - -int set_dependency_file(FILE* file); - -void print_ctl_dependency_to_file(void* _dep); - -void print_comm_dependency_to_file(void* _dep); - -void print_dyn_dependency_to_file(void* _dep); - -void print_hw_dependency_to_file(void* _dep); - -void print_dependency_to_file(void* dep); - -void print_unit_to_file(void* unit); - -void print_nton_to_file(void* _nton); - -#endif /* DEPENDENCY_H */ - +/* + * Copyright 2011 OpenSourceResearchInstitute.org + * Licensed under GNU General Public License version 2 + * + * Author: Nina Engelhardt + * + */ + +#ifndef _PRDEPENDENCY_H +#define _PRDEPENDENCY_H + + +#include +#include + +typedef struct { + int vp; + int task; +} Unit; + +typedef struct { + int from_vp; + int from_task; + int to_vp; + int to_task; +} Dependency; + +typedef struct { + int32 id; + ListOfArrays* senders; + ListOfArrays* receivers; +} NtoN; + +FILE* dependency_file; + +Dependency* new_dependency(int from_vp, int from_task, int to_vp, int to_task); + +NtoN* new_NtoN(int id); + +int set_dependency_file(FILE* file); + +void print_ctl_dependency_to_file(void* _dep); + +void print_comm_dependency_to_file(void* _dep); + +void print_dyn_dependency_to_file(void* _dep); + +void print_hw_dependency_to_file(void* _dep); + +void print_dependency_to_file(void* dep); + +void print_unit_to_file(void* unit); + +void print_nton_to_file(void* _nton); + +#endif /* DEPENDENCY_H */ + diff -r d460a47ed2d6 -r 14241f07f742 Services_offered_by_PR/probes__wrapper_library.h --- a/Services_offered_by_PR/probes__wrapper_library.h Thu Aug 08 02:39:56 2013 -0700 +++ b/Services_offered_by_PR/probes__wrapper_library.h Thu Aug 08 03:00:36 2013 -0700 @@ -1,44 +1,44 @@ -/* - * Copyright 2009 OpenSourceStewardshipFoundation.org - * Licensed under GNU General Public License version 2 - * - * Author: seanhalle@yahoo.com - * - */ - -/*NOTE: this file should only be included AFTER some other - * file has defined which kind of probe to use, and whether - * probes are turned on or off.. - * - *In other words, this is a static library that uses macros, - * and there are multiple versions of the same macro.. which - * version gets used depends on #define statements in a - * DIFFERENT file.. (traditionally PR_defs__turn_on_and_off.h) - * - *So, this file relies on #defines that appear in other files, - * which must come first in the sequence of #includes that - * include this one.. - */ - -#ifndef _PROBES_wrapper_library_H -#define _PROBES_wrapper_library_H -#define _GNU_SOURCE - -//========================================================= -// Use only these aliases within application code -//========================================================= - - -#define PR_App__record_time_point_into_new_probe PR_WL__record_time_point_into_new_probe -#define PR_App__create_single_interval_probe PR_WL__create_single_interval_probe -#define PR_App__create_histogram_probe PR_WL__create_histogram_probe -#define PR_App__index_probe_by_its_name PR_WL__index_probe_by_its_name -#define PR_App__get_probe_by_name PR_WL__get_probe_by_name -#define PR_App__record_sched_choice_into_probe PR_WL__record_sched_choice_into_probe -#define PR_App__record_interval_start_in_probe PR_WL__record_interval_start_in_probe -#define PR_App__record_interval_end_in_probe PR_WL__record_interval_end_in_probe -#define PR_App__print_stats_of_probe PR_WL__print_stats_of_probe -#define PR_App__print_stats_of_all_probes PR_WL__print_stats_of_all_probes - -#endif /* top ifndef */ - +/* + * Copyright 2009 OpenSourceStewardshipFoundation.org + * Licensed under GNU General Public License version 2 + * + * Author: seanhalle@yahoo.com + * + */ + +/*NOTE: this file should only be included AFTER some other + * file has defined which kind of probe to use, and whether + * probes are turned on or off.. + * + *In other words, this is a static library that uses macros, + * and there are multiple versions of the same macro.. which + * version gets used depends on #define statements in a + * DIFFERENT file.. (traditionally PR_defs__turn_on_and_off.h) + * + *So, this file relies on #defines that appear in other files, + * which must come first in the sequence of #includes that + * include this one.. + */ + +#ifndef _PROBES_wrapper_library_H +#define _PROBES_wrapper_library_H +#define _GNU_SOURCE + +//========================================================= +// Use only these aliases within application code +//========================================================= + + +#define PR_App__record_time_point_into_new_probe PR_WL__record_time_point_into_new_probe +#define PR_App__create_single_interval_probe PR_WL__create_single_interval_probe +#define PR_App__create_histogram_probe PR_WL__create_histogram_probe +#define PR_App__index_probe_by_its_name PR_WL__index_probe_by_its_name +#define PR_App__get_probe_by_name PR_WL__get_probe_by_name +#define PR_App__record_sched_choice_into_probe PR_WL__record_sched_choice_into_probe +#define PR_App__record_interval_start_in_probe PR_WL__record_interval_start_in_probe +#define PR_App__record_interval_end_in_probe PR_WL__record_interval_end_in_probe +#define PR_App__print_stats_of_probe PR_WL__print_stats_of_probe +#define PR_App__print_stats_of_all_probes PR_WL__print_stats_of_all_probes + +#endif /* top ifndef */ + diff -r d460a47ed2d6 -r 14241f07f742 __README__about_dir.txt --- a/__README__about_dir.txt Thu Aug 08 02:39:56 2013 -0700 +++ b/__README__about_dir.txt Thu Aug 08 03:00:36 2013 -0700 @@ -1,7 +1,7 @@ - -This directory is a copy of /usr/include/PR__include - -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). - -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. - + +This directory is a copy of /usr/include/PR__include + +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). + +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. + diff -r d460a47ed2d6 -r 14241f07f742 langlets/vreo_wrapper_library.h --- a/langlets/vreo_wrapper_library.h Thu Aug 08 02:39:56 2013 -0700 +++ b/langlets/vreo_wrapper_library.h Thu Aug 08 03:00:36 2013 -0700 @@ -1,264 +1,264 @@ -/* - * Copyright 2009 OpenSourceResearchInstitute.org - * Licensed under GNU General Public License version 2 - * - * Author: seanhalle@yahoo.com - * - */ - -#ifndef _VREO_WRAPPER_H -#define _VREO_WRAPPER_H - -#include -//#include -//#include -//#include "Measurement/dependency.h" - - //uniquely identifies VSs -- should be a jenkins char-hash of "VSs" to int32 -#define VReo_MAGIC_NUMBER 0000000003 - -//=========================================================================== -/* - //uniquely identifies VSs -- should be a jenkins char-hash of "VSs" to int32 -#define VReo_MAGIC_NUMBER 0000000003 - -#define NUM_STRUCS_IN_LANG_ENV 1000 - - //This is hardware dependent -- it's the number of cycles of scheduling - // overhead -- if a work unit is fewer than this, it is better being - // combined sequentially with other work - //This value depends on both PR overhead and VSs's plugin. At some point - // it will be derived by perf-counter measurements during init of VSs -#define MIN_WORK_UNIT_CYCLES 20000 -*/ - -//=========================================================================== -/*This header defines everything specific to the VReo semantic plug-in - */ -typedef struct _VReoIsland VReoIsland; - -//typedef struct _VReoLangReq VReoLangReq; -//typedef struct _VReoTaskStub VReoTaskStub; -//typedef void (*VReoTaskFnPtr ) ( void *, SlaveVP *); -typedef bool32 (*VReoCheckerFn ) ( VReoIsland * ); -typedef void (*VReoDoerFn ) ( VReoIsland * ); -//=========================================================================== - -/* -#define IS_A_VP NULL -#define IS_ENDED NULL -#define SEED_SLV NULL - -#define NO_ID NULL -#define ANY_CORE -1 -*/ - -//=========================================================================== - -typedef struct - { - void *buffer; - bool32 portIsFull; - SlaveVP *waitingReaderVP; //doubles as flag - SlaveVP *waitingWriterVP; - - void *reader; //either island or VP - void *writer; //either island or VP - - int32 numReaderCheckerFns; - VReoCheckerFn *readerCheckerFns; //checkers triggered when port state changes - VReoDoerFn *readerDoerFns; //corresponding doer functions - - int32 numWriterCheckerFns; - VReoCheckerFn *writerCheckerFns; //checkers triggered when port state changes - VReoDoerFn *writerDoerFns; //corresponding doer functions - } -VReoPort; - -struct _VReoIsland - { - int32 numPorts; - VReoPort **ports; //array of pointers to port structs - - int32 numCheckerFns; - VReoCheckerFn *checkerFns; //checkers triggered when state changes - VReoDoerFn *doerFns; //corresponding doer functions - - int32 lastCheckerToSucceed; - }; -//VReoIsland - -typedef struct _VReoListElem VReoListElem; - -struct _VReoListElem - { - void *payload; - VReoListElem *next; - }; -//VReoListElem - -typedef struct - { - int32 numPorts; // - VReoPort *ports; //array of port structs - VReoPort **boundaryPorts; - - int32 numIslands; - VReoIsland *islands; //array of island structs -- no pointers - - int32 numVPs; - VReoListElem *VPs; - - int32 suspendScope; //given to PR -- VPs created suspended - } -VReoCircuit; - -//Every application-defined birth param struct must have a pointer to a -// circuit as its first field. An instance of one of those app-defined -// structs is then cast to be a VReoBirthParams, in order for VReo to -// access the circuit field without knowing anything about the app-specific -// part of the structure -typedef struct - { - VReoCircuit *circuit; - } -VReoBirthParams; - -/*This is VReo's "lang meta task" - *See the proto-runtime wiki entry to learn about "lang meta task" - *In essence, this holds all the meta information that VReo needs about a task - */ -/* -struct _VReoTaskStub - { - VReoTaskStub *parentTaskStub; //for liveness, for the wait construct - int32 numLiveChildTasks; - int32 numLiveChildVPs; - bool32 isWaitingForChildTasksToEnd; - bool32 isWaitingForChildVPsToEnd; - bool32 isEnded; - }; -*/ - - -/*Semantic-layer-specific data sent inside a request from lib call in app - * to request handler called in AnimationMaster - */ -/* -struct _VReoLangReq - { - SlaveVP *callingVP; - - BirthFnPtr fnPtr; - void *initData; - int32 coreToAssignOnto; - int32 createSuspendedGroup; - - VReoCircuit *circuit; - VReoPort *port; - void *itemToPut; - } -*/ -/* VReoLangReq */; - - -/* -typedef struct - { - PrivQueueStruc *slaveReadyQ; //Shared (slaves not pinned) - PrivQueueStruc *taskReadyQ; //Shared (tasks not pinned) - - int32 nextCoreToGetNewSlv; - int32 primitiveStartTime; - - VReoCircuit *circuit; //used during debugging, to get access when no work - - #ifdef HOLISTIC__TURN_ON_OBSERVE_UCC - ListOfArrays* unitList; - ListOfArrays* ctlDependenciesList; - ListOfArrays* commDependenciesList; - NtoN** ntonGroups; - PrivDynArrayInfo* ntonGroupsInfo; - ListOfArrays* dynDependenciesList; - Unit last_in_slot[NUM_CORES * NUM_ANIM_SLOTS]; - ListOfArrays* hwArcs; - #endif - - #ifdef HOLISTIC__TURN_ON_PERF_COUNTERS - ListOfArrays* counterList[NUM_CORES]; - #endif - } -VReoLangEnv; - - -typedef struct - { - VReoCircuit *circuit; - int32 numPorts; - int32 *ports; - } -VReoVPParams; - -typedef struct - { - VReoVPParams *params; //keep here, so can free when end VP - } -VReoLangData; -*/ - -//=========================================================================== - -//======================= - -void -VReo__start( SlaveVP *seedVP ); - -void -VReo__shutdown( SlaveVP *seedVP ); - -void -VReo__wait_for_all_VReo_created_work_to_end( SlaveVP *seedVP ); - -//======================= - -void -VReo__put_into_port( void *itemToPut, VReoPort *port, SlaveVP *callingVP ); - -void * -VReo__get_from_port( VReoPort *port, SlaveVP *callingVP ); - - - -SlaveVP * -VReo__create_VP( BirthFnPtr fnPtr, void *_params, - VReoCircuit *circuit, SlaveVP *creatingVP ); - -void -VReo__end_VP( SlaveVP *VPToEnd ); - - -//======================= - - -//========================= Internal use only ============================= -/* -bool32 -VReo__assign_work_to_slot( void *_langEnv, AnimSlot *slot ); - -SlaveVP * -VReo__create_slave_with_affinity( BirthFnPtr fnPtr, void *initData, - SlaveVP *creatingSlv, int32 coreToAssignOnto); - -void -VReo__cleanup_after_shutdown(); - -//===================== ===================== - -#include "VReo_Request_Handlers.h" - -//===================== Measurement of Lang Overheads ===================== -#include "Measurement/VReo_Measurement.h" -*/ -//=========================================================================== -#endif /* _VReo_H */ - +/* + * Copyright 2009 OpenSourceResearchInstitute.org + * Licensed under GNU General Public License version 2 + * + * Author: seanhalle@yahoo.com + * + */ + +#ifndef _VREO_WRAPPER_H +#define _VREO_WRAPPER_H + +#include +//#include +//#include +//#include "Measurement/dependency.h" + + //uniquely identifies VSs -- should be a jenkins char-hash of "VSs" to int32 +#define VReo_MAGIC_NUMBER 0000000003 + +//=========================================================================== +/* + //uniquely identifies VSs -- should be a jenkins char-hash of "VSs" to int32 +#define VReo_MAGIC_NUMBER 0000000003 + +#define NUM_STRUCS_IN_LANG_ENV 1000 + + //This is hardware dependent -- it's the number of cycles of scheduling + // overhead -- if a work unit is fewer than this, it is better being + // combined sequentially with other work + //This value depends on both PR overhead and VSs's plugin. At some point + // it will be derived by perf-counter measurements during init of VSs +#define MIN_WORK_UNIT_CYCLES 20000 +*/ + +//=========================================================================== +/*This header defines everything specific to the VReo semantic plug-in + */ +typedef struct _VReoIsland VReoIsland; + +//typedef struct _VReoLangReq VReoLangReq; +//typedef struct _VReoTaskStub VReoTaskStub; +//typedef void (*VReoTaskFnPtr ) ( void *, SlaveVP *); +typedef bool32 (*VReoCheckerFn ) ( VReoIsland * ); +typedef void (*VReoDoerFn ) ( VReoIsland * ); +//=========================================================================== + +/* +#define IS_A_VP NULL +#define IS_ENDED NULL +#define SEED_SLV NULL + +#define NO_ID NULL +#define ANY_CORE -1 +*/ + +//=========================================================================== + +typedef struct + { + void *buffer; + bool32 portIsFull; + SlaveVP *waitingReaderVP; //doubles as flag + SlaveVP *waitingWriterVP; + + void *reader; //either island or VP + void *writer; //either island or VP + + int32 numReaderCheckerFns; + VReoCheckerFn *readerCheckerFns; //checkers triggered when port state changes + VReoDoerFn *readerDoerFns; //corresponding doer functions + + int32 numWriterCheckerFns; + VReoCheckerFn *writerCheckerFns; //checkers triggered when port state changes + VReoDoerFn *writerDoerFns; //corresponding doer functions + } +VReoPort; + +struct _VReoIsland + { + int32 numPorts; + VReoPort **ports; //array of pointers to port structs + + int32 numCheckerFns; + VReoCheckerFn *checkerFns; //checkers triggered when state changes + VReoDoerFn *doerFns; //corresponding doer functions + + int32 lastCheckerToSucceed; + }; +//VReoIsland + +typedef struct _VReoListElem VReoListElem; + +struct _VReoListElem + { + void *payload; + VReoListElem *next; + }; +//VReoListElem + +typedef struct + { + int32 numPorts; // + VReoPort *ports; //array of port structs + VReoPort **boundaryPorts; + + int32 numIslands; + VReoIsland *islands; //array of island structs -- no pointers + + int32 numVPs; + VReoListElem *VPs; + + int32 suspendScope; //given to PR -- VPs created suspended + } +VReoCircuit; + +//Every application-defined birth param struct must have a pointer to a +// circuit as its first field. An instance of one of those app-defined +// structs is then cast to be a VReoBirthParams, in order for VReo to +// access the circuit field without knowing anything about the app-specific +// part of the structure +typedef struct + { + VReoCircuit *circuit; + } +VReoBirthParams; + +/*This is VReo's "lang meta task" + *See the proto-runtime wiki entry to learn about "lang meta task" + *In essence, this holds all the meta information that VReo needs about a task + */ +/* +struct _VReoTaskStub + { + VReoTaskStub *parentTaskStub; //for liveness, for the wait construct + int32 numLiveChildTasks; + int32 numLiveChildVPs; + bool32 isWaitingForChildTasksToEnd; + bool32 isWaitingForChildVPsToEnd; + bool32 isEnded; + }; +*/ + + +/*Semantic-layer-specific data sent inside a request from lib call in app + * to request handler called in AnimationMaster + */ +/* +struct _VReoLangReq + { + SlaveVP *callingVP; + + BirthFnPtr fnPtr; + void *initData; + int32 coreToAssignOnto; + int32 createSuspendedGroup; + + VReoCircuit *circuit; + VReoPort *port; + void *itemToPut; + } +*/ +/* VReoLangReq */; + + +/* +typedef struct + { + PrivQueueStruc *slaveReadyQ; //Shared (slaves not pinned) + PrivQueueStruc *taskReadyQ; //Shared (tasks not pinned) + + int32 nextCoreToGetNewSlv; + int32 primitiveStartTime; + + VReoCircuit *circuit; //used during debugging, to get access when no work + + #ifdef HOLISTIC__TURN_ON_OBSERVE_UCC + ListOfArrays* unitList; + ListOfArrays* ctlDependenciesList; + ListOfArrays* commDependenciesList; + NtoN** ntonGroups; + PrivDynArrayInfo* ntonGroupsInfo; + ListOfArrays* dynDependenciesList; + Unit last_in_slot[NUM_CORES * NUM_ANIM_SLOTS]; + ListOfArrays* hwArcs; + #endif + + #ifdef HOLISTIC__TURN_ON_PERF_COUNTERS + ListOfArrays* counterList[NUM_CORES]; + #endif + } +VReoLangEnv; + + +typedef struct + { + VReoCircuit *circuit; + int32 numPorts; + int32 *ports; + } +VReoVPParams; + +typedef struct + { + VReoVPParams *params; //keep here, so can free when end VP + } +VReoLangData; +*/ + +//=========================================================================== + +//======================= + +void +VReo__start( SlaveVP *seedVP ); + +void +VReo__shutdown( SlaveVP *seedVP ); + +void +VReo__wait_for_all_VReo_created_work_to_end( SlaveVP *seedVP ); + +//======================= + +void +VReo__put_into_port( void *itemToPut, VReoPort *port, SlaveVP *callingVP ); + +void * +VReo__get_from_port( VReoPort *port, SlaveVP *callingVP ); + + + +SlaveVP * +VReo__create_VP( BirthFnPtr fnPtr, void *_params, + VReoCircuit *circuit, SlaveVP *creatingVP ); + +void +VReo__end_VP( SlaveVP *VPToEnd ); + + +//======================= + + +//========================= Internal use only ============================= +/* +bool32 +VReo__assign_work_to_slot( void *_langEnv, AnimSlot *slot ); + +SlaveVP * +VReo__create_slave_with_affinity( BirthFnPtr fnPtr, void *initData, + SlaveVP *creatingSlv, int32 coreToAssignOnto); + +void +VReo__cleanup_after_shutdown(); + +//===================== ===================== + +#include "VReo_Request_Handlers.h" + +//===================== Measurement of Lang Overheads ===================== +#include "Measurement/VReo_Measurement.h" +*/ +//=========================================================================== +#endif /* _VReo_H */ + diff -r d460a47ed2d6 -r 14241f07f742 prdynarray.h --- a/prdynarray.h Thu Aug 08 02:39:56 2013 -0700 +++ b/prdynarray.h Thu Aug 08 03:00:36 2013 -0700 @@ -1,91 +1,91 @@ -/* - * File: Vector.h - * Author: Me - * - * Created on May 14, 2010, 3:08 PM - */ - -#ifndef _DYNARRAY_H -#define _DYNARRAY_H - -#include - - - -/*WARNING: Passing a DynArray as a param is dangerous if add to the DynArray - * inside the function called! After adding or other operation that might - * change the size, must re-read the addr of the chunk of memory that is the - * array, via the DynArrayInfo. - *Here's why: An array variable is a location, either on the stack - * or in a field of a struct, whose contents is an addr. That addr is of the - * first location of a chunk of locations. The DynArray works by changing - * the chunk of locations, then modifying the contents of the original - * array variable. It overwrites the addr of the old chunk of locations - * with the addr of the new chunk. - *But when the array variable is passed as a parameter, such as - * in this: "foo( myDynArray )", then there are now two locations that hold - * the addr of the same chunk of locations. So when a call is made that - * adds to the DynArray, and inside the DynArray expands, it only updates - * the original location with the new addr. Hence, the function will begin - * overwriting memory past the end of the old chunk, because it still has - * the pointer to the old chunk of locations. - * - *A dynamic array is accessed same as any other array. However, must use - * dyn array calls, defined in here, in order to add or increase the size. - * Must re-read the original array variable after any size-changing calls. - *To pass a DynArray as a parameter to a function, can only pass the - * DynArrayInfo, then inside the function, to read the addr of the first - * location in the chunk of locations that is the array, do this: - * "localArrayCopy = *(myDynArrayInfo->addrOfPtrToArray). After that, can - * treat localArrayCopy as a normal array, as long as don't make any calls - * that add or otherwise could increase the size of the array. If do make - * such a call, then re-copy the array via the above. Can then use the - * copy up until another add to the array. - * - */ -typedef struct - { - void ***addrOfPtrToArray; //addr of var that is array of ptrs == triple * - int32 numInArray; //num entries added - int32 sizeOfArray; //num elems alloc'd - int32 sizeOfElem; //num bytes in one elem of array -- used in 2nd version - } -PrivDynArrayInfo; - -PrivDynArrayInfo * -makePrivDynArrayInfoFrom( void ***addrOfPtrToArray, int32 sizeOfArray ); - -PrivDynArrayInfo * -makePrivDynArrayOfSize( void ***addrOfPtrToArray, int32 sizeOfArray ); - -PrivDynArrayInfo * -makePrivDynArrayOfSize_Ext( void ***addrOfPtrToArray, int32 sizeOfArray ); - -int32 -addToDynArray( void *value, PrivDynArrayInfo *info ); - -void -makeHighestDynArrayIndexBe( PrivDynArrayInfo *info, int32 highestIndex ); - -void -makeHighestDynArrayIndexBeAtLeast(PrivDynArrayInfo *info,int32 highestIndex); - -void -increaseSizeOfDynArrayTo( PrivDynArrayInfo *info, int32 newSize ); - -typedef void (*FreeFnPtr) ( void * ); //fn has to cast void * to whatever - -void -freeDynArrayDeep( PrivDynArrayInfo *info, FreeFnPtr freeFnPtr ); - -void -freeDynArrayFlat( PrivDynArrayInfo *info ); - - -typedef void (*DynArrayFnPtr) ( void * ); //fn has to cast void * - -void -forAllInDynArrayDo( PrivDynArrayInfo *info, DynArrayFnPtr fnPtr ); - -#endif /* _DYNARRAY_H */ - +/* + * File: Vector.h + * Author: Me + * + * Created on May 14, 2010, 3:08 PM + */ + +#ifndef _DYNARRAY_H +#define _DYNARRAY_H + +#include + + + +/*WARNING: Passing a DynArray as a param is dangerous if add to the DynArray + * inside the function called! After adding or other operation that might + * change the size, must re-read the addr of the chunk of memory that is the + * array, via the DynArrayInfo. + *Here's why: An array variable is a location, either on the stack + * or in a field of a struct, whose contents is an addr. That addr is of the + * first location of a chunk of locations. The DynArray works by changing + * the chunk of locations, then modifying the contents of the original + * array variable. It overwrites the addr of the old chunk of locations + * with the addr of the new chunk. + *But when the array variable is passed as a parameter, such as + * in this: "foo( myDynArray )", then there are now two locations that hold + * the addr of the same chunk of locations. So when a call is made that + * adds to the DynArray, and inside the DynArray expands, it only updates + * the original location with the new addr. Hence, the function will begin + * overwriting memory past the end of the old chunk, because it still has + * the pointer to the old chunk of locations. + * + *A dynamic array is accessed same as any other array. However, must use + * dyn array calls, defined in here, in order to add or increase the size. + * Must re-read the original array variable after any size-changing calls. + *To pass a DynArray as a parameter to a function, can only pass the + * DynArrayInfo, then inside the function, to read the addr of the first + * location in the chunk of locations that is the array, do this: + * "localArrayCopy = *(myDynArrayInfo->addrOfPtrToArray). After that, can + * treat localArrayCopy as a normal array, as long as don't make any calls + * that add or otherwise could increase the size of the array. If do make + * such a call, then re-copy the array via the above. Can then use the + * copy up until another add to the array. + * + */ +typedef struct + { + void ***addrOfPtrToArray; //addr of var that is array of ptrs == triple * + int32 numInArray; //num entries added + int32 sizeOfArray; //num elems alloc'd + int32 sizeOfElem; //num bytes in one elem of array -- used in 2nd version + } +PrivDynArrayInfo; + +PrivDynArrayInfo * +makePrivDynArrayInfoFrom( void ***addrOfPtrToArray, int32 sizeOfArray ); + +PrivDynArrayInfo * +makePrivDynArrayOfSize( void ***addrOfPtrToArray, int32 sizeOfArray ); + +PrivDynArrayInfo * +makePrivDynArrayOfSize_Ext( void ***addrOfPtrToArray, int32 sizeOfArray ); + +int32 +addToDynArray( void *value, PrivDynArrayInfo *info ); + +void +makeHighestDynArrayIndexBe( PrivDynArrayInfo *info, int32 highestIndex ); + +void +makeHighestDynArrayIndexBeAtLeast(PrivDynArrayInfo *info,int32 highestIndex); + +void +increaseSizeOfDynArrayTo( PrivDynArrayInfo *info, int32 newSize ); + +typedef void (*FreeFnPtr) ( void * ); //fn has to cast void * to whatever + +void +freeDynArrayDeep( PrivDynArrayInfo *info, FreeFnPtr freeFnPtr ); + +void +freeDynArrayFlat( PrivDynArrayInfo *info ); + + +typedef void (*DynArrayFnPtr) ( void * ); //fn has to cast void * + +void +forAllInDynArrayDo( PrivDynArrayInfo *info, DynArrayFnPtr fnPtr ); + +#endif /* _DYNARRAY_H */ + diff -r d460a47ed2d6 -r 14241f07f742 prhash.h --- a/prhash.h Thu Aug 08 02:39:56 2013 -0700 +++ b/prhash.h Thu Aug 08 03:00:36 2013 -0700 @@ -1,96 +1,96 @@ -/* - * Copyright 2009 OpenSourceResearchInstitute.org - * Licensed under GNU General Public License version 2 - * - * Author: seanhalle@yahoo.com - */ - -#ifndef _PRHASH_H -#define _PRHASH_H - -#include -#include -#include -#include - -#include - -//===================== defines ===================== -#define TRUE 1 -#define FALSE 0 - -#define DEFAULT_HASH_TABLE_SIZE 1 << 10 -#define DEFAULT_POWER_OF_2_TABLE_SIZE 10 - - -//===================== structs ===================== -union hashkey_t{ - char hashable[8]; - int32 parts[2]; -}; - -typedef union hashkey_t hashkey_t; - -typedef struct _HashEntry HashEntry; - -struct _HashEntry - { - char *key; - void *content; - HashEntry *next; - }; - -typedef void (*FreeEntryContentFnPtr) ( void * ); - -typedef struct - { int32 tableSz; - int32 numEntries; - HashEntry* *entries; - int32 hashMask; - int32 prevHash; - FreeEntryContentFnPtr freeEntryContentFn; - } -HashTable; - - -//=========================================================================== -// Public functions -HashTable *makeHashTable( int numHashSlots, FreeEntryContentFnPtr freeFn ); - -int32 putEntryIntoTable( HashEntry *entry, HashTable *table); -int32 addValueIntoTable( char* key, void *value, HashTable *table); -HashEntry *getEntryFromTable( char *key, HashTable *table ); -void *getValueFromTable( char *key, HashTable *table ); - -bool8 deleteEntryFromTable( char *key, HashTable *table ); -bool8 deleteThisEntryFromTable( HashEntry *entry, HashTable *table ); -bool8 deleteEntrysValueInTable( char *key, HashTable *table ); -bool8 deleteEntryFromTableAndFreeValue( char *key, HashTable *table ); -void freeHashTable( HashTable *table ); -//char *paramBagToString( ParamBag * bag ) - -//================= Same Fns, but for 32b array key hash fn ================ -HashTable *makeHashTable32(int32 powerOf2OfSz, FreeEntryContentFnPtr freeFn); -HashTable *makeDefaultSizeHashTable32( FreeEntryContentFnPtr freeFn ); - -int32 putEntryIntoTable32( HashEntry *entry, HashTable *table); -HashEntry *addValueIntoTable32( uint32 key[], void *value, HashTable *table); -HashEntry *getEntryFromTable32( uint32 key[], HashTable *table ); -void *getValueFromTable32( uint32 key[], HashTable *table ); - -bool32 deleteEntryFromTable32( uint32 key[], HashTable *table ); - -//=========================================================================== -// Internal functions -void freeHashEntryUsing( HashEntry *entry, HashTable *table ); -unsigned int hashThisKey( char *s, int hashSz ); -void nullOutTablesArray( HashTable *table ); -void doubleTableSize( HashTable *table ); -void freeHashEntryButNotContent( HashEntry *entry ); - -uint32 -jenkHash32( const uint32 *key, /* array of uint32 values */ - int32 length); /* num uint32 in the key */ - -#endif /* _PRIVATE_HASH_H */ - +/* + * Copyright 2009 OpenSourceResearchInstitute.org + * Licensed under GNU General Public License version 2 + * + * Author: seanhalle@yahoo.com + */ + +#ifndef _PRHASH_H +#define _PRHASH_H + +#include +#include +#include +#include + +#include + +//===================== defines ===================== +#define TRUE 1 +#define FALSE 0 + +#define DEFAULT_HASH_TABLE_SIZE 1 << 10 +#define DEFAULT_POWER_OF_2_TABLE_SIZE 10 + + +//===================== structs ===================== +union hashkey_t{ + char hashable[8]; + int32 parts[2]; +}; + +typedef union hashkey_t hashkey_t; + +typedef struct _HashEntry HashEntry; + +struct _HashEntry + { + char *key; + void *content; + HashEntry *next; + }; + +typedef void (*FreeEntryContentFnPtr) ( void * ); + +typedef struct + { int32 tableSz; + int32 numEntries; + HashEntry* *entries; + int32 hashMask; + int32 prevHash; + FreeEntryContentFnPtr freeEntryContentFn; + } +HashTable; + + +//=========================================================================== +// Public functions +HashTable *makeHashTable( int numHashSlots, FreeEntryContentFnPtr freeFn ); + +int32 putEntryIntoTable( HashEntry *entry, HashTable *table); +int32 addValueIntoTable( char* key, void *value, HashTable *table); +HashEntry *getEntryFromTable( char *key, HashTable *table ); +void *getValueFromTable( char *key, HashTable *table ); + +bool8 deleteEntryFromTable( char *key, HashTable *table ); +bool8 deleteThisEntryFromTable( HashEntry *entry, HashTable *table ); +bool8 deleteEntrysValueInTable( char *key, HashTable *table ); +bool8 deleteEntryFromTableAndFreeValue( char *key, HashTable *table ); +void freeHashTable( HashTable *table ); +//char *paramBagToString( ParamBag * bag ) + +//================= Same Fns, but for 32b array key hash fn ================ +HashTable *makeHashTable32(int32 powerOf2OfSz, FreeEntryContentFnPtr freeFn); +HashTable *makeDefaultSizeHashTable32( FreeEntryContentFnPtr freeFn ); + +int32 putEntryIntoTable32( HashEntry *entry, HashTable *table); +HashEntry *addValueIntoTable32( uint32 key[], void *value, HashTable *table); +HashEntry *getEntryFromTable32( uint32 key[], HashTable *table ); +void *getValueFromTable32( uint32 key[], HashTable *table ); + +bool32 deleteEntryFromTable32( uint32 key[], HashTable *table ); + +//=========================================================================== +// Internal functions +void freeHashEntryUsing( HashEntry *entry, HashTable *table ); +unsigned int hashThisKey( char *s, int hashSz ); +void nullOutTablesArray( HashTable *table ); +void doubleTableSize( HashTable *table ); +void freeHashEntryButNotContent( HashEntry *entry ); + +uint32 +jenkHash32( const uint32 *key, /* array of uint32 values */ + int32 length); /* num uint32 in the key */ + +#endif /* _PRIVATE_HASH_H */ + diff -r d460a47ed2d6 -r 14241f07f742 prhistogram.h --- a/prhistogram.h Thu Aug 08 02:39:56 2013 -0700 +++ b/prhistogram.h Thu Aug 08 03:00:36 2013 -0700 @@ -1,102 +1,102 @@ -/* - * Copyright 2010 OpenSourceResearchInstitute.org - * Licensed under GNU General Public License version 2 - * - * Author: seanhalle@yahoo.com - * - */ - - -#ifndef _PRHISTOGRAM_H -#define _PRHISTOGRAM_H - -#include -#include - - -typedef struct - { - char *name; - int32 startOfRange; - int32 endOfRange; - int32 numBins; - int32 binWidth; - int32 *bins; - } -Histogram; - -typedef struct - { - float32 startOfRange; - float32 endOfRange; - int32 numBins; - float32 binWidth; - int32 *bins; - } -FloatHist; - -typedef struct - { - float64 startOfRange; - float64 endOfRange; - int32 numBins; - float64 binWidth; - int32 *bins; - } -DblHist; - -Histogram * -makeHistogram( int32 numBins, int32 startOfRange, int32 endOfRange ); - -Histogram * -makeFixedBinHist( int32 numBins, int32 startOfRange, int32 binWidth, - char *name ); - -Histogram * -makeFixedBinHistExt( int32 numBins, int32 startOfRange, int32 binWidth, - char *name ); - -void inline -addToHist( int32 value, Histogram *hist ); - -void inline -addIntervalToHist( uint32 startIntvl, uint32 endIntvl, Histogram *hist ); - -void inline -subIntervalFromHist( int32 startIntvl, int32 endIntvl, Histogram *hist ); - -void -saveHistToFile(Histogram *hist); - -void -printHist( Histogram *hist ); - -FloatHist * -makeFloatHistogram( int numBins, float32 startOfRange, float32 binWidth ); - -void -addToFloatHist( float32 value, FloatHist *hist ); - -void -printFloatHist( FloatHist *hist ); - -void -freeHistExt( Histogram *hist ); - -void -freeHist( Histogram *hist ); - -DblHist * -makeDblHistogram( int numBins, float64 startOfRange, float64 binWidth ); - -void -addToDblHist( float64 value, DblHist *hist ); - -void -printDblHist( DblHist *hist ); - -void -freeDblHist( DblHist *hist ); - -#endif /* _HISTOGRAM_H */ - +/* + * Copyright 2010 OpenSourceResearchInstitute.org + * Licensed under GNU General Public License version 2 + * + * Author: seanhalle@yahoo.com + * + */ + + +#ifndef _PRHISTOGRAM_H +#define _PRHISTOGRAM_H + +#include +#include + + +typedef struct + { + char *name; + int32 startOfRange; + int32 endOfRange; + int32 numBins; + int32 binWidth; + int32 *bins; + } +Histogram; + +typedef struct + { + float32 startOfRange; + float32 endOfRange; + int32 numBins; + float32 binWidth; + int32 *bins; + } +FloatHist; + +typedef struct + { + float64 startOfRange; + float64 endOfRange; + int32 numBins; + float64 binWidth; + int32 *bins; + } +DblHist; + +Histogram * +makeHistogram( int32 numBins, int32 startOfRange, int32 endOfRange ); + +Histogram * +makeFixedBinHist( int32 numBins, int32 startOfRange, int32 binWidth, + char *name ); + +Histogram * +makeFixedBinHistExt( int32 numBins, int32 startOfRange, int32 binWidth, + char *name ); + +void inline +addToHist( int32 value, Histogram *hist ); + +void inline +addIntervalToHist( uint32 startIntvl, uint32 endIntvl, Histogram *hist ); + +void inline +subIntervalFromHist( int32 startIntvl, int32 endIntvl, Histogram *hist ); + +void +saveHistToFile(Histogram *hist); + +void +printHist( Histogram *hist ); + +FloatHist * +makeFloatHistogram( int numBins, float32 startOfRange, float32 binWidth ); + +void +addToFloatHist( float32 value, FloatHist *hist ); + +void +printFloatHist( FloatHist *hist ); + +void +freeHistExt( Histogram *hist ); + +void +freeHist( Histogram *hist ); + +DblHist * +makeDblHistogram( int numBins, float64 startOfRange, float64 binWidth ); + +void +addToDblHist( float64 value, DblHist *hist ); + +void +printDblHist( DblHist *hist ); + +void +freeDblHist( DblHist *hist ); + +#endif /* _HISTOGRAM_H */ + diff -r d460a47ed2d6 -r 14241f07f742 prmalloc.h --- a/prmalloc.h Thu Aug 08 02:39:56 2013 -0700 +++ b/prmalloc.h Thu Aug 08 03:00:36 2013 -0700 @@ -1,52 +1,52 @@ -/* - * Copyright 2009 OpenSourceCodeStewardshipFoundation.org - * Licensed under GNU General Public License version 2 - * - * Author: seanhalle@yahoo.com - * - * Created on November 14, 2009, 9:07 PM - */ - -#ifndef _PRMALLOC_H -#define _PRMALLOC_H - -#include -#include -#include -#include - -void * -PR_int__malloc( size_t sizeRequested ); - -void * -PR_int__malloc_aligned( size_t sizeRequested ); - -void -PR_int__free( void *ptrToFree ); - -//Use these in application code directly -#define \ -PR__malloc PR_WL__malloc - -#define \ -PR__free PR_WL__free - -//these are implemented in the PR leaf implementation -void * -PR_WL__malloc( int32 sizeRequested ); - -void -PR_WL__free( void *ptrToFree ); - - -/*Allocates memory from the external system -- higher overhead - */ -void * -PR_ext__malloc_in_ext( size_t sizeRequested ); - -/*Frees memory that was allocated in the external system -- higher overhead - */ -void -PR_ext__free_in_ext( void *ptrToFree ); - +/* + * Copyright 2009 OpenSourceCodeStewardshipFoundation.org + * Licensed under GNU General Public License version 2 + * + * Author: seanhalle@yahoo.com + * + * Created on November 14, 2009, 9:07 PM + */ + +#ifndef _PRMALLOC_H +#define _PRMALLOC_H + +#include +#include +#include +#include + +void * +PR_int__malloc( size_t sizeRequested ); + +void * +PR_int__malloc_aligned( size_t sizeRequested ); + +void +PR_int__free( void *ptrToFree ); + +//Use these in application code directly +#define \ +PR__malloc PR_WL__malloc + +#define \ +PR__free PR_WL__free + +//these are implemented in the PR leaf implementation +void * +PR_WL__malloc( int32 sizeRequested ); + +void +PR_WL__free( void *ptrToFree ); + + +/*Allocates memory from the external system -- higher overhead + */ +void * +PR_ext__malloc_in_ext( size_t sizeRequested ); + +/*Frees memory that was allocated in the external system -- higher overhead + */ +void +PR_ext__free_in_ext( void *ptrToFree ); + #endif \ No newline at end of file diff -r d460a47ed2d6 -r 14241f07f742 prqueue.h --- a/prqueue.h Thu Aug 08 02:39:56 2013 -0700 +++ b/prqueue.h Thu Aug 08 03:00:36 2013 -0700 @@ -1,114 +1,114 @@ -/* - * Copyright 2009 OpenSourceResearchInstitute.org - * Licensed under GNU General Public License version 2 - * - * Author: seanhalle@yahoo.com - */ - -#ifndef _PRQUEUE_H -#define _PRQUEUE_H - -#include -#include - -#define TRUE 1 -#define FALSE 0 - -//================== Private Queue stuff =================== -/* It is the data that is shared so only need one mutex. */ -typedef struct - { void **insertPos; - void **extractPos; - void **startOfData; //data is pointers - void **endOfData; //set when alloc data - } -PrivQueueStruc; - -typedef void (*DynArrayFnPtr) ( void * ); //fn has to cast void * - -PrivQueueStruc* makePrivQ ( ); -bool32 isEmptyPrivQ ( PrivQueueStruc *Q ); //ret TRUE if empty -void* peekPrivQ ( PrivQueueStruc *Q ); //ret NULL if empty -void* readPrivQ ( PrivQueueStruc *Q ); //ret NULL if empty -void writePrivQ( void *in, PrivQueueStruc *Q ); - //return false when full -bool32 writeIfSpacePrivQ( void * in, PrivQueueStruc* Q ); -int32 numInPrivQ( PrivQueueStruc *Q ); -void pushPrivQ( void * in, PrivQueueStruc* Q ); -void freePrivQ( PrivQueueStruc *Q ); - - -//====================== Parallel Queue Stuff ==================== - -//========== pThreads based queue ========== -/* It is the data that is shared so only need one mutex. */ -typedef -struct - { pthread_mutex_t mutex_t; - pthread_cond_t cond_w_t; - pthread_cond_t cond_r_t; - int32 count; - int32 readPos; - int32 writePos; - void* data[1024]; //an array of pointers - int w_empty; - int w_full; - } -PThdQueueStruc; - -PThdQueueStruc* makePThdQ(); -void* readPThdQ( PThdQueueStruc *Q ); -void writePThdQ( void *in, PThdQueueStruc *Q ); - - -//========== CAS based queue ========== -typedef -struct - { volatile int32 insertLock; - volatile int32 extractLock; - volatile void* *insertPos; - volatile void* *extractPos; - void* startOfData[1024]; //data is pointers - void* *endOfData; //set when make queue - } -CASQueueStruc; - -CASQueueStruc* makeCASQ(); -void* readCASQ( CASQueueStruc *Q ); -void writeCASQ( void *in, CASQueueStruc *Q ); - - -//========= non-atomic instr based queue =========== -typedef -struct - { void* *insertPos; - void* *extractPos; - void* startOfData[1024]; //data is pointers - void* *endOfData; //set when make queue - } -SRSWQueueStruc; - -SRSWQueueStruc* makeSRSWQ(); -void freeSRSWQ( SRSWQueueStruc* Q ); -void* readSRSWQ( SRSWQueueStruc *Q ); -void writeSRSWQ( void *in, SRSWQueueStruc *Q ); - - -//========= non-atomic instr S R M W queue =========== -typedef -struct - { int32 lastQReadFrom; - int32 numInternalQs; - int32 internalQsSz; - SRSWQueueStruc* *internalQs; - } -SRMWQueueStruc; - -SRMWQueueStruc* makeSRMWQ(); -int addWriterToSRMWQ( SRMWQueueStruc *Q ); -void* readSRMWQ( SRMWQueueStruc *Q ); -void writeSRMWQ( void *in, SRMWQueueStruc *Q, int writerID ); - - -#endif /* _PRIVATE_QUEUE_H */ - +/* + * Copyright 2009 OpenSourceResearchInstitute.org + * Licensed under GNU General Public License version 2 + * + * Author: seanhalle@yahoo.com + */ + +#ifndef _PRQUEUE_H +#define _PRQUEUE_H + +#include +#include + +#define TRUE 1 +#define FALSE 0 + +//================== Private Queue stuff =================== +/* It is the data that is shared so only need one mutex. */ +typedef struct + { void **insertPos; + void **extractPos; + void **startOfData; //data is pointers + void **endOfData; //set when alloc data + } +PrivQueueStruc; + +typedef void (*DynArrayFnPtr) ( void * ); //fn has to cast void * + +PrivQueueStruc* makePrivQ ( ); +bool32 isEmptyPrivQ ( PrivQueueStruc *Q ); //ret TRUE if empty +void* peekPrivQ ( PrivQueueStruc *Q ); //ret NULL if empty +void* readPrivQ ( PrivQueueStruc *Q ); //ret NULL if empty +void writePrivQ( void *in, PrivQueueStruc *Q ); + //return false when full +bool32 writeIfSpacePrivQ( void * in, PrivQueueStruc* Q ); +int32 numInPrivQ( PrivQueueStruc *Q ); +void pushPrivQ( void * in, PrivQueueStruc* Q ); +void freePrivQ( PrivQueueStruc *Q ); + + +//====================== Parallel Queue Stuff ==================== + +//========== pThreads based queue ========== +/* It is the data that is shared so only need one mutex. */ +typedef +struct + { pthread_mutex_t mutex_t; + pthread_cond_t cond_w_t; + pthread_cond_t cond_r_t; + int32 count; + int32 readPos; + int32 writePos; + void* data[1024]; //an array of pointers + int w_empty; + int w_full; + } +PThdQueueStruc; + +PThdQueueStruc* makePThdQ(); +void* readPThdQ( PThdQueueStruc *Q ); +void writePThdQ( void *in, PThdQueueStruc *Q ); + + +//========== CAS based queue ========== +typedef +struct + { volatile int32 insertLock; + volatile int32 extractLock; + volatile void* *insertPos; + volatile void* *extractPos; + void* startOfData[1024]; //data is pointers + void* *endOfData; //set when make queue + } +CASQueueStruc; + +CASQueueStruc* makeCASQ(); +void* readCASQ( CASQueueStruc *Q ); +void writeCASQ( void *in, CASQueueStruc *Q ); + + +//========= non-atomic instr based queue =========== +typedef +struct + { void* *insertPos; + void* *extractPos; + void* startOfData[1024]; //data is pointers + void* *endOfData; //set when make queue + } +SRSWQueueStruc; + +SRSWQueueStruc* makeSRSWQ(); +void freeSRSWQ( SRSWQueueStruc* Q ); +void* readSRSWQ( SRSWQueueStruc *Q ); +void writeSRSWQ( void *in, SRSWQueueStruc *Q ); + + +//========= non-atomic instr S R M W queue =========== +typedef +struct + { int32 lastQReadFrom; + int32 numInternalQs; + int32 internalQsSz; + SRSWQueueStruc* *internalQs; + } +SRMWQueueStruc; + +SRMWQueueStruc* makeSRMWQ(); +int addWriterToSRMWQ( SRMWQueueStruc *Q ); +void* readSRMWQ( SRMWQueueStruc *Q ); +void writeSRMWQ( void *in, SRMWQueueStruc *Q, int writerID ); + + +#endif /* _PRIVATE_QUEUE_H */ +