[llvm-commits] CVS: llvm/lib/Reoptimizer/Inst/rtl/Makefile pprtl.cpp pprtl.h

Joel Stanley jstanley at cs.uiuc.edu
Thu May 22 22:27:01 PDT 2003


Changes in directory llvm/lib/Reoptimizer/Inst/rtl:

Makefile updated: 1.2 -> 1.3
pprtl.cpp updated: 1.1 -> 1.2
pprtl.h updated: 1.2 -> 1.3

---
Log message:

Bug fixes; PAPI "support" added to RTL.



---
Diffs of the changes:

Index: llvm/lib/Reoptimizer/Inst/rtl/Makefile
diff -u llvm/lib/Reoptimizer/Inst/rtl/Makefile:1.2 llvm/lib/Reoptimizer/Inst/rtl/Makefile:1.3
--- llvm/lib/Reoptimizer/Inst/rtl/Makefile:1.2	Thu May 22 08:16:40 2003
+++ llvm/lib/Reoptimizer/Inst/rtl/Makefile	Thu May 22 22:26:13 2003
@@ -1,6 +1,8 @@
 LEVEL = ../../../..
 LIBRARYNAME = pprtl
 BUILD_ARCHIVE = 1
-CXXFLAGS += -D_BUILDING_RUNTIME_LIBRARY_
+PAPIDIR = /home/vadve/shared/papi-2.3.4.1
+CPPFLAGS += -D_BUILDING_RUNTIME_LIBRARY_ -I$(PAPIDIR)/include
+CXXFLAGS += -D_BUILDING_RUNTIME_LIBRARY_ -I$(PAPIDIR)/include
 
 include $(LEVEL)/Makefile.common


Index: llvm/lib/Reoptimizer/Inst/rtl/pprtl.cpp
diff -u llvm/lib/Reoptimizer/Inst/rtl/pprtl.cpp:1.1 llvm/lib/Reoptimizer/Inst/rtl/pprtl.cpp:1.2
--- llvm/lib/Reoptimizer/Inst/rtl/pprtl.cpp:1.1	Thu May 22 08:08:59 2003
+++ llvm/lib/Reoptimizer/Inst/rtl/pprtl.cpp	Thu May 22 22:26:13 2003
@@ -1,6 +1,11 @@
 // Implementation of the performance primtive runtime library / "library of metrics"
 
 #include "pprtl.h"
+#include "papi.h"
+
+#include <sys/time.h>
+#include <stdio.h>
+#include <stdlib.h>
 
 void pp_elapsed_time_start(double* retVal) 
 {
@@ -28,4 +33,42 @@
     end = (tv.tv_sec * 1000000 + tv.tv_usec) / 1000.0; // convert to ms
     *retVal = end - *start;                            // compute diff
     printf("pp_elapsed_time_end returning %f\n", *retVal);
+}
+
+static void start_papi_sample(int* events, int numEvents) 
+{
+    if(PAPI_start_counters(events, numEvents) != PAPI_OK) {
+        fprintf(stderr, "Failed to start counter(s)!\n");
+        exit(1);
+    }
+}
+
+static void end_papi_sample(long_long* values, int numEvents)
+{
+    if(PAPI_stop_counters(values, numEvents) != PAPI_OK) {
+        fprintf(stderr, "Failed to stop counter(s)!\n");
+        exit(1);
+    }
+}
+
+void pp_L1_cache_miss_start(int* retVal)
+{
+    int events[1] = { PAPI_L1_ICM };
+    printf("pp_L1_cache_miss_start invoked: retVal addr is 0x%lx\n", (unsigned long) retVal);
+    start_papi_sample(events, 1);
+    *retVal = PAPI_L1_ICM;
+    printf("pp_L1_cache_miss_start returning!\n");
+}
+
+void pp_L1_cache_miss_end(int* retVal, int* start)
+{
+    long_long values[1];
+    
+    printf("pp_L1_cache_miss_end invoked!\n");
+    printf("Address of start is 0x%lx, value is %x\n", (unsigned long) start, *start);
+    fflush(stdout);
+
+    end_papi_sample(values, 1);
+    *retVal = values[0];
+    printf("pp_L1_cache_miss_end returning %d\n", *retVal);
 }


Index: llvm/lib/Reoptimizer/Inst/rtl/pprtl.h
diff -u llvm/lib/Reoptimizer/Inst/rtl/pprtl.h:1.2 llvm/lib/Reoptimizer/Inst/rtl/pprtl.h:1.3
--- llvm/lib/Reoptimizer/Inst/rtl/pprtl.h:1.2	Thu May 22 08:16:40 2003
+++ llvm/lib/Reoptimizer/Inst/rtl/pprtl.h	Thu May 22 22:26:13 2003
@@ -3,9 +3,6 @@
 #ifndef _INCLUDED_PPLIB_H
 #define _INCLUDED_PPLIB_H
 
-#include <sys/time.h>
-#include <stdio.h>
-
 #ifdef _BUILDING_RUNTIME_LIBRARY_
 extern "C" {
 #endif
@@ -15,6 +12,8 @@
     long     pp_timestamp(void);
     void     pp_elapsed_time_start(double* retVal);
     void     pp_elapsed_time_end(double* retVal, double* start);
+    void     pp_L1_cache_miss_start(int* retVal);
+    void     pp_L1_cache_miss_end(int* retVal, int* start);
     unsigned pp_counterPrim(void);
 
     // significant functions





More information about the llvm-commits mailing list