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"
447 fprintf(
stdout,
"PASSED with WARNING");
453 fprintf(
stdout,
"PASSED");
474 fprintf(
stdout,
"PASSED with WARNING");
480 fprintf(
stdout,
"PASSED");
504 memset(
buf,
'\0',
sizeof (
buf ) );
507 fprintf(
stdout,
"FAILED!!!");
509 fprintf(
stdout,
"\nLine # %d ", line );
512 sprintf(
buf,
"System error in %s", call );
514 }
else if (
retval > 0 ) {
515 fprintf(
stdout,
"Error: %s\n", call );
516 }
else if (
retval == 0 ) {
518 fprintf(
stdout,
"SGI requires root permissions for this test\n" );
520 fprintf(
stdout,
"Error: %s\n", call );
526 fprintf(
stdout,
"Some tests require special hardware, permissions, OS, compilers\n"
527 "or library versions. PAPI may still function perfectly on your \n"
528 "system without the particular feature being tested here. \n");
558 memset(
buf,
'\0',
sizeof (
buf ) );
565 fprintf(
stdout,
"WARNING ");
567 fprintf(
stdout,
"Line # %d ", line );
570 sprintf(
buf,
"System warning in %s", call );
572 }
else if (
retval > 0 ) {
573 fprintf(
stdout,
"Warning: %s\n", call );
574 }
else if (
retval == 0 ) {
575 fprintf(
stdout,
"Warning: %s\n", call );
598 fprintf(
stdout,
"SKIPPED\n");
613 fprintf(
stdout,
"%s", call );
616 fprintf(
stdout,
"Can not list event names.\n" );
620 if ((ev_ids = calloc(nev,
sizeof(
int))) == NULL) {
621 fprintf(
stdout,
"Can not list event names.\n" );
628 for (
i = 0;
i < nev;
i++ ) {
633 fprintf(
stdout,
"Can not list event names." );
657 if (!
TESTS_QUIET) printf(
"Couldn't add PAPI_TOT_CYC\n");
658 test_skip(__FILE__,__LINE__,
"Couldn't add PAPI_TOT_CYC",0);
663 if (!
TESTS_QUIET) printf(
"Couldn't add PAPI_TOT_CYC\n");
664 test_skip(__FILE__,__LINE__,
"Couldn't add PAPI_TOT_CYC",0);
679#define POTENTIAL_EVENTS 3
696 *papi_event = (
int ) potential_evt_to_add[
i][0];
710 int need_interrupt,
int no_software_events,
716 int i = 0, k, event_code,
retval;
717 int counters, event_found = 0;
732 test_fail( __FILE__, __LINE__,
"PAPI_get_hardware_info", 2 );
737 if (!
TESTS_QUIET) printf(
"No counters available\n");
742 printf(
"Trying to fill %d hardware counters...\n", counters);
745 if (need_interrupt) {
750 "Limiting num_counters because of "
751 "LIMITED_PMC on Power5 and Power6",1);
756 ( *evtcodes ) = (
int * ) calloc( counters,
sizeof (
int ) );
775 if (no_software_events && ( strstr(info.
symbol,
"PERF_COUNT_SW") || strstr(info.
long_descr,
"PERF_COUNT_SW") ) ) {
777 printf(
"Blocking event %s as a SW event\n", info.
symbol);
782 if (
s->cntr_umasks ) {
792 ( *evtcodes )[event_found] = event_code;
794 printf(
"event_code[%d] = %#x (%s)\n",
795 event_found, event_code, info.
symbol );
800 printf(
"%#x (%s) can't be added to the EventSet.\n",
801 event_code, info.
symbol );
805 && event_found < counters );
810 ( *evtcodes )[event_found] = event_code;
812 printf(
"event_code[%d] = %#x (%s)\n",
813 event_found, event_code, info.
symbol );
825 ( *evtcodes )[event_found] = event_code;
829 fprintf(
stdout,
"%#x is not available.\n", event_code );
834 event_found < counters );
838 if (!
TESTS_QUIET) printf(
"Tried to fill %d counters with events, "
839 "found %d\n",counters,event_found);
static const PAPI_hw_info_t * hw_info
add PAPI preset or native hardware event to an event set
add PAPI preset or native hardware event by name to an EventSet
Create a new empty PAPI EventSet.
Empty and destroy an EventSet.
Enumerate PAPI preset or native events for a given component.
Convert a numeric hardware event code to a name.
Get component specific PAPI options.
get information about a specific software component
Get the event's name and description info.
get information about the system hardware
list the events in an event set
Return the number of hardware counters on the cpu.
Query if PAPI event exists.
removes a hardware event from a PAPI event set.
Set the current debug level for error output from PAPI.
Finish using PAPI and free all related resources.
Returns a string describing the PAPI error code.
volatile int buf[CACHE_FLUSH_BUFFER_SIZE_INTS]
#define PAPI_MAX_MPX_CTRS
#define PAPI_DOM_SUPERVISOR
#define PAPI_NTV_ENUM_UMASKS
#define PAPI_HUGE_STR_LEN
static long long values[NUM_EVENTS]
static double a[MATRIX_SIZE][MATRIX_SIZE]
static double b[MATRIX_SIZE][MATRIX_SIZE]
Return codes and api definitions.
char symbol[PAPI_HUGE_STR_LEN]
char derived[PAPI_MIN_STR_LEN]
char long_descr[PAPI_HUGE_STR_LEN]
char model_string[PAPI_MAX_STR_LEN]
struct test_events_t test_events[MAX_TEST_EVENTS]
int tests_quiet(int argc, char **argv)
int add_test_events(int *number, int *mask, int allow_derived)
void validate_string(const char *name, char *s)
char * stringify_all_domains(int domains)
void PAPI_NORETURN test_hl_pass(const char *filename)
char * stringify_domain(int domain)
int add_two_nonderived_events(int *num_events, int *papi_event, int *mask)
void free_test_space(long long **values, int num_tests)
char * stringify_granularity(int granularity)
void test_print_event_header(const char *call, int evset)
int is_event_derived(unsigned int event)
int approx_equals(double a, double b)
static void print_spaces(int count)
char * stringify_all_granularities(int granularities)
void PAPI_NORETURN test_fail(const char *file, int line, const char *call, int retval)
long long ** allocate_test_space(int num_tests, int num_events)
void PAPI_NORETURN test_pass(const char *filename)
int enum_add_native_events(int *num_events, int **evtcodes, int need_interrupt, int no_software_events, int cidx)
int find_nonderived_event(void)
int add_two_events(int *num_events, int *papi_event, int *mask)
void test_warn(const char *file, int line, const char *call, int retval)
void PAPI_NORETURN test_skip(const char *file, int line, const char *call, int retval)
int remove_test_events(int *EventSet, int mask)