• Join
  • Sign In with my.TI Login
Texas Instruments
  • Products
  • Applications
  • Tools & Software
  • Support & Community
  • Sample & Buy
  • About TI
Sample & Purchase Cart Sample & Purchase Cart
  • Search
  • Advanced
TI E2E™ Community
  • Support Forums
  • Blogs
  • Groups
  • Videos
  • 简体中文
  • More ...
TI Home » TI E2E Community » Support Forums » Digital Signal Processors (DSP) » C5000 Ultra Low Power DSP » C5000 Ultra Low Power DSP Forum » Data Binning...
Share
C5000 Ultra Low Power DSP
  • Forum
  • Announcements
Options
  • Subscribe via RSS
Top 6 Wiki Links
  • C5000 Main Wiki
  • C5000 Software
  • C5515 Boot-Image Programmer
  • CSL (including CSL 3.00)
  • C5000 Connected Audio Framework
  • Porting C5000 Teaching ROM to C5535 eZdsp
  • Forums

    Data Binning...

    This question is answered
    Todd Anderson78572
    Posted by Todd Anderson78572
    on Apr 13 2012 12:38 PM
    Expert2750 points

    All:

    I need to optimize a  for()  loop for the C5505...I have a raw buffer that needs to be dealt into 3 bins...

    for (i=0;i<1000;i++)

    {

          j = 3*i;

          buff1[i] = rawbuff[j];

          buff2[i] = rawbuff[j+1];

          buff3[i] = rawbuff[j+2];

    }

    I tried to make i & j global instead of local - no better results.

    If I went from 1000 to 0, instead of 0 to 1000, would that be more optimal?

    Would a do-while work better than the for()?

    If I created a structure that had buff1, buff2, buff3, could that be made to work better than 3 independent buffers?

    I can examine the resulting assembly, and create an optimized assembly routine, but I would rather not.

     

    Regards,

    Todd Anderson

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    All Replies
    • Todd Anderson78572
      Posted by Todd Anderson78572
      on Apr 13 2012 13:38 PM
      Expert2750 points

      All:

      I just realized that the C55x has a repeat block assembly instruction.

      It could be that the main part of an assembly solution could be something like

      Repeat Block 3000 times.

          Move RawBuffer Value to ACC... with autoincrement of buffer pointer.

          Move ACC to BinX or Y or Z...with autoincrement.

      End Repeat.

       

      Does anyone have a snippet of code that does this?

       

      Regards,

      Todd Anderson

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Archaeologist
      Posted by Archaeologist
      on Apr 13 2012 15:25 PM
      Mastermind40550 points

      Are you using the optimizer?  What is the type of the elements in the buffers?

      The compiler gets pretty good (but not perfect) results for int-sized elements.  It can do the auto-increment optimization without assistance.  Try this:

      /* cl55 -O2 deal.c */
      void deal(int buff1[], int buff2[], int buff3[], int rawbuff[restrict])
      {
          int i, j;
      
          for (i=0;i<1000;i++)
          {
              j = 3*i;
              buff1[i] = rawbuff[j];
              buff2[i] = rawbuff[j+1];
              buff3[i] = rawbuff[j+2];
          }
      }
      
      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Cong Van Nguyen
      Posted by Cong Van Nguyen
      on Apr 13 2012 19:03 PM
      Intellectual940 points

      The following loop would be faster than yours:

      for (i = 1000; i != 0; i--)

      {

          *buff1++ = *rawbuff++;

          *buff2++ = *rawbuff++;

          *buff3++ = *rawbuff++;


      }

      You can also double the speed by rewriting this loop in assembly code

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Todd Anderson78572
      Posted by Todd Anderson78572
      on Apr 14 2012 19:03 PM
      Verified Answer
      Verified by Todd Anderson78572
      Expert2750 points

      All:

      Thanks for the input - looks like I can do it with a specific assembly routine - inside of my loop, it is 3 instructions, very similar to your solution Cong!

      I found that the RPTBLOCAL can be used with the following 3 instructions - simulated to some degree...

      One other caviat - turns out that my raw buffer is 32 bits wide and I need to copy the upper  16 bits to each of 3 bins.

      My repeat code looks like this:

      RPTBLOCAL  END_RPT

         mov    *(AR4+T0), *AR1+   ; Move value from raw buffer to bin 1.

         mov    *(AR4+T0), *AR2+   ; Move value from raw buffer to bin 2.

         mov    *(AR4+T0), *AR3+   ; Move value from raw buffer to bin 3.

      END_RPT:

      Thanks again for the input...

       

       

       

       

      Regards,

      Todd Anderson

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    TI E2E™ Community
    • Support Forums
    • Blogs
    • Videos
    • Groups
    • Site Support & Feedback
    • Settings
    TI E2E™ Community Groups
    • TI University Program
    • Make the Switch
    • Microcontroller Projects
    • Motor Drive & Control
    Other Communities
    • Deyisupport
    • Designsomething.org
    • beagleboard.org
    • TI on Element 14
    • TI on TechXchangeSM
    Other Technical & Support Resources
    • WEBENCH® Design Center
    • Product Information Centers
    • Technical Documents
    • TI Design Network
    • TI Technical Articles
    • TI Training

    All content and materials on this site are provided "as is". TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with regard to these materials, including but not limited to all implied warranties and conditions of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with respect to these materials. No license, either express or implied, by estoppel or otherwise, is granted by TI. Use of the information on this site may require a license from a third party, or a license from TI.

    Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms of Use of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms of Use of this site. TI, its suppliers and providers of content reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

    Follow Us Texas Instruments on Facebook Texas Instruments on Twitter Texas Instruments on LinkedIn Texas Instruments on Google+
    TI Worldwide | Contact Us | my.TI Login | Site Map | Corporate Citizenship | mobile m.ti.com (Mobile Version)

    TI is a global semiconductor design and manufacturing company. Innovate with 100,000+ analog ICs and
    embedded processors, along with software, tools and the industry’s largest sales/support staff.

    © Copyright 1995-2013 Texas Instruments Incorporated. All rights reserved.
    Trademarks | Privacy Policy | Terms of Use