<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Code execution taking a large amount of processor cycles on IMX6Ull in i.MX Processors</title>
    <link>https://community.nxp.com/t5/i-MX-Processors/Code-execution-taking-a-large-amount-of-processor-cycles-on/m-p/1609318#M202312</link>
    <description>&lt;P&gt;I am doing some timing analysis on our system that uses the IMX6ULL. I have found using the system tick counter that some instructions take a larger amount of cycles to execute than should take. The L1 data cache is enabled in our application (L1C_EnableDataCache();).&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;P&gt;This C statement:&lt;/P&gt;&lt;P&gt;recordLength = p_record-&amp;gt;recordLength / 4;&lt;/P&gt;&lt;P&gt;Assembly code of the above C statement:&lt;/P&gt;&lt;P&gt;80006fbe: add.w r3, sp, #24448 ; 0x5f80&lt;BR /&gt;80006fc2: add.w r3, r3, #20&lt;BR /&gt;80006fc6: ldr r3, [r3, #0]&lt;BR /&gt;80006fc8: ldr r3, [r3, #0]&lt;BR /&gt;80006fca: lsrs r2, r3, #2&lt;BR /&gt;80006fcc: movw r3, #4096 ; 0x1000&lt;BR /&gt;80006fd0: movt r3, #34419 ; 0x8673&lt;BR /&gt;80006fd4: str r2, [r3, #0]&lt;/P&gt;&lt;P&gt;Execution monitoring code:&lt;/P&gt;&lt;P&gt;clockTicks1 = (__MRC(15, 0, 9, 13, 0));&lt;BR /&gt;recordLength = p_record-&amp;gt;recordLength / 4;&lt;BR /&gt;clockTicks2 = (__MRC(15, 0, 9, 13, 0));&lt;BR /&gt;totalTicks = clockTicks2 - clockTicks1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The totalTicks count is consistently 200. This obviously is about 10 times the cycles the statement should take. Interrupts are turned off, so this code is not being interrupted.&lt;/P&gt;&lt;P&gt;The application is compiled with GCC.&lt;/P&gt;&lt;P&gt;Can anyone shed light on why this operation is taking so long?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 03 Mar 2023 15:54:31 GMT</pubDate>
    <dc:creator>kevincronn</dc:creator>
    <dc:date>2023-03-03T15:54:31Z</dc:date>
    <item>
      <title>Code execution taking a large amount of processor cycles on IMX6Ull</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Code-execution-taking-a-large-amount-of-processor-cycles-on/m-p/1609318#M202312</link>
      <description>&lt;P&gt;I am doing some timing analysis on our system that uses the IMX6ULL. I have found using the system tick counter that some instructions take a larger amount of cycles to execute than should take. The L1 data cache is enabled in our application (L1C_EnableDataCache();).&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;P&gt;This C statement:&lt;/P&gt;&lt;P&gt;recordLength = p_record-&amp;gt;recordLength / 4;&lt;/P&gt;&lt;P&gt;Assembly code of the above C statement:&lt;/P&gt;&lt;P&gt;80006fbe: add.w r3, sp, #24448 ; 0x5f80&lt;BR /&gt;80006fc2: add.w r3, r3, #20&lt;BR /&gt;80006fc6: ldr r3, [r3, #0]&lt;BR /&gt;80006fc8: ldr r3, [r3, #0]&lt;BR /&gt;80006fca: lsrs r2, r3, #2&lt;BR /&gt;80006fcc: movw r3, #4096 ; 0x1000&lt;BR /&gt;80006fd0: movt r3, #34419 ; 0x8673&lt;BR /&gt;80006fd4: str r2, [r3, #0]&lt;/P&gt;&lt;P&gt;Execution monitoring code:&lt;/P&gt;&lt;P&gt;clockTicks1 = (__MRC(15, 0, 9, 13, 0));&lt;BR /&gt;recordLength = p_record-&amp;gt;recordLength / 4;&lt;BR /&gt;clockTicks2 = (__MRC(15, 0, 9, 13, 0));&lt;BR /&gt;totalTicks = clockTicks2 - clockTicks1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The totalTicks count is consistently 200. This obviously is about 10 times the cycles the statement should take. Interrupts are turned off, so this code is not being interrupted.&lt;/P&gt;&lt;P&gt;The application is compiled with GCC.&lt;/P&gt;&lt;P&gt;Can anyone shed light on why this operation is taking so long?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Mar 2023 15:54:31 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Code-execution-taking-a-large-amount-of-processor-cycles-on/m-p/1609318#M202312</guid>
      <dc:creator>kevincronn</dc:creator>
      <dc:date>2023-03-03T15:54:31Z</dc:date>
    </item>
    <item>
      <title>Re: Code execution taking a large amount of processor cycles on IMX6Ull</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Code-execution-taking-a-large-amount-of-processor-cycles-on/m-p/1610877#M202438</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/77603"&gt;@kevincronn&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;I hope you are doing well.&lt;BR /&gt;Please accept my apologies for the delay in response.&lt;/P&gt;
