|
Packit |
577717 |
/* This file utility reports hardware info and native event availability on either the host
|
|
Packit |
577717 |
* CPU or on one of the attached MIC devices. It is based on the papi_native_avail utility,
|
|
Packit |
577717 |
* but uses offloading to run either on the host CPU or on a target device. */
|
|
Packit |
577717 |
/** file hybrid_native_avail.c
|
|
Packit |
577717 |
* @page papi_hybrid_native_avail
|
|
Packit |
577717 |
* @brief papi_hybrid_native_avail utility.
|
|
Packit |
577717 |
* @section NAME
|
|
Packit |
577717 |
* papi_hybrid_native_avail - provides detailed information for PAPI native events.
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* @section Synopsis
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* @section Description
|
|
Packit |
577717 |
* papi_hybrid_native_avail is a PAPI utility program that reports information
|
|
Packit |
577717 |
* about the native events available on the current platform or on an attached MIC card.
|
|
Packit |
577717 |
* A native event is an event specific to a specific hardware platform.
|
|
Packit |
577717 |
* On many platforms, a specific native event may have a number of optional settings.
|
|
Packit |
577717 |
* In such cases, the native event and the valid settings are presented,
|
|
Packit |
577717 |
* rather than every possible combination of those settings.
|
|
Packit |
577717 |
* For each native event, a name, a description, and specific bit patterns are provided.
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* @section Options
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* --help, -h print this help message
|
|
Packit |
577717 |
* -d display detailed information about native events
|
|
Packit |
577717 |
* -e EVENTNAME display detailed information about named native event
|
|
Packit |
577717 |
* -i EVENTSTR include only event names that contain EVENTSTR
|
|
Packit |
577717 |
* -x EVENTSTR exclude any event names that contain EVENTSTR
|
|
Packit |
577717 |
* --noumasks suppress display of Unit Mask information
|
|
Packit |
577717 |
* --mic < index > report events on the specified target MIC device
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* Processor-specific options
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* --darr display events supporting Data Address Range Restriction
|
|
Packit |
577717 |
* --dear display Data Event Address Register events only
|
|
Packit |
577717 |
* --iarr display events supporting Instruction Address Range Restriction
|
|
Packit |
577717 |
* --iear display Instruction Event Address Register events only
|
|
Packit |
577717 |
* --opcm display events supporting OpCode Matching
|
|
Packit |
577717 |
* --nogroups suppress display of Event grouping information
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* @section Bugs
|
|
Packit |
577717 |
* There are no known bugs in this utility.
|
|
Packit |
577717 |
* If you find a bug, it should be reported to the
|
|
Packit |
577717 |
* PAPI Mailing List at <ptools-perfapi@icl.utk.edu>.
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* Modified by Gabriel Marin <gmarin@icl.utk.edu> to use offloading.
|
|
Packit |
577717 |
*/
|
|
Packit |
577717 |
|
|
Packit |
577717 |
//#pragma offload_attribute (push,target(mic))
|
|
Packit |
577717 |
//#include "papi_test.h"
|
|
Packit |
577717 |
//#pragma offload_attribute (pop)
|
|
Packit |
577717 |
|
|
Packit |
577717 |
#include <stdlib.h>
|
|
Packit |
577717 |
#include <offload.h>
|
|
Packit |
577717 |
|
|
Packit |
577717 |
#define EVT_LINE 80
|
|
Packit |
577717 |
|
|
Packit |
577717 |
typedef struct command_flags
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
int help;
|
|
Packit |
577717 |
int details;
|
|
Packit |
577717 |
int named;
|
|
Packit |
577717 |
int include;
|
|
Packit |
577717 |
int xclude;
|
|
Packit |
577717 |
char *name, *istr, *xstr;
|
|
Packit |
577717 |
int darr;
|
|
Packit |
577717 |
int dear;
|
|
Packit |
577717 |
int iarr;
|
|
Packit |
577717 |
int iear;
|
|
Packit |
577717 |
int opcm;
|
|
Packit |
577717 |
int umask;
|
|
Packit |
577717 |
int groups;
|
|
Packit |
577717 |
int mic;
|
|
Packit |
577717 |
int devidx;
|
|
Packit |
577717 |
} command_flags_t;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
static void
|
|
Packit |
577717 |
print_help( char **argv )
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
printf( "This is the PAPI native avail program.\n" );
|
|
Packit |
577717 |
printf( "It provides availability and detail information for PAPI native events.\n" );
|
|
Packit |
577717 |
printf( "Usage: %s [options]\n", argv[0] );
|
|
Packit |
577717 |
printf( "\nOptions:\n" );
|
|
Packit |
577717 |
printf( " --help, -h print this help message\n" );
|
|
Packit |
577717 |
printf( " -d display detailed information about native events\n" );
|
|
Packit |
577717 |
printf( " -e EVENTNAME display detailed information about named native event\n" );
|
|
Packit |
577717 |
printf( " -i EVENTSTR include only event names that contain EVENTSTR\n" );
|
|
Packit |
577717 |
printf( " -x EVENTSTR exclude any event names that contain EVENTSTR\n" );
|
|
Packit |
577717 |
printf( " --noumasks suppress display of Unit Mask information\n" );
|
|
Packit |
577717 |
printf( "\nProcessor-specific options\n");
|
|
Packit |
577717 |
printf( " --darr display events supporting Data Address Range Restriction\n" );
|
|
Packit |
577717 |
printf( " --dear display Data Event Address Register events only\n" );
|
|
Packit |
577717 |
printf( " --iarr display events supporting Instruction Address Range Restriction\n" );
|
|
Packit |
577717 |
printf( " --iear display Instruction Event Address Register events only\n" );
|
|
Packit |
577717 |
printf( " --opcm display events supporting OpCode Matching\n" );
|
|
Packit |
577717 |
printf( " --nogroups suppress display of Event grouping information\n" );
|
|
Packit |
577717 |
printf( " --mic <index> display events on the specified Xeon Phi device\n" );
|
|
Packit |
577717 |
printf( "\n" );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
static int
|
|
Packit |
577717 |
no_str_arg( char *arg )
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
return ( ( arg == NULL ) || ( strlen( arg ) == 0 ) || ( arg[0] == '-' ) );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
static void
|
|
Packit |
577717 |
parse_args( int argc, char **argv, command_flags_t * f )
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
|
|
Packit |
577717 |
int i;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* Look for all currently defined commands */
|
|
Packit |
577717 |
memset( f, 0, sizeof ( command_flags_t ) );
|
|
Packit |
577717 |
f->umask = 1;
|
|
Packit |
577717 |
f->groups = 1;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
for ( i = 1; i < argc; i++ ) {
|
|
Packit |
577717 |
if ( !strcmp( argv[i], "--darr" ) )
|
|
Packit |
577717 |
f->darr = 1;
|
|
Packit |
577717 |
else if ( !strcmp( argv[i], "--dear" ) )
|
|
Packit |
577717 |
f->dear = 1;
|
|
Packit |
577717 |
else if ( !strcmp( argv[i], "--iarr" ) )
|
|
Packit |
577717 |
f->iarr = 1;
|
|
Packit |
577717 |
else if ( !strcmp( argv[i], "--iear" ) )
|
|
Packit |
577717 |
f->iear = 1;
|
|
Packit |
577717 |
else if ( !strcmp( argv[i], "--opcm" ) )
|
|
Packit |
577717 |
f->opcm = 1;
|
|
Packit |
577717 |
else if ( !strcmp( argv[i], "--noumasks" ) )
|
|
Packit |
577717 |
f->umask = 0;
|
|
Packit |
577717 |
else if ( !strcmp( argv[i], "--nogroups" ) )
|
|
Packit |
577717 |
f->groups = 0;
|
|
Packit |
577717 |
else if ( !strcmp( argv[i], "-d" ) )
|
|
Packit |
577717 |
f->details = 1;
|
|
Packit |
577717 |
else if ( !strcmp( argv[i], "--mic" ) )
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
f->mic = 1;
|
|
Packit |
577717 |
i++;
|
|
Packit |
577717 |
if ( i >= argc || no_str_arg( argv[i] ) ) {
|
|
Packit |
577717 |
printf( "Specify a device index for --mic\n");
|
|
Packit |
577717 |
exit(1);
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
f->devidx = strtol(argv[i], 0, 10);
|
|
Packit |
577717 |
} else if ( !strcmp( argv[i], "-e" ) ) {
|
|
Packit |
577717 |
f->named = 1;
|
|
Packit |
577717 |
i++;
|
|
Packit |
577717 |
f->name = argv[i];
|
|
Packit |
577717 |
if ( i >= argc || no_str_arg( f->name ) ) {
|
|
Packit |
577717 |
printf( "Invalid argument for -e\n");
|
|
Packit |
577717 |
exit(1);
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
} else if ( !strcmp( argv[i], "-i" ) ) {
|
|
Packit |
577717 |
f->include = 1;
|
|
Packit |
577717 |
i++;
|
|
Packit |
577717 |
f->istr = argv[i];
|
|
Packit |
577717 |
if ( i >= argc || no_str_arg( f->istr ) ) {
|
|
Packit |
577717 |
printf( "Invalid argument for -i\n");
|
|
Packit |
577717 |
exit(1);
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
} else if ( !strcmp( argv[i], "-x" ) ) {
|
|
Packit |
577717 |
f->xclude = 1;
|
|
Packit |
577717 |
i++;
|
|
Packit |
577717 |
f->xstr = argv[i];
|
|
Packit |
577717 |
if ( i >= argc || no_str_arg( f->xstr ) ) {
|
|
Packit |
577717 |
printf( "Invalid argument for -x\n");
|
|
Packit |
577717 |
exit(1);
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
} else if ( !strcmp( argv[i], "-h" ) || !strcmp( argv[i], "--help" ) )
|
|
Packit |
577717 |
f->help = 1;
|
|
Packit |
577717 |
else {
|
|
Packit |
577717 |
printf( "%s is not supported\n", argv[i] );
|
|
Packit |
577717 |
exit(1);
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* if help requested, print and bail */
|
|
Packit |
577717 |
if ( f->help ) {
|
|
Packit |
577717 |
print_help( argv);
|
|
Packit |
577717 |
exit( 1 );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
static void
|
|
Packit |
577717 |
space_pad( char *str, int spaces )
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
while ( spaces-- > 0 )
|
|
Packit |
577717 |
strcat( str, " " );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
static void
|
|
Packit |
577717 |
print_event( PAPI_event_info_t * info, int offset )
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
unsigned int i, j = 0;
|
|
Packit |
577717 |
char str[EVT_LINE + EVT_LINE];
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* indent by offset */
|
|
Packit |
577717 |
if ( offset ) {
|
|
Packit |
577717 |
printf( "| %-73s|\n", info->symbol );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
else {
|
|
Packit |
577717 |
printf( "| %-77s|\n", info->symbol );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
while ( j <= strlen( info->long_descr ) ) {
|
|
Packit |
577717 |
i = EVT_LINE - 12 - 2;
|
|
Packit |
577717 |
if ( i > 0 ) {
|
|
Packit |
577717 |
str[0] = 0;
|
|
Packit |
577717 |
strcat(str,"| " );
|
|
Packit |
577717 |
space_pad( str, 11 );
|
|
Packit |
577717 |
strncat( str, &info->long_descr[j], i );
|
|
Packit |
577717 |
j += i;
|
|
Packit |
577717 |
i = ( unsigned int ) strlen( str );
|
|
Packit |
577717 |
space_pad( str, EVT_LINE - ( int ) i - 1 );
|
|
Packit |
577717 |
strcat( str, "|" );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
printf( "%s\n", str );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
static int
|
|
Packit |
577717 |
parse_unit_masks( PAPI_event_info_t * info )
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
char *pmask,*ptr;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* handle the PAPI component-style events which have a component:::event type */
|
|
Packit |
577717 |
if ((ptr=strstr(info->symbol, ":::"))) {
|
|
Packit |
577717 |
ptr+=3;
|
|
Packit |
577717 |
/* handle libpfm4-style events which have a pmu::event type event name */
|
|
Packit |
577717 |
} else if ((ptr=strstr(info->symbol, "::"))) {
|
|
Packit |
577717 |
ptr+=2;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
else {
|
|
Packit |
577717 |
ptr=info->symbol;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
if ( ( pmask = strchr( ptr, ':' ) ) == NULL ) {
|
|
Packit |
577717 |
return ( 0 );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
memmove( info->symbol, pmask, ( strlen( pmask ) + 1 ) * sizeof ( char ) );
|
|
Packit |
577717 |
pmask = strchr( info->long_descr, ':' );
|
|
Packit |
577717 |
if ( pmask == NULL )
|
|
Packit |
577717 |
info->long_descr[0] = 0;
|
|
Packit |
577717 |
else
|
|
Packit |
577717 |
memmove( info->long_descr, pmask + sizeof ( char ),
|
|
Packit |
577717 |
( strlen( pmask ) + 1 ) * sizeof ( char ) );
|
|
Packit |
577717 |
return ( 1 );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
|
|
Packit |
577717 |
int
|
|
Packit |
577717 |
main( int argc, char **argv )
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
int i, j = 0, k;
|
|
Packit |
577717 |
int retval;
|
|
Packit |
577717 |
PAPI_event_info_t info;
|
|
Packit |
577717 |
const PAPI_hw_info_t *hwinfo = NULL;
|
|
Packit |
577717 |
command_flags_t flags;
|
|
Packit |
577717 |
int enum_modifier;
|
|
Packit |
577717 |
int numcmp, cid;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
int num_devices = 0;
|
|
Packit |
577717 |
int target_idx = 0;
|
|
Packit |
577717 |
int offload_mode = 0;
|
|
Packit |
577717 |
int target_ok = 0;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* Parse the command-line arguments */
|
|
Packit |
577717 |
parse_args( argc, argv, &flags );
|
|
Packit |
577717 |
|
|
Packit |
577717 |
if (flags.mic)
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
printf("Checking for Intel(R) Xeon Phi(TM) (Target CPU) devices...\n\n");
|
|
Packit |
577717 |
|
|
Packit |
577717 |
#ifdef __INTEL_OFFLOAD
|
|
Packit |
577717 |
num_devices = _Offload_number_of_devices();
|
|
Packit |
577717 |
#endif
|
|
Packit |
577717 |
printf("Number of Target devices installed: %d\n\n",num_devices);
|
|
Packit |
577717 |
|
|
Packit |
577717 |
if (flags.devidx >= num_devices) {
|
|
Packit |
577717 |
// Run in fallback-mode
|
|
Packit |
577717 |
printf("Requested device index %d is not available. Specify a device between 0 and %d\n\n",
|
|
Packit |
577717 |
flags.devidx, num_devices-1);
|
|
Packit |
577717 |
exit(1);
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
else {
|
|
Packit |
577717 |
offload_mode = 1;
|
|
Packit |
577717 |
target_idx = flags.devidx;
|
|
Packit |
577717 |
printf("PAPI will list the native events available on device mic%d\n\n", target_idx);
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* Set enum modifier mask */
|
|
Packit |
577717 |
if ( flags.dear )
|
|
Packit |
577717 |
enum_modifier = PAPI_NTV_ENUM_DEAR;
|
|
Packit |
577717 |
else if ( flags.darr )
|
|
Packit |
577717 |
enum_modifier = PAPI_NTV_ENUM_DARR;
|
|
Packit |
577717 |
else if ( flags.iear )
|
|
Packit |
577717 |
enum_modifier = PAPI_NTV_ENUM_IEAR;
|
|
Packit |
577717 |
else if ( flags.iarr )
|
|
Packit |
577717 |
enum_modifier = PAPI_NTV_ENUM_IARR;
|
|
Packit |
577717 |
else if ( flags.opcm )
|
|
Packit |
577717 |
enum_modifier = PAPI_NTV_ENUM_OPCM;
|
|
Packit |
577717 |
else
|
|
Packit |
577717 |
enum_modifier = PAPI_ENUM_EVENTS;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/// #pragma offload target(mic: target_idx) if(offload_mode) in(argc, argv) inout(TESTS_QUIET)
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* Initialize before parsing the input arguments */
|
|
Packit |
577717 |
#ifdef __INTEL_OFFLOAD
|
|
Packit |
577717 |
__Offload_report(1);
|
|
Packit |
577717 |
#endif
|
|
Packit |
577717 |
#pragma offload target(mic: target_idx) if(offload_mode)
|
|
Packit |
577717 |
|
|
Packit |
577717 |
retval = PAPI_library_init(PAPI_VER_CURRENT);
|
|
Packit |
577717 |
if ( retval != PAPI_VER_CURRENT ) {
|
|
Packit |
577717 |
fprintf(stderr,"Error! PAPI_library_init\n");
|
|
Packit |
577717 |
exit(retval);
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
|
|
Packit |
577717 |
if ( !TESTS_QUIET ) {
|
|
Packit |
577717 |
#ifdef __INTEL_OFFLOAD
|
|
Packit |
577717 |
__Offload_report(1);
|
|
Packit |
577717 |
#endif
|
|
Packit |
577717 |
#pragma offload target(mic: target_idx) if(offload_mode)
|
|
Packit |
577717 |
retval = PAPI_set_debug( PAPI_VERB_ECONT );
|
|
Packit |
577717 |
if ( retval != PAPI_OK ) {
|
|
Packit |
577717 |
fprintf(stderr,"Error! PAPI_set_debug\n");
|
|
Packit |
577717 |
exit(retval);
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
#ifdef __INTEL_OFFLOAD
|
|
Packit |
577717 |
__Offload_report(1);
|
|
Packit |
577717 |
#endif
|
|
Packit |
577717 |
#pragma offload target(mic: target_idx) if(offload_mode) nocopy(hwinfo)
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
retval = papi_print_header( "Available native events and hardware information.\n", &hwinfo );
|
|
Packit |
577717 |
fflush(stdout);
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
if ( retval != PAPI_OK ) {
|
|
Packit |
577717 |
fprintf(stderr,"Error! PAPI_get_hardware_info\n");
|
|
Packit |
577717 |
exit( 2 );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* Do this code if the event name option was specified on the commandline */
|
|
Packit |
577717 |
if ( flags.named )
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
int papi_ok = 0;
|
|
Packit |
577717 |
char *ename = flags.name;
|
|
Packit |
577717 |
int elen = 0;
|
|
Packit |
577717 |
if (ename)
|
|
Packit |
577717 |
elen = strlen(ename) + 1;
|
|
Packit |
577717 |
#ifdef __INTEL_OFFLOAD
|
|
Packit |
577717 |
__Offload_report(1);
|
|
Packit |
577717 |
#endif
|
|
Packit |
577717 |
#pragma offload target(mic: target_idx) if(offload_mode) in(ename:length(elen)) out(i)
|
|
Packit |
577717 |
papi_ok = PAPI_event_name_to_code(ename, &i);
|
|
Packit |
577717 |
|
|
Packit |
577717 |
if (papi_ok == PAPI_OK)
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
#ifdef __INTEL_OFFLOAD
|
|
Packit |
577717 |
__Offload_report(1);
|
|
Packit |
577717 |
#endif
|
|
Packit |
577717 |
#pragma offload target(mic: target_idx) if(offload_mode) out(info)
|
|
Packit |
577717 |
papi_ok = PAPI_get_event_info(i, &info;;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
if (papi_ok == PAPI_OK)
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
printf( "%-30s%s\n",
|
|
Packit |
577717 |
"Event name:", info.symbol);
|
|
Packit |
577717 |
printf( "%-29s|%s|\n", "Description:", info.long_descr );
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* if unit masks exist but none specified, process all */
|
|
Packit |
577717 |
if ( !strchr( flags.name, ':' ) )
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
#ifdef __INTEL_OFFLOAD
|
|
Packit |
577717 |
__Offload_report(1);
|
|
Packit |
577717 |
#endif
|
|
Packit |
577717 |
#pragma offload target(mic: target_idx) if(offload_mode) inout(i)
|
|
Packit |
577717 |
papi_ok = PAPI_enum_event( &i, PAPI_NTV_ENUM_UMASKS);
|
|
Packit |
577717 |
if (papi_ok == PAPI_OK )
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
printf( "\nUnit Masks:\n" );
|
|
Packit |
577717 |
do
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
#ifdef __INTEL_OFFLOAD
|
|
Packit |
577717 |
__Offload_report(1);
|
|
Packit |
577717 |
#endif
|
|
Packit |
577717 |
#pragma offload target(mic: target_idx) if(offload_mode) inout(i, info)
|
|
Packit |
577717 |
retval = PAPI_get_event_info( i, &info );
|
|
Packit |
577717 |
if ( retval == PAPI_OK ) {
|
|
Packit |
577717 |
if ( parse_unit_masks( &info ) ) {
|
|
Packit |
577717 |
printf( "%-29s|%s|%s|\n", " Mask Info:",
|
|
Packit |
577717 |
info.symbol, info.long_descr );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
#ifdef __INTEL_OFFLOAD
|
|
Packit |
577717 |
__Offload_report(1);
|
|
Packit |
577717 |
#endif
|
|
Packit |
577717 |
#pragma offload target(mic: target_idx) if(offload_mode) inout(i, info)
|
|
Packit |
577717 |
papi_ok = PAPI_enum_event(&i, PAPI_NTV_ENUM_UMASKS);
|
|
Packit |
577717 |
} while (papi_ok == PAPI_OK);
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
} else {
|
|
Packit |
577717 |
printf("Sorry, an event by the name '%s' could not be found.\n",
|
|
Packit |
577717 |
flags.name);
|
|
Packit |
577717 |
printf("Is it typed correctly?\n\n");
|
|
Packit |
577717 |
exit( 1 );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
else {
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* Print *ALL* available events */
|
|
Packit |
577717 |
|
|
Packit |
577717 |
#ifdef __INTEL_OFFLOAD
|
|
Packit |
577717 |
__Offload_report(1);
|
|
Packit |
577717 |
#endif
|
|
Packit |
577717 |
#pragma offload target(mic: target_idx) if(offload_mode)
|
|
Packit |
577717 |
numcmp = PAPI_num_components( );
|
|
Packit |
577717 |
|
|
Packit |
577717 |
j = 0;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
for ( cid = 0; cid < numcmp; cid++ ) {
|
|
Packit |
577717 |
|
|
Packit |
577717 |
PAPI_component_info_t component;
|
|
Packit |
577717 |
// if (offload_mode) // I must allocate local memory to receive the result
|
|
Packit |
577717 |
// component = (PAPI_component_info_t*)malloc(sizeof(PAPI_component_info_t));
|
|
Packit |
577717 |
// #pragma offload target(mic: target_idx) if(offload_mode) out(*component:length(sizeof(PAPI_component_info_t)) alloc_if(0) free_if(0))
|
|
Packit |
577717 |
#ifdef __INTEL_OFFLOAD
|
|
Packit |
577717 |
__Offload_report(1);
|
|
Packit |
577717 |
#endif
|
|
Packit |
577717 |
#pragma offload target(mic: target_idx) if(offload_mode) out(component)
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
memcpy(&component, PAPI_get_component_info(cid), sizeof(PAPI_component_info_t));
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* Skip disabled components */
|
|
Packit |
577717 |
if (component.disabled) continue;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
printf( "===============================================================================\n" );
|
|
Packit |
577717 |
printf( " Native Events in Component: %s\n",component.name);
|
|
Packit |
577717 |
printf( "===============================================================================\n" );
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* Always ASK FOR the first event */
|
|
Packit |
577717 |
/* Don't just assume it'll be the first numeric value */
|
|
Packit |
577717 |
i = 0 | PAPI_NATIVE_MASK;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
#ifdef __INTEL_OFFLOAD
|
|
Packit |
577717 |
__Offload_report(1);
|
|
Packit |
577717 |
#endif
|
|
Packit |
577717 |
#pragma offload target(mic: target_idx) if(offload_mode) inout(i)
|
|
Packit |
577717 |
retval=PAPI_enum_cmp_event( &i, PAPI_ENUM_FIRST, cid );
|
|
Packit |
577717 |
|
|
Packit |
577717 |
do
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
memset( &info, 0, sizeof ( info ) );
|
|
Packit |
577717 |
#ifdef __INTEL_OFFLOAD
|
|
Packit |
577717 |
__Offload_report(1);
|
|
Packit |
577717 |
#endif
|
|
Packit |
577717 |
#pragma offload target(mic: target_idx) if(offload_mode) inout(info)
|
|
Packit |
577717 |
retval = PAPI_get_event_info( i, &info );
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* This event may not exist */
|
|
Packit |
577717 |
if ( retval != PAPI_OK )
|
|
Packit |
577717 |
goto endloop;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* Bail if event name doesn't contain include string */
|
|
Packit |
577717 |
if ( flags.include ) {
|
|
Packit |
577717 |
if ( !strstr( info.symbol, flags.istr ) ) {
|
|
Packit |
577717 |
goto endloop;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* Bail if event name does contain exclude string */
|
|
Packit |
577717 |
if ( flags.xclude ) {
|
|
Packit |
577717 |
if ( strstr( info.symbol, flags.xstr ) )
|
|
Packit |
577717 |
goto endloop;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* count only events that are actually processed */
|
|
Packit |
577717 |
j++;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
print_event( &info, 0 );
|
|
Packit |
577717 |
|
|
Packit |
577717 |
if (flags.details) {
|
|
Packit |
577717 |
if (info.units[0]) printf( "| Units: %-67s|\n",
|
|
Packit |
577717 |
info.units );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* modifier = PAPI_NTV_ENUM_GROUPS returns event codes with a
|
|
Packit |
577717 |
groups id for each group in which this
|
|
Packit |
577717 |
native event lives, in bits 16 - 23 of event code
|
|
Packit |
577717 |
terminating with PAPI_ENOEVNT at the end of the list.
|
|
Packit |
577717 |
*/
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* This is an IBM Power issue */
|
|
Packit |
577717 |
if ( flags.groups ) {
|
|
Packit |
577717 |
int papi_ok = 0;
|
|
Packit |
577717 |
k = i;
|
|
Packit |
577717 |
#ifdef __INTEL_OFFLOAD
|
|
Packit |
577717 |
__Offload_report(1);
|
|
Packit |
577717 |
#endif
|
|
Packit |
577717 |
#pragma offload target(mic: target_idx) if(offload_mode) inout(k)
|
|
Packit |
577717 |
papi_ok = PAPI_enum_cmp_event(&k, PAPI_NTV_ENUM_GROUPS, cid);
|
|
Packit |
577717 |
if (papi_ok == PAPI_OK )
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
printf("Groups: ");
|
|
Packit |
577717 |
do {
|
|
Packit |
577717 |
printf( "%4d", ( ( k & PAPI_NTV_GROUP_AND_MASK ) >>
|
|
Packit |
577717 |
PAPI_NTV_GROUP_SHIFT ) - 1 );
|
|
Packit |
577717 |
#ifdef __INTEL_OFFLOAD
|
|
Packit |
577717 |
__Offload_report(1);
|
|
Packit |
577717 |
#endif
|
|
Packit |
577717 |
#pragma offload target(mic: target_idx) if(offload_mode) inout(k)
|
|
Packit |
577717 |
papi_ok = PAPI_enum_cmp_event(&k, PAPI_NTV_ENUM_GROUPS, cid);
|
|
Packit |
577717 |
} while (papi_ok==PAPI_OK );
|
|
Packit |
577717 |
printf( "\n" );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* Print umasks */
|
|
Packit |
577717 |
/* components that don't have them can just ignore */
|
|
Packit |
577717 |
|
|
Packit |
577717 |
if ( flags.umask )
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
int papi_ok = 0;
|
|
Packit |
577717 |
k = i;
|
|
Packit |
577717 |
#ifdef __INTEL_OFFLOAD
|
|
Packit |
577717 |
__Offload_report(1);
|
|
Packit |
577717 |
#endif
|
|
Packit |
577717 |
#pragma offload target(mic: target_idx) if(offload_mode) inout(k)
|
|
Packit |
577717 |
papi_ok = PAPI_enum_cmp_event(&k, PAPI_NTV_ENUM_UMASKS, cid);
|
|
Packit |
577717 |
if (papi_ok == PAPI_OK )
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
do {
|
|
Packit |
577717 |
#ifdef __INTEL_OFFLOAD
|
|
Packit |
577717 |
__Offload_report(1);
|
|
Packit |
577717 |
#endif
|
|
Packit |
577717 |
#pragma offload target(mic: target_idx) if(offload_mode) inout(info)
|
|
Packit |
577717 |
retval = PAPI_get_event_info(k, &info;;
|
|
Packit |
577717 |
if ( retval == PAPI_OK ) {
|
|
Packit |
577717 |
if (parse_unit_masks( &info ))
|
|
Packit |
577717 |
print_event(&info, 2);
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
#ifdef __INTEL_OFFLOAD
|
|
Packit |
577717 |
__Offload_report(1);
|
|
Packit |
577717 |
#endif
|
|
Packit |
577717 |
#pragma offload target(mic: target_idx) if(offload_mode) inout(k)
|
|
Packit |
577717 |
papi_ok = PAPI_enum_cmp_event(&k, PAPI_NTV_ENUM_UMASKS, cid);
|
|
Packit |
577717 |
} while (papi_ok == PAPI_OK);
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
printf( "--------------------------------------------------------------------------------\n" );
|
|
Packit |
577717 |
|
|
Packit |
577717 |
endloop:
|
|
Packit |
577717 |
#ifdef __INTEL_OFFLOAD
|
|
Packit |
577717 |
__Offload_report(1);
|
|
Packit |
577717 |
#endif
|
|
Packit |
577717 |
#pragma offload target(mic: target_idx) if(offload_mode) inout(i)
|
|
Packit |
577717 |
retval=PAPI_enum_cmp_event(&i, enum_modifier, cid);
|
|
Packit |
577717 |
} while (retval == PAPI_OK );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
printf("\n");
|
|
Packit |
577717 |
printf( "Total events reported: %d\n", j );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
return 0;
|
|
Packit |
577717 |
}
|