• Resolved

CCS/TMDXIDK5718: Measuring processing time on A15

Intellectual 810 points

Replies: 8

Views: 87

Part Number: TMDXIDK5718

Tool/software: Code Composer Studio

I am creating a boot program for MPU (A15) using "TMDXIDK5718".
I want to measure the processing time of a function in a program.

I tried the following code, but the return value of the “clock” function was always “0xFFFFFFFF”.

clock_t start = clock();
func();
clock_t end = clock();

I think I should use the "Performance Monitor Count" register.
But I don't know what code to write.
Could you provide a sample code like the one above?

Thank you.

  • Hi,

    Your query has been assigned to a TI engineer. Please note that feedback may be delayed due to holidays in the USA.

     

    Best Regards
    Biser
  • In reply to Biser Gatchev-XID:

    Hi,

    For CSL (bare-metal), please see the following files:

    • pdk_am57xx_1_0_16/packages/ti/csl/arch/a15/cp15.h : header
    • pdk_am57xx_1_0_16/packages/ti/csl/arch/a15/V1/performance_unit.asm : asm source

    These functions are provided for PMU: ARM_CCNT_Enable, ARM_CCNT_Reset, ARM_CCNT_Read. I think you would simply call ARM_CCNT_Read() before (start) and after (end) your function call.

    Please see this thread for using A15 PMU as a time stamp provider in an RTOS-based application:

    https://e2e.ti.com/support/processors/f/791/t/617492?DRA756-A15-example-of-timestamp-provider-in-core-clock-cycles

    Regards,
    Frank

  • In reply to Frank Livingston:


    Thank you for your reply.
    The following code was able to get a value like processing time.

    unsigned int start_time, end_time;
    ARM_CCNT_Enable();
    start_time = ARM_CCNT_Read();
    func();
    end_time = ARM_CCNT_Read();

    start_time = 0

    end_time = 18052
    The result was obtained.

    How can I convert this "18052" to milliseconds?

    Thank you.

  • In reply to koji fukumoto:

    Hi,

    Please see the header in performance_unit.asm:

    * The CCNT is divided by 64 (by setting Bit 3 of PMNC to 1)
    * CCNT Read returns the clock value divided by 64 cycles.
    * To get the actual CPU cycle multiple it with 64

    You can confirm the PMU Cycle Counter is configured this way be inspecting the assembly code in performance_unit.asm. To understand the code, please refer to relevant ARM documentation, e.g.

    • DDI0438I_cortex_a15_r4p0_trm.pdf: ARM Cortex-A15 MPCore Processor Reference Manual. See Section 11.3, PMU register summary.
    • DDI0406C_C_arm_architecture_reference_manual.pdf: ARM Architecture Reference Manual ARMv7-A and ARMv7-R edition. This will provide details concerning the PMCR, PMCNTENSET, and PMCCNTR regiters, as well as details concerning the assembly language instructions.

    To get a time in msec.:

    • Multiply PMCCNTR "delta" (end-start) value by 64 to obtain CPU cycle count
    • Divide CPU cycle count by CPU clock speed. This is the wall-clock time in seconds.
    • Convert sec. to msec. by multiplying by 1000.

    Regards,
    Frank

  • In reply to Frank Livingston:

    Hi,
    Thank you for your reply.

    The CPU clock of TMDXIDK5718 is 1.5GHz.
    Is the following calculation method correct?

    unsigned int start_time, end_time;
    double procMS;
    
    ARM_CCNT_Enable();
    start_time = ARM_CCNT_Read();
    func();
    end_time = ARM_CCNT_Read();
    
    procMS = (end_time - start_time) * 64.0 / 1610612736.0 * 1000.0;
    

    Thank you.

  • In reply to koji fukumoto:

    I would multiply by 1.5e6 rather than 1.5*1024^3.

  • In reply to Frank Livingston:

    Hi,
    Thank you for your reply.

    It is confirmation just in case.
    Is it “1.5e6” instead of “1.5e9”?
    (Is "1,500,000" instead of "1,500,000,000"?)

  • In reply to koji fukumoto:

    Hi,

    Yes, it should be 1.5e9 (Giga), not 1.5e6 (Mega).

    Regards,
    Frank