# HG changeset patch # User Some Random Person # Date 1331361026 28800 # Node ID 10a72bcedbf02196ff080ab6b6b74a5a71d612c3 # Parent 64737d3deeb4a0df26eb1afdcf40f444a4671cdb fixed include paths, and various minor fixes, while updating SSR to use this brch diff -r 64737d3deeb4 -r 10a72bcedbf0 CoreLoop.c --- a/CoreLoop.c Fri Mar 09 10:46:36 2012 -0800 +++ b/CoreLoop.c Fri Mar 09 22:30:26 2012 -0800 @@ -57,7 +57,7 @@ pthread_mutex_lock( &suspendLock ); while( !(_VMSMasterEnv->setupComplete) ) { - pthread_cond_wait( &suspend_cond, + pthread_cond_wait( &suspendCond, &suspendLock ); } pthread_mutex_unlock( &suspendLock ); @@ -130,7 +130,7 @@ switchToSlv(currVP); //Slave suspend makes core "return" from this call flushRegisters(); - MEAS__endCoreLoop_for_Sys; + MEAS__capture_end_susp_in_CoreLoop_forSys; }//CoreLoop } diff -r 64737d3deeb4 -r 10a72bcedbf0 Defines/VMS_defs__MEAS.h --- a/Defines/VMS_defs__MEAS.h Fri Mar 09 10:46:36 2012 -0800 +++ b/Defines/VMS_defs__MEAS.h Fri Mar 09 22:30:26 2012 -0800 @@ -278,7 +278,7 @@ { currVP->totalSuspCycles += numCycles; \ currVP->numGoodSusp++; \ } \ - /*recorded every time, but only read if currVP == MasterVP*/ \ + /*recorded every time, but only read if currVP == MasterVP*/ \ _VMSMasterEnv->startMaster.longVal = endSusp.longVal; #else diff -r 64737d3deeb4 -r 10a72bcedbf0 Probes/probes.c --- a/Probes/probes.c Fri Mar 09 10:46:36 2012 -0800 +++ b/Probes/probes.c Fri Mar 09 22:30:26 2012 -0800 @@ -8,7 +8,7 @@ #include #include -#include "VMS.h" +#include "../VMS.h" @@ -37,7 +37,15 @@ { } - +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 ) { @@ -170,7 +178,7 @@ } -/*Everything is local to the animating procr, so no need for request, do +/*Everything is local to the animating slaveVP, so no need for request, do * work locally, in the anim Slv */ void @@ -180,11 +188,11 @@ probe = _VMSMasterEnv->intervalProbes[ probeID ]; probe->schedChoiceWasRecorded = TRUE; probe->coreNum = animatingSlv->coreAnimatedBy; - probe->slaveID = animatingSlv->procrID; + probe->slaveID = animatingSlv->slaveID; probe->slaveCreateSecs = animatingSlv->createPtInSecs; } -/*Everything is local to the animating procr, so no need for request, do +/*Everything is local to the animating slaveVP, so no need for request, do * work locally, in the anim Slv */ void @@ -197,13 +205,14 @@ //record *start* point as last thing, after lookup #ifdef PROBES__USE_TIME_OF_DAY_PROBES gettimeofday( &(probe->startStamp), NULL); -#else #ifdef PROBES__USE_TSC_PROBES +#endif +#ifdef PROBES__USE_TSC_PROBES probe->startStamp = getTSCount(); #endif } -/*Everything is local to the animating procr, except the histogram, so do +/*Everything is local to the animating slaveVP, except the histogram, so do * work locally, in the anim Slv -- may lose a few histogram counts * *This should be safe to run inside SlaveVP @@ -214,7 +223,7 @@ //Record first thing -- before looking up the probe to store it into #ifdef PROBES__USE_TIME_OF_DAY_PROBES - struct timeval endStamp, interval; + struct timeval endStamp; gettimeofday( &(endStamp), NULL); #endif #ifdef PROBES__USE_TSC_PROBES @@ -229,8 +238,7 @@ #ifdef PROBES__USE_TIME_OF_DAY_PROBES if( probe->hist != NULL ) - { interval = probe->endStamp - probe->startStamp; - addToDblHist( interval.tv_sec + interval.tv_usec/1000000.0, probe->hist ); + { addToDblHist( giveInterval( probe->startStamp, endStamp), probe->hist ); } #endif #ifdef PROBES__USE_TSC_PROBES @@ -256,7 +264,7 @@ if( probe->schedChoiceWasRecorded ) - { printf( "coreNum: %d, procrID: %d, procrCreated: %0.6f | ", + { printf( "coreNum: %d, slaveID: %d, slaveVPCreated: %0.6f | ", probe->coreNum, probe->slaveID, probe->slaveCreateSecs ); } diff -r 64737d3deeb4 -r 10a72bcedbf0 README_Code_Overview.txt --- a/README_Code_Overview.txt Fri Mar 09 10:46:36 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,18 +0,0 @@ - -This file is intended to help those new to VMS to find their way around the code. - -Some observations: --] VMS.h is the top header file, and is the root of a tree of #includes that pulls in all the other headers - --] Defines directory contains all the header files that hold #define statements - --] VMS has several kinds of function, grouped according to what kind of code should call them: VMS_App_.. for applications to call, VMS_WL_.. for wrapper-library code to call, VMS_PI_.. for plugin code to call, and VMS_int_.. for VMS to use internally. Sometimes VMS_int_ functions are called from the wrapper library or plugin, but this should only be done by programmers who have gained an in-depth knowledge of VMS's implementation and understand that VMS_int_ functions are not protected for concurrent use.. - --] VMS has its own version of malloc, unfortunately, which is due to the system malloc breaking when the stack-pointer register is manipulated, which VMS must. The VMS form of malloc must be used in code that runs inside the VMS system, especially all application code that uses a VMS-based language. However, mallocs performed in the main thread, outside the VMS-language program, cannot use VMS malloc.. this presents some issues crossing the boundary.. - --] VMS has many macros used in the code.. either for measurements or debug.. all measurement, debug, and statistics gathering statements can be turned on or off with a compiler switch. All compiler switches for doing this are found in Defines/VMS_defs__turn_on_and_off.h. The rest of the files in Defines directory contain the macro definitions, hardware constants, and any other #define statements. - --] The best way to learn VMS is to turn on DEBUG__TURN_ON_SEQUENTIAL_MODE, which allows using a normal debugger while sequentially going through both application code and VMS internals. Setting breakpoints at various spots in the code is a good way to see the VMS system in operation. - --] VMS has several "VMS primitives" implemented with assembly code. The net effect of these assembly functions is to perform the switching between application code and the VMS system. - diff -r 64737d3deeb4 -r 10a72bcedbf0 VMS.h --- a/VMS.h Fri Mar 09 10:46:36 2012 -0800 +++ b/VMS.h Fri Mar 09 22:30:26 2012 -0800 @@ -11,10 +11,10 @@ #define _GNU_SOURCE #include "VMS_primitive_data_types.h" -#include "C_Libraries/DynArray/DynArray.h" -#include "C_Libraries/Hash_impl/PrivateHash.h" -#include "C_Libraries/Histogram/Histogram.h" -#include "C_Libraries/Queue_impl/PrivateQueue.h" +#include "DynArray/DynArray.h" +#include "Hash_impl/PrivateHash.h" +#include "Histogram/Histogram.h" +#include "Queue_impl/PrivateQueue.h" #include "vmalloc.h" #include @@ -107,7 +107,7 @@ * assembly code to fail -- hard-codes offsets of fields */ struct _SlaveVP - { int procrID; //each slave given a unique ID + { int slaveID; //each slave given a unique ID int coreAnimatedBy; void *startOfStack; void *stackPtr; @@ -212,15 +212,12 @@ //============================= Global Vars ================================ +volatile MasterEnv *_VMSMasterEnv __align_to_cacheline__; + pthread_t coreLoopThdHandles[ NUM_CORES ]; //pthread's virt-procr state ThdParams *coreLoopThdParams [ NUM_CORES ]; -pthread_mutex_t suspendLock; -pthread_cond_t suspend_cond; - -volatile MasterEnv *_VMSMasterEnv __align_to_cacheline__; - -pthread_mutex_t suspendLock = PTHREAD_MUTEX_INITIALIZER; -pthread_cond_t suspend_cond = PTHREAD_COND_INITIALIZER; +pthread_mutex_t suspendLock = PTHREAD_MUTEX_INITIALIZER; +pthread_cond_t suspendCond = PTHREAD_COND_INITIALIZER; //========================= Function Prototypes =========================== @@ -237,7 +234,7 @@ VMS_SS__init(); //Fix; -/*seed-procr creation -- put box around language, have lang register stuff +/*seed-slaveVP creation -- put box around language, have lang register stuff with VMS. have main program explicitly INIT Lang! -- makes more sense to C programmers -- makes it clear that there's a transition. diff -r 64737d3deeb4 -r 10a72bcedbf0 VMS__HW_dependent.c --- a/VMS__HW_dependent.c Fri Mar 09 10:46:36 2012 -0800 +++ b/VMS__HW_dependent.c Fri Mar 09 22:30:26 2012 -0800 @@ -26,7 +26,7 @@ //Set slave's instr pointer to a helper Fn that copies params from stack slaveVP->resumeInstrPtr = (TopLevelFnPtr)&startUpTopLevelFn; - //fnPtr takes two params -- void *dataParam & void *animProcr + //fnPtr takes two params -- void *dataParam & void *animSlv // Stack grows *down*, so start it at highest stack addr, minus room // for 2 params + return addr. stackPtr = diff -r 64737d3deeb4 -r 10a72bcedbf0 VMS__WL.c --- a/VMS__WL.c Fri Mar 09 10:46:36 2012 -0800 +++ b/VMS__WL.c Fri Mar 09 22:30:26 2012 -0800 @@ -83,7 +83,7 @@ * be malloc'd if this is called inside the same call chain before the * send of the last request is called. * - *The request handler has to call VMS__free_VMSReq for any of these + *The request handler has to call VMS_int__free_VMSReq for any of these */ inline void VMS_WL__add_sem_request_in_mallocd_VMSReqst( void *semReqData, diff -r 64737d3deeb4 -r 10a72bcedbf0 VMS__int.c --- a/VMS__int.c Fri Mar 09 10:46:36 2012 -0800 +++ b/VMS__int.c Fri Mar 09 22:30:26 2012 -0800 @@ -22,7 +22,7 @@ newSlv = VMS_int__malloc( sizeof(SlaveVP) ); stackLocs = VMS_int__malloc( VIRT_PROCR_STACK_SIZE ); if( stackLocs == 0 ) - { perror("VMS__malloc stack"); exit(1); } + { perror("VMS_int__malloc stack"); exit(1); } _VMSMasterEnv->numSlavesAlive += 1; @@ -91,7 +91,7 @@ VMS_ext__dissipate_slaveVP( SlaveVP *slaveToDissipate ) { //NOTE: dataParam was given to the processor, so should either have - // been alloc'd with VMS__malloc, or freed by the level above animSlv. + // been alloc'd with VMS_int__malloc, or freed by the level above animSlv. //So, all that's left to free here is the stack and the SlaveVP struc // itself //Note, should not stack-allocate the data param -- no guarantee, in @@ -115,7 +115,7 @@ * VMS_malloc mechanism. Then it calls this, which first asks the malloc * system to disown any state that did use VMS_malloc, and then frees the * statck and the processor-struct itself. - *If the dissipated processor is the sole (remaining) owner of VMS__malloc'd + *If the dissipated processor is the sole (remaining) owner of VMS_int__malloc'd * state, then that state gets freed (or sent to recycling) as a side-effect * of dis-owning it. */ @@ -132,7 +132,7 @@ } //NOTE: dataParam was given to the processor, so should either have - // been alloc'd with VMS__malloc, or freed by the level above animSlv. + // been alloc'd with VMS_int__malloc, or freed by the level above animSlv. //So, all that's left to free here is the stack and the SlaveVP struc // itself //Note, should not stack-allocate initial data -- no guarantee, in @@ -157,7 +157,7 @@ void *dataParam, void *stackLocs ) { newSlv->startOfStack = stackLocs; - newSlv->procrID = _VMSMasterEnv->numSlavesCreated++; + newSlv->slaveID = _VMSMasterEnv->numSlavesCreated++; newSlv->requests = NULL; newSlv->schedSlot = NULL; diff -r 64737d3deeb4 -r 10a72bcedbf0 VMS__startup_and_shutdown.c --- a/VMS__startup_and_shutdown.c Fri Mar 09 10:46:36 2012 -0800 +++ b/VMS__startup_and_shutdown.c Fri Mar 09 22:30:26 2012 -0800 @@ -78,10 +78,57 @@ #endif } + +/*TODO: finish implementing + *This function returns information about the version of VMS, the language + * the program is being run in, its version, and information on the + * hardware. + */ +/* +char * +VMS_App__give_environment_string() + { + //-------------------------- + fprintf(output, "#\n# >> Build information <<\n"); + fprintf(output, "# GCC VERSION: %d.%d.%d\n",__GNUC__,__GNUC_MINOR__,__GNUC_PATCHLEVEL__); + fprintf(output, "# Build Date: %s %s\n", __DATE__, __TIME__); + + fprintf(output, "#\n# >> Hardware information <<\n"); + fprintf(output, "# Hardware Architecture: "); + #ifdef __x86_64 + fprintf(output, "x86_64"); + #endif //__x86_64 + #ifdef __i386 + fprintf(output, "x86"); + #endif //__i386 + fprintf(output, "\n"); + fprintf(output, "# Number of Cores: %d\n", NUM_CORES); + //-------------------------- + + //VMS Plugins + fprintf(output, "#\n# >> VMS Plugins <<\n"); + fprintf(output, "# Language : "); + fprintf(output, _LANG_NAME_); + fprintf(output, "\n"); + //Meta info gets set by calls from the language during its init, + // and info registered by calls from inside the application + fprintf(output, "# Scheduler: %s\n", _VMSMasterEnv->metaInfo->schedulerInfo); + + //-------------------------- + //Application + fprintf(output, "#\n# >> Application <<\n"); + fprintf(output, "# Name: %s\n", _VMSMasterEnv->metaInfo->appInfo); + fprintf(output, "# Data Set:\n%s\n",_VMSMasterEnv->metaInfo->inputSet); + + //-------------------------- + } + */ + /*This structure holds all the information VMS needs to manage a program. VMS * stores information about what percent of CPU time the program is getting, what * language it uses, the request handlers to call for its slaves, and so on. */ +/* typedef struct { void *semEnv; RequestHdlrFnPtr requestHandler; @@ -96,25 +143,29 @@ pthread_cond_t doneCond; } VMSProcess; +*/ +/* void VMS__start_VMS_running() { create_masterEnv(); #ifdef DEBUG__TURN_ON_SEQUENTIAL_MODE - /*Nothing else to create for sequential mode*/ + //Nothing else to create for sequential mode #else create_the_coreLoop_OS_threads(); #endif } +*/ /*A pointer to the startup-function for the language is given as the last * argument to the call. Use this to initialize a program in the language. * This creates a data structure that encapsulates the bookkeeping info * VMS uses to track and schedule a program run. */ +/* VMSProcess * VMS__spawn_program_on_data_in_Lang( TopLevelFnPtr prog_seed_fn, void *data, LangInitFnPtr langInitFnPtr ) @@ -128,15 +179,16 @@ newProcess->dataForSeed = data; newProcess->seedFnPtr = prog_seed_fn; - /*The language's spawn-process function fills in the plugin function-ptrs in - * the VMSProcess struct, gives the struct to VMS, which then makes and - * queues the seed SlaveVP, which starts processors made from the code being - * animated. - */ + //The language's spawn-process function fills in the plugin function-ptrs in + // the VMSProcess struct, gives the struct to VMS, which then makes and + // queues the seed SlaveVP, which starts processors made from the code being + // animated. + (*langInitFnPtr)( newProcess ); return newProcess; } +*/ /*When all SlaveVPs owned by the program-run associated to the process have * dissipated, then return from this call. There is no language to cleanup, @@ -154,6 +206,7 @@ * the process ending (last SlaveVP owned by it dissipates), then VMS signals * this to wakeup. This then calls the cleanup fn and returns the result. */ +/* void * VMS__give_results_when_done_for( VMSProcess *process ) { void *result; @@ -173,20 +226,23 @@ return result; } +*/ /*Turns off the VMS system, and frees all data associated with it. Does this * by creating shutdown SlaveVPs and inserting them into scheduling slots. * Will probably have to wake up sleeping cores as part of this -- the fn that * inserts the new SlaveVPs should handle the wakeup.. */ +/* void VMS__shutdown() { for( cores ) - { slave = VMS_int__create_new_SlaveVP( shutdownFN, NULL ); + { slave = VMS_int__create_new_SlaveVP( shutdownFn, NULL ); VMS_int__insert_slave_onto_core( SlaveVP *slave, coreNum ); } } +*/ /* VMS__start_VMS_running(); @@ -373,7 +429,7 @@ pthread_mutex_lock( &suspendLock ); _VMSMasterEnv->setupComplete = 1; pthread_mutex_unlock( &suspendLock ); - pthread_cond_broadcast( &suspend_cond ); + pthread_cond_broadcast( &suspendCond ); //wait for all to complete @@ -437,7 +493,7 @@ /*Am trying to be cute, avoiding IF statement in coreLoop that checks for - * a special shutdown procr. Ended up with extra-complex shutdown sequence. + * a special shutdown slaveVP. Ended up with extra-complex shutdown sequence. *This function has the sole purpose of setting the stack and framePtr * to the coreLoop's stack and framePtr.. it does that then jumps to the * core loop's shutdown point -- might be able to just call Pthread_exit diff -r 64737d3deeb4 -r 10a72bcedbf0 VMS_primitive_data_types.h --- a/VMS_primitive_data_types.h Fri Mar 09 10:46:36 2012 -0800 +++ b/VMS_primitive_data_types.h Fri Mar 09 22:30:26 2012 -0800 @@ -39,6 +39,7 @@ 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; diff -r 64737d3deeb4 -r 10a72bcedbf0 __README__Code_Overview.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/__README__Code_Overview.txt Fri Mar 09 22:30:26 2012 -0800 @@ -0,0 +1,20 @@ + +This file is intended to help those new to VMS to find their way around the code. + +Some observations: +-] VMS.h is the top header file, and is the root of a tree of #includes that pulls in all the other headers + +-] Defines directory contains all the header files that hold #define statements + +-] VMS has several kinds of function, grouped according to what kind of code should call them: VMS_App_.. for applications to call, VMS_WL_.. for wrapper-library code to call, VMS_PI_.. for plugin code to call, and VMS_int_.. for VMS to use internally. Sometimes VMS_int_ functions are called from the wrapper library or plugin, but this should only be done by programmers who have gained an in-depth knowledge of VMS's implementation and understand that VMS_int_ functions are not protected for concurrent use.. + +-] VMS has its own version of malloc, unfortunately, which is due to the system malloc breaking when the stack-pointer register is manipulated, which VMS must do. The VMS form of malloc must be used in code that runs inside the VMS system, especially all application code that uses a VMS-based language. However, a complication is that the malloc implementation is not protected with a lock. However, mallocs performed in the main thread, outside the VMS-language program, cannot use VMS malloc.. this presents some issues crossing the boundary.. + +-] Things in the code are turned on and off by using #define in combination with #ifdef. All defines for doing this are found in Defines/VMS_defs__turn_on_and_off.h. The rest of the files in Defines directory contain macro definitions, hardware constants, and any other #define statements. + +-] VMS has many macros used in the code.. such as for measurements and debug.. all measurement, debug, and statistics gathering statements can be turned on or off by commenting-out or uncommenting the appropriate #define. + +-] The best way to learn VMS is to uncomment DEBUG__TURN_ON_SEQUENTIAL_MODE, which allows using a normal debugger while sequentially executing through both application code and VMS internals. Setting breakpoints at various spots in the code is a good way to see the VMS system in operation. + +-] VMS has several "VMS primitives" implemented with assembly code. The net effect of these assembly functions is to perform the switching between application code and the VMS system. +