[llvm-commits] CVS: llvm/lib/Reoptimizer/LightWtProfiling/Trigger/FirstTrigger.cpp GetTimer.h Makefile SLI.cpp SecondTrigger.cpp Timer.cpp

Brian Gaeke gaeke at cs.uiuc.edu
Tue Aug 5 13:22:01 PDT 2003


Changes in directory llvm/lib/Reoptimizer/LightWtProfiling/Trigger:

FirstTrigger.cpp updated: 1.5 -> 1.6
GetTimer.h updated: 1.1 -> 1.2
Makefile updated: 1.2 -> 1.3
SLI.cpp updated: 1.1 -> 1.2
SecondTrigger.cpp updated: 1.2 -> 1.3
Timer.cpp updated: 1.1 -> 1.2

---
Log message:

Miscellaneous cleanups.

FirstTrigger.cpp, SecondTrigger.cpp: Rewrite top-of-file comment.
 Remove excess #includes; include C++ versions instead of C versions.
 Rewrite some comments and remove some dead code & variables.
 Take default values of env. variables from #defines in GetTimer.h.
GetTimer.h: Add top-of-file comment and #include guards.
 Move more configuration variables into this file.
Makefile: Get rid of excess LIBRARYNAME definitions.
SLI.cpp: Remove excess #includes.
Timer.cpp: Include C++ headers instead of C versions, and include GetTimer.h.
 Remove some dead code & variables.
 Take default values of env. variables from #defines in GetTimer.h.


---
Diffs of the changes:

Index: llvm/lib/Reoptimizer/LightWtProfiling/Trigger/FirstTrigger.cpp
diff -u llvm/lib/Reoptimizer/LightWtProfiling/Trigger/FirstTrigger.cpp:1.5 llvm/lib/Reoptimizer/LightWtProfiling/Trigger/FirstTrigger.cpp:1.6
--- llvm/lib/Reoptimizer/LightWtProfiling/Trigger/FirstTrigger.cpp:1.5	Fri Jul 18 17:45:59 2003
+++ llvm/lib/Reoptimizer/LightWtProfiling/Trigger/FirstTrigger.cpp	Tue Aug  5 13:21:26 2003
@@ -1,9 +1,10 @@
-//==llvm/Reoptimizer/LightwtProfiling/Trigger/FirstTrigger.cpp----*- C++ -*--=//
-// Implements First level trigger function
+//===-- LightWtProfiling/Trigger/FirstTrigger.cpp ----------------*- C++ -*--=//
 //
-// The trigger function is called at run time by instrumented code.
-//     The trigger function must analyse, and potentially optimize
-//     the trace that executes
+// This file implements the reoptimizer's first-level trigger.  The
+// first-level trigger is a call, placed at the back-edge of each loop, to
+// the function llvm_first_trigger(). It counts how many times each branch
+// is taken, and if the counter exceeds a threshold, performs second-level
+// instrumentation on the loop.
 //
 //===----------------------------------------------------------------------===//
 
@@ -11,27 +12,24 @@
 #include "llvm/Reoptimizer/InstrUtils.h"
 #include "llvm/Reoptimizer/TraceCache.h"
 #include "llvm/Reoptimizer/GetTraceTime.h"
-#include <sys/time.h>
-#include <stdlib.h>
-#include <sys/time.h>
-#include <iostream>
-#include <fstream>
 #include "llvm/Reoptimizer/CFG.h"
+#include <sys/time.h>
+#include <cstdlib>
 #include <algorithm>
 #include "GetTimer.h"
+#ifdef __sparc
+#include <libcpc.h>
+#endif
 
 using namespace std;
 
 extern long THRESHOLD_LEVEL_2;
 extern long LEVEL_TWO_EXITS; 
 
+// Function used as space for the trace cache:
+extern int dummyFunction2(int);
 
-#ifdef __sparc
-#include <libcpc.h>
-#endif
-
-//global counters for diagonistcs
-//extern "C" int initialize_timer();
+// Global counters for diagnostics:
 int initialize_timer();
 extern uint64_t llvm_interval_counter;
 extern std::map<uint64_t, int> exitCounter;
@@ -39,21 +37,11 @@
 extern std::map<uint64_t, uint64_t> firstTriggerAddr; //tracestart addr
 extern std::map<uint64_t, std::pair<long, long> > backOffCounters; 
 
-#ifdef GET_ALL_INFO
-int global_threshold2;
-#endif
-
-//#define THRESHOLD_LEVEL_2 50
-
-//good, bad backoff
+// Good, bad backoff
 void insert_address_at(uint64_t n, uint64_t m);
-
 void doInstrumentation(uint64_t addr1, uint64_t addr2, VirtualMem *vm);
 
