PAPI not working for me on an Intel Xeon X5570 processor?

Open discussion of PAPI.

PAPI not working for me on an Intel Xeon X5570 processor?

Postby PalaceChan » Mon Jul 30, 2012 4:18 pm

I downloaded papi version 4.4.0, went into the src directory, did ./configure --prefix /my/dir and then make followed by make install. After doing that I took some code snippet from hwinfo in ctests (namely the following):

Code: Select all
#include <stdio.h>
#include <papi.h>

using namespace std;

int
papi_print_header( char *prompt, const PAPI_hw_info_t ** hwinfo )
{
    if ( ( *hwinfo = PAPI_get_hardware_info(  ) ) == NULL )
        return ( PAPI_ESBSTR );

    printf( "%s", prompt );
    printf
        ( "--------------------------------------------------------------------------------\n" );
    printf( "PAPI Version             : %d.%d.%d.%d\n",
            PAPI_VERSION_MAJOR( PAPI_VERSION ),
            PAPI_VERSION_MINOR( PAPI_VERSION ),
            PAPI_VERSION_REVISION( PAPI_VERSION ),
            PAPI_VERSION_INCREMENT( PAPI_VERSION ) );
    printf( "Vendor string and code   : %s (%d)\n", ( *hwinfo )->vendor_string,
            ( *hwinfo )->vendor );
    printf( "Model string and code    : %s (%d)\n", ( *hwinfo )->model_string,
            ( *hwinfo )->model );
    printf( "CPU Revision             : %f\n", ( *hwinfo )->revision );
    if ( ( *hwinfo )->cpuid_family > 0 )
        printf
            ( "CPUID Info               : Family: %d  Model: %d  Stepping: %d\n",
              ( *hwinfo )->cpuid_family, ( *hwinfo )->cpuid_model,
              ( *hwinfo )->cpuid_stepping );
    printf( "CPU Megahertz            : %f\n", ( *hwinfo )->mhz );
    printf( "CPU Clock Megahertz      : %d\n", ( *hwinfo )->clock_mhz );
    if ( ( *hwinfo )->threads > 0 )
        printf( "Hdw Threads per core     : %d\n", ( *hwinfo )->threads );
    if ( ( *hwinfo )->cores > 0 )
        printf( "Cores per Socket         : %d\n", ( *hwinfo )->cores );
    if ( ( *hwinfo )->sockets > 0 )
        printf( "Sockets                  : %d\n", ( *hwinfo )->sockets );
    if ( ( *hwinfo )->nnodes > 0 )
        printf( "NUMA Nodes               : %d\n", ( *hwinfo )->nnodes );
    printf( "CPUs per Node            : %d\n", ( *hwinfo )->ncpu );
    printf( "Total CPUs               : %d\n", ( *hwinfo )->totalcpus );
    printf( "Number Hardware Counters : %d\n",
            PAPI_get_opt( PAPI_MAX_HWCTRS, NULL ) );
    printf( "Max Multiplex Counters   : %d\n",
            PAPI_get_opt( PAPI_MAX_MPX_CTRS, NULL ) );
    printf
        ( "--------------------------------------------------------------------------------\n" );
    printf( "\n" );
    return PAPI_OK;
}

void
validate_string( char *name, char *s )
{
    if ( ( s == NULL ) || ( strlen( s ) == 0 ) ) {
        char s2[1024] = "";
        sprintf( s2, "%s was NULL or length 0", name );
        cerr << "Failed at line " << __LINE__ << endl;
    }
}


And added this simple main:

Code: Select all
int main(int argc, char** argv)
{

    int retval, i, j;
    const PAPI_hw_info_t *hwinfo = NULL;
    const PAPI_mh_info_t *mh;


    retval = PAPI_library_init( PAPI_VER_CURRENT );
    if ( retval != PAPI_VER_CURRENT )
        cerr << "Failed at line " << __LINE__ << endl;

    retval =
        papi_print_header
        ( "Test case hwinfo.c: Check output of PAPI_get_hardware_info.\n",
          &hwinfo );
    if ( retval != PAPI_OK )
        cerr << "Failed at line " << __LINE__ << endl;
}


I build it as follows:
Code: Select all
g++ main.cpp -I /home/pchan/rabbit/papi/include /home/avelazqu/rabbit/papi/lib/libpapi.a


and when I run it, I get the following output:

Code: Select all
Test case hwinfo.c: Check output of PAPI_get_hardware_info.
--------------------------------------------------------------------------------
PAPI Version             : 4.4.0.0
Vendor string and code   :  (0)
Model string and code    :  (0)
CPU Revision             : 0.000000
CPU Megahertz            : 0.000000
CPU Clock Megahertz      : 0
CPUs per Node            : 0
Total CPUs               : 0
Number Hardware Counters : 0
Max Multiplex Counters   : 0
--------------------------------------------------------------------------------


I'm confused as to why it seems this is not working and how to get PAPI working on my system.
PalaceChan
 
Posts: 4
Joined: Mon Jul 30, 2012 4:10 pm

Re: PAPI not working for me on an Intel Xeon X5570 processor

Postby PalaceChan » Tue Jul 31, 2012 5:59 pm

Also, even simpler, I go into the utils subdirectory of the src directory and am able to build the examples. I run all of them and they all fail. In utils, when I run papi_avail I get that out of the 107 possible events, 0 are available. Why would this be the case?
PalaceChan
 
Posts: 4
Joined: Mon Jul 30, 2012 4:10 pm

Re: PAPI not working for me on an Intel Xeon X5570 processor

Postby danterpstra » Wed Aug 01, 2012 9:52 am

It looks like your processor isn't being recognized. What does proc/cpuinfo say about your machine? What version of linux are you running? What's the output of configure?
danterpstra
 
