VMS/VMS_Implementations/SSR_impls/SSR__MC_shared_impl

view SSR_Counter_Recording.c @ 76:6647aea90477

commented out uses of SemEnv->lastReqType .. wasn't compiling..
author Sean Halle <seanhalle@yahoo.com>
date Sun, 15 Jul 2012 02:03:43 -0700
parents 81a0f076b12e
children
line source
1 /*
2 *
3 * author: Nina Engelhardt
4 */
6 #include "SSR_Counter_Recording.h"
7 #include "VMS_impl/VMS.h"
8 #include "SSR.h"
10 #ifdef HOLISTIC__TURN_ON_PERF_COUNTERS
12 void SSR__init_counter_data_structs(){
13 SSRSemEnv *semanticEnv = _VMSMasterEnv->semanticEnv;
14 int i;
15 for(i=0;i<NUM_CORES;i++){
16 semanticEnv->counterList[i] = makeListOfArrays(sizeof(CounterEvent), 128);
17 }
18 }
20 void addToListOfArraysCounterEvent(CounterEvent value, ListOfArrays* list){
21 int offset_in_fragment = list->next_free_index % list->num_entries_per_fragment;
22 if(offset_in_fragment == 0){
23 void* newBlock = malloc(list->entry_size * list->num_entries_per_fragment);
24 addToDynArray(newBlock,list->dim1info);
25 }
26 CounterEvent* typedFragment = (CounterEvent*) ((list->dim1)[list->dim1info->numInArray -1]);
27 typedFragment[offset_in_fragment] = value;
28 list->next_free_index++;
29 }
31 void SSR__counter_handler(int evt_type, int vpid, int task, SlaveVP* pr, uint64 cycles, uint64 instrs, uint64 cachem)
32 {
34 if (pr->typeOfVP == Master || pr->typeOfVP == Shutdown)
35 { //Only save values for application work, done in a SlaveVP
36 return;
37 }
39 SSRSemEnv *semanticEnv = _VMSMasterEnv->semanticEnv;
41 CounterEvent e;
42 e.event_type = evt_type;
43 e.vp = vpid;
44 e.task = task;
46 e.cycles = cycles;
47 e.instrs = instrs;
48 e.cachem = cachem;
50 if(pr){
51 e.coreID = pr->coreAnimatedBy;
52 e.slot = pr->animSlotAssignedTo;
53 } else {
54 e.coreID = -1;
55 e.slot = NULL;
56 }
58 int corenum;
60 if(pr) corenum = pr->coreAnimatedBy; else return;
62 if(evt_type==Work_start || evt_type==Work_end || evt_type==AppResponderInvocation_start){
63 addToListOfArrays_ext(CounterEvent,e,semanticEnv->counterList[corenum]);
64 } else {
65 addToListOfArraysCounterEvent(e,semanticEnv->counterList[corenum]);
66 }
67 }
69 void set_counter_file(FILE* f){
70 counterfile = f;
71 }
73 void print_counter_events_to_file(void* _e){
74 CounterEvent* e = (CounterEvent*) _e;
75 fprintf(counterfile, "event, ");
76 switch(e->event_type){
77 case AppResponderInvocation_start:
78 fprintf(counterfile, "AppResponderInvocation_start");
79 break;
80 case AppResponder_start:
81 fprintf(counterfile, "AppResponder_start");
82 break;
83 case AppResponder_end:
84 fprintf(counterfile, "AppResponder_end");
85 break;
86 case AssignerInvocation_start:
87 fprintf(counterfile, "AssignerInvocation_start");
88 break;
89 case NextAssigner_start:
90 fprintf(counterfile, "NextAssigner_start");
91 break;
92 case Assigner_start:
93 fprintf(counterfile, "Assigner_start");
94 break;
95 case Assigner_end:
96 fprintf(counterfile, "Assigner_end");
97 break;
98 case Work_end:
99 fprintf(counterfile, "Work_end");
100 break;
101 case Work_start:
102 fprintf(counterfile, "Work_start");
103 break;
104 case HwResponderInvocation_start:
105 fprintf(counterfile, "HwResponderInvocation_start");
106 break;
107 case Timestamp_start:
108 fprintf(counterfile, "Timestamp_start");
109 break;
110 case Timestamp_end:
111 fprintf(counterfile, "Timestamp_end");
112 break;
113 default:
114 fprintf(counterfile, "unknown event");
115 }
116 fprintf(counterfile,", %d, %d, %llu, %llu, %llu",e->vp,e->task,e->cycles,e->instrs,e->cachem);
117 if(e->coreID >=0)
118 fprintf(counterfile,", %d",e->coreID);
119 fprintf(counterfile,"\n");
120 fflush(counterfile);
121 }
122 #endif