25 if ( (
s == NULL ) || ( strlen(
s ) == 0 ) ) {
27 sprintf(
s2,
"%s was NULL or length 0",
name );
38 printf(
"Out of tolerance range %2.2f: %.0f vs %.0f [%.0f,%.0f]\n",
52 (
long long ** ) malloc( (
size_t )
num_tests *
53 sizeof (
long long * ) );
60 (
long long * ) malloc( (
size_t )
num_events *
61 sizeof (
long long ) );
89 if (strcmp(info.
derived,
"NOT_DERIVED")) {
105 for (
i = 0;
i < 3;
i++ ) {
109 if ( ( info.
count > 0 ) &&
110 !strcmp( info.
derived,
"NOT_DERIVED" ) )
111 return ( potential_evt_to_add[
i] );
156 char name_string[BUFSIZ];
189 fprintf( stdout,
"%#x %s is not available.\n",
302 strcpy(
buf + strlen(
buf ),
"|" );
307 test_fail( __FILE__, __LINE__,
"Unrecognized domains!", 0 );
316 return (
"PAPI_DOM_SUPERVISOR" );
318 return (
"PAPI_DOM_USER" );
320 return (
"PAPI_DOM_KERNEL" );
322 return (
"PAPI_DOM_OTHER" );
324 return (
"PAPI_DOM_ALL" );
326 test_fail( __FILE__, __LINE__,
"Unrecognized domains!", 0 );
339 if ( granularities &
i ) {
341 strcpy(
buf + strlen(
buf ),
"|" );
342 strcpy(
buf + strlen(
buf ),
347 test_fail( __FILE__, __LINE__,
"Unrecognized granularity!", 0 );
355 switch ( granularity ) {
357 return (
"PAPI_GRN_THR" );
359 return (
"PAPI_GRN_PROC" );
361 return (
"PAPI_GRN_PROCG" );
363 return (
"PAPI_GRN_SYS_CPU" );
365 return (
"PAPI_GRN_SYS" );
367 test_fail( __FILE__, __LINE__,
"Unrecognized granularity!", 0 );
382 && ( ( strcasecmp( argv[1],
"TESTS_QUIET" ) == 0 )
383 || ( strcasecmp( argv[1],
"-q" ) == 0 ) ) ) {
394 value=
getenv(
"TESTS_COLOR");
405 if (!isatty(fileno(stdout))) {
412 #define RED "\033[1;31m" 413 #define YELLOW "\033[1;33m" 414 #define GREEN "\033[1;32m" 415 #define NORMAL "\033[0m" 422 fprintf(stdout,
" ");
447 fprintf( stdout,
"PASSED with WARNING");
449 fprintf( stdout,
"\n");
453 fprintf( stdout,
"PASSED");
455 fprintf( stdout,
"\n");
481 memset(
buf,
'\0',
sizeof (
buf ) );
484 fprintf( stdout,
"FAILED!!!");
486 fprintf( stdout,
"\nLine # %d ", line );
489 sprintf(
buf,
"System error in %s", call );
491 }
else if (
retval > 0 ) {
492 fprintf( stdout,
"Error: %s\n", call );
493 }
else if (
retval == 0 ) {
495 fprintf( stdout,
"SGI requires root permissions for this test\n" );
497 fprintf( stdout,
"Error: %s\n", call );
503 fprintf(stdout,
"Some tests require special hardware, permissions, OS, compilers\n" 504 "or library versions. PAPI may still function perfectly on your \n" 505 "system without the particular feature being tested here. \n");
535 memset(
buf,
'\0',
sizeof (
buf ) );
542 fprintf( stdout,
"WARNING ");
544 fprintf( stdout,
"Line # %d ", line );
547 sprintf(
buf,
"System warning in %s", call );
549 }
else if (
retval > 0 ) {
550 fprintf( stdout,
"Warning: %s\n", call );
551 }
else if (
retval == 0 ) {
552 fprintf( stdout,
"Warning: %s\n", call );
575 fprintf( stdout,
"SKIPPED\n");
590 fprintf( stdout,
"%s", call );
593 fprintf( stdout,
"Can not list event names.\n" );
597 if ((ev_ids = calloc(nev,
sizeof(
int))) == NULL) {
598 fprintf( stdout,
"Can not list event names.\n" );
605 for (
i = 0;
i < nev;
i++ ) {
610 fprintf( stdout,
"Can not list event names." );
612 fprintf( stdout,
"\n" );
634 if (!
TESTS_QUIET) printf(
"Couldn't add PAPI_TOT_CYC\n");
635 test_skip(__FILE__,__LINE__,
"Couldn't add PAPI_TOT_CYC",0);
640 if (!
TESTS_QUIET) printf(
"Couldn't add PAPI_TOT_CYC\n");
641 test_skip(__FILE__,__LINE__,
"Couldn't add PAPI_TOT_CYC",0);
656 #define POTENTIAL_EVENTS 3 673 *papi_event = ( int ) potential_evt_to_add[
i][0];
687 int need_interrupt,
int no_software_events,
693 int i = 0, k, event_code,
retval;
694 int counters, event_found = 0;
709 test_fail( __FILE__, __LINE__,
"PAPI_get_hardware_info", 2 );
714 if (!
TESTS_QUIET) printf(
"No counters available\n");
719 printf(
"Trying to fill %d hardware counters...\n", counters);
722 if (need_interrupt) {
727 "Limiting num_counters because of " 728 "LIMITED_PMC on Power5 and Power6",1);
733 ( *evtcodes ) = (
int * ) calloc( counters,
sizeof (
int ) );
752 if (no_software_events && ( strstr(info.
symbol,
"PERF_COUNT_SW") || strstr(info.
long_descr,
"PERF_COUNT_SW") ) ) {
754 printf(
"Blocking event %s as a SW event\n", info.
symbol);
759 if (
s->cntr_umasks ) {
769 ( *evtcodes )[event_found] = event_code;
771 printf(
"event_code[%d] = %#x (%s)\n",
772 event_found, event_code, info.
symbol );
777 printf(
"%#x (%s) can't be added to the EventSet.\n",
778 event_code, info.
symbol );
782 && event_found < counters );
787 ( *evtcodes )[event_found] = event_code;
789 printf(
"event_code[%d] = %#x (%s)\n",
790 event_found, event_code, info.
symbol );
802 ( *evtcodes )[event_found] = event_code;
806 fprintf( stdout,
"%#x is not available.\n", event_code );
811 event_found < counters );
815 if (!
TESTS_QUIET) printf(
"Tried to fill %d counters with events, " 816 "found %d\n",counters,event_found);
int PAPI_is_initialized(void)
void test_fail(const char *file, int line, const char *call, int retval)
const PAPI_component_info_t * PAPI_get_component_info(int cidx)
int PAPI_add_event(int EventSet, int EventCode)
int is_event_derived(unsigned int event)
int remove_test_events(int *EventSet, int mask)
int tests_quiet(int argc, char **argv)
int PAPI_remove_event(int EventSet, int EventCode)
int enum_add_native_events(int *num_events, int **evtcodes, int need_interrupt, int no_software_events, int cidx)
void test_warn(const char *file, int line, const char *call, int retval)
void free_test_space(long long **values, int num_tests)
char * stringify_granularity(int granularity)
int add_two_events(int *num_events, int *papi_event, int *mask)
char long_descr[PAPI_HUGE_STR_LEN]
char filename[MAXNAMESIZE]
char derived[PAPI_MIN_STR_LEN]
Return codes and api definitions.
int PAPI_get_event_info(int EventCode, PAPI_event_info_t *info)
#define PAPI_MAX_MPX_CTRS
int PAPI_add_named_event(int EventSet, const char *EventName)
char * stringify_all_domains(int domains)
void test_print_event_header(const char *call, int evset)
int find_nonderived_event(void)
int PAPI_num_hwctrs(void)
#define PAPI_DOM_SUPERVISOR
int PAPI_get_cmp_opt(int option, PAPI_option_t *ptr, int cidx)
char symbol[PAPI_HUGE_STR_LEN]
#define PAPI_HUGE_STR_LEN
int add_two_nonderived_events(int *num_events, int *papi_event, int *mask)
char model_string[PAPI_MAX_STR_LEN]
static void print_spaces(int count)
long long ** allocate_test_space(int num_tests, int num_events)
int PAPI_enum_cmp_event(int *EventCode, int modifier, int cidx)
int PAPI_create_eventset(int *EventSet)
int PAPI_event_code_to_name(int EventCode, char *out)
char * stringify_domain(int domain)
int PAPI_query_event(int EventCode)
void test_pass(const char *filename)
char * stringify_all_granularities(int granularities)
char * PAPI_strerror(int errorCode)
add PAPI preset or native hardware event to an event set
int PAPI_destroy_eventset(int *EventSet)
void validate_string(const char *name, char *s)
int add_test_events(int *number, int *mask, int allow_derived)
int approx_equals(double a, double b)
void test_skip(const char *file, int line, const char *call, int retval)
const PAPI_hw_info_t * PAPI_get_hardware_info(void)
static long long values[NUM_EVENTS]
static const PAPI_hw_info_t * hw_info
volatile int buf[CACHE_FLUSH_BUFFER_SIZE_INTS]
static double b[MATRIX_SIZE][MATRIX_SIZE]
int PAPI_set_debug(int level)
static double a[MATRIX_SIZE][MATRIX_SIZE]
struct test_events_t test_events[MAX_TEST_EVENTS]
int PAPI_list_events(int EventSet, int *Events, int *number)