0
\$\begingroup\$

I have a function that computes the sum of even numbers in a Fibonacci sequence less than a boundary.

Should I be worried about this calculation? Can the TMS320C6713 handle it?

When I run the following code on Visual Studio on my 64-bit computer with a value of 4294967295 (232 -1), it returns 4611685999100035072.

unsigned long long int sum = 0;
unsigned int f_n0 = 0;
unsigned int f_n1 = 1;
unsigned long long int f_n2 = 0;

unsigned long long int list_fibonacci(unsigned long long int boundary)
{
   while ((f_n2 = f_n0 + f_n1) < boundary)
   {
       if (f_n2 % 2 == 0)                      
          sum += f_n2;                         
       f_n0 = f_n1;                         
       f_n1 = f_n2;                         
   }
   return sum;
}

Thank you.

\$\endgroup\$
  • \$\begingroup\$ What exactly are you worried about here? I'm no DSP expert, but that DSP seems fairly capable of doing math really quickly. Do you have a time constraint? Or are you just concerned about whether or not the hardware can do it? \$\endgroup\$ – Brendan Simpson Mar 31 '16 at 20:07
  • \$\begingroup\$ @BrendanSimpson It's the hardware. It's my first time working with a DSP. \$\endgroup\$ – massakrienen Mar 31 '16 at 21:31
0
\$\begingroup\$

Its been a while since I've worked on DSP's from TI, to answer, yes it will do this and it will do it fast. If you intend to do lots of these operations, you will have to account for I\O time to send and recieve. They will do 256-bit operations (VLIW). The DSP's also have a lot of special registers and functions you will want to get familiar with this document. The power of a DSP is better utilized when you optimize functions with assembly, compilers don't do a great job. To make your function run fast, you will need to optimize the mod\remainder function as this function does not have a direct assembly equivalent. You will also want to look at how f_n0, f_n1 and f_n2 are being stored in memory. This is assumming you want this to run very fast.

The best way would be to compile the function and load it on the DSP, then go through and optimize the assembly by hand.

\$\endgroup\$
  • \$\begingroup\$ Right now my concern is if it can store an unsigned long long int variable. It is at least 64 bits in size. \$\endgroup\$ – massakrienen Apr 1 '16 at 0:56
  • \$\begingroup\$ You can do that on any machine, depending on the compiler. \$\endgroup\$ – Voltage Spike Apr 1 '16 at 17:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.