#include #include #include #include #include #include #include "pmu.h" #include "testbed.h" struct armv8_event { char * name; int id; uint32_t init_val; char * note; }; static struct armv8_event a57_list[6]= { {"INST",0x8,0,"instruction retired"}, {"CYCL",0x11,0,"CPU running cycle"}, {"L1D MISS",0x3,0,"L1D CACHE MISS/REFILL"}, {"L1D ACCESS",0x4,0,"L1D CACHE ACCESS"}, {"L2 MISS",0x17,0,"L2 CACHE MISS/REFILL"}, {"L2 ACCESS",0x16,0,"L2 CACHE ACCESS"} }; static int e[6]; void init_testbed(void) { int i; struct armv8_event * p_list; init_pmu_registers(); p_list=a57_list; for(i=0;i<6;i++) { e[i]=create_pmu_event(p_list[i].name,p_list[i].id, p_list[i].init_val,p_list[i].note); } } void run_test(int reptition, int warm_up,void (*test_func)(void *),void * arg) { uint32_t t0,t1; uint32_t freq; uint32_t cycle; uint64_t total_time=0; uint32_t loop_count=0; int i; if(warm_up) test_func(arg); freq=read_32bit_sysreg(CNTFRQ_EL0); start_pmu_event(e[0]); start_pmu_event(e[1]); start_pmu_event(e[2]); start_pmu_event(e[3]); start_pmu_event(e[4]); start_pmu_event(e[5]); set_pmu_event_base(e[0]); set_pmu_event_base(e[1]); set_pmu_event_base(e[2]); set_pmu_event_base(e[3]); set_pmu_event_base(e[4]); set_pmu_event_base(e[5]); t0=read_32bit_sysreg(CNTVCT_EL0); for(i=0;i