/* 
* File:    INSTALL.txt
* CVS:     $Id: INSTALL.txt,v 1.29 2008-08-21 19:23:47 sbk Exp $
* Author:  Kevin London
*          london@cs.utk.edu
* Mods:    Dan Terpstra
*          terpstra@cs.utk.edu
* Mods:    Philip Mucci
*          mucci@cs.utk.edu
* Mods:    Harald Servat
*          harald.servat@gmail.com
* Mods:    <your name here>
*          <your email address>
*/

*****************************************************************************
HOW TO INSTALL PAPI ONTO YOUR SYSTEM
*****************************************************************************

On some of the systems that PAPI supports, you can install PAPI right 
out of the box without any additional setup. Others require drivers or 
patches to be installed first.

The general installation steps are below, but first find your particular 
Operating System's section for any additional steps that may be necessary.
NOTE: the configure and make files are located in the papi/src directory.

General Installation

1.	% ./configure
	% make

2.	Check for errors. 

	a) Run a simple test case: (This will run ctests/zero)

	% make test

	If you get good counts, you can optionally run all the test programs
	with the included test harness. This will run the tests in quiet mode, 
	which will print PASSED, FAILED, or SKIPPED. Tests are SKIPPED if the
	functionality being tested is not supported by that platform.

	% make fulltest (This will run ./run_tests.sh)

	To run the tests in verbose mode:

	% ./run_tests.sh -v

3.	Create a PAPI binary distribution or install PAPI directly.

	a) To install PAPI libraries and header files from the build tree:

	% make install

	b) To install PAPI manual pages from the build tree:

	% make install-man

	c) To install PAPI test programs from the build tree:

	% make install-tests

	d) To install all of the above in one step from the build tree:

	% make install-all

	e) To create a binary kit, papi-<arch>.tgz:

	% make dist

*****************************************************************************
MORE ABOUT CONFIGURE OPTIONS
*****************************************************************************

Beginning with PAPI 3.5.0, there is an extensive array of options available
from the configure command-line. These options select default directories,
32- or 64-bit library modes, driver versions, compiler settings and more.
For complete details on the command-line options:
	% ./configure --help

*****************************************************************************
Operating System Specific Installation Steps (In Alphabetical Order by OS)
*****************************************************************************

AIX - IBM POWER3, POWER4, POWER5, POWER6
*****************************************************************************
PAPI is supported on AIX 5.x for POWER3,4,5 and 6.
Use ./configure to select the desired make options for your system, 
specifying the --with_bitmode=32 or --with-bitmode=64 to select wordlength.
32 bits is the default.

1.	On AIX 5.x, the bos.pmapi is a product level fileset (part of the OS).
	However, it is not installed by default. Consult your sysadmin to 
	make sure it is installed. 
2.	Follow the general instructions for installing PAPI.

WARNING: PAPI requires XLC version 6 or greater.
Your version can be determined by running 'lslpp -a -l | grep -i xlc'.

BG/L 
*****************************************************************************
BG/L is a cross-compiled environment. The machine on which PAPI is compiled
is not the machine on which PAPI runs. To compile PAPI on BG/L, specify the 
BG/L environment as shown below:

	% ./configure --with-OS=bgl
	% make

The testing targets in the make file will not work in the BG/L environment.
Since BG/L supports multiple queueing systems, you must manually execute
programs in the ctests and ftests directories to check for successful
library creation. You can also manually edit the run_tests.sh script to
automate testing for your installation. 

WARNING: ./configure might fail if the cross compiler is not in your path.
	 In that is the case, just add it to your path 
	 and everything should work.

Catamount - Cray XT3/XT4 Opteron
*****************************************************************************
The Cray XT3/4 is a cross-compiled environment. In this case, configure
can automatically detect the catamount operating system and make appropriate
default assignments. Alternatively, you can specify the OS to configure.
Please note that although Catamount contains the necessary PerfCtr patches
to access the hardware counters, a customized copy of the Perfctr 2.5.4 source
is necessary to compile and link PAPI. Contact Cray for a copy of these sources.

Before running configure to create the make file that supports a Catamount
build of PAPI and perfctr-2.5.4, execute the following module commands:

% module purge
% module load Base-opts PrgEnv-gnu
% module swap gcc gcc-catamount/3.3
% module swap xt-mpt xt-mpt/$XTOS_VERSION
% module unload xtpe-target-cnl
% module load xtpe-target-catamount

Execute configure

% configure --with-perfmon=2.2 --prefix=<install-dir> --with-OS=catamount

The testing targets in the make file will not work in the Catamount 
environment. It is necessary to log into an interactive session and run the 
tests manually through the job submission system. For example, instead of:
	% make test