&lt;DIV&gt;&lt;FONT face="arial, sans-serif"&gt;It could be because other background processes in linux may be using processor cycles.&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="arial, sans-serif"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="arial, sans-serif"&gt;For performance and cycle measurement, one can refer to PMU in ARMv7 architecture.&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="arial, sans-serif"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="arial, sans-serif"&gt;One can refer to the below-mentioned links for performance measurements using pmu.&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;STRONG&gt;&lt;A href="https://pittrasg.github.io/blog/2020/pmusarm/" target="_blank" rel="noopener" data-saferedirecturl="https://www.google.com/url?q=https://pittrasg.github.io/blog/2020/pmusarm/&amp;amp;source=gmail&amp;amp;ust=1678274418950000&amp;amp;usg=AOvVaw03YyncJVcB2hU2JktTuNOn"&gt;&lt;FONT face="arial, sans-serif"&gt;How to Use ARM Performance Monitoring Units(PMU) in ARMv7&lt;/FONT&gt;&lt;/A&gt;&lt;/STRONG&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;A href="https://github.com/XKCP/XKCP/tree/master/support/Kernel-PMU" target="_blank" rel="noopener" data-saferedirecturl="https://www.google.com/url?q=https://github.com/XKCP/XKCP/tree/master/support/Kernel-PMU&amp;amp;source=gmail&amp;amp;ust=1678274418950000&amp;amp;usg=AOvVaw3nMt7awe9V5fYrheN6cs5b"&gt;&lt;FONT face="arial, sans-serif"&gt;Kernel-PMU&lt;/FONT&gt;&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="arial, sans-serif"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="arial, sans-serif"&gt;Another easy way is to use perf (perf stat)&amp;nbsp;utility&amp;nbsp;to count cycles.&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="arial, sans-serif"&gt;&lt;SPAN&gt;To measure&amp;nbsp;performance in C source code one can refer to&amp;nbsp;&lt;/SPAN&gt;&lt;A title="https://man7.org/linux/man-pages/man2/perf_event_open.2.html" href="https://man7.org/linux/man-pages/man2/perf_event_open.2.html" target="_blank" rel="noopener noreferrer" data-saferedirecturl="https://www.google.com/url?q=https://man7.org/linux/man-pages/man2/perf_event_open.2.html&amp;amp;source=gmail&amp;amp;ust=1678274418950000&amp;amp;usg=AOvVaw0M5oFF1bim-_Ukt_VmGH8o"&gt;&lt;STRONG&gt;&lt;SPAN&gt;perf_event_open&amp;nbsp;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/A&gt;&lt;SPAN&gt;system call.&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;P&gt;Thanks &amp;amp; Regards,&lt;BR /&gt;Sanket Parekh&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2023 12:09:47 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Code-execution-taking-a-large-amount-of-processor-cycles-on/m-p/1610877#M202438</guid>
      <dc:creator>Sanket_Parekh</dc:creator>
      <dc:date>2023-03-07T12:09:47Z</dc:date>
    </item>
  </channel>
</rss>

