Archer:PTLSim

From Grid-Appliance Wiki

Jump to: navigation, search

Contents

Tool Introduction

HOW-TO author: Renato Figueiredo renato
Name of Application: PTLSim basic
Overview: PTLsim is a cycle accurate x86 microprocessor simulator.
Download link: [1]

Installation

  • Go to the main page of PTLSim and download the latest tar.bz2 source code package with the simulator to your appliance. For example, as of May 2008 the latest code snapshot was ptlsim-20071230-r228.tar.bz2
  • Copy the source package into /home/griduser in your Grid appliance.
  • Uncompress the package and compile the PTLsim code:
cd /home/griduser
bunzip2 ptlsim*.bz2
tar -xf ptlsim*.tar
cd ptlsim
make

Tutorial: local execution

You can run a simple test of the ptlsim installation as follows:

./ptlsim /bin/ls -la

After a few seconds you should see the output of the "ls -la" UNIX command, prepended by some information related to PTLsim

You can now configure PTLsim to extract configuration parameters for the ls command from a file. See the PTLsim user's manual for more details; basically the configuration file for a program /somepath/somebinary needs to be placed in a specific location under your home directory: /home/griduser/.ptlsim/somepath/somebinary.conf. In the case of /bin/ls, you need to create /home/griduser/.ptlsim/bin/ls.conf:

cd
mkdir -p .ptlsim/bin

Create ls.conf in this directory to have the following content:

-logfile ptlsim.log -loglevel 1 -stats ls.stats -stopinsns 10000

Execute PTLsim again and you will see now that it fetches the configuration from the ls.conf file and only simulates 10000 instructions - and the simulation is much faster:

./ptlsim /bin/ls -la

Statistics for this run are stored in ls.stats. Run the following command to parse the statistics file:

./ptlstats ls.stats

Browse the PTLSim Web site and the user manual for additional examples on how to run PTLsim locally in your appliance.

Tutorial: remote execution with Condor

In order to execute a PTLsim simulation remotely with Condor, you need to appropriately set up environment variables, transfer and place configuration files in the appropriate places. This can be done with the use of shell scripts and appropriately configured Condor submit files.

  • Set up a directory for job submission and copy the "ls" application to this directory. You will run "ls" remotely, and this example shows how you could run any other application by sending it over using Condor:
cd
mkdir ptlsim_submit
cd ptlsim_submit
cp /bin/ls .
  • Create a Condor configuration file ptlsim_condor with the following contents:
# It's a vanilla (unmodified binary) job
Universe = vanilla

# Job will execute a launcher script which sets up the environment for ptlsim
Executable = ptlsim_launch.sh

# Specify Condor log/output/error files
Log = ptlsim.$(Cluster).$(Process).log
Output = ptlsim.$(Cluster).$(Process).out
Error = ptlsim.$(Cluster).$(Process).err

# transfer the application configuration file (ls.conf in this example),
# the ptlsim binary, and the application binary in your local directory (ls)
transfer_input_files = /home/griduser/.ptlsim/bin/ls.conf, /home/griduser/ptlsim/ptlsim, ls

should_transfer_files = YES
when_to_transfer_output = ON_EXIT
Queue 
  • Create the launcher shell script ptlsim_launch.sh that prepares your job for execution in the remote machine scheduled by Condor. What this script does is, it sets up your $HOME variable on the execute machine to be whatever temporary directory Condor assigns for you job (using /bin/pwd), creates a placeholder for your configuration file, and copies it there. For example, if your job runs on temporary directory /tmp/123456, this script:
    • sets your $HOME to /tmp/123456
    • copies the ptlsim and ls binaries to your $HOME
    • creates a directory /tmp/123456/.ptlsim/tmp/123456
    • moves the ls.conf to /tmp/123456/.ptlsim/tmp/123456
    • makes ptlsim and ls executable
    • simulates /tmp/123456/ls -la; not the the configuration ls.conf is extracted appropriately since it is placed under /tmp/123456/.ptlsim/tmp/123456
#!/bin/sh

# Set up the home directory to be the Condor temporary directory assigned
# when the job executes
export HOME=`/bin/pwd`

# Create the .ptlsim directory to hold the application's configuration file
# and move the configuration file there
/bin/mkdir -p .ptlsim/$HOME
/bin/mv ls.conf .ptlsim/$HOME

# Ensure both ptlsim and ls are executable
/bin/chmod 755 $HOME/ptlsim $HOME/ls

# Run ptlsim
$HOME/ptlsim $HOME/ls -la
  • Make the launcher script executable and submit the job:
chmod 755 ptlsim_launch.sh
condor_submit ptlsim_condor
  • Once the job is complete, you should see the ptlsim.log and ls.stats file have been created. Double-check they are correct.

Future Work

PTLsim/X is in the plans for future work; it's more involved because it requires a full Xen boot. If you're interested in working on this as a project, feel free to contact us.

Personal tools