PAPI  5.0.1.0
appio_list_events.c
Go to the documentation of this file.
00001 /****************************/
00002 /* THIS IS OPEN SOURCE CODE */
00003 /****************************/
00004 
00015 #include <stdio.h>
00016 #include <stdlib.h>
00017 #include "papi_test.h"
00018 
00019 int main (int argc, char **argv)
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("0x%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 }
00088 
00089 // vim:set ai ts=4 sw=4 sts=4 et:
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines