+/* Extract the value corresponding to an event */
+long_long
+papi_counter(long_long values[],int event)
+{
+ int i;
+ for(i=0;i<N_PAPI_EVENTS;i++) {
+ if(papi_events[i].event_code==event) {
+ return values[i];
+ }
+ }
+ /* Passed a wrong event? */
+ debugBelch("Event %d is not part of event set\n",event);
+ return 0;
+}
+
+/* Add the events of papi_events into an event set */
+void
+papi_add_events(int EventSet)
+{
+ int i;
+ for(i=0;i<N_PAPI_EVENTS;i++) {
+ if((papi_error=PAPI_add_event(EventSet,
+ papi_events[i].event_code))
+ != PAPI_OK)
+ debugBelch("Failed adding %s to event set with error code %d\n",
+ papi_events[i].event_name,papi_error);
+ }
+}
+
+/* We should be using elapsed cycles
+ * to be consistent with time metric chosen in Stats.c (Elapsed time).
+ * This is an approximation to the cycles that the program spends.
+ * Note that the counters, in contrast, are virtual and user space.
+ */
+#define PAPI_cycles PAPI_get_virt_cyc
+