Simple Performance Optimization Tool (SPOT) 2.0 User's Guide

Chapter 2 Using the SPOT Software

This chapter covers how to compile a program to get the most information from the spot command, and how to run the resulting application under the SPOT software.

Using the spot Command

You can run the spot command from either the directory where it is installed, or by adding the installation directory (by default, /opt/SUNWspro/extra/bin) to your system’s $PATH environmental variable.

There are two ways you can run the spot command:

The two command lines are:


Example 2–1 Command line to run application under spot


$ spot application parameters

Where application is the name of the application being investigated and parameters is the application arguments.


Example 2–2 Command line to attach spot to a running process


$ spot -P pid

Where pid is the process ID number of the running application.

There are a number of command-line options:

Each of the tools called by spot can be invoked stand-alone. If invoked stand-alone, the data collected by these tools will not be in HTML format.

Example of Compiling and Running an Application Under SPOT

The code shown in Using the spot Command is a program which has three routines, each of which targets a different kind of events:


Example 2–3 Example Test Code

#include <stdio.h>
#include <stdlib.h>

void fp_routine(double *out, double *in1, double *in2,int n)
{
  for (int i=0; i<n; i++) {out[i]=in1[i]+in2[i];}
}

int** cache_miss(int **array, int size, int step)
{
  for (int i=0; i<size-step; i++){array[i]=(int*)&array[i+step];}
  for (int i=size-step; i<size; i++)
     {array[i]=(int*)&array[i-size+step];}
  int ** cp=(int**)array[0];
  for (int i=0; i<size*16; i++) {cp= (int**)*cp;}
  return cp;
}

int** tlb_miss(int **array, int size, int step)
{
  for (int i=0; i<size-step; i++){array[i]=(int*)&array[i+step];}
  for (int i=size-step; i<size; i++)
    {array[i]=(int*)&array[i-size+step];}

  int ** cp=(int**)array[0];
  for (int i=0; i<size*16; i++) {cp= (int**)*cp;}
  return cp;
}

void main()
{
  double * out, *in1, *in2;
  int **array;
  out=(double*) calloc(sizeof(double),10*1024*1024);
  in1=(double*) calloc(sizeof(double),10*1024*1024);
  in2=(double*) calloc(sizeof(double),10*1024*1024);
  for (int rpt=0; rpt <100; rpt++)
    fp_routine(out,in1,in2,10*1024*1024);
  free(out);
  free(in1);
  free(in2);
  array=(int**)calloc(sizeof(int*),10*1024*1024);
  cache_miss(array,10*1024*1024,64/sizeof(int*));
  tlb_miss(array,10*1024*1024,8192/sizeof(int*));
  free (array);
}

The program is compiled, using Sun Studio 12, in the following way:


$ cc -g -O -xbinopt=prepare -o test test.c

The key compiler flags are:

Running an Application Under spot

To get the most information from the spot run with the -X option. The downside of using this option is that it takes longer to gather the data. If spot is run with root privileges, as well as the -X option, it will also gather bandwidth utilization and trap data. The command line to run the example application under spot is:.


$ spot -X test

SPOT will produce a subdirectory spot_run1 and several files in the current directory. One of the files is spot_summary.html. To start examining SPOT’s output, view the content of spot_summary.html in a browser. Subsequent spot runs in the current directory will produce spot_run2, spot_run3, etc. and will add content to spot_summary.html.