Posts: 63
Joined: Wed Jun 23, 2010 2:21 pm

Re: PAPI not working for me on an Intel Xeon X5570 processor

Postby PalaceChan » Wed Aug 01, 2012 10:28 am

the last part of /proc/info says:

Code: Select all
...
processor       : 7
vendor_id       : GenuineIntel
cpu family      : 6
model           : 26
model name      : Intel(R) Xeon(R) CPU           X5570  @ 2.93GHz
stepping        : 5
cpu MHz         : 2933.528
cache size      : 8192 KB
physical id     : 0
siblings        : 4
core id         : 3
cpu cores       : 4
apicid          : 6
fpu             : yes
fpu_exception   : yes
cpuid level     : 11
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx rdtscp lm constant_tsc ida nonstop_tsc pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr sse4_1 sse4_2 popcnt lahf_lm
bogomips        : 5866.78
clflush size    : 64
cache_alignment : 64
address sizes   : 40 bits physical, 48 bits virtual
power management: [8]


(that is the last one, there are two physical cpus, all with the same Xeon, 8 logical cores)

As for version of linux, uname -a says:

Code: Select all
Linux my_machine 2.6.18-308.4.1.el5 #1 SMP Wed Mar 28 01:54:56 EDT 2012 x86_64 x86_64 x86_64 GNU/Linux


Finally the output of configure (I ran with --prefix option) is this:
Code: Select all
checking for architecture... x86_64
checking for OS... linux
checking for OS version... 2.6.18-308.4.1.el5
checking for user events...
checking for static user events build...
checking for perf_event workaround level... autodetect
checking for xlc... no
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ANSI C... none needed
checking for xlf... no
checking for gfortran... gfortran
checking whether we are using the GNU Fortran 77 compiler... yes
checking whether gfortran accepts -g... yes
checking for gawk... gawk
checking how to run the C preprocessor... gcc -E
checking whether ln -s works... yes
checking whether make sets $(MAKE)... yes
checking for ranlib... ranlib
checking for egrep... grep -E
checking for ANSI C header files... yes
checking for inline... inline
checking whether time.h and sys/time.h may both be included... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking sys/time.h usability... yes
checking sys/time.h presence... yes
checking for sys/time.h... yes
checking c_asm.h usability... no
checking c_asm.h presence... no
checking for c_asm.h... no
checking intrinsics.h usability... no
checking intrinsics.h presence... no
checking for intrinsics.h... no
checking mach/mach_time.h usability... no
checking mach/mach_time.h presence... no
checking for mach/mach_time.h... no
checking for gethrtime... no
checking for read_real_time... no
checking for time_base_to_time... no
checking for clock_gettime... no
checking for mach_absolute_time... no
checking for dlopen and dlerror symbols in base system... not found
checking for dlopen and dlerror symbols in -ldl... found
checking for components to build...
checking for debug build...
checking for CPU type... i7
checking for ffsll... yes
checking for working gettid... no
checking for working syscall(SYS_gettid)... yes
checking for working MMTIMER... no
checking for working CLOCK_REALTIME_HR POSIX 1b timer... no
checking for working CLOCK_REALTIME POSIX 1b timer... yes
checking for real time clock or cycle counter... clock_realtime
checking for working __thread... yes
checking for high performance thread local storage... __thread
checking for working CLOCK_THREAD_CPUTIME_ID POSIX 1b timer... yes
checking for thread virtual clock or cycle counter... clock_thread_cputime_id
configure: Generating papi_events_table.h
checking for which libraries to build... shared static
checking for link test cases with shared library...
checking for /sys/class/perfctr... no
checking for /dev/perfctr... no
checking for /sys/kernel/perfmon/version... no
checking for /proc/perfmon... no
checking for /proc/sys/kernel/perf_event_paranoid... no
checking platform... generic_platform
configure: Compiling genpapifdef with gcc
configure: Generating fpapi.h
configure: Generating f77papi.h
configure: Generating f90papi.h
configure: Makefile.inc will be included in the generated Makefile
configure: creating ./config.status
config.status: creating Makefile
config.status: creating config.h
config.status: config.h is unchanged
PalaceChan
 
Posts: 4
Joined: Mon Jul 30, 2012 4:10 pm

Re: PAPI not working for me on an Intel Xeon X5570 processor

Postby danterpstra » Wed Aug 01, 2012 11:01 am

The problem is your linux kernel.
2.6.18 is pretty ancient.
If you MUST use this kernel, you'll need to patch it with either perfctr or perfmon2.
You'd really be better off upgrading to a more recent kernel, like 3.3 or 3.4.
If this isn't an option, try a recent redhat, centos or debian release.
danterpstra
 
Posts: 63
Joined: Wed Jun 23, 2010 2:21 pm

Re: PAPI not working for me on an Intel Xeon X5570 processor

Postby PalaceChan » Wed Aug 01, 2012 11:18 am

Ah I see, this is what I was fearing. On a more recent kernel 3.3+ would I need a kernel patch? (My personal laptop runs arch linux and has 3.4 kernel)
PalaceChan
 
Posts: 4
Joined: Mon Jul 30, 2012 4:10 pm

Re: PAPI not working for me on an Intel Xeon X5570 processor

Postby danterpstra » Wed Aug 01, 2012 11:29 am

All kernels since 2.6.32 have built-in support for performance counters, so you won't need a patch, but you will need to make sure the perf_events module is enabled. You should, for example, be able to install PAPI on your laptop with no patches.
The performance counter support has evolved pretty rapidly, so the more recent the kernel, the better off you'll be.
danterpstra
 
Posts: 63
Joined: Wed Jun 23, 2010 2:21 pm


Return to General discussion

Who is online

Users browsing this forum: Rereesogy and 1 guest

cron