Skip to content

Commit

Permalink
Set default value of options (that don't need a value) to 1
Browse files Browse the repository at this point in the history
  • Loading branch information
TomTheBear committed Aug 1, 2018
1 parent 1870388 commit 7933391
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/includes/perfmon_perfevent.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ int perf_pmc_setup(struct perf_event_attr *attr, PerfmonEvent *event)
{
for(int j = 0; j < event->numberOfOptions; j++)
{

switch (event->options[j].type)
{
case EVENT_OPTION_COUNT_KERNEL:
Expand All @@ -275,7 +275,7 @@ int perf_pmc_setup(struct perf_event_attr *attr, PerfmonEvent *event)
case EVENT_OPTION_IN_TRANS:
case EVENT_OPTION_IN_TRANS_ABORT:
getEventOptionConfig("/sys/devices/cpu", event->options[j].type, &reg, &start, &end);
printf("Type %d, start %d, end %d\n", reg, start, end);
printf("Event %s Type %d, reg %d, start %d, end %d, value 0x%lx\n", event->name, event->options[j].type, reg, start, end, event->options[j].value);
switch(reg)
{
case PERF_EVENT_CONFIG_REG:
Expand Down Expand Up @@ -379,7 +379,7 @@ int perf_uncore_setup(struct perf_event_attr *attr, RegisterType type, PerfmonEv
{
for(int j = 0; j < event->numberOfOptions; j++)
{

switch (event->options[j].type)
{
case EVENT_OPTION_COUNT_KERNEL:
Expand Down
22 changes: 13 additions & 9 deletions src/perfmon.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,10 @@ char* eventOptionTypeName[NUM_EVENT_OPTIONS] = {
"OCCUPANCY_EDGEDETECT",
"OCCUPANCY_INVERT",
"IN_TRANSACTION",
"IN_TRANSACTION_ABORTED"
"IN_TRANSACTION_ABORTED",
#ifdef LIKWID_USE_PERFEVENT
,"PERF_PID"
,"PERF_FLAGS"
"PERF_PID",
"PERF_FLAGS",
#endif
};

Expand Down Expand Up @@ -343,7 +343,7 @@ getEvent(bstring event_str, bstring counter_str, PerfmonEvent* event)
}

static int
assignOption(PerfmonEvent* event, bstring entry, int index, EventOptionType type, int zero_value)
assignOption(PerfmonEvent* event, bstring entry, int index, EventOptionType type, int noval_value)
{
int found_double = -1;
int return_index = index;
Expand All @@ -358,22 +358,26 @@ assignOption(PerfmonEvent* event, bstring entry, int index, EventOptionType type
}
if (found_double >= 0)
{
DEBUG_PRINT(DEBUGLEV_INFO, "Found option multiple times for event %s, last value wins!", event->name);
index = found_double;
}
else
{
return_index++;
}
event->options[index].type = type;
if (zero_value)
if (noval_value)
{
event->options[index].value = 0;
event->options[index].value = noval_value;
}
else
{
value = 0;
sscanf(bdata(entry), "%llx", &value);
event->options[index].value = value;
int ret = sscanf(bdata(entry), "%llx", &value);
if (ret == 1)
{
event->options[index].value = value;
}
}
return return_index;
}
Expand Down Expand Up @@ -445,7 +449,7 @@ parseOptions(struct bstrList* tokens, PerfmonEvent* event, RegisterIndex index)
fprintf(stderr, "WARN: Option '%s' unknown, skipping option\n", bdata(subtokens->entry[0]));
continue;
}
event->options[event->numberOfOptions].value = 0;
event->options[event->numberOfOptions].value = 1;
}
else if (subtokens->qty == 2)
{
Expand Down

0 comments on commit 7933391

Please sign in to comment.