PAPI 7.1.0.0
Loading...
Searching...
No Matches
papi_component_avail.c File Reference
Include dependency graph for papi_component_avail.c:

Go to the source code of this file.

Data Structures

struct  command_flags_t
 

Macros

#define EVT_LINE   80
 

Functions

static void force_cmp_init (int cid)
 
static void print_help (char **argv)
 
static void parse_args (int argc, char **argv, command_flags_t *f)
 
int main (int argc, char **argv)
 

Macro Definition Documentation

◆ EVT_LINE

#define EVT_LINE   80

Definition at line 33 of file papi_component_avail.c.

Function Documentation

◆ force_cmp_init()

void force_cmp_init ( int  cid)
static

Definition at line 193 of file papi_component_avail.c.

194{
195 int nvt_code = 0 | PAPI_NATIVE_MASK;
196 PAPI_enum_cmp_event(&nvt_code, PAPI_ENUM_FIRST, cid);
197}
Enumerate PAPI preset or native events for a given component.
#define PAPI_ENUM_FIRST
Definition: f90papi.h:85
#define PAPI_NATIVE_MASK
Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 81 of file papi_component_avail.c.

82{
83 int i;
84 int retval;
85 const PAPI_hw_info_t *hwinfo = NULL;
86 const PAPI_component_info_t* cmpinfo;
87 command_flags_t flags;
88 int numcmp, cid;
89
90 /* Initialize before parsing the input arguments */
92 if ( retval != PAPI_VER_CURRENT ) {
93 fprintf(stderr,"Error! PAPI_library_init\n");
94 return retval;
95 }
96
97 parse_args( argc, argv, &flags );
98
100 if ( retval != PAPI_OK ) {
101 fprintf(stderr,"Error! PAPI_set_debug\n");
102 return retval;
103 }
104
105 retval = papi_print_header( "Available components and "
106 "hardware information.\n", &hwinfo );
107 if ( retval != PAPI_OK ) {
108 fprintf(stderr,"Error! PAPI_get_hardware_info\n");
109 return 2;
110 }
111
112 /* Compiled-in Components */
113 numcmp = PAPI_num_components( );
114
115 printf("Compiled-in components:\n");
116 for ( cid = 0; cid < numcmp; cid++ ) {
117 cmpinfo = PAPI_get_component_info( cid );
118
119 printf( "Name: %-23s %s\n", cmpinfo->name ,cmpinfo->description);
120
121 if (cmpinfo->disabled == PAPI_EDELAY_INIT) {
122 force_cmp_init(cid);
123 }
124 if (cmpinfo->disabled) {
125 printf(" \\-> Disabled: %s\n",cmpinfo->disabled_reason);
126 }
127
128 if ( flags.details ) {
129 printf( " %-23s Version:\t\t\t%s\n", " ", cmpinfo->version );
130 printf( " %-23s Number of native events:\t%d\n", " ", cmpinfo->num_native_events);
131 printf( " %-23s Number of preset events:\t%d\n", " ", cmpinfo->num_preset_events);
132 printf("\n");
133 }
134 }
135
136 printf("\nActive components:\n");
137 numcmp = PAPI_num_components( );
138
139 for ( cid = 0; cid < numcmp; cid++ ) {
140 cmpinfo = PAPI_get_component_info( cid );
141 if (cmpinfo->disabled) continue;
142
143 printf( "Name: %-23s %s\n", cmpinfo->name ,cmpinfo->description);
144 printf( " %-23s Native: %d, Preset: %d, Counters: %d\n",
145 " ", cmpinfo->num_native_events, cmpinfo->num_preset_events, cmpinfo->num_cntrs);
146
147 int pmus=0;
148 for (i=0; i<PAPI_PMU_MAX; i++) { // Count pmus to print.
149 if (cmpinfo->pmu_names[i] != NULL) pmus++; // Non-Null get printed.
150 }
151
152 if (pmus) { // If we have any, print.
153 printf( " %-23s PMUs supported: ", " ");
154 int line_len = 48, name_len;
155 for (i=0 ; i<PAPI_PMU_MAX ; i++) {
156 if (cmpinfo->pmu_names[i] == NULL) continue;
157
158 name_len = strlen(cmpinfo->pmu_names[i]);
159
160 if ((line_len + 2 + name_len) > 130) { // If it would be too long,
161 printf("\n %-23s ", " "); // terminate line without printing current name,
162 line_len = 48; // reset line length.
163 }
164
165 // if it is not the first entry on a line, separate the names
166 if (line_len > 48) {
167 printf(", ");
168 line_len += 2; // account for the separator.
169 }
170 printf("%s", cmpinfo->pmu_names[i]);
171 line_len += name_len; // Add the new name to the length.
172 }
173
174 printf("\n");
175 } // end if we had PMUs to print.
176
177 printf("\n"); // extra line.
178
179 if ( flags.details ) {
180 printf( " %-23s Version:\t\t\t%s\n", " ", cmpinfo->version );
181 printf( " %-23s Fast counter read:\t\t%d\n", " ", cmpinfo->fast_counter_read);
182 printf("\n");
183 }
184 }
185
186
187 printf
188 ( "\n--------------------------------------------------------------------------------\n" );
189
190 return 0;
191}
int i
get information about a specific software component
initialize the PAPI library.
Get the number of components available on the system.
Set the current debug level for error output from PAPI.
#define PAPI_VER_CURRENT
Definition: f90papi.h:54
#define PAPI_OK
Definition: f90papi.h:73
#define PAPI_VERB_ECONT
Definition: f90papi.h:164
#define PAPI_EDELAY_INIT
Definition: f90papi.h:271
#define PAPI_PMU_MAX
Definition: f90papi.h:101
static void force_cmp_init(int cid)
static void parse_args(int argc, char **argv, command_flags_t *f)
FILE * stderr
int papi_print_header(char *prompt, const PAPI_hw_info_t **hwinfo)
Definition: print_header.c:12
char description[PAPI_MAX_STR_LEN]
Definition: papi.h:630
unsigned int fast_counter_read
Definition: papi.h:655
char name[PAPI_MAX_STR_LEN]
Definition: papi.h:627
char disabled_reason[PAPI_HUGE_STR_LEN]
Definition: papi.h:634
char version[PAPI_MIN_STR_LEN]
Definition: papi.h:631
char * pmu_names[PAPI_PMU_MAX]
Definition: papi.h:648
Hardware info structure.
Definition: papi.h:774
int retval
Definition: zero_fork.c:53
Here is the call graph for this function:

