changeset 39:6a367b5d9a2d perf_counters

Separate UCC recording from VMS core and put it into SSR plugin
author Nina Engelhardt
date Mon, 05 Dec 2011 19:00:51 +0100
parents 5dbcafa52169
children bde026832af7
files SSR.h SSR_PluginFns.c SSR_Request_Handlers.c SSR_lib.c dependency.c dependency.h
diffstat 6 files changed, 139 insertions(+), 27 deletions(-) [+]
line diff
     1.1 --- a/SSR.h	Tue Sep 27 18:07:59 2011 +0200
     1.2 +++ b/SSR.h	Mon Dec 05 19:00:51 2011 +0100
     1.3 @@ -12,6 +12,7 @@
     1.4  #include "VMS/Queue_impl/PrivateQueue.h"
     1.5  #include "VMS/Hash_impl/PrivateHash.h"
     1.6  #include "VMS/VMS.h"
     1.7 +#include "dependency.h"
     1.8  
     1.9  
    1.10  //===========================================================================
    1.11 @@ -103,6 +104,17 @@
    1.12                         //fix limit on num with dynArray
    1.13     SSRSingleton     fnSingletons[NUM_STRUCS_IN_SEM_ENV];
    1.14     SSRTrans         transactionStrucs[NUM_STRUCS_IN_SEM_ENV];
    1.15 +   
    1.16 +   #ifdef OBSERVE_UCC
    1.17 +   Unit*** unitcollection;
    1.18 +   PrivDynArrayInfo* unitcollectionInfo;
    1.19 +   Dependency** ctlDependencies;
    1.20 +   PrivDynArrayInfo* ctlDependenciesInfo;
    1.21 +   Dependency** commDependencies;
    1.22 +   PrivDynArrayInfo* commDependenciesInfo;
    1.23 +   //NtoN structure?
    1.24 +   #endif
    1.25 +   
    1.26   }
    1.27  SSRSemEnv;
    1.28  
     2.1 --- a/SSR_PluginFns.c	Tue Sep 27 18:07:59 2011 +0200
     2.2 +++ b/SSR_PluginFns.c	Mon Dec 05 19:00:51 2011 +0100
     2.3 @@ -209,10 +209,8 @@
     2.4     
     2.5     DEBUG1(dbgRqstHdlr,"(new VP: %d)\n",newPr->procrID)
     2.6  
     2.7 -   #ifdef DETECT_DEPENDENCIES
     2.8 -   int lastRecordIdx = requestingPr->counter_history_array_info->numInArray -1;
     2.9 -   CounterRecord* lastRecord = requestingPr->counter_history[lastRecordIdx];
    2.10 -   addToDynArray((void*)new_dependency(requestingPr->procrID,lastRecord->task_position,newPr->procrID,0),_VMSMasterEnv->dependenciesInfo);     
    2.11 +   #ifdef OBSERVE_UCC
    2.12 +   addToDynArray((void*)new_dependency(requestingPr->procrID,requestingPr->numTimesScheduled,newPr->procrID,0),semEnv->commDependenciesInfo);     
    2.13     #endif
    2.14  
    2.15        //For SSR, caller needs ptr to created processor returned to it
    2.16 @@ -232,6 +230,10 @@
    2.17     CounterRecord* lastRecord = procr->counter_history[lastRecordIdx];
    2.18     saveLowTimeStampCountInto(lastRecord->unblocked_timestamp);
    2.19     #endif
    2.20 -
    2.21 +   #ifdef OBSERVE_UCC
    2.22 +   Dependency* newd = new_dependency(procr->procrID,procr->numTimesScheduled,
    2.23 +                                     procr->procrID,procr->numTimesScheduled + 1);
    2.24 +   addToDynArray((void*) newd ,semEnv->ctlDependenciesInfo);   
    2.25 +   #endif
    2.26     writePrivQ( procr, semEnv->readyVPQs[ procr->coreAnimatedBy] );
    2.27   }
     3.1 --- a/SSR_Request_Handlers.c	Tue Sep 27 18:07:59 2011 +0200
     3.2 +++ b/SSR_Request_Handlers.c	Mon Dec 05 19:00:51 2011 +0100
     3.3 @@ -126,12 +126,9 @@
     3.4      }
     3.5     else
     3.6      {    
     3.7 -       #ifdef DETECT_DEPENDENCIES
     3.8 -       int fromRecordIdx = sendPr->counter_history_array_info->numInArray -1;
     3.9 -       CounterRecord* fromRecord = sendPr->counter_history[fromRecordIdx];
    3.10 -       int toRecordIdx = receivePr->counter_history_array_info->numInArray -1;
    3.11 -       CounterRecord* toRecord = receivePr->counter_history[toRecordIdx];
    3.12 -       addToDynArray((void*)new_dependency(sendPr->procrID,fromRecord->task_position,receivePr->procrID,toRecord->task_position),_VMSMasterEnv->dependenciesInfo);     
    3.13 +       #ifdef OBSERVE_UCC
    3.14 +       addToDynArray((void*)new_dependency(sendPr->procrID,sendPr->numTimesScheduled,
    3.15 +                receivePr->procrID,receivePr->numTimesScheduled +1),semEnv->commDependenciesInfo);     
    3.16         #endif
    3.17  
    3.18         //waiting request is a receive, so it pairs to this send
    3.19 @@ -174,13 +171,6 @@
    3.20     receivePr = semReq->receivePr; //For "send", know both send & recv procrs
    3.21     sendPr    = semReq->sendPr;    
    3.22     
    3.23 -       #ifdef DETECT_DEPENDENCIES
    3.24 -       int fromRecordIdx = sendPr->counter_history_array_info->numInArray -1;
    3.25 -       CounterRecord* fromRecord = sendPr->counter_history[fromRecordIdx];
    3.26 -       int toRecordIdx = receivePr->counter_history_array_info->numInArray -1;
    3.27 -       CounterRecord* toRecord = receivePr->counter_history[toRecordIdx];
    3.28 -       addToDynArray((void*)new_dependency(sendPr->procrID,fromRecord->task_position,receivePr->procrID,toRecord->task_position),_VMSMasterEnv->dependenciesInfo);     
    3.29 -       #endif    
    3.30         
    3.31     key[0] = (int)receivePr->procrID;
    3.32     key[1] = (int)sendPr->procrID;
    3.33 @@ -197,6 +187,11 @@
    3.34      }
    3.35     else
    3.36      {    //waiting request is a receive, so it completes pair with this send
    3.37 +      #ifdef OBSERVE_UCC
    3.38 +      addToDynArray((void*) new_dependency(sendPr->procrID,sendPr->numTimesScheduled,
    3.39 +                                          receivePr->procrID,receivePr->numTimesScheduled +1)
    3.40 +                    ,semEnv->commDependenciesInfo);     
    3.41 +      #endif 
    3.42           //First, remove the waiting receive request from the entry
    3.43        entry->content = waitingReq->nextReqInHashEntry;
    3.44        VMS__free( waitingReq ); //Don't use contents -- so free it
    3.45 @@ -215,7 +210,7 @@
    3.46           //bring both processors back from suspend
    3.47        resume_procr( sendPr,    semEnv );
    3.48        resume_procr( receivePr, semEnv );
    3.49 -      
    3.50 +            
    3.51        return;
    3.52      }
    3.53   }
    3.54 @@ -297,12 +292,9 @@
    3.55        sendPr = waitingReq->sendPr;
    3.56        VMS__free( waitingReq );
    3.57  
    3.58 -       #ifdef DETECT_DEPENDENCIES
    3.59 -       int fromRecordIdx = sendPr->counter_history_array_info->numInArray -1;
    3.60 -       CounterRecord* fromRecord = sendPr->counter_history[fromRecordIdx];
    3.61 -       int toRecordIdx = receivePr->counter_history_array_info->numInArray -1;
    3.62 -       CounterRecord* toRecord = receivePr->counter_history[toRecordIdx];
    3.63 -       addToDynArray((void*)new_dependency(sendPr->procrID,fromRecord->task_position,receivePr->procrID,toRecord->task_position),_VMSMasterEnv->dependenciesInfo);     
    3.64 +       #ifdef OBSERVE_UCC
    3.65 +       addToDynArray((void*)new_dependency(sendPr->procrID,sendPr->numTimesScheduled,
    3.66 +                receivePr->procrID,receivePr->numTimesScheduled +1),semEnv->commDependenciesInfo);     
    3.67         #endif
    3.68        
    3.69        resume_procr( sendPr,    semEnv );
    3.70 @@ -341,7 +333,11 @@
    3.71        //At this point, know have waiting request(s) -- should be send(s)
    3.72     if( waitingReq->reqType == send_from_to )
    3.73      {    //waiting request is a send, so pair it with this receive
    3.74 -
    3.75 +      #ifdef OBSERVE_UCC
    3.76 +      addToDynArray((void*) new_dependency(sendPr->procrID,sendPr->numTimesScheduled,
    3.77 +                                          receivePr->procrID,receivePr->numTimesScheduled +1)
    3.78 +                    ,semEnv->commDependenciesInfo);     
    3.79 +      #endif  
    3.80           //For from-to, should only ever be a single reqst waiting tobe paird
    3.81        entry->content = waitingReq->nextReqInHashEntry;
    3.82        if( entry->content != NULL ) printf("\nERROR in handleRecvFromTo\n");
     4.1 --- a/SSR_lib.c	Tue Sep 27 18:07:59 2011 +0200
     4.2 +++ b/SSR_lib.c	Mon Dec 05 19:00:51 2011 +0100
     4.3 @@ -208,6 +208,15 @@
     4.4        // the master environment
     4.5     semanticEnv = VMS__malloc( sizeof( SSRSemEnv ) );
     4.6     _VMSMasterEnv->semanticEnv = semanticEnv;
     4.7 +   
     4.8 +   #ifdef OBSERVE_UCC
     4.9 +   //TODO: set up unit recording structure
    4.10 +   semanticEnv->ctlDependencies = VMS__malloc(10*sizeof(void*));
    4.11 +   semanticEnv->ctlDependenciesInfo = makePrivDynArrayInfoFrom((void***)&(semanticEnv->ctlDependencies),10);
    4.12 +   semanticEnv->commDependencies = VMS__malloc(10*sizeof(void*));
    4.13 +   semanticEnv->commDependenciesInfo = makePrivDynArrayInfoFrom((void***)&(semanticEnv->commDependencies),10);
    4.14 +   //TODO: set up N:N recording structure
    4.15 +   #endif
    4.16  
    4.17        //create the ready queue, hash tables used for pairing send to receive
    4.18        // and so forth
    4.19 @@ -247,10 +256,46 @@
    4.20  SSR__cleanup_after_shutdown()
    4.21   { SSRSemEnv *semanticEnv;
    4.22     int coreIdx;
    4.23 +   
    4.24 +   semanticEnv = _VMSMasterEnv->semanticEnv;
    4.25  
    4.26 +   #ifdef OBSERVE_UCC
    4.27 +   FILE* output;
    4.28 +   int n;
    4.29 +   char filename[255];    
    4.30 +    for(n=0;n<255;n++)
    4.31 +    {
    4.32 +        sprintf(filename, "./counters/Dependencies.%d.dot",n);
    4.33 +        output = fopen(filename,"r");
    4.34 +        if(output)
    4.35 +        {
    4.36 +            fclose(output);
    4.37 +        }else{
    4.38 +            break;
    4.39 +        }
    4.40 +    }
    4.41 +   if(n<255){
    4.42 +    printf("Saving Dependencies to File: %s ...\n", filename);
    4.43 +    output = fopen(filename,"w+");
    4.44 +    if(output!=NULL){
    4.45 +        set_dependency_file(output);
    4.46 +        fprintf(output,"digraph Dependencies {\n");
    4.47 +        set_dot_file(output);
    4.48 +        //FIXME:  first line still depends on counters being enabled, replace w/ unit struct!
    4.49 +        forAllInDynArrayDo(_VMSMasterEnv->counter_history_array_info, &print_dot_node_info );
    4.50 +        forAllInDynArrayDo( semanticEnv->commDependenciesInfo, &print_dependency_to_file );
    4.51 +        forAllInDynArrayDo( semanticEnv->ctlDependenciesInfo, &print_dependency_to_file );
    4.52 +        fprintf(output,"}\n");
    4.53 +    } else
    4.54 +        printf("Opening Dependencies file failed. Please check that folder \"counters\" exists in run directory and has write permission.\n");
    4.55 +   } else {
    4.56 +       printf("Could not open Dependencies file, please clean \"counters\" folder. (Must contain less than 255 files.)\n");
    4.57 +   }
    4.58 +#endif
    4.59 +   
    4.60  /* It's all allocated inside VMS's big chunk -- that's about to be freed, so
    4.61   *  nothing to do here
    4.62 -   semanticEnv = _VMSMasterEnv->semanticEnv;
    4.63 +   
    4.64  
    4.65     for( coreIdx = 0; coreIdx < NUM_CORES; coreIdx++ )
    4.66      {
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/dependency.c	Mon Dec 05 19:00:51 2011 +0100
     5.3 @@ -0,0 +1,22 @@
     5.4 +#include "dependency.h"
     5.5 +#include "VMS/VMS.h"
     5.6 +
     5.7 +Dependency* new_dependency(int from_vp, int from_task, int to_vp, int to_task){
     5.8 +    Dependency* newDep = (Dependency*) VMS__malloc(sizeof(Dependency));
     5.9 +    if (newDep!=NULL){
    5.10 +        newDep->from_vp = from_vp;
    5.11 +        newDep->from_task = from_task;
    5.12 +        newDep->to_vp = to_vp;
    5.13 +        newDep->to_task = to_task;
    5.14 +    }
    5.15 +    return newDep;
    5.16 +}
    5.17 +
    5.18 +int set_dependency_file(FILE* file){
    5.19 +    dependency_file = file;
    5.20 +}
    5.21 +
    5.22 +void print_dependency_to_file(void* _dep){
    5.23 +    Dependency* dep = (Dependency*) _dep;
    5.24 +    fprintf(dependency_file,"VP_%d_%d -> VP_%d_%d;\n",dep->from_vp,dep->from_task,dep->to_vp,dep->to_task);
    5.25 +}
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/dependency.h	Mon Dec 05 19:00:51 2011 +0100
     6.3 @@ -0,0 +1,35 @@
     6.4 +/* 
     6.5 + * File:   dependency.h
     6.6 + * Author: engelhardt
     6.7 + *
     6.8 + * Created on 29. August 2011, 17:41
     6.9 + */
    6.10 +
    6.11 +#ifndef DEPENDENCY_H
    6.12 +#define	DEPENDENCY_H
    6.13 +
    6.14 +
    6.15 +#include <stdio.h>
    6.16 +
    6.17 +typedef struct {
    6.18 +    int vp;
    6.19 +    int task;
    6.20 +} Unit;
    6.21 +
    6.22 +typedef struct {
    6.23 +    int from_vp;
    6.24 +    int from_task;
    6.25 +    int to_vp;
    6.26 +    int to_task;
    6.27 +} Dependency; 
    6.28 +
    6.29 +FILE* dependency_file;
    6.30 +
    6.31 +Dependency* new_dependency(int from_vp, int from_task, int to_vp, int to_task);
    6.32 +
    6.33 +int set_dependency_file(FILE* file);
    6.34 +
    6.35 +void print_dependency_to_file(void* dep);
    6.36 +
    6.37 +#endif	/* DEPENDENCY_H */
    6.38 +