# HG changeset patch # User Nina Engelhardt # Date 1323108051 -3600 # Node ID 6a367b5d9a2db3a39c4ce94a66dfd242fce2acb5 # Parent 5dbcafa5216962b2126024673ce199daee451179 Separate UCC recording from VMS core and put it into SSR plugin diff -r 5dbcafa52169 -r 6a367b5d9a2d SSR.h --- a/SSR.h Tue Sep 27 18:07:59 2011 +0200 +++ b/SSR.h Mon Dec 05 19:00:51 2011 +0100 @@ -12,6 +12,7 @@ #include "VMS/Queue_impl/PrivateQueue.h" #include "VMS/Hash_impl/PrivateHash.h" #include "VMS/VMS.h" +#include "dependency.h" //=========================================================================== @@ -103,6 +104,17 @@ //fix limit on num with dynArray SSRSingleton fnSingletons[NUM_STRUCS_IN_SEM_ENV]; SSRTrans transactionStrucs[NUM_STRUCS_IN_SEM_ENV]; + + #ifdef OBSERVE_UCC + Unit*** unitcollection; + PrivDynArrayInfo* unitcollectionInfo; + Dependency** ctlDependencies; + PrivDynArrayInfo* ctlDependenciesInfo; + Dependency** commDependencies; + PrivDynArrayInfo* commDependenciesInfo; + //NtoN structure? + #endif + } SSRSemEnv; diff -r 5dbcafa52169 -r 6a367b5d9a2d SSR_PluginFns.c --- a/SSR_PluginFns.c Tue Sep 27 18:07:59 2011 +0200 +++ b/SSR_PluginFns.c Mon Dec 05 19:00:51 2011 +0100 @@ -209,10 +209,8 @@ DEBUG1(dbgRqstHdlr,"(new VP: %d)\n",newPr->procrID) - #ifdef DETECT_DEPENDENCIES - int lastRecordIdx = requestingPr->counter_history_array_info->numInArray -1; - CounterRecord* lastRecord = requestingPr->counter_history[lastRecordIdx]; - addToDynArray((void*)new_dependency(requestingPr->procrID,lastRecord->task_position,newPr->procrID,0),_VMSMasterEnv->dependenciesInfo); + #ifdef OBSERVE_UCC + addToDynArray((void*)new_dependency(requestingPr->procrID,requestingPr->numTimesScheduled,newPr->procrID,0),semEnv->commDependenciesInfo); #endif //For SSR, caller needs ptr to created processor returned to it @@ -232,6 +230,10 @@ CounterRecord* lastRecord = procr->counter_history[lastRecordIdx]; saveLowTimeStampCountInto(lastRecord->unblocked_timestamp); #endif - + #ifdef OBSERVE_UCC + Dependency* newd = new_dependency(procr->procrID,procr->numTimesScheduled, + procr->procrID,procr->numTimesScheduled + 1); + addToDynArray((void*) newd ,semEnv->ctlDependenciesInfo); + #endif writePrivQ( procr, semEnv->readyVPQs[ procr->coreAnimatedBy] ); } diff -r 5dbcafa52169 -r 6a367b5d9a2d SSR_Request_Handlers.c --- a/SSR_Request_Handlers.c Tue Sep 27 18:07:59 2011 +0200 +++ b/SSR_Request_Handlers.c Mon Dec 05 19:00:51 2011 +0100 @@ -126,12 +126,9 @@ } else { - #ifdef DETECT_DEPENDENCIES - int fromRecordIdx = sendPr->counter_history_array_info->numInArray -1; - CounterRecord* fromRecord = sendPr->counter_history[fromRecordIdx]; - int toRecordIdx = receivePr->counter_history_array_info->numInArray -1; - CounterRecord* toRecord = receivePr->counter_history[toRecordIdx]; - addToDynArray((void*)new_dependency(sendPr->procrID,fromRecord->task_position,receivePr->procrID,toRecord->task_position),_VMSMasterEnv->dependenciesInfo); + #ifdef OBSERVE_UCC + addToDynArray((void*)new_dependency(sendPr->procrID,sendPr->numTimesScheduled, + receivePr->procrID,receivePr->numTimesScheduled +1),semEnv->commDependenciesInfo); #endif //waiting request is a receive, so it pairs to this send @@ -174,13 +171,6 @@ receivePr = semReq->receivePr; //For "send", know both send & recv procrs sendPr = semReq->sendPr; - #ifdef DETECT_DEPENDENCIES - int fromRecordIdx = sendPr->counter_history_array_info->numInArray -1; - CounterRecord* fromRecord = sendPr->counter_history[fromRecordIdx]; - int toRecordIdx = receivePr->counter_history_array_info->numInArray -1; - CounterRecord* toRecord = receivePr->counter_history[toRecordIdx]; - addToDynArray((void*)new_dependency(sendPr->procrID,fromRecord->task_position,receivePr->procrID,toRecord->task_position),_VMSMasterEnv->dependenciesInfo); - #endif key[0] = (int)receivePr->procrID; key[1] = (int)sendPr->procrID; @@ -197,6 +187,11 @@ } else { //waiting request is a receive, so it completes pair with this send + #ifdef OBSERVE_UCC + addToDynArray((void*) new_dependency(sendPr->procrID,sendPr->numTimesScheduled, + receivePr->procrID,receivePr->numTimesScheduled +1) + ,semEnv->commDependenciesInfo); + #endif //First, remove the waiting receive request from the entry entry->content = waitingReq->nextReqInHashEntry; VMS__free( waitingReq ); //Don't use contents -- so free it @@ -215,7 +210,7 @@ //bring both processors back from suspend resume_procr( sendPr, semEnv ); resume_procr( receivePr, semEnv ); - + return; } } @@ -297,12 +292,9 @@ sendPr = waitingReq->sendPr; VMS__free( waitingReq ); - #ifdef DETECT_DEPENDENCIES - int fromRecordIdx = sendPr->counter_history_array_info->numInArray -1; - CounterRecord* fromRecord = sendPr->counter_history[fromRecordIdx]; - int toRecordIdx = receivePr->counter_history_array_info->numInArray -1; - CounterRecord* toRecord = receivePr->counter_history[toRecordIdx]; - addToDynArray((void*)new_dependency(sendPr->procrID,fromRecord->task_position,receivePr->procrID,toRecord->task_position),_VMSMasterEnv->dependenciesInfo); + #ifdef OBSERVE_UCC + addToDynArray((void*)new_dependency(sendPr->procrID,sendPr->numTimesScheduled, + receivePr->procrID,receivePr->numTimesScheduled +1),semEnv->commDependenciesInfo); #endif resume_procr( sendPr, semEnv ); @@ -341,7 +333,11 @@ //At this point, know have waiting request(s) -- should be send(s) if( waitingReq->reqType == send_from_to ) { //waiting request is a send, so pair it with this receive - + #ifdef OBSERVE_UCC + addToDynArray((void*) new_dependency(sendPr->procrID,sendPr->numTimesScheduled, + receivePr->procrID,receivePr->numTimesScheduled +1) + ,semEnv->commDependenciesInfo); + #endif //For from-to, should only ever be a single reqst waiting tobe paird entry->content = waitingReq->nextReqInHashEntry; if( entry->content != NULL ) printf("\nERROR in handleRecvFromTo\n"); diff -r 5dbcafa52169 -r 6a367b5d9a2d SSR_lib.c --- a/SSR_lib.c Tue Sep 27 18:07:59 2011 +0200 +++ b/SSR_lib.c Mon Dec 05 19:00:51 2011 +0100 @@ -208,6 +208,15 @@ // the master environment semanticEnv = VMS__malloc( sizeof( SSRSemEnv ) ); _VMSMasterEnv->semanticEnv = semanticEnv; + + #ifdef OBSERVE_UCC + //TODO: set up unit recording structure + semanticEnv->ctlDependencies = VMS__malloc(10*sizeof(void*)); + semanticEnv->ctlDependenciesInfo = makePrivDynArrayInfoFrom((void***)&(semanticEnv->ctlDependencies),10); + semanticEnv->commDependencies = VMS__malloc(10*sizeof(void*)); + semanticEnv->commDependenciesInfo = makePrivDynArrayInfoFrom((void***)&(semanticEnv->commDependencies),10); + //TODO: set up N:N recording structure + #endif //create the ready queue, hash tables used for pairing send to receive // and so forth @@ -247,10 +256,46 @@ SSR__cleanup_after_shutdown() { SSRSemEnv *semanticEnv; int coreIdx; + + semanticEnv = _VMSMasterEnv->semanticEnv; + #ifdef OBSERVE_UCC + FILE* output; + int n; + char filename[255]; + for(n=0;n<255;n++) + { + sprintf(filename, "./counters/Dependencies.%d.dot",n); + output = fopen(filename,"r"); + if(output) + { + fclose(output); + }else{ + break; + } + } + if(n<255){ + printf("Saving Dependencies to File: %s ...\n", filename); + output = fopen(filename,"w+"); + if(output!=NULL){ + set_dependency_file(output); + fprintf(output,"digraph Dependencies {\n"); + set_dot_file(output); + //FIXME: first line still depends on counters being enabled, replace w/ unit struct! + forAllInDynArrayDo(_VMSMasterEnv->counter_history_array_info, &print_dot_node_info ); + forAllInDynArrayDo( semanticEnv->commDependenciesInfo, &print_dependency_to_file ); + forAllInDynArrayDo( semanticEnv->ctlDependenciesInfo, &print_dependency_to_file ); + fprintf(output,"}\n"); + } else + printf("Opening Dependencies file failed. Please check that folder \"counters\" exists in run directory and has write permission.\n"); + } else { + printf("Could not open Dependencies file, please clean \"counters\" folder. (Must contain less than 255 files.)\n"); + } +#endif + /* It's all allocated inside VMS's big chunk -- that's about to be freed, so * nothing to do here - semanticEnv = _VMSMasterEnv->semanticEnv; + for( coreIdx = 0; coreIdx < NUM_CORES; coreIdx++ ) { diff -r 5dbcafa52169 -r 6a367b5d9a2d dependency.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dependency.c Mon Dec 05 19:00:51 2011 +0100 @@ -0,0 +1,22 @@ +#include "dependency.h" +#include "VMS/VMS.h" + +Dependency* new_dependency(int from_vp, int from_task, int to_vp, int to_task){ + Dependency* newDep = (Dependency*) VMS__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; +} + +int set_dependency_file(FILE* file){ + dependency_file = file; +} + +void print_dependency_to_file(void* _dep){ + Dependency* dep = (Dependency*) _dep; + fprintf(dependency_file,"VP_%d_%d -> VP_%d_%d;\n",dep->from_vp,dep->from_task,dep->to_vp,dep->to_task); +} diff -r 5dbcafa52169 -r 6a367b5d9a2d dependency.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dependency.h Mon Dec 05 19:00:51 2011 +0100 @@ -0,0 +1,35 @@ +/* + * File: dependency.h + * Author: engelhardt + * + * Created on 29. August 2011, 17:41 + */ + +#ifndef DEPENDENCY_H +#define DEPENDENCY_H + + +#include + +typedef struct { + int vp; + int task; +} Unit; + +typedef struct { + int from_vp; + int from_task; + int to_vp; + int to_task; +} Dependency; + +FILE* dependency_file; + +Dependency* new_dependency(int from_vp, int from_task, int to_vp, int to_task); + +int set_dependency_file(FILE* file); + +void print_dependency_to_file(void* dep); + +#endif /* DEPENDENCY_H */ +