Table of Contents
In this exercise, you will work with pre-built components from the integrator example to compose several CCA-based applications and execute them. The integrator application is a simple example, designed to illustrate the basics of creating, building, and running component-based applications without scientific complexities a more realistic application would also present. The purpose of this application is to numerically integrate a one-dimensional function. Several different integrators and functions are available, in the form of components. A “driver” component controls the calculation, and for the Monte Carlo integrator, a random number generator is also required. The specific components available are:
drivers.CXXDriver,
drivers.F90Driver,
integrators.MonteCarlo,
integrators.Trapezoid,
integrators.Simpson
functions.CubeFunction (x3, which integrates to 0.25),
functions.LinearFunction (x, which integrates to 0.5),
functions.PiFunction (4/(1+x2), which integrates to π),
functions.QuinticFunction (x5-4x4, which integrates to 1/6 - 4/5, or roughly -0.633),
functions.SquareFunction (x2, which integrates to 1/3)
randomgens.RandNumGenerator (required by integrators.MonteCarlo)
The Ccaffeine framework provide three different ways for users to
interact with it in order to assemble and run CCA applications. You
can type commands in yourself at the framework's prompt, execute a
script containing those same commands, or use a graphical user
interface. The graphical approach is the easiest for most people to
get a feel for how components work, so we will start with that (Section 2.1, “Using the GUI Front-End to Ccaffeine”) and later discuss how actions in
the GUI map onto instructions in a script (see Section 2.2, “
Running Ccaffeine Using an rc File
”).
In practice, most users set the GUI interface aside after they become more comfortable with the CCA environment in favor of the scripting approach. That's especially true once they've developed a bunch of components and want to run simulations with them in batch jobs, where GUIs tend not to be so convenient. Of course it is entirely up to you which approach you use in the long run.
![]() |
Note |
|---|---|
|
This exercise uses the |
![]() |
Tip |
|---|---|
|
These exercises can involve a fair amount of typing. You may find
it convenient to use the online HTML version of this Guide (at
http://www.cca-forum.org/tutorials/#sources
to cut and paste the necessary inputs. Note, however, that not
everything can be cut-and-based directly. Take particular care with
lines that had to be broken for purposes of documentation, and for
placeholder values such as “ |
There is a graphical front-end for Ccaffeine (known as ccafe-gui,
or “the GUI”) which provides a fairly simple visual
programming metaphor for the assembly of applications using CCA
components. The current GUI is a Java tool, making it quite
portable. It can also be used over network connections, so that
you can run it on your local machine to create and run
applications on a computer somewhere else. In this exercise,
we'll use the Ccaffeine GUI to assemble and run several different
“applications” using the components already available
in the tutorial-src tree.
Ccaffeine and its GUI are run as two separate processes, possibly on two different machines. In any event, you'll need two separate terminal sessions to control and monitor the two processes. We will refer to these as “Ccaffeine host” and “GUI host”.
In this exercise, we will invoke Ccaffeine on the Ccaffeine host with:
gui-backend.sh --port3314\--ccafe-rc
rc_file![]()
The default for ccafe-client (and
ccafe-batch) is to direct most of their own
output, as well as the output from applications within them, to
files named pOut
(for the stdout stream) and
npErr (for the
stderr stream), where
n denotes the MPI
rank of the process. (In this Guide, we'll be running
sequentially, so we'll have only npOut0 and
pErr0.) The gui-backend.sh
script invokes ccafe-client with the
--ccafe-io2tty to direct its output to the
terminal instead of to the files (the files will still be created,
but will contain just a few startup messages relating to the MPI
rank and the process id). Using --ccafe-io2tty
is more convenient for more interactive development work, but if
you're going to run an actual application, you probably want to
capture the output in the files instead. With the current
gui-backend.sh, this would require modifying
the script, but for “production” computing with CCA,
we expect most people to use the rc approach of the
previous section rather than the GUI.
The Ccaffeine GUI is implemented in Java, and is available as a
jar file that can be used
with any recent version of the Java runtime or the full software
development kit. Because the Java invocation is long and hard
to remember, we provide convenience scripts to simplify using
it. Which one you need depends on your circumstances:
This is the script to use if you're running the GUI on the same machine as the backend. This script is configured and installed as part of the CCA tools build process.
This is the script to use if you're running the GUI on a
Linux-like machine and want to
connect to Ccaffeine running remotely.
You will need to download this to your local machine,
along with the GUI's jar file, following the
directions in Section B.2, “The Ccaffeine GUI”.
This is the script to use if you're running the GUI on a
Windows machine and want to connect
to Ccaffeine running remotely. You
will need to download this to your local machine, along
with the GUI's jar
file, following the directions in Section B.2, “The Ccaffeine GUI”.
Below, we will refer to simple-gui.sh, but you should replace it with whichever command is appropriate for your situation.
![]() |
Note |
|---|---|
|
While the GUI can be run remotely, using the X11 protocol to display on your local X11 server, this is generally unacceptably slow because of the way Java handles graphics in X11. You will probably get more satisfactory performance if you can run the GUI on your local system and allow it to connect over the network to the remote host where you're running Ccaffeine. Tunneling the GUI-Ccaffeine connection over your ssh connection is a straightforward way to deal with firewalls that often prevent direct access to most ports on remote hosts. It has the added advantage, for the purposes of this Guide, that you would use the same arguments to invoke the GUI running remotely through a tunnel or locally on the same machine as the backend. For more information, see Appendix A, Remote Access for the CCA Environment and in particular Section A.3, “Tunneling other Connections through SSH”. |
In this exercise, we will invoke the GUI on the GUI host with:
simple-gui.sh --builderPort3314\--host
localhost![]()
|
This tells the GUI which port to use for the connection to
Ccaffeine host. In general, it should match the
ccafe-client |
|
This tells the GUI which host to connect to for the Ccaffeine
backend. In general, it should be the Ccaffeine host (though when
tunneling the connection through ssh, it would be |
![]() |
Note |
|---|---|
|
Since gui.sh is designed to be used on the same machine as Ccaffeine is running on, it does not take a --host argument. The simple-gui scripts do require it. |
![]() |
Note |
|---|---|
|
Ccaffeine should be running and ready to receive the GUI's connection before you start the GUI. If you're scripting their execution, especially on the same machine, the sleep command can help build in a few seconds of delay. |
![]() |
Note |
|---|---|
|
Once the GUI displays on your screen, it may take a few more seconds before it will respond to user actions. |
Run gui-backend.sh on the Ccaffeine host
using the appropriate port and the
test_gui_rc rc file. The
command will look something like:
gui-backend.sh --port3314\ --ccafe-rc$TUTORIAL_SRC/components/tests/test_gui_rc
depending on the port number assigned to you, and whether or
not you've copied the rc file to your local directory.
In the Ccaffeine host terminal window, you will see something like:
(Ccaffeine host)
my rank: -1, my pid: 9625
Type: Server
Run the simple-gui.sh on the GUI host.
Once the GUI connects to Ccaffeine, Ccaffeine begins running the
rc file it was invoked with. In the GUI host
terminal window, you first see some startup messages from the
GUI itself, followed by a series of messages as Ccaffeine
processes the rc file and the GUI displays the
results. These are debugging messages and can largely be
ignored.
In the Ccaffeine host terminal, you should see some additional
messages as Ccaffeine processes the rc file, like:
(Ccaffeine host)
CCAFFEINE configured with spec (0.8.2) and babel (1.0.4).
CCAFFEINE configured with classic (0.5.7).
CCAFFEINE configured without neo and neo components.
CmdLineClient parsing ...
CmdContextCCA::initRC: Found components/tests/test_gui_rc.
# There are allegedly 11 classes in the component path
Finally, in the GUI host window, you should see some output associated with the GUI's initialization process, and the GUI itself should have appeared on your display, looking something like this:

![]() |
Tip |
|---|---|
|
The default layout has the palette area fairly narrow. You can click-and-drag on the bar separating the palette and the arena to adjust the width. |
As mentioned above, the test_gui_rc sets
up the path and loads the framework's
palette with a set of available components.
rc files are explained in detail in Section 2.2, “
Running Ccaffeine Using an rc File
”.
We will begin by instantiating a drivers.CXXDriver component.
Click-and-drag the component you want from the palette
to the arena. When you release the mouse button in
the arena, a dialog box will pop up prompting you to
name this instance of the component. The default will be the
last part of the component's class name
(i.e. CXXDriver for drivers.CXXDriver) with
a numerical suffix to insure the name is unique. The suffix
starts at 0 and simply counts up according to the number of
instances of that component you've created in that session.
You can, of course, enter any instance name you like, as long
as it is unique across all components in the arena,
but for simplicity, we will always accept the default value in
this Guide.
For the first application, follow the same procedure to instantiate:
drivers.CXXDriver,
functions.PiFunction,
integrators.MonteCarlo,
randomgens.RandNumGenerator,
(you may notice some debugging messages in the GUI host terminal window as you do this), and your GUI should look something like this:

![]() |
Tip |
|---|---|
|
You can drag components around the arena to arrange them as suits you -- just click on the black area of the compoment and drag it to the new location. The positions have no bearing on the operation of the GUI or your application. |
The next step is to begin making connections between the ports
of your components. Click-and-release CXXDriver0's
integrate uses port, then click-and-release
MonteCarlo0's integrate provides port and a
red line should be drawn between the two:

![]() |
Tip |
|---|---|
|
If you hover the cursor over a particular port on a component,
a “tool tip” box will pop up with the port's name
and type based on the arguments to the Also notice that when you hover over a particular port (either uses or provides), matching ports of the opposite type (either provides or uses) will be highlighted. |
![]() |
Note |
|---|---|
|
You can move components around even after their ports are connected -- the connections will automatically rearrange. There is no harm in connections crossing each other, nor in connections passing behind other components (though of course they may make it harder to interpret the “wiring diagram” correctly). |
Complete the first application by making the following connections:
CXXDriver0's integrate to
MonteCarlo0's integrate
MonteCarlo0's function to
PiFunction0's function
MonteCarlo0's RandomGeneratorPort to
RandNumGenerator0's RandomGeneratorPort.
At this point, your GUI should look something like:

The application is now fully assembled and is ready to run. If
you click-and-release the go button on the
CXXDriver0 component, you should see the result appear in
the Ccaffeine host terminal, “Value =
3.139160” (since Monte Carlo integration
is based on random sampling, you will not get exactly the same
result every time you run it, but for this example, it should
always be reasonbly close to π) and the message
“IN: ##specific go command
successful” in the GUI host terminal.
Next, we're going to use some of the other components to assemble a different application using the
integrators.Simpson and
functions.CubeFunction
components. Since they're already in the palette, you can instantiate them in the same way as Step 3.

![]() |
Tip |
|---|---|
|
As we've mentioned, wiring diagrams can become hard to interpret when they become cluttered, as is the case with the screen shot above. To help interpret the diagram, remember the following:
|
Next, we break the port connections we don't need so we can
reconnect to the new components. Right-click on the
integrate (either the user or the provider)
and a dialog box will pop up asking you to confirm that you want
to break the connection. (A bug in the GUI causes this dialog
box to appear twice sometimes. Just respond appropriately both
times.) You will need to break the following connections:
CXXDriver0's integrate to
MonteCarlo0's integrate
MonteCarlo0's function to
PiFunction0's function
Whether or not MonteCarlo0 remains connected to
RandNumGenerator0 is immaterial because neither component is
connected to any other component in the arena and so
will no be involved when a disjoint assembly of components is
executed.
Assemble the new application by making the following connections:
CXXDriver0's integrate to
Simpson0's integrate
Simpson0's function to
PiFunction0's function

Click-and-release the go button on the CXXDriver0
component, you should see the result appear in the Ccaffeine host
terminal, “Value =
3.141593” and the message
“IN: ##specific go command
successful” in the GUI host terminal.
Finally, create a third application by replacing PiFunction0
with CubeFunction0. When you click on the go you
should get “Value =
0.250000” in the Ccaffeine host terminal
(with a deterministic integrator, the result should be
repeatable).

At this point, you should understand how to instantiate
components, how to connect and disconnect their ports, and how
to execute the application with the go port. Feel
free to use any and all of the components available in the
palette to experiment with other integration
applications.
![]() |
Note |
|---|---|
|
Observe that as a user of CCA components, you have no idea what language each component is implemented in. (Admittedly, the names of the drivers are suggestive of the implementation language, but those names were chosen at the convenience of the component developer, and they provide no guarantees regarding the components' implementations.) The language interoperability features of Babel allow components to be hooked together regardless of implementation language with complete transparency. |
To politely exit the GUI, select → . This will terminate both the GUI and the backend ccafe-client sessions.
![]() |
Tip |
|---|---|
|
If you've used the GUI to setup and start a long-running simulation, and you don't want to leave the GUI running continuously, you can use the → option to close the GUI but leave the backend running. However it is currently impossible to reattach to a running session. |