Blame src/utils/print_header.c

Packit Service a1973e
#include <stdio.h>
Packit Service a1973e
#include <sys/utsname.h>
Packit Service a1973e
Packit Service a1973e
#include "papi.h"
Packit Service a1973e
Packit Service a1973e
/*  Support routine to display header information to the screen
Packit Service a1973e
	from the hardware info data structure. The same code was duplicated
Packit Service a1973e
	in a number of tests and utilities. Seems to make sense to refactor.
Packit Service a1973e
	This may not be the best place for it to live, but it works for now.
Packit Service a1973e
 */
Packit Service a1973e
int
Packit Service a1973e
papi_print_header( char *prompt, const PAPI_hw_info_t ** hwinfo )
Packit Service a1973e
{
Packit Service a1973e
	int cnt, mpx;
Packit Service a1973e
	struct utsname uname_info;
Packit Service a1973e
	PAPI_option_t options;
Packit Service a1973e
Packit Service a1973e
	if ( ( *hwinfo = PAPI_get_hardware_info(  ) ) == NULL ) {
Packit Service a1973e
   		return PAPI_ESYS;
Packit Service a1973e
	}
Packit Service a1973e
Packit Service a1973e
	PAPI_get_opt(PAPI_COMPONENTINFO,&options);
Packit Service a1973e
Packit Service a1973e
	uname(&uname_info);
Packit Service a1973e
Packit Service a1973e
	printf( "%s", prompt );
Packit Service a1973e
	printf
Packit Service a1973e
		( "--------------------------------------------------------------------------------\n" );
Packit Service a1973e
	printf( "PAPI version             : %d.%d.%d.%d\n",
Packit Service a1973e
			PAPI_VERSION_MAJOR( PAPI_VERSION ),
Packit Service a1973e
			PAPI_VERSION_MINOR( PAPI_VERSION ),
Packit Service a1973e
			PAPI_VERSION_REVISION( PAPI_VERSION ),
Packit Service a1973e
			PAPI_VERSION_INCREMENT( PAPI_VERSION ) );
Packit Service a1973e
	printf( "Operating system         : %s %s\n",
Packit Service a1973e
		uname_info.sysname, uname_info.release);
Packit Service a1973e
	printf( "Vendor string and code   : %s (%d, 0x%x)\n",
Packit Service a1973e
			( *hwinfo )->vendor_string,
Packit Service a1973e
			( *hwinfo )->vendor,
Packit Service a1973e
			( *hwinfo )->vendor );
Packit Service a1973e
	printf( "Model string and code    : %s (%d, 0x%x)\n",
Packit Service a1973e
			( *hwinfo )->model_string,
Packit Service a1973e
			( *hwinfo )->model,
Packit Service a1973e
			( *hwinfo )->model );
Packit Service a1973e
	printf( "CPU revision             : %f\n", ( *hwinfo )->revision );
Packit Service a1973e
	if ( ( *hwinfo )->cpuid_family > 0 ) {
Packit Service a1973e
		printf( "CPUID                    : Family/Model/Stepping %d/%d/%d, "
Packit Service a1973e
			"0x%02x/0x%02x/0x%02x\n",
Packit Service a1973e
			( *hwinfo )->cpuid_family,
Packit Service a1973e
			( *hwinfo )->cpuid_model,
Packit Service a1973e
			( *hwinfo )->cpuid_stepping,
Packit Service a1973e
			( *hwinfo )->cpuid_family,
Packit Service a1973e
			( *hwinfo )->cpuid_model,
Packit Service a1973e
			( *hwinfo )->cpuid_stepping );
Packit Service a1973e
	}
Packit Service a1973e
	printf( "CPU Max MHz              : %d\n", ( *hwinfo )->cpu_max_mhz );
Packit Service a1973e
	printf( "CPU Min MHz              : %d\n", ( *hwinfo )->cpu_min_mhz );
Packit Service a1973e
	printf( "Total cores              : %d\n", ( *hwinfo )->totalcpus );
Packit Service a1973e
Packit Service a1973e
	if ( ( *hwinfo )->threads > 0 )
Packit Service a1973e
		printf( "SMT threads per core     : %d\n", ( *hwinfo )->threads );
Packit Service a1973e
	if ( ( *hwinfo )->cores > 0 )
Packit Service a1973e
		printf( "Cores per socket         : %d\n", ( *hwinfo )->cores );
Packit Service a1973e
	if ( ( *hwinfo )->sockets > 0 )
Packit Service a1973e
		printf( "Sockets                  : %d\n", ( *hwinfo )->sockets );
Packit Service a1973e
	printf( "Cores per NUMA region    : %d\n", ( *hwinfo )->ncpu );
Packit Service a1973e
	printf( "NUMA regions             : %d\n", ( *hwinfo )->nnodes );
Packit Service a1973e
	printf( "Running in a VM          : %s\n", ( *hwinfo )->virtualized?
Packit Service a1973e
		"yes":"no");
Packit Service a1973e
	if ( (*hwinfo)->virtualized) {
Packit Service a1973e
           printf( "VM Vendor                : %s\n", (*hwinfo)->virtual_vendor_string);
Packit Service a1973e
	}
Packit Service a1973e
	cnt = PAPI_get_opt( PAPI_MAX_HWCTRS, NULL );
Packit Service a1973e
	mpx = PAPI_get_opt( PAPI_MAX_MPX_CTRS, NULL );
Packit Service a1973e
	if ( cnt >= 0 ) {
Packit Service a1973e
		printf( "Number Hardware Counters : %d\n",cnt );
Packit Service a1973e
	} else {
Packit Service a1973e
		printf( "Number Hardware Counters : PAPI error %d: %s\n", cnt, PAPI_strerror(cnt));
Packit Service a1973e
	}
Packit Service a1973e
	if ( mpx >= 0 ) {
Packit Service a1973e
		printf( "Max Multiplex Counters   : %d\n", mpx );
Packit Service a1973e
	} else {
Packit Service a1973e
		printf( "Max Multiplex Counters   : PAPI error %d: %s\n", mpx, PAPI_strerror(mpx));
Packit Service a1973e
	}
Packit Service a1973e
	printf("Fast counter read (rdpmc): %s\n",
Packit Service a1973e
		options.cmp_info->fast_counter_read?"yes":"no");
Packit Service a1973e
	printf( "--------------------------------------------------------------------------------\n" );
Packit Service a1973e
	printf( "\n" );
Packit Service a1973e
	return PAPI_OK;
Packit Service a1973e
}
Packit Service a1973e