-//function used as dummy function
-int dummyFunction2(int);
-
-int reopt_threshold=30;
+int reopt_threshold = DEFAULT_THRESHOLD_LEVEL_1;
 int exit_count=0;
 
 TraceCache *tr;
@@ -77,14 +65,14 @@
   if(getenv("THRESHOLD_LEVEL_2")!=NULL)
     THRESHOLD_LEVEL_2 = atoi(getenv("THRESHOLD_LEVEL_2"));
   else
-    THRESHOLD_LEVEL_2= 50;
+    THRESHOLD_LEVEL_2= DEFAULT_THRESHOLD_LEVEL_2;
 
   LEVEL_TWO_EXITS = THRESHOLD_LEVEL_2/3;
 
   if(getenv("THRESHOLD_LEVEL_1")!=NULL)
     reopt_threshold = atoi(getenv("THRESHOLD_LEVEL_1"));
   else
-    reopt_threshold = 30;
+    reopt_threshold = DEFAULT_THRESHOLD_LEVEL_1;
 
   *t=30;
 


Index: llvm/lib/Reoptimizer/LightWtProfiling/Trigger/GetTimer.h
diff -u llvm/lib/Reoptimizer/LightWtProfiling/Trigger/GetTimer.h:1.1 llvm/lib/Reoptimizer/LightWtProfiling/Trigger/GetTimer.h:1.2
--- llvm/lib/Reoptimizer/LightWtProfiling/Trigger/GetTimer.h:1.1	Fri Jul 18 11:06:05 2003
+++ llvm/lib/Reoptimizer/LightWtProfiling/Trigger/GetTimer.h	Tue Aug  5 13:21:26 2003
@@ -1,6 +1,26 @@
-//Define common #defines here
-//#define GET_ALL_INFO
+//===-- GetTimer.h - LightWtProfiling reoptimizer knobs ----------*- C++ -*-==//
+//
+// Configuration parameters for the LightWtProfiling reoptimizer.
+//
+//===----------------------------------------------------------------------===//
 
+#ifndef GETTIMER_H
+#define GETTIMER_H
+
+#define GET_ALL_INFO
+// #undef GET_COVERAGE
 #define MAX_PATH_HISTORIES 12
 #define MAX_ALLOWED_PATHS 6
 #define THRESHOLD_PERCENTAGE 90
+
+// Default values for the THRESHOLD_LEVEL_2 and THRESHOLD_LEVEL_1
+// environment variables, used in FirstTrigger.cpp and SecondTrigger.cpp
+#define DEFAULT_THRESHOLD_LEVEL_2        50
+#define DEFAULT_THRESHOLD_LEVEL_1        30
+
+// Default values for the LLVM_TIMER_INTERVAL_SEC and LLVM_TIMER_INTERVAL_MSEC
+// environment variables, used in Timer.cpp
+#define DEFAULT_LLVM_TIMER_INTERVAL_SEC  3
+#define DEFAULT_LLVM_TIMER_INTERVAL_MSEC 0
+
+#endif // GETTIMER_H


Index: llvm/lib/Reoptimizer/LightWtProfiling/Trigger/Makefile
diff -u llvm/lib/Reoptimizer/LightWtProfiling/Trigger/Makefile:1.2 llvm/lib/Reoptimizer/LightWtProfiling/Trigger/Makefile:1.3
--- llvm/lib/Reoptimizer/LightWtProfiling/Trigger/Makefile:1.2	Fri Jul 18 11:04:09 2003
+++ llvm/lib/Reoptimizer/LightWtProfiling/Trigger/Makefile	Tue Aug  5 13:21:26 2003
@@ -1,12 +1,5 @@
 
 LEVEL = ../../../..
-ifdef GET_COVERAGE
-LIBRARYNAME = firstTrigger2
-else
-ifdef GET_EXTENSIVE
-LIBRARYNAME = firstTrigger3
-else
 LIBRARYNAME = firstTrigger
-endif
-endif
+
 include $(LEVEL)/Makefile.common


Index: llvm/lib/Reoptimizer/LightWtProfiling/Trigger/SLI.cpp
diff -u llvm/lib/Reoptimizer/LightWtProfiling/Trigger/SLI.cpp:1.1 llvm/lib/Reoptimizer/LightWtProfiling/Trigger/SLI.cpp:1.2
--- llvm/lib/Reoptimizer/LightWtProfiling/Trigger/SLI.cpp:1.1	Fri Jul 18 11:03:45 2003
+++ llvm/lib/Reoptimizer/LightWtProfiling/Trigger/SLI.cpp	Tue Aug  5 13:21:27 2003
@@ -9,9 +9,6 @@
 #include "llvm/Module.h"
 #include "GetTimer.h"
 #include <algorithm>
