Blame src/components/libmsr/README

Packit Service a1973e
/** 
Packit Service a1973e
* @file:   README
Packit Service a1973e
* CVS:     $Id$
Packit Service a1973e
* @author: Asim YarKhan
Packit Service a1973e
*          yarkhan@icl.utk.edu
Packit Service a1973e
* @defgroup papi_components Components
Packit Service a1973e
* @brief Component Specific Readme file: libmsr
Packit Service a1973e
*/
Packit Service a1973e
Packit Service a1973e
/** @page component_readme Component Readme
Packit Service a1973e
Packit Service a1973e
@section Component Specific Information
Packit Service a1973e
Packit Service a1973e
libmsr/
Packit Service a1973e
Packit Service a1973e
NOTE: This libmsr component is an initial version, and has been tested
Packit Service a1973e
with libmsr (v0.1.17 11/2015) and the msr_safe kernel module (19/2015
Packit Service a1973e
version).
Packit Service a1973e
  https://github.com/scalability-llnl/libmsr
Packit Service a1973e
  https://github.com/scalability-llnl/msr-safe
Packit Service a1973e
Packit Service a1973e
Packit Service a1973e
The PAPI libmsr component supports measuring and capping power usage
Packit Service a1973e
on recent Intel architectures using the RAPL interface exposed through
Packit Service a1973e
MSRs (model-specific registers).  
Packit Service a1973e
Packit Service a1973e
Lawrence Livermore National Laboratory has released a library (libmsr)
Packit Service a1973e
designed to provide a simple, safe, consistent interface to several of
Packit Service a1973e
the model-specific registers (MSRs) in Intel processors.  The problem
Packit Service a1973e
is that permitting open access to the MSRs on a machine can be a
Packit Service a1973e
safety hazard, so access to MSRs is usually limited.  In order to
Packit Service a1973e
encourage system administrators to give wider access to the MSRs on a
Packit Service a1973e
machine, LLNL has released a Linux kernel module (msr_safe) which
Packit Service a1973e
provides safer, white-listed access to the MSRs.
Packit Service a1973e
Packit Service a1973e
PAPI has created a libmsr component that can provide read and write
Packit Service a1973e
access to the information and controls exposed via the libmsr library.
Packit Service a1973e
Packit Service a1973e
This PAPI component introduces a new ability for PAPI; it is the first
Packit Service a1973e
case where PAPI is writing information to a counter as well as reading
Packit Service a1973e
the data from the counter.
Packit Service a1973e
Packit Service a1973e
Packit Service a1973e
--------------------------------------------------
Packit Service a1973e
ENABLE ACCESS TO THE MSRS (MODEL SPECIFIC REGISTERS)
Packit Service a1973e
Packit Service a1973e
https://github.com/scalability-llnl/msr-safe
Packit Service a1973e
Packit Service a1973e
To use this component, the system will need to provide access to Model
Packit Service a1973e
Specific Registers (MSRs) from user space.  The actions described
Packit Service a1973e
below will generally require superuser ability.  Note, these actions
Packit Service a1973e
may have security and performance consequences, so please make sure
Packit Service a1973e
you know what you are doing.
Packit Service a1973e
Packit Service a1973e
  OPTION 1: EITHER: Enable MSR access using msr-safe
Packit Service a1973e
    Install the msr-safe module from LLNL, 
Packit Service a1973e
       lsmod | grep msr        (should show msr_safe)
Packit Service a1973e
    Use chmod to set site-appropriate access permissions (e.g. 766) for 
Packit Service a1973e
       /dev/cpu/*/msr_safe /dev/cpu/msr_batch /dev/cpu/msr_whitelist
Packit Service a1973e
    Load a whitelist appropriate for your machine
Packit Service a1973e
       e.g. for SandyBridge: 
Packit Service a1973e
         cat msr-safe/whitelists/wl_062D > /dev/cpu/msr_whitelist
Packit Service a1973e
    
Packit Service a1973e
  OPTION 2: OR: Enable MSR access via the filesystem and elevated permissions.
Packit Service a1973e
    Or, enable access to the standard MSRs filesystem
Packit Service a1973e
    
Packit Service a1973e
    For Linux kernel version < 3.7, using only file system checks
