PAPI  5.0.1.0
net_list_events.c
Go to the documentation of this file.
00001 /****************************/
00002 /* THIS IS OPEN SOURCE CODE */
00003 /****************************/
00004 
00014 #include <stdio.h>
00015 #include <stdlib.h>
00016 #include "papi_test.h"
00017 
00018 int main (int argc, char **argv)
00019 {
00020     int retval,cid,numcmp;
00021     int total_events=0;
00022     int code;
00023     char event_name[PAPI_MAX_STR_LEN];
00024     int r;
00025     const PAPI_component_info_t *cmpinfo = NULL;
00026 
00027     /* Set TESTS_QUIET variable */
00028     tests_quiet( argc, argv );
00029 
00030     /* PAPI Initialization */
00031     retval = PAPI_library_init( PAPI_VER_CURRENT );
00032     if ( retval != PAPI_VER_CURRENT ) {
00033         test_fail(__FILE__, __LINE__,"PAPI_library_init failed\n",retval);
00034     }
00035 
00036     if (!TESTS_QUIET) {
00037         printf("Listing all net events\n");
00038     }
00039 
00040     numcmp = PAPI_num_components();
00041 
00042     for(cid=0; cid<numcmp; cid++) {
00043 
00044         if ( (cmpinfo = PAPI_get_component_info(cid)) == NULL) {
00045             test_fail(__FILE__, __LINE__,"PAPI_get_component_info failed\n",-1);
00046         }
00047 
00048         if ( strstr(cmpinfo->name, "net") == NULL) {
00049             continue;
00050         }
00051 
00052         if (!TESTS_QUIET) {
00053             printf("Component %d (%d) - %d events - %s\n",
00054                 cid, cmpinfo->CmpIdx,
00055                 cmpinfo->num_native_events, cmpinfo->name);
00056         }
00057 
00058         code = PAPI_NATIVE_MASK;
00059 
00060         r = PAPI_enum_cmp_event( &code, PAPI_ENUM_FIRST, cid );
00061         while ( r == PAPI_OK ) {
00062 
00063             retval = PAPI_event_code_to_name( code, event_name );
00064             if ( retval != PAPI_OK ) {
00065                 test_fail( __FILE__, __LINE__, "PAPI_event_code_to_name", retval );
00066             }
00067 
00068             if (!TESTS_QUIET) {
00069                 printf("0x%x %s\n", code, event_name);
00070             }
00071 
00072             total_events++;
00073 
00074             r = PAPI_enum_cmp_event( &code, PAPI_ENUM_EVENTS, cid );
00075         }
00076 
00077     }
00078 
00079     if (total_events==0) {
00080         test_skip(__FILE__,__LINE__,"No net events found", 0);
00081     }
00082 
00083     test_pass( __FILE__, NULL, 0 );
00084 
00085     return 0;
00086 }
00087 
00088 // vim:set ai ts=4 sw=4 sts=4 et:
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines