Next: Resolving Type Errors Up: The Concert Tutorial Previous: Using the Emulator

Compiling and Running Programs

After a program is debugged and tested using the emulator, it can be compiled to run production workloads. Currently, a CA program can be compiled for either the uniprocessor simulator running on a Sparc workstation or for the CM5. The Concert compiler first translates a CA program into C++ code and then invokes the Gnu g++ compiler to produce the final executable file.

In order to run the system, ensure that your path contains the concert driver script, which is located in the directory $CONCERT_ROOT_PATH/bin. You can run the compiler either from the command line or from within emacs. Running from the command line it operates much like the other batch compilers such as gcc. The compiler is invoked with the command concert, and it it prints out a short message describing the available flags when invoked with the -h option.


indigo-rilla > concert -h
Concert Compiler V2.0.1 Alpha Fri Feb 25 11:40:58 CST 1994
Bugs/comments to concert-bugs@red-herring.cs.uiuc.edu
Copyright (c) 1991, 1992, 1993, 1994
The University of Illinois Board of Trustees.
All Rights Reserved.
Usage: concert file file ... [-h] [-0] [-O2] [-g] [-p] [-C] [-L] [-I] [-e]
     -h        print this list
     -O        optimize CA
     -O2       optimize c++ (g++ -O2)
     -g        debugging information
     -p        profiling information
     -C        output c++ but do not compile
     -I        lisp interactive mode
     -L        assume happenstance locality
     -e        emulator

Basic Command Line Interface

The following shows the compilation of the fib program for the uniprocessor simulator from the command line.


indigo-rilla > concert fib-example.ca
Concert Compiler V2.0.1 Alpha Fri Feb 25 11:40:58 CST 1994
Bugs/comments to concert-bugs@red-herring.cs.uiuc.edu
Copyright (c) 1991, 1992, 1993, 1994
The University of Illinois Board of Trustees.
All Rights Reserved.
Input and Attribute Evaluation
Reading: /b/ca/concert2.0.1/lib/standard-prologue.ca...
...Closing: /b/ca/concert2.0.1/lib/standard-prologue.ca
Reading: fib-example.ca...
...Closing: fib-example.ca
Core Code Translation
Dominator Computation
Control Dependence Computation
Static Single Assignment Conversion
Type Inference
  Type Inference pass 1
Program Transformations
Output
Compilation Complete
27 Methods Output of 154 Compiled in 17 Classes
Compiling C++ Code

g++   -pipe  -I/b/ca/concert2.0.1//include -o fib-example.ca.1.o 
 -c fib-example.ca.1.cc
g++   -pipe  -I/b/ca/concert2.0.1//include -o fib-example.ca.o 
 -c fib-example.ca.cc
g++   -pipe  -o fib-example.ca.exec fib-example.ca.1.o fib-example.ca.o 
 /b/ca/concert2.0.1//lib/librt_uni.a /b/ca/concert2.0.1//lib/libg++.a -lm
indigo-rilla >

Note that there appears to be two source files: the given one and standard-prologue.ca. This second file contains the definitions of built in Concurrent Aggregates primitives. Once the compiler has successfully compiled a program, it generates several files. They are the executable program, the intermediate files containing the C++ intermediate code, and the object files. For a input program, filename, the compiler produces:

filename.*cc
as the C++ intermediate code,
filename.*o
as the object files, and
filename.exec
as the final executable program.

Running the .exec file executes the CA program. The result and the CPU time are displayed. Note that this time is the total processor time for the simulator, and so has nothing in particular to do with the program's execution time on a parallel machine. Below shows an execution of the fib program compiled previously.


indigo-rilla > fib-example.ca.exec

89 


program took 0.080000 seconds

-----------------------------------------------------------

Compiling Programs for the CM5

In order to generate and run CM5 executables, ensure that the concertCM5 driver script, which is also located in $CONCERT_ROOT_PATH/bin, is in your path. The only difference in compiling for SUN workstations and the CM5 is that the user program is linked to different runtime libraries. The procedure for generating an executable for the CM5 is as follows:

Compiler Options

Besides the -e option discussed previously, the Concert compiler has several additional options to control optimization levels and output files.

The compiler has three optimization levels. The first level, the default, is no optimization. This is the quickest way (outside of the emulator) to get a program to run, however, the resulting program will run relatively slowly.

The second level of optimization, using the -O flag, causes the Concert compiler to optimize the Concurrent Aggregates program before it generates C++ code. One of the feature of such optimization is an incremental type inference system. Depending on the use of object-oriented features of the language (particularly polymorphism) good type inference may involve several passes and hence more time. In addition, large programs may require lots of memory to optimize. When optimization is enabled, the Concert compiler will report type errors. This can be a good way to debug you program.

The third level of optimization causes the resulting C++ code to be compiled with optimization (-O2). Very large CA functions can result in very large C++ functions which may require large amounts of memory. The code resulting from the third level of optimization is by far the fastest. The flag -L tells the compiler to assume that objects may be local even if it has no other reason to suspect they might be. This option will increase code size and may produce faster execution on very small numbers of processors.

