appio_list_events.c File Reference

Include dependency graph for appio_list_events.c:

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 List all appio events codes and names.

Function Documentation

int main ( int  argc,
char **  argv 
)
Author:
Tushar Mohan (adapted for appio from original linux-net code)

test case for the appio component

Definition at line 19 of file appio_list_events.c.

00020 {
00021     int retval,cid,numcmp;
00022     int total_events=0;
00023     int code;
00024     char event_name[PAPI_MAX_STR_LEN];
00025     int r;
00026     const PAPI_component_info_t *cmpinfo = NULL;
00027 
00028     /* Set TESTS_QUIET variable */
00029     tests_quiet( argc, argv );
00030 
00031     /* PAPI Initialization */
00032     retval = PAPI_library_init( PAPI_VER_CURRENT );
00033     if ( retval != PAPI_VER_CURRENT ) {
00034         test_fail(__FILE__, __LINE__,"PAPI_library_init failed\n",retval);
00035     }
00036 
00037     if (!TESTS_QUIET) {
00038         printf("Listing all appio events\n");
00039     }
00040 
00041     numcmp = PAPI_num_components();
00042 
00043     for(cid=0; cid<numcmp; cid++) {
00044 
00045         if ( (cmpinfo = PAPI_get_component_info(cid)) == NULL) {
00046             test_fail(__FILE__, __LINE__,"PAPI_get_component_info failed\n",-1);
00047         }
00048 
00049         if ( strstr(cmpinfo->name, "appio") == NULL) {
00050             continue;
00051         }
00052 
00053         if (!TESTS_QUIET) {
00054             printf("Component %d (%d) - %d events - %s\n",
00055                 cid, cmpinfo->CmpIdx,
00056                 cmpinfo->num_native_events, cmpinfo->name);
00057         }
00058 
00059         code = PAPI_NATIVE_MASK;
00060 
00061         r = PAPI_enum_cmp_event( &code, PAPI_ENUM_FIRST, cid );
00062         while ( r == PAPI_OK ) {
00063 
00064             retval = PAPI_event_code_to_name( code, event_name );
00065             if ( retval != PAPI_OK ) {
00066                 test_fail( __FILE__, __LINE__, "PAPI_event_code_to_name", retval );
00067             }
00068 
00069             if (!TESTS_QUIET) {
00070                 printf("%#x %s\n", code, event_name);
00071             }
00072 
00073             total_events++;
00074 
00075             r = PAPI_enum_cmp_event( &code, PAPI_ENUM_EVENTS, cid );
00076         }
00077 
00078     }
00079 
00080     if (total_events==0) {
00081         test_skip(__FILE__,__LINE__,"No appio events found", 0);
00082     }
00083 
00084     test_pass( __FILE__, NULL, 0 );
00085 
00086     return 0;
00087 }

Here is the call graph for this function:


Generated on 8 Sep 2016 for PAPI by  doxygen 1.6.1