use:
	% yod -sz 1 ctests/zero
and instead of:
	% make fulltest
useg
	% ./run_cat_tests.sh

PLATFORM NOTES:
PAPI on Catamount currently supports single event overflow. It does not 
support multiple event overflow or profiling. Many of the overflow and
profile tests in the PAPI distribution WILL SEGFAULT in this release.

CNL - Cray XT3/XT4 Opteron
*****************************************************************************
The Cray XT3/4 is  a cross-compiled environment. You must specify the OS and
perfmon version to configure as shown below.

Before running configure to create the make file that supports a Cray XT CNL
build of PAPI, execute the following module commands:

% module purge
% module load Base-opts PrgEnv-gnu

Check CNL compute nodes for the version of perfmon2 that it supports:

% aprun -b -a xt cat /sys/kernel/perfmon/version

and use this version when configuring PAPI:

% configure --with-perfmon=2.3 --prefix=<install-dir> --with-OS=CNL

The testing targets in the make file will not work in the XT CNL environment.
It is necessary to log into an interactive session and run the tests
manually through the job submission system. For example, instead of:
	% make test
use:
	% aprun -n1 ctests/zero
and instead of:
	% make fulltest
use:
	% ./run_cat_tests.sh
after substituting "aprun -n1" for "yod -sz 1" in run_cat_tests.sh.

CNL - Cray X2
*****************************************************************************
The Cray X2 is a cross-compiled environment. You must specify the OS and
perfmon version to configure as shown below.

Before running configure to create the make file that supports a Cray X2 CNL
build of PAPI, execute the following module commands:

% module purge
% module load PrgEnv-x2

Check CNL compute nodes for the version of perfmon2 that it supports:

% aprun -b -a x2 cat /sys/kernel/perfmon/version

and use this version when configuring PAPI:

% configure --with-perfmon=2.3 --prefix=<install-dir> --with-OS=CNL

The testing targets in the make file will not work in the X2 CNL environment.
It is necessary to log into an interactive session and run the tests
manually through the job submission system. For example, instead of:
	% make test
use:
	% aprun -n1 ctests/zero
and instead of:
	% make fulltest
use:
	% ./run_cat_tests.sh
after substituting "aprun -n1" for "yod -sz 1" in run_cat_tests.sh.

FreeBSD - i386 & amd64
*****************************************************************************
PAPI requires FreeBSD 6 or higher to work.

Kernel needs some modifications to provide PAPI access to the performance 
monitoring counters. Simply, add "options HWPMC_HOOKS" and "device hwpmc" in
the kernel configuration file. For i386 systems, add also "device apic".
(You can obtain more information in hwpmc(4), see NOTE 1 to check the
supported HW)

After this step, just recompile the kernel and boot it.

FreeBSD 7 does not ship with a fortran compiler. To compile fortan tests
you will need to install a fortran compiler first (e.g. installing it from
/usr/ports/lang/gcc42), and setup the F77 environment variable with the 
compiler you want to use (e.g. gfortran42). 

Now, see NOTE 2, and follow the "General Installation" steps.

NOTE 1: 
HWPMC driver supports the following processors: Intel Pentium 2,
Intel Pentium Pro, Intel Pentium 3, Intel Pentium M, Intel Celeron,
Intel Pentium 4, AMD K7 (AMD Athlon) and AMD K8 (AMD Athlon64 / Opteron).

NOTE 2:
Fortran compilers may issue errors due to "Integer too big for its kind *".
Add to FFLAGS environment variable a compiler option to use int*8 by default
(in gfortran42 it is -fdefault-integer-8).

Linux - IBM Cell
*****************************************************************************
PAPI on Cell requires the perfmon2 patch and libpfm library available from
sourceforge <http://sourceforge.net/projects/perfmon2>. If the kernel is
properly patched, PAPI should configure and build as described under General
Installation, above. Support for Cell is currently experimental and limited
to basic counting and native event support, with a limited number of PRESET
events. 

Linux - Itanium I, II, Montecito, Montvale
*****************************************************************************
PAPI on Itanium Linux links to the perfmon library. The library version and 
the Itanium version are automatically determined by configure.
If you wish to override the defaults, a number of pfm options are available
to configure. Use:
	% ./configure --help
to learn more about these options.

Follow the general installation instructions to complete your installation.

PERFMON2:
The Itanium Linux kernel comes preconfigured with the perfmon driver. If you
choose, you can patch your kernel with the newer perfmon2 driver, found at
http://sourceforge.net/projects/perfmon2. The standard installation procdeure
applies in this case; configure and make will recognize the proper driver.
Since this software is still evolving, not all features are guaranteed to work.