-#include <iostream>
-#include <vector>
-#include <map>
 
 using namespace std;
 


Index: llvm/lib/Reoptimizer/LightWtProfiling/Trigger/SecondTrigger.cpp
diff -u llvm/lib/Reoptimizer/LightWtProfiling/Trigger/SecondTrigger.cpp:1.2 llvm/lib/Reoptimizer/LightWtProfiling/Trigger/SecondTrigger.cpp:1.3
--- llvm/lib/Reoptimizer/LightWtProfiling/Trigger/SecondTrigger.cpp:1.2	Fri Jul 18 11:07:16 2003
+++ llvm/lib/Reoptimizer/LightWtProfiling/Trigger/SecondTrigger.cpp	Tue Aug  5 13:21:27 2003
@@ -1,10 +1,10 @@
-
-//==llvm/Reoptimizer/LightwtProfiling/Trigger/SecondTrigger.cpp----*- C++ -*--=//
-// Implements Second level trigger function
+//===-- LightWtProfiling/Trigger/SecondTrigger.cpp ---------------*- C++ -*--=//
 //
-// The trigger function is called at run time by instrumented code.
-//     The trigger function must analyse, and potentially optimize
-//     the trace that executes
+// This file implements the reoptimizer's second-level trigger.
+// Second-level instrumentation is performed by the first-level trigger
+// function (see FirstTrigger.cpp). It records the paths taken through the
+// instrumented region, as well as the number of early exits taken from
+// the region.
 //
 //===----------------------------------------------------------------------===//
 
@@ -18,12 +18,8 @@
 #include "llvm/Module.h"
 #include "GetTimer.h"
 #include <sys/time.h>
-#include <stdlib.h>
-#include <sys/time.h>
 #include <sys/types.h>
-#include <iostream>
-#include <fstream>
-#include <map>
+#include <cstdlib>
 
 #ifdef __sparc
 #include <libcpc.h>
@@ -32,9 +28,6 @@
 using std::map;
 using std::vector;
 using std::pair;
-
-//#define GET_COVERAGE
-//undef GET_COVERAGE
 
 extern "C" void llvm_time_end2();
 extern "C" void llvm_time_start();


Index: llvm/lib/Reoptimizer/LightWtProfiling/Trigger/Timer.cpp
diff -u llvm/lib/Reoptimizer/LightWtProfiling/Trigger/Timer.cpp:1.1 llvm/lib/Reoptimizer/LightWtProfiling/Trigger/Timer.cpp:1.2
--- llvm/lib/Reoptimizer/LightWtProfiling/Trigger/Timer.cpp:1.1	Fri Jul 18 17:46:34 2003
+++ llvm/lib/Reoptimizer/LightWtProfiling/Trigger/Timer.cpp	Tue Aug  5 13:21:27 2003
@@ -1,12 +1,10 @@
 #include <unistd.h>
 #include <signal.h>
 #include <sys/time.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#define INTERVAL_USEC 000000
-#define INTERVAL_SEC  10
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include "GetTimer.h"
 
 extern "C" void do_timer_interval();
 uint64_t llvm_interval_counter;
@@ -15,9 +13,6 @@
 sigset_t sig_old;
 sigset_t sig_all;
 
- 
-
-
 void mask_interrupt()
 {
   //sigprocmask(SIG_BLOCK, &sig_usr2, &sig_old);
@@ -52,8 +47,7 @@
 
 int initialize_timer()
 {
-  //printf("Intializing timer\n");
-  int duration_sec=0, duration_msec=0;
+  int duration_sec, duration_msec;
   //struct sigaction *nvec, *ovec;
   timer_t timer_id;
   struct sigevent timer_evp;
@@ -66,11 +60,11 @@
   //duration of timer
   if(getenv("LLVM_TIMER_INTERVAL_SEC")!=NULL)
     duration_sec = atoi(getenv("LLVM_TIMER_INTERVAL_SEC"));
-  else duration_sec = 3;
+  else duration_sec = DEFAULT_LLVM_TIMER_INTERVAL_SEC;
   
   if(getenv("LLVM_TIMER_INTERVAL_MSEC")!=NULL)
     duration_sec = atoi(getenv("LLVM_TIMER_INTERVAL_MSEC"));
-  else duration_msec = 0;
+  else duration_msec = DEFAULT_LLVM_TIMER_INTERVAL_MSEC;
 
   if(timer_create(CLOCK_REALTIME, &timer_evp, &timer_id)<0)
     printf(" error\n");





More information about the llvm-commits mailing list