📄 ixperfprofacccodelet.c
字号:
printf("***********************\n"); printf("Executing Demo All Mode\n"); printf("***********************\n\n"); /* Demo north mode of bus pmu functionality */ status = ixPerfProfAccCodeletSelection (IX_PERFPROF_ACC_CODELET_MODE_BUS_PMU_NORTH_MODE, IX_PERFPROF_ACC_BUS_PMU_PEC1_NORTH_BUS_IDLE_SELECT, IX_PERFPROF_ACC_BUS_PMU_PEC2_NORTH_BUS_WRITE_SELECT, IX_PERFPROF_ACC_BUS_PMU_PEC3_NORTH_BUS_READ_SELECT, IX_PERFPROF_ACC_BUS_PMU_PEC4_NORTH_NPEA_REQ_SELECT, IX_PERFPROF_ACC_BUS_PMU_PEC5_NORTH_NPEB_REQ_SELECT, IX_PERFPROF_ACC_BUS_PMU_PEC6_NORTH_NPEC_REQ_SELECT, IX_PERFPROF_ACC_BUS_PMU_PEC7_CYCLE_COUNT_SELECT, 0, 0); if (IX_PERFPROF_ACC_STATUS_SUCCESS != status) { return status; } /* end if */ else { printf("Events selected:\n"); printf("IX_PERFPROF_ACC_BUS_PMU_PEC1_NORTH_BUS_IDLE_SELECT\n"); printf("IX_PERFPROF_ACC_BUS_PMU_PEC2_NORTH_BUS_WRITE_SELECT\n"); printf("IX_PERFPROF_ACC_BUS_PMU_PEC3_NORTH_BUS_READ_SELECT\n"); printf("IX_PERFPROF_ACC_BUS_PMU_PEC4_NORTH_NPEA_REQ_SELECT\n"); printf("IX_PERFPROF_ACC_BUS_PMU_PEC5_NORTH_NPEB_REQ_SELECT\n"); printf("IX_PERFPROF_ACC_BUS_PMU_PEC6_NORTH_NPEC_REQ_SELECT\n"); printf("IX_PERFPROF_ACC_BUS_PMU_PEC7_CYCLE_COUNT_SELECT\n"); } /* Demonstrate event counting mode of xscale pmu functionality */ status = ixPerfProfAccCodeletSelection (IX_PERFPROF_ACC_CODELET_MODE_XSCALE_PMU_EVENT_COUNTING, clkCntDiv, numEvents, IX_PERFPROF_ACC_XSCALE_PMU_EVENT_CACHE_MISS, IX_PERFPROF_ACC_XSCALE_PMU_EVENT_BRANCH_EXEC, IX_PERFPROF_ACC_XSCALE_PMU_EVENT_INST_EXEC, IX_PERFPROF_ACC_XSCALE_PMU_EVENT_CACHE_INSTRUCTION, 0, 0, 0); if (IX_PERFPROF_ACC_STATUS_SUCCESS != status) { return status; } /* end if */ else { printf("Events selected:\n"); printf("IX_PERFPROF_ACC_XSCALE_PMU_EVENT_CACHE_MISS\n"); printf("IX_PERFPROF_ACC_XSCALE_PMU_EVENT_BRANCH_EXEC\n"); printf("IX_PERFPROF_ACC_XSCALE_PMU_EVENT_INST_EXEC\n"); printf("IX_PERFPROF_ACC_XSCALE_PMU_EVENT_CACHE_INSTRUCTION\n"); } /* Demonstrate time sampling mode of xscale pmu functionality */ status = ixPerfProfAccCodeletSelection (IX_PERFPROF_ACC_CODELET_MODE_XSCALE_PMU_TIME_SAMPLING, samplingRate, clkCntDiv, 0, 0, 0, 0, 0, 0, 0); if (IX_PERFPROF_ACC_STATUS_SUCCESS != status) { return status; } /* end if */ /* Demonstrate event sampling of xscale pmu functionality */ status = ixPerfProfAccCodeletSelection (IX_PERFPROF_ACC_CODELET_MODE_XSCALE_PMU_EVENT_SAMPLING, numEvents, IX_PERFPROF_ACC_XSCALE_PMU_EVENT_ONCE, samplingRate, IX_PERFPROF_ACC_XSCALE_PMU_EVENT_INST_TLB_MISS, samplingRate, IX_PERFPROF_ACC_XSCALE_PMU_EVENT_CACHE_MISS, samplingRate, IX_PERFPROF_ACC_XSCALE_PMU_EVENT_BRANCH_EXEC, samplingRate); if (IX_PERFPROF_ACC_STATUS_SUCCESS != status) { return status; } /* end if */ else { printf("Events selected:\n"); printf("IX_PERFPROF_ACC_XSCALE_PMU_EVENT_ONCE\n"); printf("IX_PERFPROF_ACC_XSCALE_PMU_EVENT_INST_TLB_MISS\n"); printf("IX_PERFPROF_ACC_XSCALE_PMU_EVENT_CACHE_MISS\n"); printf("IX_PERFPROF_ACC_XSCALE_PMU_EVENT_BRANCH_EXEC\n"); } /* Demonstrate obtaining PMSR value */ status = ixPerfProfAccCodeletSelection (IX_PERFPROF_ACC_CODELET_MODE_BUS_PMU_PMSR_GET, 0, 0, 0, 0, 0, 0, 0, 0, 0); if (IX_PERFPROF_ACC_STATUS_SUCCESS != status) { return status; } /* end if */ #ifdef __vxworks /* Demonstrate xcycle measurement functionality */ status = ixPerfProfAccCodeletSelection (IX_PERFPROF_ACC_CODELET_MODE_XCYCLE, numRun, 0, 0, 0, 0, 0, 0, 0, 0); if (IX_PERFPROF_ACC_STATUS_SUCCESS != status) { return status; } /* end if */ #endif return IX_PERFPROF_ACC_STATUS_SUCCESS;} /* end of function ixPerfProfAccCodeletAll *//** *Function definition: ixPerfProfAccCodeletHelp() *Print "how to use" information on the screen. */voidixPerfProfAccCodeletHelp(void){ printf("******************\n"); printf("PerfProf Help Menu\n"); printf("******************\n"); printf("To use the codelet, call function ixPerfProfAccCodeletMain\n"); printf("passing in one of the following as the mode:\n"); printf("0 - for help\n"); printf("1 - for demonstration of all profiling\n"); printf("2 - for demonstration of Bus Pmu North Bus profiling\n"); printf("3 - for demonstration of Bus Pmu South Bus profiling\n"); printf("4 - for demonstration of Bus Pmu Sdram Bus profiling\n"); printf("5 - for demonstration of XScale Pmu Event Sampling\n"); printf("6 - for demonstration of XScale Pmu Time Sampling\n"); printf("7 - for demonstration of XScale Pmu Event Counting\n"); printf("8 - for demonstration of Xcycle measurement\n"); printf("Users will be able to start the codelet by calling ixPerfProfAccCodeletMain\n"); printf("and passing in up to eight parameters. The parameters are represented in the\n"); printf("following order:\n"); printf("\nHelp Mode\n"); printf("Mode - Select IX_PERFPROF_ACC_CODELET_MODE_HELP\n"); printf("Set the rest of the parameters to 0.\n"); printf("\nAll functionalities mode.\n"); printf("Mode - Select IX_PERFPROF_ACC_CODELET_MODE_ALL\n"); printf("Set the rest of the parameters to 0.\n"); printf("\nBus PMU north mode\n"); printf("Mode - Select IX_PERFPROF_ACC_CODELET_MODE_BUS_PMU_NORTH_MODE\n"); printf("param1 - Select proper PEC1 value from main header file.\n"); printf("param2 - Select proper PEC2 value from main header file.\n"); printf("param3 - Select proper PEC3 value from main header file.\n"); printf("param4 - Select proper PEC4 value from main header file.\n"); printf("param5 - Select proper PEC5 value from main header file.\n"); printf("param6 - Select proper PEC6 value from main header file.\n"); printf("param7 - Select proper PEC7 value from main header file.\n"); printf("Set the rest of the parameters to 0."); printf("\nBus PMU south mode\n"); printf("Mode - Select IX_PERFPROF_ACC_CODELET_MODE_BUS_PMU_SOUTH_MODE\n"); printf("param1 - Select proper PEC1 value from main header file.\n"); printf("param2 - Select proper PEC2 value from main header file.\n"); printf("param3 - Select proper PEC3 value from main header file.\n"); printf("param4 - Select proper PEC4 value from main header file.\n"); printf("param5 - Select proper PEC5 value from main header file.\n"); printf("param6 - Select proper PEC6 value from main header file.\n"); printf("param7 - Select proper PEC7 value from main header file.\n"); printf("Set the rest of the parameters to 0."); printf("\nBus PMU sdram mode\n"); printf("Mode - Select IX_PERFPROF_ACC_CODELET_MODE_BUS_PMU_SDRAM_MODE\n"); printf("param1 - Select proper PEC1 value from main header file.\n"); printf("param2 - Select proper PEC2 value from main header file.\n"); printf("param3 - Select proper PEC3 value from main header file.\n"); printf("param4 - Select proper PEC4 value from main header file.\n"); printf("param5 - Select proper PEC5 value from main header file.\n"); printf("param6 - Select proper PEC6 value from main header file.\n"); printf("param7 - Select proper PEC7 value from main header file.\n"); printf("Set the rest of the parameters to 0."); printf("\nBus PMU PMSR Get\n"); printf("Mode - Select IX_PERFPROF_ACC_CODELET_MODE_BUS_PMU_PMSR_GET\n"); printf("Set the rest of the parameters to 0.\n"); printf("\nXScale PMU Event Sampling\n"); printf("Mode - Select IX_PERFPROF_ACC_CODELET_MODE_XSCALE_PMU_EVENT_SAMPLING\n"); printf("param1 - Number of events\n"); printf("param2 - Event 1\n"); printf("param3 - Sampling rate of Event 1\n"); printf("param4 - Event 2\n"); printf("param5 - Sampling rate of Event 2\n"); printf("param6 - Event 3\n"); printf("param7 - Sampling rate of Event 3\n"); printf("param8 - Event 4\n"); printf("param9 - Sampling rate of Event 4\n"); printf("\nXScale PMU Time Sampling\n"); printf("Mode - Select IX_PERFPROF_ACC_CODELET_MODE_XSCALE_PMU_TIME_SAMPLING\n"); printf("param1 - Sampling rate.\n"); printf("param2 - Clock count divider.\n"); printf("Set the rest of the parameters to 0.\n"); printf("\nXScale PMU Event Counting \n"); printf("Mode - Select IX_PERFPROF_ACC_CODELET_MODE_XSCALE_PMU_EVENT_COUNTING\n"); printf("param1 - Clock count divider.\n"); printf("param2 - Number of events.\n"); printf("param3 - Event 1.\n"); printf("param4 - Event 2.\n"); printf("param5 - Event 3.\n"); printf("param6 - Event 4.\n"); printf("Set the rest of the parameters to 0.\n"); #ifdef __vxworks printf("\nXcycle Measurement\n"); printf("Select IX_PERFPROF_ACC_CODELET_MODE_XCYCLE\n"); printf("param1 - Number of runs required.\n"); printf("Set the rest of the parameters to 0.\n"); #endif return;} /* end of function ixPerfProfAccCodeletHelp *//** *Function definition: ixPerfProfAccCodeletProfileSort() *Sort the event results array into descending order of frequency. */voidixPerfProfAccCodeletProfileSort (IxPerfProfAccXscalePmuSamplePcProfile *profileArray, UINT32 total){ UINT32 i; /* Counter to go through values in the array */ UINT32 j; /* Counter to compare with other value in array */ UINT32 profileMax; /* Higest value in array */ UINT32 indexTempMax;/* Index of array component that contains maximum value */ UINT32 pc; /* Program counter value */ for (i = 0 ; i < total; i++) { indexTempMax=i; /* Look for any value higher than the current value and store it in its location */ profileMax = profileArray[i].freq; for (j =i ; j < total; j++) { if (profileMax < profileArray[j].freq) { indexTempMax=j; profileMax = profileArray[j].freq; } /* end if */ } /* end for */ /* swap freq */ profileArray[indexTempMax].freq=profileArray[i].freq; profileArray[i].freq = profileMax; /* swap pc */ pc = profileArray[indexTempMax].programCounter; profileArray[indexTempMax].programCounter = profileArray[i].programCounter; profileArray[i].programCounter= pc; } /* end for */} /* end ixPerfProfAccCodeletProfileSort *//* * Function definition: ixPerfProfAccCodeletMain - * calls the help function if help mode is chosen. Else it calls * the function that enables selection of individual modes and corresponding events. */PUBLIC voidixPerfProfAccCodeletMain( IxPerfProfAccCodeletMode mode, UINT32 param1, UINT32 param2, UINT32 param3, UINT32 param4, UINT32 param5, UINT32 param6, UINT32 param7, UINT32 param8, UINT32 param9){ /* Initialise status */ IxPerfProfAccStatus statusMain = IX_PERFPROF_ACC_STATUS_SUCCESS; /* Check if mode selected is for demo all. If it is, call the demo all function */ if (IX_PERFPROF_ACC_CODELET_MODE_ALL == mode) { statusMain = ixPerfProfAccCodeletAll(); /* If function does not return a success print help and exit. */ if (IX_PERFPROF_ACC_STATUS_SUCCESS!=statusMain) { ixPerfProfAccCodeletHelp(); }/* end if */ return; }/* end if */ /* If mode selected is NOT demo all, then call the individual mode selection function */ else { statusMain = ixPerfProfAccCodeletSelection (mode, param1, param2, param3, param4, param5, param6, param7, param8, param9); /* If function does not return a success due to some error, print help and exit. */ if (IX_PERFPROF_ACC_STATUS_SUCCESS!=statusMain) { ixPerfProfAccCodeletHelp(); }/* end if */ return; }/* end else */} /* end of function ixPerfProfAccCodeletMain */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -