|
Packit |
577717 |
/* From Paul Drongowski at HP. Thanks. */
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* I have not been able to call PAPI_describe_event without
|
|
Packit |
577717 |
incurring a segv, including the sample code on the man page.
|
|
Packit |
577717 |
I noticed that PAPI_describe_event is not exercised by the
|
|
Packit |
577717 |
PAPI test programs, so I haven't been able to check the
|
|
Packit |
577717 |
function call using known good code. (Or steal your code
|
|
Packit |
577717 |
for that matter. :-)
|
|
Packit |
577717 |
*/
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* PAPI_describe_event has been deprecated in PAPI 3, since
|
|
Packit |
577717 |
its functionality exists in other API calls. Below shows
|
|
Packit |
577717 |
several ways that this call was used, with replacement
|
|
Packit |
577717 |
code compatible with PAPI 3.
|
|
Packit |
577717 |
*/
|
|
Packit |
577717 |
|
|
Packit |
577717 |
#include <stdio.h>
|
|
Packit |
577717 |
#include <stdlib.h>
|
|
Packit |
577717 |
#include <string.h>
|
|
Packit |
577717 |
|
|
Packit |
577717 |
#include "papi.h"
|
|
Packit |
577717 |
#include "papi_test.h"
|
|
Packit |
577717 |
|
|
Packit |
577717 |
int
|
|
Packit |
577717 |
main( int argc, char **argv )
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
int EventSet = PAPI_NULL;
|
|
Packit |
577717 |
int retval;
|
|
Packit |
577717 |
long long g1[2];
|
|
Packit |
577717 |
int eventcode = PAPI_TOT_INS;
|
|
Packit |
577717 |
PAPI_event_info_t info, info1, info2;
|
|
Packit |
577717 |
int quiet;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* Set TESTS_QUIET variable */
|
|
Packit |
577717 |
quiet=tests_quiet( argc, argv );
|
|
Packit |
577717 |
|
|
Packit |
577717 |
|
|
Packit |
577717 |
retval = PAPI_library_init( PAPI_VER_CURRENT );
|
|
Packit |
577717 |
if (retval != PAPI_VER_CURRENT ) {
|
|
Packit |
577717 |
test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
if ( ( retval = PAPI_create_eventset( &EventSet ) ) != PAPI_OK ) {
|
|
Packit |
577717 |
test_fail( __FILE__, __LINE__, "PAPI_create_eventset", retval );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
if ( ( retval = PAPI_query_event( eventcode ) ) != PAPI_OK ) {
|
|
Packit |
577717 |
if (!quiet) printf("Trouble checking event\n");
|
|
Packit |
577717 |
test_skip( __FILE__, __LINE__, "PAPI_query_event(PAPI_TOT_INS)",
|
|
Packit |
577717 |
retval );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
if ( ( retval = PAPI_add_event( EventSet, eventcode ) ) != PAPI_OK )
|
|
Packit |
577717 |
test_fail( __FILE__, __LINE__, "PAPI_add_event(PAPI_TOT_INS)", retval );
|
|
Packit |
577717 |
|
|
Packit |
577717 |
if ( ( retval = PAPI_start( EventSet ) ) != PAPI_OK )
|
|
Packit |
577717 |
test_fail( __FILE__, __LINE__, "PAPI_start", retval );
|
|
Packit |
577717 |
|
|
Packit |
577717 |
if ( ( retval = PAPI_stop( EventSet, g1 ) ) != PAPI_OK )
|
|
Packit |
577717 |
test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* Case 0, no info, should fail */
|
|
Packit |
577717 |
eventcode = 0;
|
|
Packit |
577717 |
/*
|
|
Packit |
577717 |
if ( ( retval = PAPI_describe_event(eventname,(int *)&eventcode,eventdesc) ) == PAPI_OK)
|
|
Packit |
577717 |
test_fail(__FILE__,__LINE__,"PAPI_describe_event",retval);
|
|
Packit |
577717 |
*/
|
|
Packit |
577717 |
if (!quiet) {
|
|
Packit |
577717 |
printf("This test expects a 'PAPI Error' to be returned from this PAPI call.\n");
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
if ( ( retval = PAPI_get_event_info( eventcode, &info ) ) == PAPI_OK )
|
|
Packit |
577717 |
test_fail( __FILE__, __LINE__, "PAPI_get_event_info", retval );
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* Case 1, fill in name field. */
|
|
Packit |
577717 |
eventcode = PAPI_TOT_INS;
|
|
Packit |
577717 |
/*
|
|
Packit |
577717 |
if ( ( retval = PAPI_describe_event(eventname,(int *)&eventcode,eventdesc) ) != PAPI_OK)
|
|
Packit |
577717 |
test_fail(__FILE__,__LINE__,"PAPI_describe_event",retval);
|
|
Packit |
577717 |
*/
|
|
Packit |
577717 |
if ( ( retval = PAPI_get_event_info( eventcode, &info1 ) ) != PAPI_OK )
|
|
Packit |
577717 |
test_fail( __FILE__, __LINE__, "PAPI_get_event_info", retval );
|
|
Packit |
577717 |
|
|
Packit |
577717 |
if ( strcmp( info1.symbol, "PAPI_TOT_INS" ) != 0 )
|
|
Packit |
577717 |
test_fail( __FILE__, __LINE__,
|
|
Packit |
577717 |
"PAPI_get_event_info symbol value is bogus", retval );
|
|
Packit |
577717 |
if ( strlen( info1.long_descr ) == 0 )
|
|
Packit |
577717 |
test_fail( __FILE__, __LINE__,
|
|
Packit |
577717 |
"PAPI_get_event_info long_descr value is bogus", retval );
|
|
Packit |
577717 |
|
|
Packit |
577717 |
eventcode = 0;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* Case 2, fill in code field. */
|
|
Packit |
577717 |
/*
|
|
Packit |
577717 |
if ( ( retval = PAPI_describe_event(eventname,(int *)&eventcode,eventdesc) ) != PAPI_OK)
|
|
Packit |
577717 |
test_fail(__FILE__,__LINE__,"PAPI_describe_event",retval);
|
|
Packit |
577717 |
*/
|
|
Packit |
577717 |
if ( ( retval = PAPI_event_name_to_code( info1.symbol, ( int * ) &eventcode ) ) != PAPI_OK ) {
|
|
Packit |
577717 |
test_fail( __FILE__, __LINE__, "PAPI_event_name_to_code", retval );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
if ( eventcode != PAPI_TOT_INS )
|
|
Packit |
577717 |
test_fail( __FILE__, __LINE__,
|
|
Packit |
577717 |
"PAPI_event_name_to_code code value is bogus", retval );
|
|
Packit |
577717 |
|
|
Packit |
577717 |
if ( ( retval = PAPI_get_event_info( eventcode, &info2 ) ) != PAPI_OK )
|
|
Packit |
577717 |
test_fail( __FILE__, __LINE__, "PAPI_get_event_info", retval );
|
|
Packit |
577717 |
|
|
Packit |
577717 |
if ( strcmp( info2.symbol, "PAPI_TOT_INS" ) != 0 )
|
|
Packit |
577717 |
test_fail( __FILE__, __LINE__,
|
|
Packit |
577717 |
"PAPI_get_event_info symbol value is bogus", retval );
|
|
Packit |
577717 |
if ( strlen( info2.long_descr ) == 0 )
|
|
Packit |
577717 |
test_fail( __FILE__, __LINE__,
|
|
Packit |
577717 |
"PAPI_get_event_info long_descr value is bogus", retval );
|
|
Packit |
577717 |
|
|
Packit |
577717 |
test_pass( __FILE__ );
|
|
Packit |
577717 |
|
|
Packit |
577717 |
return 0;
|
|
Packit |
577717 |
}
|