|
Packit |
577717 |
/* This test checks that mixing PAPI_flips and the other high
|
|
Packit |
577717 |
* level calls does the right thing.
|
|
Packit |
577717 |
* by Kevin London
|
|
Packit |
577717 |
*/
|
|
Packit |
577717 |
|
|
Packit |
577717 |
#include <stdio.h>
|
|
Packit |
577717 |
#include <stdlib.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 retval;
|
|
Packit |
577717 |
int Events, fip = 0;
|
|
Packit |
577717 |
long long values, flpins;
|
|
Packit |
577717 |
float real_time, proc_time, mflops;
|
|
Packit |
577717 |
int quiet;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* Set TESTS_QUIET variable */
|
|
Packit |
577717 |
quiet=tests_quiet( argc, argv );
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* Initialize PAPI library */
|
|
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 |
/* First see if we have PAPI_FP_INS event */
|
|
Packit |
577717 |
if ( PAPI_query_event( PAPI_FP_INS ) == PAPI_OK ) {
|
|
Packit |
577717 |
fip = 1;
|
|
Packit |
577717 |
Events = PAPI_FP_INS;
|
|
Packit |
577717 |
/* If not, look for PAPI_FP_OPS */
|
|
Packit |
577717 |
} else if ( PAPI_query_event( PAPI_FP_OPS ) == PAPI_OK ) {
|
|
Packit |
577717 |
fip = 2;
|
|
Packit |
577717 |
Events = PAPI_FP_OPS;
|
|
Packit |
577717 |
} else {
|
|
Packit |
577717 |
if ( !quiet ) {
|
|
Packit |
577717 |
printf( "PAPI_FP_INS and PAPI_FP_OPS are not defined for this platform.\n" );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
test_skip( __FILE__, __LINE__, "FLOPS event not supported", 1);
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* Start counting flips or flops event */
|
|
Packit |
577717 |
if ( fip == 1 ) {
|
|
Packit |
577717 |
retval = PAPI_flips( &real_time, &proc_time, &flpins, &mflops );
|
|
Packit |
577717 |
if (retval != PAPI_OK ) {
|
|
Packit |
577717 |
test_fail( __FILE__, __LINE__, "PAPI_flips", retval );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
} else {
|
|
Packit |
577717 |
retval = PAPI_flops( &real_time, &proc_time, &flpins, &mflops );
|
|
Packit |
577717 |
if (retval != PAPI_OK ) {
|
|
Packit |
577717 |
test_fail( __FILE__, __LINE__, "PAPI_flops", retval );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* If we are flipsing/flopsing, then start_counters should fail */
|
|
Packit |
577717 |
retval = PAPI_start_counters( &Events, 1 );
|
|
Packit |
577717 |
if (retval == PAPI_OK) {
|
|
Packit |
577717 |
test_fail( __FILE__, __LINE__, "PAPI_start_counters", retval );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* Try flipsing/flopsing again, should work */
|
|
Packit |
577717 |
if ( fip == 1 ) {
|
|
Packit |
577717 |
retval = PAPI_flips( &real_time, &proc_time, &flpins, &mflops );
|
|
Packit |
577717 |
if (retval != PAPI_OK ) {
|
|
Packit |
577717 |
test_fail( __FILE__, __LINE__, "PAPI_flips", retval );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
} else {
|
|
Packit |
577717 |
retval = PAPI_flops( &real_time, &proc_time, &flpins, &mflops );
|
|
Packit |
577717 |
if (retval != PAPI_OK) {
|
|
Packit |
577717 |
test_fail( __FILE__, __LINE__, "PAPI_flops", retval );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* If we are flipsing/flopsing, then read should fail */
|
|
Packit |
577717 |
if ( ( retval = PAPI_read_counters( &values, 1 ) ) == PAPI_OK ) {
|
|
Packit |
577717 |
test_fail( __FILE__, __LINE__, "PAPI_read_counters", retval );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* Stop should still work then */
|
|
Packit |
577717 |
if ( ( retval = PAPI_stop_counters( &values, 1 ) ) != PAPI_OK ) {
|
|
Packit |
577717 |
test_fail( __FILE__, __LINE__, "PAPI_stop_counters", retval );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* Restart flips/flops */
|
|
Packit |
577717 |
if ( fip == 1 ) {
|
|
Packit |
577717 |
retval = PAPI_flips( &real_time, &proc_time, &flpins, &mflops );
|
|
Packit |
577717 |
if (retval != PAPI_OK) {
|
|
Packit |
577717 |
test_fail( __FILE__, __LINE__, "PAPI_flips", retval );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
} else {
|
|
Packit |
577717 |
retval = PAPI_flops( &real_time, &proc_time, &flpins, &mflops );
|
|
Packit |
577717 |
if (retval != PAPI_OK) {
|
|
Packit |
577717 |
test_fail( __FILE__, __LINE__, "PAPI_flops", retval );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* Try reading again, should fail */
|
|
Packit |
577717 |
if ( ( retval = PAPI_read_counters( &values, 1 ) ) == PAPI_OK ) {
|
|
Packit |
577717 |
test_fail( __FILE__, __LINE__, "PAPI_read_counters", retval );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* Stop */
|
|
Packit |
577717 |
if ( ( retval = PAPI_stop_counters( &values, 1 ) ) != PAPI_OK ) {
|
|
Packit |
577717 |
test_fail( __FILE__, __LINE__, "PAPI_stop_counters", retval );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* Now try starting, should work */
|
|
Packit |
577717 |
if ( ( retval = PAPI_start_counters( &Events, 1 ) ) != PAPI_OK ) {
|
|
Packit |
577717 |
test_fail( __FILE__, __LINE__, "PAPI_start_counters", retval );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* Read should work too */
|
|
Packit |
577717 |
if ( ( retval = PAPI_read_counters( &values, 1 ) ) != PAPI_OK ) {
|
|
Packit |
577717 |
test_fail( __FILE__, __LINE__, "PAPI_read_counters", retval );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* flipsing/flopsing should fail */
|
|
Packit |
577717 |
if ( fip == 1 ) {
|
|
Packit |
577717 |
retval = PAPI_flips( &real_time, &proc_time, &flpins, &mflops );
|
|
Packit |
577717 |
if (retval == PAPI_OK ) {
|
|
Packit |
577717 |
test_fail( __FILE__, __LINE__, "PAPI_flips", retval );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
} else {
|
|
Packit |
577717 |
retval = PAPI_flops( &real_time, &proc_time, &flpins, &mflops );
|
|
Packit |
577717 |
if (retval == PAPI_OK ) {
|
|
Packit |
577717 |
test_fail( __FILE__, __LINE__, "PAPI_flops", retval );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* Stop everything */
|
|
Packit |
577717 |
if ( ( retval = PAPI_stop_counters( &values, 1 ) ) != PAPI_OK ) {
|
|
Packit |
577717 |
test_fail( __FILE__, __LINE__, "PAPI_stop_counters", retval );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
test_pass( __FILE__ );
|
|
Packit |
577717 |
|
|
Packit |
577717 |
return 0;
|
|
Packit |
577717 |
}
|