PLATFORM NOTES:
The earprofile test fails under perfmon for Itanium I and II. It has been
reconfigured to work on the perfmon2 interface.

Linux - MIPS/MIPS64
****************************************************************************

If the kernel is patched with Perfmon2, you're all set to go. 

Linux - PPC64 (POWER4,5,6 and PowerPC970)
****************************************************************************
PERFCTR:
Linux/PPC64 requires that the kernel be patched and recompiled with the
PerfCtr patch.   The required patches and complete installation instructions
are provided in the papi/src/perfctr-2.7.x directory. PPC64 is the ONLY 
platform that REQUIRES use of PerfCtr 2.7.x.

*- IF YOU HAVE ALREADY PATCHED YOUR KERNEL AND/OR INSTALLED PERFCTR -*

WARNING: You should always use a PerfCtr distribution that has been distributed
with a version of PAPI or your build will fail. The reason for this is that
PAPI builds a shared library of the Perfctr runtime, on which libpapi.so
depends. PAPI also depends on the .a file, which it decomposes into component
objects files and includes in the libpapi.a file for convenience. If you
install a new perfctr, even a shared library, YOU MUST REBUILD PAPI to get
a proper, working libpapi.a.

There are several options in configure to allow you to specify your perfctr 
version and location. Use:
	% ./configure --help
to learn more about these options.

Follow the general installation instructions to complete your installation.

PERFMON2:
Make sure that your Linux/PPC64 kernel is patched with the newest perfmon2
driver found at http://sourceforge.net/projects/perfmon2. The standard 
installation procedure applies here.

For 32-bit builds using the internal libpfm-3.y library:
Follow the standard configure and make procedure in this documentation.

For 64-bit builds using the internal libpfm-3.y library:
First, configure with the following command:

	CFLAGS="-m64" FFLAGS="-m64" LDFLAGS="-m64" \
	./configure \
	--libdir=/usr/local/lib64

Next, build papi using the following command, and then follow the normal
installation procedure.

	make BITMODE=64

For 64-bit builds using an externally built 64-bit libpfm library:
First, build a 64-bit libpfm by issuing the following from the latest libpfm
project code available at: http://sourceforge.net/projects/perfmon2.

	make BITMODE=64 install

Next, configure with the following command, and then follow the normal
build and installation procedure.

	CFLAGS="-m64" FFLAGS="-m64" LDFLAGS="-m64" \
	./configure \
	--libdir=/usr/local/lib64 \
	--with-pfm-prefix=/usr/local \
	--with-pfm-libdir=/usr/local/lib64

Note: BITMODE is ignored by PAPI's Makefile, and is only used by
libpfm's Makefile.

Linux/x86 - Intel Pentium, Core and AMD Athlon, Opteron
*****************************************************************************
Linux/x86 requires that the kernel be patched and recompiled to enable access
to the performance counters.

Historically, PAPI has used the PerfCtr patch.
This version of PAPI also supports the perfmon2 patch found at
http://sourceforge.net/projects/perfmon2. Installation details for perfmon2
can also be found at this website. Since this software is still evolving, 
not all features are guaranteed to work on all platforms.

No matter which driver is installed, this version of PAPI still builds the 
libpfm library to provide information on native events.

Detailed instructions on installing the perfctr patch are provided below.

The required perfctr patches and complete installation instructions are 
provided in the papi/src/perfctr-2.6.x directory. Please see the INSTALL file
in that directory.

Do not forget, you also need to build your kernel with APIC support in order
for hardware overflow to work. This is very important for accurate statistical
profiling ala gprof via the hardware counters.

So, when you configure your kernel to build with PERFCTR as above, make
sure you turn on APIC support in the "Processor type and features" section.
This should be enabled by default if you are on an SMP, but it is disabled
by default on a UP. 

In our 2.4.x kernels:
> grep PIC /usr/src/linux/.config
/usr/src/linux/.config:CONFIG_X86_GOOD_APIC=y
/usr/src/linux/.config:CONFIG_X86_UP_APIC=y
/usr/src/linux/.config:CONFIG_X86_UP_IOAPIC=y
/usr/src/linux/.config:CONFIG_X86_LOCAL_APIC=y
/usr/src/linux/.config:CONFIG_X86_IO_APIC=y

You can verify the APIC is working after rebooting with the new kernel
by running the 'perfex -i' command found in the perfctr/examples/perfex
directory.

