21int main(
int argc,
char **argv) {
24 long long high=0,low=0,average=0;
25 long long expected_cond=500000,expected_total=1000000;
34 long long count_total,count_conditional,count_taken,count_nottaken;
35 int cond_avail=1,nottaken_avail=1;
41 printf(
"\nTesting the PAPI_BR_TKN event.\n");
42 printf(
"\tIt measures total number of conditional branches not taken\n");
71 if (!
quiet) printf(
"Could not add PAPI_BR_CN\n");
84 if (!
quiet) printf(
"Could not add PAPI_BR_TKN\n");
96 if (!
quiet) printf(
"Could not add PAPI_BR_NTK\n");
123 if (nottaken_avail) {
131 printf(
"The test code has:\n");
132 printf(
"\t%lld total branches\n",count_total);
134 printf(
"\t%lld conditional branches\n",count_conditional);
136 printf(
"\t%lld taken branches\n",count_taken);
137 if (nottaken_avail) {
138 printf(
"\t%lld not-taken branches\n",count_nottaken);
144 printf(
"Testing a loop with %lld conditional taken branches (%d times):\n",
145 expected_cond,num_runs);
148 for(
i=0;
i<num_runs;
i++) {
157 fprintf(
stderr,
"\tCode unimplemented\n");
158 test_skip( __FILE__, __LINE__,
"unimplemented", 0);
163 "reading PAPI_BR_TKN",
retval );
171 average=(
total/num_runs);
175 if ((error > 1.0) || (error<-1.0)) {
176 if (!
quiet) printf(
"Instruction count off by more than 1%%\n");
181 if (!
quiet) printf(
"\n");
188 if ((error > 1.0) || (error<-1.0)) {
189 if (!
quiet) printf(
"Instruction count off by more than 1%%\n");
190 test_fail( __FILE__, __LINE__,
"Error too high", 1 );
193 test_warn(__FILE__,__LINE__,
"Using TOTAL BRANCHES as base rather than CONDITIONAL BRANCHES\n",0);
int branches_testcode(void)
add PAPI preset or native hardware event by name to an EventSet
Create a new empty PAPI EventSet.
initialize the PAPI library.
Reset the hardware event counts in an event set.
Finish using PAPI and free all related resources.
Start counting hardware events in an event set.
Stop counting hardware events in an event set.
double display_error(long long average, long long high, long long low, long long expected, int quiet)
Return codes and api definitions.
int tests_quiet(int argc, char **argv)
void PAPI_NORETURN test_fail(const char *file, int line, const char *call, int retval)
void PAPI_NORETURN test_pass(const char *filename)
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)
#define CODE_UNIMPLEMENTED