infiniband_list_events.c File Reference

Include dependency graph for infiniband_list_events.c:

Go to the source code of this file.

Functions

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

Function Documentation

int main ( int  argc,
char **  argv 
)
Author:
Jose Pedro Oliveira

test case for the linux-infiniband component Adapted from its counterpart in the net component.

Definition at line 19 of file infiniband_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 infiniband 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, "infiniband") == 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         if (cmpinfo->disabled) {
00059             test_skip(__FILE__,__LINE__,"Component infiniband is disabled", 0);
00060             continue;
00061         }
00062 
00063         code = PAPI_NATIVE_MASK;
00064 
00065         r = PAPI_enum_cmp_event( &code, PAPI_ENUM_FIRST, cid );
00066         while ( r == PAPI_OK ) {
00067 
00068             retval = PAPI_event_code_to_name( code, event_name );
00069             if ( retval != PAPI_OK ) {
00070                 test_fail( __FILE__, __LINE__, "PAPI_event_code_to_name", retval );
00071             }
00072 
00073             if (!TESTS_QUIET) {
00074                 printf("%#x %s\n", code, event_name);
00075             }
00076 
00077             total_events++;
00078 
00079             r = PAPI_enum_cmp_event( &code, PAPI_ENUM_EVENTS, cid );
00080         }
00081 
00082     }
00083 
00084     if (total_events==0) {
00085         test_skip(__FILE__,__LINE__,"No infiniband events found", 0);
00086     }
00087 
00088     test_pass( __FILE__, NULL, 0 );
00089 
00090     return 0;
00091 }

Here is the call graph for this function:


Generated on 26 Jan 2016 for PAPI by  doxygen 1.6.1