COMP-621 Optimizing Compilers Winter 2006 Notes
COMP-621
Home
A general note on resourcefulness
Index of Information on this Page
News News News
16-02-2006 - Benchmarks - The benchmarks for this year are now available in a tar.gz package here (16.6mb). One or two of them are tied to SABS but otherwise it's mostly just java/aj files that can be compiled normally. Each benchmark has a 'benchmark.txt' with comments about the program and a README (or readme.txt, or README.txt) which gives compiling/running instructions.
13-02-2006 - Screenshots - if you are looking for a good way to capture screenshots try the Gimp (Gnu Image Manipulation Program). It's a pretty useful open-source image processor. It is already installed on the lab machines (or Sable machines) and can be executed with the command gimp. To acquire a screenshot, follow the File - Acquire - Screen Shot menu structure. This is a good way to handle your screenshots because the Gimp can save in practically any file type you might want (e.g. eps files for latex).
If you are using Windows, the PrtScrn key and MS Paint should work well, though there is a Gimp version available for Windows.
09-02-2006 - If anyone has problems getting Eclipse and the Soot plugin set up, please let me know and I will help sort things out. It should be fairly simple. I tested both Eclipse 3.0.1 and Eclipse 3.1.1 with no problems following the directions given in the Soot Plugin Intall instructions and Jennifer's how-to on using your own Soot main class in the plugin. If you would like to test your setup with an example main class, put this file in your myclasses directory and try to run it. It is a simple driver which tags all assignment statements with the color blue: AssignStmtDriver.java compiled: AssignStmtDriver.class. You might be interested in looking at the code for that class in order to get the general idea of how to add tags.
09-02-2006 - More Info for Assignment #2 - Jennifer of the Soot Eclipse plugin fame has written up a short Wiki on how to get your own soot Main class working with the plugin (so that you can run your analysis/tagger directly from Eclipse). You can find it here on the sable svn here. You will need to make sure that you have the Soot plugin installed, of course. If you are using the lab machines I suggest installing it in your own directory (something like ~/eclipsePlugins/). You can then follow Jennifer's instructions on how to point the plugin to your own soot extensions. You can then run any Soot main class by right-clicking on a java file in your eclipse package view and following the Soot - Process [Source/Class] Files menu structure. There are default options to generate Jimple or Grimp but if you want to specify your own main class you will need to select Manage Configurations and create a new configuration. Enter your fully-qualified main class in the last preference panel in the soot plugin configuration (called Soot Main Class). You can now run soot using this menu structure. The resulting output files will show up in your project under the directory "sootOutput" as you are familiar with. If those files (jimple, java, etc) have been tagged then these tags should show up if you open the files in Eclipse.
07-02-2006 - Information for Assignment #2 - This assignment may require a bit of work getting software downloaded, installed, and working. Don't wait till the last minute or you may find yourself in a bind. Specifically, here are things you will need:
- A working source install of soot - To get the latest version you can use svn. The instructions are here (under "repository access"). Please note that you will, of course, need to have a svn client installed on your machine. If you are unfamiliar with svn then try reading the man page ("man svn" at a linux command prompt) or the Wiki entry. You can also just download the soot source in a jar or tar.gz from the download page. Note that you will need jasmin and polyglot. If you plan on using the CS lab machines to do your work you will need some extra space. You can ask the SOCS help desk for more space by emailing help @ cs mcgill ca (fix the spamified email).
- The Eclipse IDE. The latest version can be downloaded here. However, if you are working in the CS labs, it is already installed. You can run it from the command line by calling 'eclipse-3.1' or find it on your applications menu (3.1 is required for the Soot plugin). If you run into problems installing, start by checking the FAQ. Remember, it's written in Java so you will need a working JDK but I presume you have one by now!
- Knowledge of how to implement a new analysis and transformer. You can read the Soot tutorial on flow analysis here. It gives a good overview of what you will need to get started. For some example source files which outline a flow analysis, check out FlowAnalysisClass.java (which implements the actual analysis) and AnalysisDriver.java (which implements a main method to start soot with and adds an inner-class BodyTransformer which uses the analysis to add tags to a method body). Realize these are outlines, not fully functioning classes. An example of how to call your personally-created main method (see AnalysisDriver) is as follows:
java soot.YOURPACKAGE.AnalysisDriver [soot options] [files]
In the example AnalysisDriver source, there is no package so simply adding the class to your classpath and calling 'java AnalsysiDriver' should work fine. Note that because AnalysisDriver explicitly adds the transformer to the pack manager you do not need to deal with any specific command line arguements for your analysis or transformer.
- If you have properly run your analysis and transformer (which tags the output files) then you should be able to open the output files and see your tags in Eclipse if your Soot Eclipse plugin is properly installed
- Jennifer, who developed the Soot Eclipse plugin, has added her thesis to the Sable research page here. You might find Chapter 5 most useful for this assignment.
07-02-2006 - I have looked over everyone's assignment #1. As a general note on graduate school and personal pride in one's work I have the following suggestions when submitting things - even if it's only a homework assignment:- Spell-check your work. Sloppy spelling is easy to fix so there is no good excuse for it. If grammar is not your forte, consider running your work through Microsoft Word or a similar product which makes grammar suggestions.
- Hand in well formatted print-outs. Proof read what you are going to hand in to check for printing mistakes and other errors.
- If you hand-write something, look it over and ask yourself if you would want to have to correct it.
- If you hit a stumbling block, try harder. Nobody likes a quitter. Try Google, man pages, and mailing-lists (and start your work early enough that you have the time to do this).
- When adding data to your work try to present it in the most concise and readable fashion. Charts, graphs, and tables are good for this. Clearly label elements. Do not use descriptors such as "int" and "cli" when "interpreter" and "client" are appropriate - even if the person reading your work is familiar with the topic. If they have difficulty understanding things immediately they are more likely to stop reading.
- When running experiments such as performance measurements it is always good to state the hardware and software used. Also, run the tests five to ten times each and throw out the highest and lowest results before averaging. Clearly state this, and anything else pertinent to the running of your experiments. If someone does not have enough information to recreate your experiments cloesly then there is little worth to your findings.
- Always ask yourself if you've a) only stated the well-known answer or if b) you've gone the extra step to try and investigate further. If a, seriously consider b.
- Clearly label your work. Name, ID#, email address, and course number at a minimum. Submit all of your work as a cohesive unit. If you are sending a file do not label it generically such as "cs621_ass1" - add your name in the file name as a unique identifier.
- In general, have pride in your efforts and respect in yourself to submit what you consider to be good work
31-01-2006 - I have updated the ~cs621/Winter2006 directory and scripts. There were some problems initially with permissions and classpaths but they should all be fixed now. The ~cs621/abc-1.1.0/bin/abc script should now work without any problems as well as ~cs621/soot-2.2.2/soot. These scripts do assume that 'java' resolves to a proper java JVM so make sure this works. Sorry for the problems.
Helpful Questions And Answers
Throughout the course, if I get asked a good question I will respond to
all students in the class. I will try to also remember to post the responses
on this page as well.
Jan. 23rd Question #1: Logging into lab machines remotely.
Soot
In this course you will need to run Soot, both from the command line
and using the Eclipse plugin.
Soot is installed in ~cs621/Winter2006/ on the lab machines. To
run it, you need a suitable Java runtime, and Soot's classes need to be
on your classpath.
I have setup a script that will help you run Soot. It is located at:~cs621/Winter2006/soot-2.2.2/soot
You can put this directory in your path, and run soot by simply calling that script 'soot' without having to include the full path - this script sets up the classpath for you. Please note that you will probably want to specify your java runtime classes as an argument to the soot classpath. These are in a jar located in your java JRE/lib directory called rt.jar.
If you want to setup your own shell to include the proper classpaths and such, Minimally you need:
export
JAVADIR=/opt/sun-jdk-1.4.2.10
export PATH=$JAVADIR/bin:$PATH
export
CLASSPATH=.:~cs621/Winter2006/jasmin-2.2.2/classes:~cs621/Winter2006/polyglot-1.3.2/classes:~cs621/Winter2006/polyglot-1.3.2/cup-classes:~cs621/Winter2006/soot-2.2.2/classes
in your .profile for bash, or the setenv equivalents for csh. If you're having trouble and want to take a look at my .bashrc file, it's here.
$ java soot.Main
should then work (Make sure you're getting version 2.2.2). The above location of Java is for the lab7-x
machines at McGill, other machines will have different configurations.
Eclipse Soot Plugin
You will need to install the Eclipse plugin yourself. Make sure to use eclipse-3.1 as this is the version that the plugin was designed for. The SOCS staff has installed the plugin but it is still not working properly. I will try and get them to fix this. For now, you can install the plugin yourself by following the directions here:Eclipse Soot Plugin Installation
Please Note that you will have to specify an install directory somewhere within your own home folder, since you won't have write permissions to /usr/lib/. Just create a folder somewhere that will be out of the way, and make sure to specify it when installing the plugin. I have tried this out and it works fine.
Don't rely on SOCS to get the plugin working in time. If you want to modify either the Eclipse plugin or Soot, or to run them locally whilst not at a lab machine, you will obviously need to get the sources yourself. Instructions and files can be found in the links below. Note that writing analyses and transformations that use the Soot framework doesn't necessarily require modification of code in the Soot distribution.
Soot Links
Once this is working, there are in-depth tutorials available from the
Soot homepage.
Soot Home
How-To Set up a Soot Project in Eclipse
Soot API
Eclipse Plugin for
Soot
Eclipse 3.0.1 Downloads
Profiling
As stated earlier, the Sun 1.4.2_10 JDK is installed in /opt/sun-jdk-1.4.2.10. Additional JDKs/VMs are also available:
You can run java with the -help option to see available options. Note the all-important -X
option, which prints help on many "hidden" options.
For profiling, we gather data using the built-in hprof program, invoked
with the -Xrunhprof option. Start with java -Xrunhprof:help to
see the different ways of collecting data. You can use the heap,
cpu, and monitor flags to do time, space, and contention profling, and
you can write the data to a text file. For help, check here:
Using
hprof
Also, feel free to investigate other Java profilers. Many exist, the following is a short sampling:
AspectJ
Version 1.1.0 of the AspectBench Compiler for AspectJ, abc, is installed in
~cs621/Winter2006/abc-1.1.0/ and within this directory there is a /bin directory with a script 'abc' to run it. This script sets the proper classpath for abc to run.
The IBM AspectJ compiler, ajc (now associated with the Eclipse Foundation), is installed in
~cs621/Winter2006/ajc-1.2.1
More information on how to use these compilers is available from their
home pages.
AspectBench Compiler
Home
ABC download
page
AspectJ Home
The following notes appeared at the end of the ajc-1.2.1 installation
process:
The automatic installation process is complete. We recommend you
complete the installation as follows:
1) Add /home/course/cs621/Winter2006/ajc-1.2.1/lib/aspectjrt.jar to
your CLASSPATH. This small .jar file contains classes required by any
program compiled with the ajc compiler.
2) Modify your PATH to include
/home/course/cs621/Winter2006/ajc-1.2.1/bin. This will make it easier
to run ajc and ajbrowser.
These steps are described in more detail in
/home/course/cs621/Winter2006/ajc-1.2.1/README-AspectJ.html.
Benchmarks
2006 class benchmarks (16.61mb .tar.gz)
2005 class benchmarks (3.1mb .tar.gz)
2003 class benchmarks (2.3mb .jar)
2002 class benchmarks (2.5mb .jar)
Benchmark description form
Existing AspectJ benchmarks
Useful Information
Question #1: Logging in to the lab machines remotely
is it currently possible to access the lab for the comp621
course remotely, via ssh? It would be most useful for the assignments!
Could you indicate me some documentation for this or a similar access?
You can most certainly access lab computers remotely using ssh. I'll give
you some information here, but you can also check out the SOCS docs for SSH
here:SOCS SSH page
SOCS actually has a fairly good set of documentation for the services and facilities in the labs. The index is here:SOCS Help Index
Anyhow, to login to a lab machine simply use:ssh user@labX-Y.cs.mcgill.ca
where 'user' is your cs login name, and X is the lab you would like to login to and 'Y' is one of the available computers (usually from 1 to 20 is available, if not more, for each lab). I generally use lab 6 or 7, but you may use whatever machines you'd like. Here is a concrete example for me (using my login 'mbatch'):ssh -XC mbatch@lab6-2.cs.mcgill.ca
If you would like to use graphical programs remotely, this is also possible if you have an X-server on your remote machine. The '-XC' option specifies that ssh should do port-forwarding for X windows (so you can run graphical displays remotely) and to compress the network traffic.
If you have a linux machine you will of course have an X-server already.
It is also very easy to get an X-Server running on a Mac OSX machine, if
that is what you have. See the website here:X11 for Mac OS X
You can get a Microsoft Windows X-server running using Cygwin/X at:Cygwin/X
If you want to run a graphical program and maintain use of your shell prompt, call the programs in the background like this:(prompt): eclipse &
The trailing '&' symbol will run the program "in the background" (but since it is graphical, you will see the windows).
If you're unsure of what a particular program is called use a bash shell and use tab-completion. For example, typing "ec " in my shell lists the available options quite nicely:echo echo-client-2 eclipse eclipse-2.1 eclipse3.0.1