Top Up Prev Next Bottom Contents Index Search

1.6 Building standalone programs that use Ptolemy libraries.

Sometimes it is necessary to create small standalone programs that use part of the Ptolemy libraries.

Examples of this are the desire to use Ptolemy kernel classes such as StringList or the need to isolate an obscure bug or memory leak. The $PTOLEMY/mk/ file provides the make definitions to make this possible. This file provides make rule definitions to build various binaries some using the Pure Sofware Inc.1 utilities.

The usage for this makefile is:

make -f $PTOLEMY/mk/ stars.mk_variable_defs filename.suffix

Where stars.mk_variable_defs is zero or more makefile variables used in $PTOLEMY/mk/, such as SDF=1. filename is the base name of the file to be compiled, and the basename of the output file. and
Suffix Binary Type
.bin Standard binary
.debug Binary with debug symbols
.purify Binary with Purify and debug symbols
.quantify Binary with Quantify linked in
.purecov Binary with Pure Coverage linked in
suffix is one of the forms listed in table

TABLE 1-1: Table of filename suffixes and binary types.

It is possible to use these makefiles to create binaries that do not have any Ptolemy code. A reason why you might want to do this is to take advantage of the Pure Software make definitions in To specify no Ptolemy libraries, use the make argument NOPTOLEMY=1.

1.6.1 Standalone example using StringList

For example, say you want to use the StringList class in a standalone program named

#include "StringList.h"
main() {
StringList testing = "This is a test\n";
cout << testing;
To build it you would type:

make -f $PTOLEMY/mk/ bar.bin If you wanted to make a new standalone program that also uses part of the CG domain, just define the domain make variables (as used in on the make command line:

make -f $PTOLEMY/mk/ CG=1 bar.bin If you are going to do this often, it may be useful to create a new directory in which to test this program. In this directory, execute the commands:

ln -s $PTOLEMY/mk/ makefile
ln -s $PTOLEMY/mk/ make.template
By having these symbolic links, you will not have to supply the make argument
-f $PTOLEMY/mk/ as before.

1.6.2 Standalone example that tests a Scheduler

Here is an example of a minimal file that can be used to call the setup in a Scheduler for instance. If the file contains:

#include <iostream.h>
#include "Galaxy.h"
#include "SDFStar.h"
#include "AcyCluster.h"
#include "AcyLoopScheduler.h"
#include "SDFPortHole.h"

main() {
// First create a simple galaxy and some stars.
SDFStar star[3];
Galaxy topGalaxy;

// Add ports to stars.
OutSDFPort p0,p1;
InSDFPort p2,p3;

// initialize the ports

// Connect `em up. The graph is
// star[1] (3) <--- (2) star[0] (3) ---> (2) star[2]

// Scheduling
AcyLoopScheduler sched;
cout << "No problem till now. Calling sched.setup()...\n";
int i;
for (i = 0 ; i < 3 ; i++) {
cout << star[i].fullName() << "\n";
cout << "Repetitions = " << star[i].reps() << "\n";
StringList sch = sched.displaySchedule();
cout << sch;
The command to compile this and produce a standalone binary would be:

make -f $PTOLEMY/mk/ OPTIMIZER= SDF=1 \
USE_SHARED_LIBS=yes testAcyLoopSched.debug

Top Up Prev Next Bottom Contents Index Search

1 Rational ( sells tools such as:
Purify, which can be used to find memory leaks and out of bounds memory accesses.
Quantify, which can be used to profile performance.
Purecov, which can be used to provide code coverage information.

Copyright © 1990-1997, University of California. All rights reserved.