# HG changeset patch # User Sean Halle # Date 1374865954 25200 # Node ID 9971d5905599796e0f197cabf5a8cbfeb604c935 # Parent 972ce554264cb0eae47082088df8ef9f867db264 just capturing a point in the middle of development.. diff -r 972ce554264c -r 9971d5905599 Defines/MEAS__macros_to_be_moved_to_langs.h --- a/Defines/MEAS__macros_to_be_moved_to_langs.h Sun Jul 21 13:48:17 2013 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,64 +0,0 @@ -/* - * Copyright 2009 OpenSourceResearchInstitute.org - * Licensed under GNU General Public License version 2 - * - * Author: seanhalle@yahoo.com - * - */ - -#ifndef _PR_LANG_SPEC_DEFS_H -#define _PR_LANG_SPEC_DEFS_H - - - -//=================== Language-specific Measurement Stuff =================== -// -//TODO: move these into the language implementation directories -// - - -//=========================================================================== -//VCilk - -#ifdef VCILK - -/*These defines are used in the macros below*/ -#define spawnHistIdx 1 //note: starts at 1 -#define syncHistIdx 2 - -#define MEAS__Make_Meas_Hists_for_VCilk( slave, magicNum ) \ - do \ - { VCilkLangEnv * \ - langEnv = PR_PI__get_lang_env_from_slave( slave, magicNum ); \ - langEnv->measHistsInfo = \ - makePrivDynArrayOfSize( (void***)&(_PRTopEnv->measHists), 200); \ - histInfo = langEnv->measHistsInfo; - makeAMeasHist( histInfo, spawnHistIdx, "Spawn", 50, 0, 200 ) \ - makeAMeasHist( histInfo, syncHistIdx, "Sync", 50, 0, 200 ) \ - }while(FALSE); /* macro magic to protect local vars from name collision */ - -#define Meas_startSpawn fixme; /* changed names -- added __Cilk to end*/ - -#define Meas_startSpawn__Cilk \ - int32 startStamp, endStamp; \ - saveLowTimeStampCountInto( startStamp ); \ - -#define Meas_endSpawn__Cilk \ - saveLowTimeStampCountInto( endStamp ); \ - addIntervalToHist( startStamp, endStamp, \ - _PRTopEnv->measHists[ spawnHistIdx ] ); - -#define Meas_startSync__Cilk \ - int32 startStamp, endStamp; \ - saveLowTimeStampCountInto( startStamp ); \ - -#define Meas_endSync__Cilk \ - saveLowTimeStampCountInto( endStamp ); \ - addIntervalToHist( startStamp, endStamp, \ - _PRTopEnv->measHists[ syncHistIdx ] ); -#endif - -//=========================================================================== - -#endif /* _PR_DEFS_H */ - diff -r 972ce554264c -r 9971d5905599 Defines/PR_defs.h --- a/Defines/PR_defs.h Sun Jul 21 13:48:17 2013 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,43 +0,0 @@ -/* - * Copyright 2009 OpenSourceResearchInstitute.org - * Licensed under GNU General Public License version 2 - * - * Author: seanhalle@yahoo.com - * - */ - -#ifndef _PR_DEFS_MAIN_H -#define _PR_DEFS_MAIN_H -#define _GNU_SOURCE - -//=========================== PR-wide defs =============================== - -#define SUCCESS 0 - - //only after macro-expansion are the defs of writePrivQ, aso looked up - // so these defs can be at the top, and writePrivQ defined later on.. -#define writePRQ writePrivQ -#define readPRQ readPrivQ -#define makePRQ makePrivQ -#define numInPRQ numInPrivQ -#define PRQueueStruc PrivQueueStruc - - -/*The language should re-define this, but need a default in case it doesn't*/ -#ifndef _LANG_NAME_ -#define _LANG_NAME_ "" -#endif - -//====================== Hardware Constants ============================ -#include "PR_defs__HW_constants.h" - -//====================== Macros ====================== - //for turning macros and other PR features on and off -#include "PR_defs__turn_on_and_off.h" - -#include "../Services_Offered_by_PR/Debugging/DEBUG__macros.h" -#include "../Services_Offered_by_PR/Measurement_and_Stats/MEAS__macros.h" - -//=========================================================================== -#endif /* */ - diff -r 972ce554264c -r 9971d5905599 Defines/PR_defs__HW_constants.h --- a/Defines/PR_defs__HW_constants.h Sun Jul 21 13:48:17 2013 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,67 +0,0 @@ -/* - * Copyright 2012 OpenSourceResearchInstitute - * Licensed under BSD - * - * Author: seanhalle@yahoo.com - * - */ - -#ifndef _PR_HW_SPEC_DEFS_H -#define _PR_HW_SPEC_DEFS_H -#define _GNU_SOURCE - - -//========================= Hardware related Constants ===================== - //This value is the number of hardware threads in the shared memory - // machine -#define NUM_CORES 4 - //Now, check if sequential mode is on, and set num cores to 1, so that - // lang plugin code doesn't have to check for sequential mode -#ifdef DEBUG__TURN_ON_SEQUENTIAL_MODE - #undef NUM_CORES - #define NUM_CORES 1 -#endif - - - //tradeoff amortizing master fixed overhead vs imbalance potential - // when work-stealing, can make bigger, at risk of losing cache affinity -#define NUM_ANIM_SLOTS 1 - - //number of PRLangEnv structs created inside a process -- can't start more - // than this many langlets inside a single process -#define NUM_IN_COLLECTION 64 - - //These are for backoff inside core-loop, which reduces lock contention -#define NUM_REPS_W_NO_WORK_BEFORE_YIELD 10 -#define NUM_REPS_W_NO_WORK_BEFORE_BACKOFF 2 -#define MASTERLOCK_RETRIES_BEFORE_YIELD 100 -#define NUM_TRIES_BEFORE_DO_BACKOFF 10 -#define GET_LOCK_BACKOFF_WEIGHT 100 - - // stack size in virtual processors created -#define VIRT_PROCR_STACK_SIZE 0x8000 /* 32K */ - - // memory for PR_int__malloc -#define MALLOC_ADDITIONAL_MEM_FROM_OS_SIZE 0x8000000 /* 128M */ - - //Frequency of TS counts -- have to do tests to verify - //NOTE: turn off (in BIOS) TURBO-BOOST and SPEED-STEP else won't be const -#define TSCOUNT_FREQ 3180000000 -#define TSC_LOW_CYCLES 27 -#define TSC_LOWHI_CYCLES 45 - -#define CACHE_LINE_SZ 256 -#define PAGE_SIZE 4096 - -//To prevent false-sharing, aligns a variable to a cache-line boundary. -//No need to use for local vars because those are never shared between cores -#define __align_to_cacheline__ __attribute__ ((aligned(CACHE_LINE_SZ))) - -//aligns a pointer to cacheline. The memory area has to contain at least -//CACHE_LINE_SZ bytes more then needed -#define __align_address(ptr) ((void*)(((uintptr_t)(ptr))&((uintptr_t)(~0x0FF)))) - -//=========================================================================== - -#endif /* _PR_DEFS_H */ - diff -r 972ce554264c -r 9971d5905599 PR.h --- a/PR.h Sun Jul 21 13:48:17 2013 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,100 +0,0 @@ -/* - * Copyright 2012 OpenSourceResearchInstitute.org - * Licensed under GNU General Public License version 2 - * - * Author: seanhalle@yahoo.com - * - */ - -#ifndef _PR_H -#define _PR_H -#define _GNU_SOURCE - -#include "DynArray/DynArray.h" -#include "Hash_impl/PrivateHash.h" -#include "Histogram/Histogram.h" -#include "Queue_impl/PrivateQueue.h" - -#include "PR_primitive_data_types.h" -#include "Services_Offered_by_PR/Memory_Handling/vmalloc.h" - -#include -#include - -//================= Defines: included from separate files ================= -// -// Note: ALL defines are in other files, none are in here -// -#include "Defines/PR_defs.h" - - -//================================ Typedefs ================================= -// -#include "PR__structs.h" - -//============================ HW Dependent Fns ================================ - -#include "HW_Dependent_Primitives/PR__HW_measurement.h" -#include "HW_Dependent_Primitives/PR__primitives.h" - - -//============================= Global Vars ================================ - -volatile TopEnv *_PRTopEnv __align_to_cacheline__; - - //these are global, but only used for startup and shutdown -pthread_t coreCtlrThdHandles[ NUM_CORES ]; //pthread's virt-procr state -ThdParams *coreCtlrThdParams [ NUM_CORES ]; - -pthread_mutex_t suspendLock; -pthread_cond_t suspendCond; - -//========================= 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. - * - * PR_OS 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! - */ - -inline bool32 masterFunction( AnimSlot *slot ); - -//============== include internally used fn prototypes ================ - -//include fn prototypes used internally in the proto-runtime implementation -#include "PR__int.h" - -//include fn prototypes used by plugin -#include "PR__PI.h" - -//include fn prototype used by wrapper library -#include "PR__WL.h" - -//================================= -#define implement_me() printf("Unimpl Fn: \n%s \n%s : %d\n", __FILE__, __FUNCTION__, __LINE__) -//#define fix_me printf("Fix me at: \n%s \n%s : %s\n", __FILE__, __FUNCTION__, __LINE__) - - -//========================= 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 972ce554264c -r 9971d5905599 PR__PI.h --- a/PR__PI.h Sun Jul 21 13:48:17 2013 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,195 +0,0 @@ -/* - * 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 "PR_primitive_data_types.h" - -//========================= 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 - - -//============ -//=== 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 972ce554264c -r 9971d5905599 PR__WL.h --- a/PR__WL.h Sun Jul 21 13:48:17 2013 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,154 +0,0 @@ -/* - * Copyright 2009 OpenSourceResearchInstitute.org - * Licensed under GNU General Public License version 2 - * - * Author: seanhalle@yahoo.com - * - */ - - - -/* This header defines the PR functions available to the language's - * wrapper library. - */ - -#ifndef _PR__WL_H -#define _PR__WL_H -#define _GNU_SOURCE - -#include "PR__common/PR__primitive_data_types.h" -#include "PR__common/PR__common_structs.h" -//========================= 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 ); - -#define \ -PR__malloc PR_WL__malloc - -#define \ -PR__free PR_WL__free - - - -//============== include internally used fn prototypes ================ -#include "PR__int.h" - - -#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 972ce554264c -r 9971d5905599 PR__common.h --- a/PR__common.h Sun Jul 21 13:48:17 2013 -0700 +++ b/PR__common.h Fri Jul 26 12:12:34 2013 -0700 @@ -17,7 +17,10 @@ #include "PR__primitive_data_types.h" #include "PR__common_structs.h" -//#include "Services_Offered_by_PR/Memory_Handling/vmalloc.h" +#include "Services_Offered_by_PR/Memory_Handling/vmalloc__wrapper_library.h" +#include "Services_offered_by_PR/Debugging/DEBUG__macros.h" +#include "Services_offered_by_PR/Measurement_and_Stats/MEAS__macros.h" +#include "Services_offered_by_PR/Measurement_and_Stats/probes__wrapper_library.h" //#include //#include diff -r 972ce554264c -r 9971d5905599 PR__common_structs.h --- a/PR__common_structs.h Sun Jul 21 13:48:17 2013 -0700 +++ b/PR__common_structs.h Fri Jul 26 12:12:34 2013 -0700 @@ -6,13 +6,27 @@ * */ -#ifndef _PR__structs_H -#define _PR__structs_H +#ifndef _PR__common_structs_H +#define _PR__common_structs_H #define _GNU_SOURCE -//#include -//#include +#include +#include +#include "PR_defs__turn_on_and_off.h" +#include "PR__primitive_data_types.h" +#include "Services_offered_by_PR/Measurement_and_Stats/MEAS__macros.h" +#include "Services_offered_by_PR/Debugging/DEBUG__macros.h" + + +#include "Histogram/Histogram.h" //reqd by PRProcess +#include "Hash_impl/PrivateHash.h" //reqd by PRProcess +#include "DynArray/DynArray.h" //reqd by PRProcess +#include "Queue_impl/PrivateQueue.h" //reqd by PRLangEnv, in turn reqd by PRProcess + + +//#include "HW_Dependent_Primitives/PR__HW_measurement.h" +//#include "HW_Dependent_Primitives/PR__primitives.h" //================================ Typedefs ================================= //=== @@ -21,17 +35,17 @@ //typedef unsigned long long TSCount; -//typedef struct _AnimSlot AnimSlot; -//typedef struct _PRReqst PRReqst; +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 _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 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 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 @@ -39,20 +53,15 @@ 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 (*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 * ); +typedef void (*ResumeSlvFnPtr) ( SlaveVP *, void * ); //=========== MEASUREMENT STUFF ========== -// MEAS__Insert_Counter_Handler + MEAS__Insert_Counter_Handler //======================================== -//============================ HW Dependent Fns ================================ - -//#include "HW_Dependent_Primitives/PR__HW_measurement.h" -//#include "HW_Dependent_Primitives/PR__primitives.h" - typedef struct { //These are set by the plugin during startup and the application @@ -68,7 +77,7 @@ * stores information about what percent of CPU time the program is getting, * */ -/* + typedef struct { int32 numEnvsWithWork; @@ -112,7 +121,7 @@ //========================================== } PRProcess; -*/ + //============= Request Related =========== // @@ -255,82 +264,6 @@ MultiLang }; -/* The one and only global variable, holds many odds and ends - */ -typedef struct - { //The offsets of these fields are hard-coded into assembly - void *coreCtlrReturnPt; //offset to this field used in asm - int8 falseSharePad1[256 - sizeof(void*)]; - int32 masterLock; //offset to this field used in asm - int8 falseSharePad2[256 - sizeof(int32)]; - int32 wrapperLock; //offset to this field used in asm - int8 falseSharePad3[256 - sizeof(int32)]; - int32 mallocLock; //offset to this field used in asm - int8 falseSharePad4[256 - sizeof(int32)]; - //============ below this, no fields are used in asm ============= - - //Basic PR infrastructure -// enum PRMode mode; - SlaveVP **masterVPs; - AnimSlot ***allAnimSlots; - PrivQueueStruc *slaveRecycleQ; - SlaveVP *slotTaskSlvs[NUM_CORES][NUM_ANIM_SLOTS]; - SlaveVP *idleSlv[NUM_CORES][NUM_ANIM_SLOTS]; - - //Memory management related - MallocArrays *freeLists; - int32 amtOfOutstandingMem;//total currently allocated - - //Random number seeds -- random nums used in various places - uint32_t seed1; - uint32_t seed2; - - PRSysMetaInfo *metaInfo; //info about this PR system -- vers, build, etc - - //============== This only used by multi-lang mode ============ - PRProcess **processes; - int32 numProcesses; - int32 currProcessIdx; //used to choose which process gets slot - int32 firstProcessReady; //use while starting up coreCtlr - - //initialize flags for waiting for activity within PR to complete - bool32 allActivityIsDone; - pthread_mutex_t activityDoneLock; - pthread_cond_t activityDoneCond; - - SlaveAssigner overrideAssigner; - - //============== Below this is only used by single-lang mode ============== - void *protoLangEnv; - //Slave creation -- global count of slaves existing, across langs and processes - int32 numSlavesCreated; //used to give unique ID to processor - int32 numTasksCreated; //to give unique ID to a task - int32 numSlavesAlive; - - bool32 *coreIsDone; - int32 numCoresDone; - int32 shutdownInitiated; - - - //=========== 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; - //========================================== - } -TopEnv; - //===================== These are prologs ==================== //===A prolog is data immediately before pointer returned by a create function. @@ -413,19 +346,6 @@ } PRExcp; //exception -//======================= OS Thread related =============================== - -void * coreController( void *paramsIn ); //standard PThreads fn prototype -void * coreCtlr_Seq( void *paramsIn ); //standard PThreads fn prototype -void animationMaster( void *initData, SlaveVP *masterVP ); - - -typedef struct - { - void *endThdPt; - unsigned int coreNum; - } -ThdParams; #endif /* _PR__structs_H */ diff -r 972ce554264c -r 9971d5905599 PR__int.h --- a/PR__int.h Sun Jul 21 13:48:17 2013 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,244 +0,0 @@ -/* - * 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 - - -/* 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 ); -#define PR_WL__give_lang_data PR_int__give_lang_data_from_slave - -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 972ce554264c -r 9971d5905599 PR__structs.h --- a/PR__structs.h Sun Jul 21 13:48:17 2013 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,432 +0,0 @@ -/* - * Copyright 2009 OpenSourceResearchInstitute.org - * Licensed under GNU General Public License version 2 - * - * Author: seanhalle@yahoo.com - * - */ - -#ifndef _PR__structs_H -#define _PR__structs_H -#define _GNU_SOURCE - -#include "PR_primitive_data_types.h" - -#include -#include - - -//================================ 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 - //======================================== - -//============================ HW Dependent Fns ================================ - -#include "HW_Dependent_Primitives/PR__HW_measurement.h" -#include "HW_Dependent_Primitives/PR__primitives.h" - - -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 - }; - -/* The one and only global variable, holds many odds and ends - */ -typedef struct - { //The offsets of these fields are hard-coded into assembly - void *coreCtlrReturnPt; //offset to this field used in asm - int8 falseSharePad1[256 - sizeof(void*)]; - int32 masterLock; //offset to this field used in asm - int8 falseSharePad2[256 - sizeof(int32)]; - int32 wrapperLock; //offset to this field used in asm - int8 falseSharePad3[256 - sizeof(int32)]; - int32 mallocLock; //offset to this field used in asm - int8 falseSharePad4[256 - sizeof(int32)]; - //============ below this, no fields are used in asm ============= - - //Basic PR infrastructure -// enum PRMode mode; - SlaveVP **masterVPs; - AnimSlot ***allAnimSlots; - PrivQueueStruc *slaveRecycleQ; - SlaveVP *slotTaskSlvs[NUM_CORES][NUM_ANIM_SLOTS]; - SlaveVP *idleSlv[NUM_CORES][NUM_ANIM_SLOTS]; - - //Memory management related - MallocArrays *freeLists; - int32 amtOfOutstandingMem;//total currently allocated - - //Random number seeds -- random nums used in various places - uint32_t seed1; - uint32_t seed2; - - PRSysMetaInfo *metaInfo; //info about this PR system -- vers, build, etc - - //============== This only used by multi-lang mode ============ - PRProcess **processes; - int32 numProcesses; - int32 currProcessIdx; //used to choose which process gets slot - int32 firstProcessReady; //use while starting up coreCtlr - - //initialize flags for waiting for activity within PR to complete - bool32 allActivityIsDone; - pthread_mutex_t activityDoneLock; - pthread_cond_t activityDoneCond; - - SlaveAssigner overrideAssigner; - - //============== Below this is only used by single-lang mode ============== - void *protoLangEnv; - //Slave creation -- global count of slaves existing, across langs and processes - int32 numSlavesCreated; //used to give unique ID to processor - int32 numTasksCreated; //to give unique ID to a task - int32 numSlavesAlive; - - bool32 *coreIsDone; - int32 numCoresDone; - int32 shutdownInitiated; - - - //=========== 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; - //========================================== - } -TopEnv; - - -//===================== 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 - -//======================= OS Thread related =============================== - -void * coreController( void *paramsIn ); //standard PThreads fn prototype -void * coreCtlr_Seq( void *paramsIn ); //standard PThreads fn prototype -void animationMaster( void *initData, SlaveVP *masterVP ); - - -typedef struct - { - void *endThdPt; - unsigned int coreNum; - } -ThdParams; - -#endif /* _PR__structs_H */ - diff -r 972ce554264c -r 9971d5905599 Services_offered_by_PR/Measurement_and_Stats/MEAS__Counter_Recording.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Services_offered_by_PR/Measurement_and_Stats/MEAS__Counter_Recording.c Fri Jul 26 12:12:34 2013 -0700 @@ -0,0 +1,156 @@ +/* + * + * author: Nina Engelhardt + */ + +#include "MEAS__Counter_Recording.h" +//#include "PR__common_includes/PR__common_structs.h" +//#include "PRServ__wrapper_library/PRServ__wrapper_library.h" + +#ifdef HOLISTIC__TURN_ON_PERF_COUNTERS + +void +MEAS__init_counter_data_structs_for_Lang( SlaveVP *slave, int32 magicNum ) + { + PRServLangEnv *langEnv = + (PRServLangEnv *)PR_SS__give_lang_env_for_slave( slave, magicNum ); + int i; + for(i=0;icounterList[i] = makeListOfArrays(sizeof(CounterEvent), 128); + } + } + +/*Pass file by side effect.. + *The reason is that using doAllInListOfArrays, to which one passes the pointer + * to a function, which is then applied to all the elements.. but, that fn + * can only take one input -- the element from the list of arrays.. so, it + * can't also be passed the file.. hence pass the file by side effect + * + *However, multiple cores could be trying to do this.. so, create a separate + * lock just for counters, and acquire that when set the file, then release + * once all the printing is done. + */ +void +MEAS__set_counter_file(FILE* f) + { + acquire counter lock + counterfile = f; + } + +MEAS__release_counter_file() + { + release counter lock + } + +void +MEAS__addToListOfArraysCounterEvent(CounterEvent value, ListOfArrays* list) + { + int offset_in_fragment = list->next_free_index % list->num_entries_per_fragment; + if(offset_in_fragment == 0) + { void* newBlock = malloc(list->entry_size * list->num_entries_per_fragment); + addToDynArray(newBlock,list->dim1info); + } + CounterEvent* typedFragment = (CounterEvent*) ((list->dim1)[list->dim1info->numInArray -1]); + typedFragment[offset_in_fragment] = value; + list->next_free_index++; + } + +void +MEAS__counter_handler(int evt_type, int vpid, int task, SlaveVP* pr, uint64 cycles, uint64 instrs) + { + if (pr->typeOfVP == Master_VP || pr->typeOfVP == ShutdownVP) + { //Only save values for application work, done in a SlaveVP + return; + } + + //Note: have made many changes without compiler flag turned on, nor test.. + PRLangEnv *langEnv = + PR_int__give_proto_lang_env_from_slave( pr, magicNum); + + CounterEvent e; + e.event_type = evt_type; + e.vp = vpid; + e.task = task; + + e.cycles = cycles; + e.instrs = instrs; + + if(pr) + { e.coreID = pr->coreAnimatedBy; + e.slot = pr->animSlotAssignedTo; + } + else + { e.coreID = -1; + e.slot = NULL; + } + + int corenum; + + if(pr) + corenum = pr->coreAnimatedBy; + else + return; + + if(evt_type==Work_start || evt_type==Work_end || evt_type==AppResponderInvocation_start) + { addToListOfArrays_ext(CounterEvent,e,langEnv->counterList[corenum]); + } + else + { MEAS__addToListOfArraysCounterEvent(e,langEnv->counterList[corenum]); + } + } + + + +void +MEAS__print_counter_event_to_file( void* _e ) + { + CounterEvent* e = (CounterEvent*) _e; + fprintf(counterfile, "event, "); + switch(e->event_type) + { + case AppResponderInvocation_start: + fprintf(counterfile, "AppResponderInvocation_start"); + break; + case AppResponder_start: + fprintf(counterfile, "AppResponder_start"); + break; + case AppResponder_end: + fprintf(counterfile, "AppResponder_end"); + break; + case AssignerInvocation_start: + fprintf(counterfile, "AssignerInvocation_start"); + break; + case NextAssigner_start: + fprintf(counterfile, "NextAssigner_start"); + break; + case Assigner_start: + fprintf(counterfile, "Assigner_start"); + break; + case Assigner_end: + fprintf(counterfile, "Assigner_end"); + break; + case Work_end: + fprintf(counterfile, "Work_end"); + break; + case Work_start: + fprintf(counterfile, "Work_start"); + break; + case HwResponderInvocation_start: + fprintf(counterfile, "HwResponderInvocation_start"); + break; + case Timestamp_start: + fprintf(counterfile, "Timestamp_start"); + break; + case Timestamp_end: + fprintf(counterfile, "Timestamp_end"); + break; + default: + fprintf(counterfile, "unknown event"); + } + fprintf(counterfile,", %d, %d, %llu, %llu",e->vp,e->task,e->cycles,e->instrs); + if(e->coreID >=0) + fprintf(counterfile,", %d",e->coreID); + fprintf(counterfile,"\n"); + fflush(counterfile); + } +#endif diff -r 972ce554264c -r 9971d5905599 Services_offered_by_PR/Measurement_and_Stats/MEAS__Counter_Recording.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Services_offered_by_PR/Measurement_and_Stats/MEAS__Counter_Recording.h Fri Jul 26 12:12:34 2013 -0700 @@ -0,0 +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 */ + diff -r 972ce554264c -r 9971d5905599 Services_offered_by_PR/Measurement_and_Stats/MEAS__macros.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Services_offered_by_PR/Measurement_and_Stats/MEAS__macros.h Fri Jul 26 12:12:34 2013 -0700 @@ -0,0 +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 */ + diff -r 972ce554264c -r 9971d5905599 Services_offered_by_PR/Measurement_and_Stats/dependency.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Services_offered_by_PR/Measurement_and_Stats/dependency.c Fri Jul 26 12:12:34 2013 -0700 @@ -0,0 +1,79 @@ + + +#include "dependency.h" + +Dependency* new_dependency(int from_vp, int from_task, int to_vp, int to_task){ + Dependency* newDep = (Dependency*) PR_int__malloc(sizeof(Dependency)); + if (newDep!=NULL){ + newDep->from_vp = from_vp; + newDep->from_task = from_task; + newDep->to_vp = to_vp; + newDep->to_task = to_task; + } + return newDep; +} + +NtoN* new_NtoN(int id){ + NtoN* newn = (NtoN*) PR_int__malloc(sizeof(NtoN)); + newn->id = id; + newn->senders = makeListOfArrays(sizeof(Unit), 64); + newn->receivers = makeListOfArrays(sizeof(Unit), 64); + return newn; +} + +int set_dependency_file(FILE* file){ + dependency_file = file; +} + +void print_ctl_dependency_to_file(void* _dep){ + Dependency* dep = (Dependency*) _dep; + if(!dep) return; + fprintf(dependency_file,"ctlDep,%d,%d,%d,%d\n",dep->from_vp,dep->from_task,dep->to_vp,dep->to_task); +} + +void print_comm_dependency_to_file(void* _dep){ + Dependency* dep = (Dependency*) _dep; + if(!dep) return; + fprintf(dependency_file,"commDep,%d,%d,%d,%d\n",dep->from_vp,dep->from_task,dep->to_vp,dep->to_task); +} + +void print_dyn_dependency_to_file(void* _dep){ + Dependency* dep = (Dependency*) _dep; + if(!dep) return; + fprintf(dependency_file,"dynDep,%d,%d,%d,%d\n",dep->from_vp,dep->from_task,dep->to_vp,dep->to_task); +} + +void print_hw_dependency_to_file(void* _dep){ + Dependency* dep = (Dependency*) _dep; + if(!dep) return; + fprintf(dependency_file,"hwDep,%d,%d,%d,%d\n",dep->from_vp,dep->from_task,dep->to_vp,dep->to_task); +} + +void print_dependency_to_file(void* _dep){ + Dependency* dep = (Dependency*) _dep; + if(!dep) return; + fprintf(dependency_file,"VP_%d_%d -> VP_%d_%d;\n",dep->from_vp,dep->from_task,dep->to_vp,dep->to_task); +} + +void print_unit_to_file(void* _unit){ + Unit* unit = (Unit*) _unit; + if(!unit) return; + fprintf(dependency_file,"unit,%d,%d\n",unit->vp,unit->task); +} + +void print_nton_set_helper(void* _u){ + Unit* u = (Unit*) _u; + if(!u) return; + fprintf(dependency_file,",%d,%d",u->vp,u->task); +} + +void print_nton_to_file(void* _nton){ + NtoN* nton = (NtoN*) _nton; + if(!nton) return; + //assert(nton->senders->next_free_index==nton->receivers->next_free_index); + int numInSet = nton->senders->next_free_index; + fprintf(dependency_file,"NtoN,%d",numInSet); + forAllInListOfArraysDo(nton->senders,&print_nton_set_helper); + forAllInListOfArraysDo(nton->receivers,&print_nton_set_helper); + fprintf(dependency_file,"\n"); +} \ No newline at end of file diff -r 972ce554264c -r 9971d5905599 Services_offered_by_PR/Measurement_and_Stats/dependency.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Services_offered_by_PR/Measurement_and_Stats/dependency.h Fri Jul 26 12:12:34 2013 -0700 @@ -0,0 +1,57 @@ +/* + * File: dependency.h + * Author: Nina Engelhardt + * + * Created on 29. August 2011, 17:41 + */ + +#ifndef _PR__DEPENDENCY_H +#define _PR__DEPENDENCY_H + + +#include +#include "PR__common_includes/PR__primitive_data_types.h" +#include "ListOfArrays/ListOfArrays.h" + +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 972ce554264c -r 9971d5905599 Services_offered_by_PR/Measurement_and_Stats/probes__wrapper_library.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Services_offered_by_PR/Measurement_and_Stats/probes__wrapper_library.c Fri Jul 26 12:12:34 2013 -0700 @@ -0,0 +1,151 @@ +/* + * Copyright 2010 OpenSourceStewardshipFoundation + * + * Licensed under BSD + */ + +#include +#include +#include + +#include "probes__wrapper_library.h" + + + +//==================== Probes ================= +/* + * In practice, probe operations are called from the app, from inside slaves + * -- so have to be sure each probe is single-Slv owned, and be sure that + * any place common structures are modified it's done inside the master. + * So -- the only place common structures are modified is during creation. + * after that, all mods are to individual instances. + * + * Thniking perhaps should change the semantics to be that probes are + * attached to the virtual processor -- and then everything is guaranteed + * to be isolated -- except then can't take any intervals that span Slvs, + * and would have to transfer the probes to Master env when Slv dissipates.. + * gets messy.. + * + * For now, just making so that probe creation causes a suspend, so that + * the dynamic array in the master env is only modified from the master + * + */ + +//============================ Helpers =========================== +inline void +doNothing() + { + } + +float64 inline +giveInterval( struct timeval _start, struct timeval _end ) + { float64 start, end; + start = _start.tv_sec + _start.tv_usec / 1000000.0; + end = _end.tv_sec + _end.tv_usec / 1000000.0; + return end - start; + } + +//================================================================= +IntervalProbe * +create_generic_probe( char *nameStr, SlaveVP *animSlv ) + { + PRServiceReq reqData; + + reqData.reqType = make_probe; + reqData.nameStr = nameStr; + + PR_WL__send_service_request( &reqData, animSlv ); + + return animSlv->dataRetFromReq; + } + +/*Use this version from outside PR -- it uses external malloc, and modifies + * dynamic array, so can't be animated in a slave Slv + */ +/* Can't access _PRTopEnv in a wrapper library +IntervalProbe * +ext__create_generic_probe( char *nameStr ) + { IntervalProbe *newProbe; + int32 nameLen; + + newProbe = malloc( sizeof(IntervalProbe) ); + nameLen = strlen( nameStr ); + newProbe->nameStr = malloc( nameLen ); + memcpy( newProbe->nameStr, nameStr, nameLen ); + newProbe->hist = NULL; + newProbe->schedChoiceWasRecorded = FALSE; + newProbe->probeID = + addToDynArray( newProbe, _PRTopEnv->dynIntervalProbesInfo ); + + return newProbe; + } +*/ +//============================ Fns def in header ======================= + +int32 +PR_impl__create_single_interval_probe( char *nameStr, SlaveVP *animSlv ) + { IntervalProbe *newProbe; + + newProbe = create_generic_probe( nameStr, animSlv ); + + return newProbe->probeID; + } + +int32 +PR_impl__create_histogram_probe( int32 numBins, float64 startValue, + float64 binWidth, char *nameStr, SlaveVP *animSlv ) + { IntervalProbe *newProbe; + + newProbe = create_generic_probe( nameStr, animSlv ); + +#ifdef PROBES__USE_TIME_OF_DAY_PROBES + DblHist *hist; + hist = makeDblHistogram( numBins, startValue, binWidth ); +#else + Histogram *hist; + hist = makeHistogram( numBins, startValue, binWidth ); +#endif + newProbe->hist = hist; + return newProbe->probeID; + } + + +int32 +PR_impl__record_time_point_into_new_probe( char *nameStr, SlaveVP *animSlv) + { IntervalProbe *newProbe; + struct timeval *startStamp; + float64 startSecs; + + newProbe = create_generic_probe( nameStr, animSlv ); + newProbe->endSecs = 0; + + + gettimeofday( &(newProbe->startStamp), NULL); + + //turn into a double + startStamp = &(newProbe->startStamp); + startSecs = startStamp->tv_sec + ( startStamp->tv_usec / 1000000.0 ); + newProbe->startSecs = startSecs; + + return newProbe->probeID; + } + +int32 +PR_ext_impl__record_time_point_into_new_probe( char *nameStr ) + { IntervalProbe *newProbe; + struct timeval *startStamp; + float64 startSecs; + + newProbe = ext__create_generic_probe( nameStr ); + newProbe->endSecs = 0; + + gettimeofday( &(newProbe->startStamp), NULL); + + //turn into a double + startStamp = &(newProbe->startStamp); + startSecs = startStamp->tv_sec + ( startStamp->tv_usec / 1000000.0 ); + newProbe->startSecs = startSecs; + + return newProbe->probeID; + } + diff -r 972ce554264c -r 9971d5905599 Services_offered_by_PR/Measurement_and_Stats/probes__wrapper_library.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Services_offered_by_PR/Measurement_and_Stats/probes__wrapper_library.h Fri Jul 26 12:12:34 2013 -0700 @@ -0,0 +1,192 @@ +/* + * Copyright 2009 OpenSourceStewardshipFoundation.org + * Licensed under GNU General Public License version 2 + * + * Author: seanhalle@yahoo.com + * + */ + +#ifndef _PROBES_wrapper_library_H +#define _PROBES_wrapper_library_H +#define _GNU_SOURCE + +#include "PR__common_includes/PR__common_structs.h" + +#include + +/*Note on order of include files: + * This file relies on #defines that appear in other files, which must come + * first in the #include sequence.. + */ + +/*Use these aliases in 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 + + +//========================== +#ifdef PROBES__USE_TSC_PROBES + #define PROBES__Insert_timestamps_and_intervals_into_probe_struct \ + TSCount startStamp; \ + TSCount endStamp; \ + TSCount interval; \ + Histogram *hist; /*if left NULL, then is single interval probe*/ +#endif +#ifdef PROBES__USE_TIME_OF_DAY_PROBES + #define PROBES__Insert_timestamps_and_intervals_into_probe_struct \ + struct timeval startStamp; \ + struct timeval endStamp; \ + float64 startSecs; \ + float64 endSecs; \ + float64 interval; \ + DblHist *hist; /*if NULL, then is single interval probe*/ +#endif +#ifdef PROBES__USE_PERF_CTR_PROBES + #define PROBES__Insert_timestamps_and_intervals_into_probe_struct \ + int64 startStamp; \ + int64 endStamp; \ + int64 interval; \ + Histogram *hist; /*if left NULL, then is single interval probe*/ +#endif + +//typedef struct _IntervalProbe IntervalProbe; -- is in PR.h +struct _IntervalProbe + { + char *nameStr; + int32 probeID; + + int32 schedChoiceWasRecorded; + int32 coreNum; + int32 slaveNum; + float64 slaveCreateSecs; + PROBES__Insert_timestamps_and_intervals_into_probe_struct; + }; + +//=========================== NEVER USE THESE ========================== +/*NEVER use these in any code!! These are here only for use in the macros + * defined in this file!! + */ +int32 +PR_impl__create_single_interval_probe( char *nameStr, SlaveVP *animSlv ); + +int32 +PR_impl__create_histogram_probe( int32 numBins, float64 startValue, + float64 binWidth, char *nameStr, SlaveVP *animSlv ); + +int32 +PR_impl__record_time_point_into_new_probe( char *nameStr, SlaveVP *animSlv); + +int32 +PR_ext_impl__record_time_point_into_new_probe( char *nameStr ); + +void +PR_impl__free_probe( IntervalProbe *probe ); + +void +PR_impl__index_probe_by_its_name( int32 probeID, SlaveVP *animSlv ); + +IntervalProbe * +PR_impl__get_probe_by_name( char *probeName, SlaveVP *animSlv ); + +void +PR_impl__record_sched_choice_into_probe( int32 probeID, SlaveVP *animSlv ); + +void +PR_impl__record_interval_start_in_probe( int32 probeID ); + +void +PR_impl__record_interval_end_in_probe( int32 probeID ); + +void +PR_impl__print_stats_of_probe( IntervalProbe *probe ); + +void +PR_impl__print_stats_of_all_probes(); + + +//======================== Probes ============================= +// +// Use macros to allow turning probes off with a #define switch +// This means probes have zero impact on performance when off +//============================================================= + +#ifdef PROBES__TURN_ON_STATS_PROBES + + #define PROBES__Create_Probe_Bookkeeping_Vars \ + _PRTopEnv->dynIntervalProbesInfo = \ + makePrivDynArrayOfSize( (void***)&(_PRTopEnv->intervalProbes), 200); \ + \ + _PRTopEnv->probeNameHashTbl = makeHashTable( 1000, &PR__free ); \ + \ + /*put creation time directly into master env, for fast retrieval*/ \ + struct timeval timeStamp; \ + gettimeofday( &(timeStamp), NULL); \ + _PRTopEnv->createPtInSecs = \ + timeStamp.tv_sec +(timeStamp.tv_usec/1000000.0); + + #define PR_WL__record_time_point_into_new_probe( nameStr, animSlv ) \ + PR_impl__record_time_point_in_new_probe( nameStr, animSlv ) + + #define PR_ext__record_time_point_into_new_probe( nameStr ) \ + PR_ext_impl__record_time_point_into_new_probe( nameStr ) + + #define PR_WL__create_single_interval_probe( nameStr, animSlv ) \ + PR_impl__create_single_interval_probe( nameStr, animSlv ) + + #define PR_WL__create_histogram_probe( numBins, startValue, \ + binWidth, nameStr, animSlv ) \ + PR_impl__create_histogram_probe( numBins, startValue, \ + binWidth, nameStr, animSlv ) + #define PR_int__free_probe( probe ) \ + PR_impl__free_probe( probe ) + + #define PR_WL__index_probe_by_its_name( probeID, animSlv ) \ + PR_impl__index_probe_by_its_name( probeID, animSlv ) + + #define PR_WL__get_probe_by_name( probeID, animSlv ) \ + PR_impl__get_probe_by_name( probeName, animSlv ) + + #define PR_WL__record_sched_choice_into_probe( probeID, animSlv ) \ + PR_impl__record_sched_choice_into_probe( probeID, animSlv ) + + #define PR_WL__record_interval_start_in_probe( probeID ) \ + PR_impl__record_interval_start_in_probe( probeID ) + + #define PR_WL__record_interval_end_in_probe( probeID ) \ + PR_impl__record_interval_end_in_probe( probeID ) + + #define PR_WL__print_stats_of_probe( probeID ) \ + PR_impl__print_stats_of_probe( probeID ) + + #define PR_WL__print_stats_of_all_probes() \ + PR_impl__print_stats_of_all_probes() + + +#else + #define PROBES__Create_Probe_Bookkeeping_Vars + #define PR_WL__record_time_point_into_new_probe( nameStr, animSlv ) 0 /* do nothing */ + #define PR_ext__record_time_point_into_new_probe( nameStr ) 0 /* do nothing */ + #define PR_WL__create_single_interval_probe( nameStr, animSlv ) 0 /* do nothing */ + #define PR_WL__create_histogram_probe( numBins, startValue, \ + binWidth, nameStr, animSlv ) \ + 0 /* do nothing */ + #define PR_WL__index_probe_by_its_name( probeID, animSlv ) /* do nothing */ + #define PR_WL__get_probe_by_name( probeID, animSlv ) NULL /* do nothing */ + #define PR_WL__record_sched_choice_into_probe( probeID, animSlv ) /* do nothing */ + #define PR_WL__record_interval_start_in_probe( probeID ) /* do nothing */ + #define PR_WL__record_interval_end_in_probe( probeID ) /* do nothing */ + #define PR_WL__print_stats_of_probe( probeID ) ; /* do nothing */ + #define PR_WL__print_stats_of_all_probes() ;/* do nothing */ + +#endif /* defined PROBES__TURN_ON_STATS_PROBES */ + +#endif /* _PROBES_H */ + diff -r 972ce554264c -r 9971d5905599 Services_offered_by_PR/Memory_Handling/vmalloc__structs.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Services_offered_by_PR/Memory_Handling/vmalloc__structs.h Fri Jul 26 12:12:34 2013 -0700 @@ -0,0 +1,89 @@ +/* + * 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 _VMALLOC_structs_H +#define _VMALLOC_structs_H + +#include +#include +#include "PR__common_includes/PR__primitive_data_types.h" + +#define SMALL_CHUNK_SIZE 32 +#define SMALL_CHUNK_COUNT 4 +#define LOWER_BOUND 128 //Biggest chunk size that is created for the small chunks +#define BIG_LOWER_BOUND 160 //Smallest chunk size that is created for the big chunks + +#define LOG54 0.3219280948873623 +#define LOG128 7 + +typedef struct _MallocProlog MallocProlog; + +struct _MallocProlog + { + MallocProlog *nextChunkInFreeList; + MallocProlog *prevChunkInFreeList; + MallocProlog *nextHigherInMem; + MallocProlog *nextLowerInMem; + }; +//MallocProlog + + typedef struct MallocArrays MallocArrays; + + struct MallocArrays + { + MallocProlog **smallChunks; + MallocProlog **bigChunks; + uint64 bigChunksSearchVector[2]; + void *memSpace; + uint32 containerCount; + }; + //MallocArrays + +typedef struct + { + MallocProlog *firstChunkInFreeList; + int32 numInList; //TODO not used + } +FreeListHead; + +void * +PR_int__malloc( size_t sizeRequested ); + +void * +PR_WL__malloc( int32 sizeRequested ); /*BUG: -- get master lock */ + +void * +PR_int__malloc_aligned( size_t sizeRequested ); + +void +PR_int__free( void *ptrToFree ); + +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 ); + + +MallocArrays * +PR_ext__create_free_list(); + +void +PR_ext__free_free_list(MallocArrays *freeLists ); + +#endif \ No newline at end of file diff -r 972ce554264c -r 9971d5905599 Services_offered_by_PR/Memory_Handling/vmalloc__wrapper_library.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Services_offered_by_PR/Memory_Handling/vmalloc__wrapper_library.h Fri Jul 26 12:12:34 2013 -0700 @@ -0,0 +1,28 @@ +/* + * 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 _VMALLOC_wrapper_library_H +#define _VMALLOC_wrapper_library_H + +/*Can call PR__malloc and PR__free from the main thread or from wrapper + * library code, or other library, after PR__start() has been called + */ + + +void * +PR_WL__malloc( int32 sizeRequested ); + +void +PR_WL__free( void *ptrToFree ); + +#define PR__malloc PR_WL__malloc +#define PR__free PR_WL__free + + +#endif \ No newline at end of file