Table of Contents
Previous Chapter
The following tutorials assume that the user has read Chapters 1,2 and 4 of this manual and has a basic familiarity with graphical interfaces which employ mice and menus to communicate with users, with X windows, and with UNIX commands and editors. These tutorials will guide you, step by step, through the process of creating and running CODE programs.
In this example we will be creating a CODE program that sums the elements of a 100 element vector. We first initialize two vectors of 50 elements each and then add the two vectors separately, in parallel. The resulting partial sums are then added to produce the final sum.
Contents of the Tutorial
I. Preliminaries
I. Preliminaries
Get the X-Windows system running. Create a directory to hold the files associated with the program and
cd to that directory. Before running CODE, ensure that it is present on your UNIX path (or be prepared to type a complete path name). Then enter
code2 sumvector.grf
at the UNIX prompt. This will run CODE and create a program called "sumvector." A single window will be opened and all activity will take place within it. Figure 4.1 shows the CODE window.
II. Entering Example 1
Our goal is to draw the following graph:
Figure 5.1.1
You may enter and annotate the nodes and arcs of your program in any order, but we will adopt the following sequence of operations:
Step 1. Draw all the nodes and arcs in a graph.
By doing this regularly you can avoid losing your work in case of a system crash.
Before we start, it is important to point out that you should save your work periodically. Then, in the (unlikely of course!) event that the CODE system crashes, your work will not be lost.
To save your work as you go, click on the Save button at the upper right of the banner line.
Correcting mistakes:
STEP 1. Draw all the Nodes and Arcs in a Graph
A. Draw all the nodes.
1.Draw the UC node, INIT by
a. Position the create cursor in the CODE window, where the UC INIT is to be located.
2. Draw the UCs ADD1, ADD2, and PRINTSUM.
.
B. Draw all the arcs.
1. Draw the arc V1 by,
a. With the create cursor, click on the lower arrow of UC, INIT.
2. Draw the arcs V2, SUM1 and SUM2.
At this point the graph looks like Fig. 5.1.2.
Fig. 5.1.2
A. Enter information about the nodes
1. Enter information about INIT
b. Click the open cursor on the UC INIT to open its attribute form. It looks like Fig.5.1.3
c. Click on the node name field and a text box will appear. Enter the name 'INIT' in this
d. The value in the UID field is automatically generated by CODE. It is a debugging aid
Fig. 5.1.3
i. To exit the UC INIT attribute form, click on the white space outside the form in the
cursor.
Specification field of ADD1 is as shown below,
3. Enter information about ADD2 as in 1.
Specification field of ADD2 is as shown below,
4. Enter information about PRINTSUM as in 1.
code to be entered in the Node Specification field of PRINTSUM is as shown below,
The name 'INIT' will be displayed next to the node, but you can move it with the Move
2. Enter information about ADD1 as in 1.
The one difference is that ADD1 is not a Start node. The code to be entered in the Node
The one difference is that ADD1 is not a Start node. The code to be entered in the Node
The one difference is that PRINTSUM must be designated as a termination node. The
B. Enter information about the arcs
1. Enter information about V1
a. Click the open cursor on the arc V1 to open its attribute form. It looks like Fig. 5.1.5.
Fig.5.1.5
c. The value in the UID field is automatically generated by CODE.
d. Click on the Arc Topology Rule field and another text box will appear. The code to be
e. Exit from both the text box and the form by clicking on the white space outside the
The name 'V1' will be displayed next to the arc, but you can move it with the Move cursor.
2. Enter information about V2, SUM1 and SUM2 as in 1.
The Arc Topology Rule field of V2 is,
The Arc Topology Rule for SUM1 is,
The Arc Topology Rule for SUM2 is,
C. Enter information about the program
a. Click the open cursor on the Program button in the CODE window, to open its
Fig.5.1.6
c. Click on the Global Types field and a text box will appear. The code to be entered in
d. Click on the Global Function Signatures field and another text box will appear. The
e. The Global Function Definitions and Documentation fields are to be left blank.
f. Click on the Translation Options field, to bring up it's attribute form. Now, click on the
g. Exit from the program form by clicking on the white space outside the form in the
III. Executing Example1 on the Sequent
We will now compile and run the program in the following order:
Step 1. Save and compile the program.
STEP 1. Save and Compile the Program
a. Click on the Save button.
example1.
At this stage, the following files and directories will be present under the directory
STEP 2. Create the Files which record the Node Function Definitions
$cd ./sumvector.sequent The following files will be present in this directory.
$vi filename.c Record all node function definitions in this file. Give it the same
These will be present in the directory in which CODE2 has been
installed.
STEP 3. Create the executable and run it
you must do is get the generated source files onto a sequent and enter "make" to compile
them. You must also have compiled any external source files that you wish to link with the
CODE program. See the Chapter on `Translating and Running Programs' for the details.
At the University of Texas Department of Computer Sciences, the following command
should be given to login onto the Sequent.
$make This will create the executable 'sumvector'.
below,
These operations will depend on how your workstation is connected to the Sequent. What
$rlogin qt
After having logged in on the Sequent, give the following commands,
$cc -c filename.c Compile the file specifying node function definitions.
$./sumvector Run the executable. The output displayed should be that shown