◆ parse_args()

static void parse_args ( int  argc,
char **  argv,
command_flags_t f 
)
static

Definition at line 57 of file papi_component_avail.c.

58{
59 int i;
60
61 /* Look for all currently defined commands */
62 memset( f, 0, sizeof ( command_flags_t ) );
63 for ( i = 1; i < argc; i++ ) {
64 if ( !strcmp( argv[i], "-d" ) ) {
65 f->details = 1;
66 } else if ( !strcmp( argv[i], "-h" ) || !strcmp( argv[i], "--help" ) )
67 f->help = 1;
68 else
69 printf( "%s is not supported\n", argv[i] );
70 }
71
72 /* if help requested, print and bail */
73 if ( f->help ) {
74 print_help( argv );
75 exit( 1 );
76 }
77
78}
double f(double a)
Definition: cpi.c:23
static void print_help(void)
Definition: papi_cost.c:85
Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_help()

static void print_help ( char **  argv)
static

Definition at line 46 of file papi_component_avail.c.

47{
48 printf( "This is the PAPI component avail program.\n" );
49 printf( "It provides availability of installed PAPI components.\n" );
50 printf( "Usage: %s [options]\n", argv[0] );
51 printf( "Options:\n\n" );
52 printf( " --help, -h print this help message\n" );
53 printf( " -d print detailed information on each component\n" );
54}