Packit Service a1973e
         chmod 666 /dev/cpu/*/msr
Packit Service a1973e
    
Packit Service a1973e
    For Linux kernel version >= 3.7, using capabilities
Packit Service a1973e
         chmod 666 /dev/cpu/*/msr
Packit Service a1973e
         The final executable needs CAP_SYS_RWIO to open MSR device files [1]
Packit Service a1973e
         setcap cap_sys_rawio=ep <user_executable>
Packit Service a1973e
         The final executable cannot be on a shared network partition.
Packit Service a1973e
    
Packit Service a1973e
    The dynamic linker on most operating systems will remove variables
Packit Service a1973e
    that control dynamic linking from the environment of executables
Packit Service a1973e
    with extended rights, such as setuid executables or executables
Packit Service a1973e
    with raised capabilities. One such variable is
Packit Service a1973e
    LD_LIBRARY_PATH. Therefore, executables that have the RAWIO
Packit Service a1973e
    capability can only load shared libraries from default system
Packit Service a1973e
    directories.
Packit Service a1973e
    
Packit Service a1973e
    One can work around this restriction by either installing the
Packit Service a1973e
    shared libraries in system directories, linking statically against
Packit Service a1973e
    those libraries, or using the -rpath linker option to specify the
Packit Service a1973e
    full path to the shared libraries during the linking step.
Packit Service a1973e
Packit Service a1973e
Packit Service a1973e
--------------------------------------------------
Packit Service a1973e
COMPILE THE LIBMSR LIBRARY TO ACCESS THE MSRS
Packit Service a1973e
Packit Service a1973e
https://github.com/scalability-llnl/libmsr
Packit Service a1973e
Packit Service a1973e
Get the library and follow the instructions to build using CMake.
Packit Service a1973e
This library contains a subdirectory, test, which will exercise the
Packit Service a1973e
functionality.
Packit Service a1973e
Packit Service a1973e
--------------------------------------------------
Packit Service a1973e
CONFIGURING THE PAPI LIBMSR COMPONENT
Packit Service a1973e
Packit Service a1973e
Set libmsr library and header files by configuring within the component.
Packit Service a1973e
    % cd <papi_dir>/src/components/libmsr
Packit Service a1973e
    % ./configure --with-libmsr-incdir=<PATH> --with-libmsr-libdir=<PATH> 
Packit Service a1973e
Then, at the higher src dirctory, configure with this component
Packit Service a1973e
    % cd <papi_dir>/src
Packit Service a1973e
    % ./configure --with-components="libmsr"
Packit Service a1973e
    or if you want to specify the compilers and enable debug.
Packit Service a1973e
    % ./configure CC=gcc F77=gfortran --with-debug --with-components="libmsr"
Packit Service a1973e
Finally, follow the standard PAPI build (make) instructions
Packit Service a1973e
    % make 
Packit Service a1973e
To use the module, make sure that the libraries are accessible.  
Packit Service a1973e
    % export LD_LIBRARY_PATH=${PAPIDIR}/src:${PAPIDIR}/src/libpfm4/lib:${LIBMSRDIR}/lib:${LD_LIBRARY_PATH}
Packit Service a1973e
To check the installation, the following should show some available counters 
Packit Service a1973e
    % ./utils/papi_native_avail | grep libmsr
Packit Service a1973e
To check the installation, the following should some counter values
Packit Service a1973e
    % ./utils/papi_native_avail -e "libmsr:::PKG_WATTS:PACKAGE0"
Packit Service a1973e
    % ./utils/papi_command_line  "libmsr:::PKG_WATTS:PACKAGE0"
Packit Service a1973e
    % ./utils/papi_command_line  "libmsr:::PKG_DELTA_ENERGY:PACKAGE0"
Packit Service a1973e
Packit Service a1973e
Packit Service a1973e
--------------------------------------------------
Packit Service a1973e
USE THE PAPI LIBMSR COMPONENT 
Packit Service a1973e
Packit Service a1973e
See the components/libmsr/utils/README file for instructions.  This
Packit Service a1973e
test demonstrates how to write power constraints, and gives an
Packit Service a1973e
estimate of the overheads for reading and writing information to the
Packit Service a1973e
RAPL MSRs.
Packit Service a1973e
Packit Service a1973e
Packit Service a1973e
[1] http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=c903f0456bc69176912dee6dd25c6a66ee1aed00
Packit Service a1973e
Packit Service a1973e
*/