In addition, the -g flag enables the compiler to include debugging information. The -I flag invokes the compiler interactively. Commands available in the interactive mode are explained in the next section.

The compiler can also be invoked within emacs. To compile a file from within Emacs, you must be in that file's buffer. Typing M-c will cause Emacs to display the default compile command concert which you can edit to add whatever flags you desire. Then press enter and Emacs will invoke the compiler on the buffer's file.

Interactive Mode

In interactive mode, the effect of changing the compile switches can be achieved through functions calls.

(set-optimization-level N)
where N is 0, 1, or 2, sets the optimization level to no optimization, -O and -O2 respectively.
(precise-types)
enables full type inference but no optimization. This is useful when tracking down type errors.
(debugging)
sets debugging on.
(no-debugging)
sets debugging off.
(profiling)
sets profiling on.
(no-profiling)
sets profiling off.

Programs can be compiled with the following calls:

(ca "filename")
Compile the CA program and compile and link the resulting C++ code.
(ca2out "filename")
Compile the program CA program, leaving the C++ output uncompiled.

Compiler Error Messages

There are a wide variety of compiler error messages that you may see when using the Concurrent Aggregates compiler. Since this compiler is an ongoing research project, there is no guarantee that it works perfectly all of the time. Hence, the error messages are divided up into two categories: those that are caused by the program being compiled and those that are internal to the compiler. Naturally, if you see any of the second kind, they should be reported. We briefly describe some common messages here, [5] contains a complete listing of all Concert error messages.

Program Error Messages

The following are error messages that indicate that something is wrong with the program being compiled.

Class not defined
means that you have used a class that you have not defined. The most likely cause of this is misspelling of a user-defined or built-in class name
A ... expected
means that the compiler could not find the type of input that is was expecting. This indicates that your program has some piece of invalid syntax. Check the syntax of the form that signaled the error in the language description and check your program for typographical errors.
No ... can start with this
indicates that the compiler has found an invalid character in the file. This suggests a syntax error in your program. Check the syntax of the form that signaled the error in the language description and check your program for typographical errors.
Superclass ... not defined
indicates that a class inherits from a non-existent superclass. This is most often brought about by misspelling the superclass name, or by using a class name before it is defined in the file.
Warning: no type for ... in ...
means that the type inference system was unable to determine the type of a variable. This often indicates misuse of the variable. Check all usages of the indicated variable in the method.
Note: type check on ...
means that the type inference system was unable to prove that your program would execute without a runtime type error. This does not necessarily indicate an error, but if you program does have a runtime type error, this may indicate a place to start looking for the problem.

Compiler Error Messages

These are errors that you should never see, for they indicate that something has gone wrong with the compiler. They should be reported to the Concurrent Systems Architecture Group. As the compiler is an ongoing research project, it is possible that an error in your program will confuse it, and it will produce an internal error. Hence, the best policy with all of these error messages is to first check your program for obvious errors, and, if you do not find any, report the problem to the Concert development team (send mail to concert-bugs@red-herring.cs.uiuc.edu).

In case of these errors (and other) you will get a message like:


Concert compiler internal error [possible error in user program as well]
Check your code for an error and report the cause of this error to:
concert-bugs@red-herring.cs.uiuc.edu

Executing a Concurrent Aggregates Program

The executable program produced by the compiler has several builtin command line options. Executing the program with the -h option, for example, simply prints out a list of runtime options, as shown below for the fib program.


indigo-rilla > fib-example.ca.exec -h

usage prog [-n NUM_PROCS] [-t] [-p] [-a RANDOM/LOCAL] [-s RATE] [-m MEMORY]
     -n NUM_PROCS             set the number of processors
     -t                       enable message tracing with debugging
     -p                       enable performance profiling
     -a RANDOM/LOCAL             set aggregate send policy
     -s RATE                  set events/sample rate
     -m MEMORY                set total memory usage of nodes (in MB)

The following command line options are admissible on both the CM5 and the uniprocessor simulator:

-n NUM_PROCS
controls the number of processors which should be used for running the program. Note that this number should be smaller than the size of the CM5 partition which is used for running the job. On the simulator, this option controls the number of processors simulated, and if used in conjunction with the concurrency statistic (described below), allows determining how much concurrency a program has.
-a RANDOM/LOCAL
controls how messages are mapped to aggregate representatives. LOCAL always maps a message to the representative nearest the originator (that is, to a local representative) and RANDOM maps messages to arbitrary representatives.
-m MEMORY
controls the memory utilization of the program. The supplied argument (given in units of MBytes) determines the total memory usage (over all the processors). The default value for the simulator is set at 16MB (this amount is split up among the simulated processors), and for the CM5 is set at 8MB per node. The maximum value of this option is limited on the simulator by the configured swap space, and by the per-node memory on the CM5.

The additional command line options -t, -p, and -s are used for collecting statistics and debugging. They are described in sections 9 and 8.



Next: Resolving Type Errors Up: The Concert Tutorial


Julian Dolby
Vijay Karamcheti
John Plevyak
Xingbin Zhang
Concurrent Systems Architecture Group