PAPI on x86 assumes PerfCtr 2.6.x. You can change this with the 
'--with-perfctr=<5,6,7> option to ./configure. THIS IS NOT ADVISED.
PerfCtr version 2.5.4 is specific for Cray XT3, and PerfCtr 2.7.x is
supported only for PPC64.
NOTE: THE VERSIONS OF PERFCTR DO NOT CORRESPOND TO LINUX KERNEL VERSIONS.

*- IF YOU HAVE ALREADY PATCHED YOUR KERNEL AND/OR INSTALLED PERFCTR -*

WARNING: You should always use a PerfCtr distribution that has been distributed
with a version of PAPI or your build may fail. Newer versions with backward
compatibility may also work. PAPI builds a shared library of the Perfctr 
runtime, on which libpapi.so depends. PAPI also depends on the .a file, 
which it decomposes into component objects files and includes in the libpapi.a 
file for convenience. If you install a new PerfCtr, even a shared library, 
YOU MUST REBUILD PAPI to get a proper, working libpapi.a. 

There are several options in configure to allow you to specify your perfctr 
version and location. Use:
	% ./configure --help
to learn more about these options.

Follow the general installation instructions to complete your installation.PERFCT

*- IF PERFCTR IS INSTALLED BUT PAPI FAILS TO INITIALIZE -*

You may be running udev, which is not smart enough to know the permissions of 
dynamically created devices. To fix this, find your udev/devices directory, 
often /lib/udev/devices or /etc/udev/devices and perform the following actions:

 mknod perfctr c 10 182
 chmod 644 perfctr

On Ubuntu 6.06 (and probably other debian distros),  add a line to 
/etc/udev/rules.d/40-permissions.rules like this:

KERNEL=="perfctr", MODE="0666"

On SuSE, you may need to add something like the following to
/etc/udev/rules.d/50-udev-default.rules:
 (SuSE does not have the 40-permissions.rules file in it.]

# cpu devices
KERNEL=="cpu[0-9]*",            NAME="cpu/%n/cpuid"
KERNEL=="msr[0-9]*",            NAME="cpu/%n/msr"
KERNEL=="microcode",            NAME="cpu/microcode", MODE="0600"
KERNEL=="perfctr",              NAME="perfctr", MODE="0644"

These lines tell udev to always create the device file with the appropriate permissions.
Use 'perfex -i' from the perfctr distribution to test this fix.

PLATFORM NOTES:
Opteron fails the matrix-hl test because the default definition of PAPI_FP_OPS
overcounts speculative floating point operations.

IRIX - MIPS
*****************************************************************************
No additional steps are required to install PAPI on IRIX. Follow the 
general installation guide, and everything should work.

Linux - SiCortex
*****************************************************************************

Assuming the default 64 bit build:

When compiling on the nodes:

     ./configure \
     --with-pfm-libdir=/usr/lib64 \
     --with-pfm-incdir=/usr/include \

When cross-compiling on the front end:

     If /etc/sicortex-release is < V2.3 and r81:

     ./configure \
     --with-pfm-libdir=/opt/sicortex/rootfs/default/usr/lib64 \
     --with-pfm-incdir=/opt/sicortex/rootfs/default/usr/include \
     --with-arch=mips64 --host=x86_64 --build=mips64 \
     --with-perfmon=2.4 --with-virtualtimer=clock_thread_cputime_id \
     --with-tls --with-ffsll --with-pfm-events=static \
     --with-walltimer=gettimeofday 

     If you have a machine that is more recent that V2.3 and R80, then change
     the last line to:

     --with-walltimer=cycle

Solaris 8 - Ultrasparc
*****************************************************************************
The only requirement for Solaris is that you must be running version 2.8 or 
newer.  As long as that requirement is met, no additional steps are required 
to install PAPI and you can follow the general installation guide.

Solaris 10 - Ultrasparc
*****************************************************************************
PAPI is not yet implemented on Solaris 10, but work is underway. Check the 
PAPI website for current information.

Unicos - Cray X1
*****************************************************************************
No additional steps are required to get PAPI working on Unicos.
Follow the general installation guide, and everything should work.

PLATFORM NOTES:
Cray X1 is not actively supported. PAPI 3.6 currently compiles and links and
successfully completes many tests, but has not been fulled debugged on all tests.
If you have a need for a specific unimplemented feature on this platform, either 
use PAPI 3.5 or contact the PAPI team for support.


Windows XP/2000/Server 2003 - Intel Pentium III or AMD Athlon / Opteron
*****************************************************************************
PAPI 3.6 has not been ported to or tested on Windows. This is left as an
exercise for the student.
PAPI 3.5 for Windows runs on Pentium III, Athlon and Opteron, for 
Windows 2000, Windows XP and Windows Server 2003. If you must run PAPI on a
Windows platform, please use PAPI 3.5.

