Skip to content

Adding and Running Applications

Carbon Research Group edited this page Mar 30, 2016 · 55 revisions

Running applications:

Running each application is done through make. Look at the file ‘’tests/apps/Makefile’’ for a list of targets, however one simple example would be the ping_pong test which sends messages between two cores. Run this test by typing the following command:

# make ping_pong_app_test

The other applications have a similar organization. For example, to run barnes from the SPLASH2 benchmark suite found in the tests/benchmarks directory, use _bench_test instead of _app_test like this:

# make barnes_bench_test

Distributing a simulation:

To distribute a Graphite simulation across multiple machines, edit the [general/num_processes] and [process_map] sections of the configuration file carbon_sim.cfg.

To run a Graphite simulation on two machines “server1.csail.mit.edu” and “server2.csail.mit.edu”, make the following changes to “carbon_sim.cfg”.

[general]
num_processes = 2

[process_map]
process0 = "server1.csail.mit.edu"
process1 = "server2.csail.mit.edu"

The above technique can also be used to run a Graphite simulation on two processes belonging to the same machine.

Configuring Graphite:

One important aspect of graphite is configuring the different models used for simulation. To do this edit the “carbon_sim.cfg” file (which is loaded by default) or instruct the simulator to use a separate config file using the “-c” command line argument.

Also note that applications run from the build system use several parameters to control simulation. In particular, you can set the “CORES” variable in the build system to control the number of cores or the “PROCS” variable to control the number of processes. Once the environment is setup to distribute simulations you can simply set the PROC variable as follows to distribute it:

# make ping_pong_app_test CORES=16 PROCS=2

This will run the ping_pong test with 16 cores and distribute the simulation across two machines.

Adding a new application to the build system:

To add a new application to be integrated into the build system, start by making a new directory in the “test/apps” directory with the target applications name:

# mkdir tests/apps/my_app

Next add / edit the sources for your application to that directory. In this case we will use a hello_world type app for simplicity.

:: File: tests/apps/my_app/my_app.c ::
    #include "stdio.h"
    int main(int argc, char **argv) {
        printf("hi from my app.\n");
    }

Now add a makefile in the directory specifying the sources, target and number of cores:

:: File: tests/apps/my_app/Makefile ::
TARGET = my_app
SOURCES = my_app.c
include ../../Makefile.tests

Now you can build your application like other integrated applications:

# make && make my_app_app_test

This should be the expected output:

hi from my app.
[spawn_master.py] Exited with return code: 0

Compiling, linking and running an application outside of the build system:

Set the environment variables ${GRAPHITE_HOME} and ${PIN_HOME} to point to the directories where Graphite and Pin are installed.

# export GRAPHITE_HOME=[PATH/TO/GRAPHITE]
# export PIN_HOME=[PATH/TO/PIN]
# export LD_LIBRARY_PATH=${PIN_HOME}/intel64/runtime

Compiling an application to be run with the simulator:

If the application does not use any Carbon API functions like CarbonSpawnThread(), CarbonMutexLock(), CarbonBarrierWait(), etc., you can skip this step and proceed to the Linking an application section. If it does use Carbon API functions, the application needs to be compiled by pointing to the relevant include files within the Graphite directory. To do this, add the following compiler flags:

-I${GRAPHITE_HOME}/common/user

Linking an application to be run with the simulator:

Due to the fact that the simulator needs to call several functions from the application’s binary we need to link the application with a Graphite library and tell the linker to include some symbols that aren’t directly referenced in the application. To do this use the following linker flags:

-static -u CarbonStartSim -u CarbonStopSim -u pthread_create -u pthread_join
-L${GRAPHITE_HOME}/lib -L${GRAPHITE_HOME}/contrib/dsent -L${GRAPHITE_HOME}/contrib/db_utils -L${GRAPHITE_HOME}/contrib/mcpat
-lcarbon_sim -ldsent_contrib -lmcpat -ldb_utils -ldb -lboost_filesystem-mt -lboost_system-mt -pthread -lstdc++ -lm

Running an application outside of the build system:

To run an application outside of the build system you need to first setup the CARBON_PROCESS_INDEX to 0 for a single simulation. This environment variable is set to different values for each process by our spawning script when running distributed simulations.

# export CARBON_PROCESS_INDEX=0

Next you need to run the application under pin using graphite as the pin tool as follows.

# ${PIN_HOME}/intel64/bin/pinbin -tool_exit_timeout 1 -mt -t ${GRAPHITE_HOME}/lib/pin_sim -c ${GRAPHITE_HOME}/carbon_sim.cfg -- [PATH/TO/YOUR/APPLICATION]

This tells the simulator to use the configuration file found at ${GRAPHITE_HOME}/carbon_sim.cfg and to run the application located at [PATH/TO/YOUR/APPLICATION].

Running an application from the PARSEC benchmark suite:

We ONLY support PARSEC 3.0.

Step 1

Download PARSEC. Set the environment variables ${PARSEC_HOME} and ${GRAPHITE_HOME} to point to the root of the PARSEC and Graphite installation directories respectively. Change to the PARSEC installation directory.

# cd ${PARSEC_HOME}

Step 2

Copy the PARSEC setup scripts and patches to the PARSEC installation directory.

# cp -r ${GRAPHITE_HOME}/tools/parsec/setup_parsec_3.0 ${PARSEC_HOME}

Step 3

Run the script that automatically sets up the build configuration files, untars the inputs and applies patches.

# ./setup_parsec_3.0/run.sh

The script while running, will print out its actions. If you already have PARSEC setup and wish to perform only part of the commands, please edit the script accordingly. The script has comments that will guide you through the process.
Only the simmedium inputs are untarred. If you wish to use other input sizes for simulation, you should edit the file setup_parsec_3.0/inputs.sh accordingly. The graphite PARSEC Makefile (tests/Makefile.parsec) is also setup to run simmedium inputs.

Step 4

Return to the Graphite home directory.

# cd ${GRAPHITE_HOME}

Edit tests/Makefile.parsec to set PARSEC_HOME to point to the root of the PARSEC installation directory and PARSEC_LOCAL to point to the directory within the Graphite installation where PARSEC is run from (Note: using the default value of PARSEC_LOCAL should suffice).

# make setup_parsec

The above make rule will create PARSEC shadow directories and symbolic links to your PARSEC installation. This enables multiple users in different graphite branches to run PARSEC apps with a single install.

Step 5

Run make [app]_parsec to simulate [app] with Graphite using the parameters specified in tests/Makefile.parsec.

For example, to run blackscholes,

# make blackscholes_parsec

Benchmarks that work

For PARSEC 3.0, blackscholes, swaptions, fluidanimate, canneal, streamcluster and facesim work in full & lite modes, and dedup, ferret and bodytrack work in lite mode only. For facesim, the inputs have to be copied from the PARSEC 2.1 distribution (the inputs are not included within PARSEC 3.0).

Regression Suite:

Graphite has a regression suite to ensure that code changes don’t have adverse effects on existing applications. This can be beneficial if you are implementing a new model and want to make sure that it doesn’t introduce any bugs.

To run the fast regression suite (a few minutes), type:

# make regress_quick

To run the larger regression suite (3-7 hrs depending on your machine configuration), type:

# make regress_bench