Sign in

username:

password:



Not a member?

Search c55x



Search tips

Subscribe to c55x



c55x by Keywords

AIC23 | C5509 | CCS | CSL | EMIF | EVM | GEL | GPIO | HPI | Interfacing | JTAG | McBSP | OMAP | Omap15 | OMAP59 | RTDX | SDRAM | TMS320VC5509 | USB | XDS5

Ads

Discussion Groups

Discussion Groups | TMS320C55x | Fast abs() function

Technical discussions about the TI C55x DSPs (including the c5501, c5502, c5503, c5507, c5509, c5510 and OMAP5910).

  

Post a new Thread

Fast abs() function - Marko Panger AGB Lab - Jun 22 2:24:58 2007



Hello,

I'm working on a 5509a DSP. I trying t optimize a critical function as 
much as possible. Analyzing the code showed that the most
time is spent in while calling the std::abs() function in a for loop.

Is any of you aware of a optimized version of this function or is there 
any fast algorithm to compute this ?

By consulting the assembler users guide seems that the 55x architecture 
has an dedicated assembler instruction for computing the abs value but I
don't know how to mix C/C++ instructions.

Thanks,
Marko



(You need to be a member of c55x -- send a blank email to c55x-subscribe@yahoogroups.com )

Re: Fast abs() function - Jeff Brower - Jun 22 16:26:06 2007

Marko-

> I'm working on a 5509a DSP. I trying t optimize a critical function as
> much as possible. Analyzing the code showed that the most
> time is spent in while calling the std::abs() function in a for loop.
> 
> Is any of you aware of a optimized version of this function or is there
> any fast algorithm to compute this ?
> 
> By consulting the assembler users guide seems that the 55x architecture
> has an dedicated assembler instruction for computing the abs value but I
> don't know how to mix C/C++ instructions.

Calling asm from C/C++ code is easy and well-documented in the TI C/C++ guide docs. 
But one thing you can try as an intermediate step is intrinsics, which allow C
statements to be replaced by inline statements that expand into specific asm
instructions.  Try here:

  http://focus.ti.com/lit/ug/spru281f/spru281f.pdf

Section 6.5.4, Using Intrinsics to Access Assembly Language Statements, shows some
abs() intrinsics.

-Jeff



(You need to be a member of c55x -- send a blank email to c55x-subscribe@yahoogroups.com )

Re: Fast abs() function - Marko Panger AGB Lab - Jun 26 3:22:51 2007

Hi Jeff,

I have already tried intrinsics but the _abs() doesn't work for me
("corelations.cpp", line 1035: error: identifier "_abs" is undefined).
Am I missing something ?

In general I prefer not to stick with the assembler on the 55x due to
the silicon issues.

Thanks,
Marko

Jeff Brower wrote:
> Marko-
>
>   
>> I'm working on a 5509a DSP. I trying t optimize a critical function as
>> much as possible. Analyzing the code showed that the most
>> time is spent in while calling the std::abs() function in a for loop.
>>
>> Is any of you aware of a optimized version of this function or is there
>> any fast algorithm to compute this ?
>>
>> By consulting the assembler users guide seems that the 55x architecture
>> has an dedicated assembler instruction for computing the abs value but I
>> don't know how to mix C/C++ instructions.
>>     
>
> Calling asm from C/C++ code is easy and well-documented in the TI C/C++ guide docs. 
> But one thing you can try as an intermediate step is intrinsics, which allow C
> statements to be replaced by inline statements that expand into specific asm
> instructions.  Try here:
>
>   http://focus.ti.com/lit/ug/spru281f/spru281f.pdf
>
> Section 6.5.4, Using Intrinsics to Access Assembly Language Statements, shows some
> abs() intrinsics.
>
> -Jeff
>



(You need to be a member of c55x -- send a blank email to c55x-subscribe@yahoogroups.com )

Re: Fast abs() function - Jeff Brower - Jun 26 11:22:52 2007

Marko-

> I have already tried intrinsics but the _abs() doesn't work for me
> ("corelations.cpp", line 1035: error: identifier "_abs" is
undefined).
> Am I missing something ?

As I recall, SPRU281f mentions _abss, _labss, etc. as the intrinsic names.  The
trailing 's' means a saturated result.

> In general I prefer not to stick with the assembler on the 55x due to
> the silicon issues.

That doesn't make any sense.  In the first place, it's rare that CCS allows entry of
silicon version in the target setup, and in those cases where it does both the
compiler and assembler would use the information to avoid relevant silicon errata. 
Whether the compiler generates the asm instruction or you generate it isn't going to
matter.

-Jeff

> Jeff Brower wrote:
> > Marko-
> >
> >
> >> I'm working on a 5509a DSP. I trying t optimize a critical function as
> >> much as possible. Analyzing the code showed that the most
> >> time is spent in while calling the std::abs() function in a for loop.
> >>
> >> Is any of you aware of a optimized version of this function or is there
> >> any fast algorithm to compute this ?
> >>
> >> By consulting the assembler users guide seems that the 55x architecture
> >> has an dedicated assembler instruction for computing the abs value but I
> >> don't know how to mix C/C++ instructions.
> >>
> >
> > Calling asm from C/C++ code is easy and well-documented in the TI C/C++ guide docs.
> > But one thing you can try as an intermediate step is intrinsics, which allow C
> > statements to be replaced by inline statements that expand into specific asm
> > instructions.  Try here:
> >
> >   http://focus.ti.com/lit/ug/spru281f/spru281f.pdf
> >
> > Section 6.5.4, Using Intrinsics to Access Assembly Language Statements, shows some
> > abs() intrinsics.
> >
> > -Jeff



(You need to be a member of c55x -- send a blank email to c55x-subscribe@yahoogroups.com )

Re: Fast abs() function - Marko Panger AGB Lab - Jun 27 3:04:23 2007

Hi,

The _abs() function is listed in the CC help menu for the 55x arch.

marko

Jeff Brower wrote:
> Marko-
>
>   
>> I have already tried intrinsics but the _abs() doesn't work for me
>> ("corelations.cpp", line 1035: error: identifier "_abs" is
undefined).
>> Am I missing something ?
>>     
>
> As I recall, SPRU281f mentions _abss, _labss, etc. as the intrinsic names.  The
> trailing 's' means a saturated result.
>
>   
>> In general I prefer not to stick with the assembler on the 55x due to
>> the silicon issues.
>>     
>
> That doesn't make any sense.  In the first place, it's rare that CCS allows entry of
> silicon version in the target setup, and in those cases where it does both the
> compiler and assembler would use the information to avoid relevant silicon errata. 
> Whether the compiler generates the asm instruction or you generate it isn't going to
> matter.
>
> -Jeff
>
>   
>> Jeff Brower wrote:
>>     
>>> Marko-
>>>
>>>
>>>       
>>>> I'm working on a 5509a DSP. I trying t optimize a critical function as
>>>> much as possible. Analyzing the code showed that the most
>>>> time is spent in while calling the std::abs() function in a for loop.
>>>>
>>>> Is any of you aware of a optimized version of this function or is there
>>>> any fast algorithm to compute this ?
>>>>
>>>> By consulting the assembler users guide seems that the 55x architecture
>>>> has an dedicated assembler instruction for computing the abs value but I
>>>> don't know how to mix C/C++ instructions.
>>>>
>>>>         
>>> Calling asm from C/C++ code is easy and well-documented in the TI C/C++ guide
docs.
>>> But one thing you can try as an intermediate step is intrinsics, which allow C
>>> statements to be replaced by inline statements that expand into specific asm
>>> instructions.  Try here:
>>>
>>>   http://focus.ti.com/lit/ug/spru281f/spru281f.pdf
>>>
>>> Section 6.5.4, Using Intrinsics to Access Assembly Language Statements, shows
some
>>> abs() intrinsics.
>>>
>>> -Jeff
>>>       
>



(You need to be a member of c55x -- send a blank email to c55x-subscribe@yahoogroups.com )

Re: Fast abs() function - Jeff Brower - Jun 27 16:40:14 2007

Marko-

> The _abs() function is listed in the CC help menu for the 55x arch.

Yes I see that also...  I would just say that if CCS Help and one of the SPRUs are in
conflict, go with the SPRU.

Did you try _abss()?  Does it work?  It shouldn't matter that your result is
saturated.

-Jeff

> Jeff Brower wrote:
> > Marko-
> >
> >
> >> I have already tried intrinsics but the _abs() doesn't work for me
> >> ("corelations.cpp", line 1035: error: identifier "_abs" is
undefined).
> >> Am I missing something ?
> >>
> >
> > As I recall, SPRU281f mentions _abss, _labss, etc. as the intrinsic names.  The
> > trailing 's' means a saturated result.
> >
> >
> >> In general I prefer not to stick with the assembler on the 55x due to
> >> the silicon issues.
> >>
> >
> > That doesn't make any sense.  In the first place, it's rare that CCS allows entry of
> > silicon version in the target setup, and in those cases where it does both the
> > compiler and assembler would use the information to avoid relevant silicon errata.
> > Whether the compiler generates the asm instruction or you generate it isn't going to
> > matter.
> >
> > -Jeff
> >
> >
> >> Jeff Brower wrote:
> >>
> >>> Marko-
> >>>
> >>>
> >>>
> >>>> I'm working on a 5509a DSP. I trying t optimize a critical function as
> >>>> much as possible. Analyzing the code showed that the most
> >>>> time is spent in while calling the std::abs() function in a for loop.
> >>>>
> >>>> Is any of you aware of a optimized version of this function or is there
> >>>> any fast algorithm to compute this ?
> >>>>
> >>>> By consulting the assembler users guide seems that the 55x architecture
> >>>> has an dedicated assembler instruction for computing the abs value but I
> >>>> don't know how to mix C/C++ instructions.
> >>>>
> >>>>
> >>> Calling asm from C/C++ code is easy and well-documented in the TI C/C++ guide
docs.
> >>> But one thing you can try as an intermediate step is intrinsics, which allow
C
> >>> statements to be replaced by inline statements that expand into specific asm
> >>> instructions.  Try here:
> >>>
> >>>   http://focus.ti.com/lit/ug/spru281f/spru281f.pdf
> >>>
> >>> Section 6.5.4, Using Intrinsics to Access Assembly Language Statements, shows
some
> >>> abs() intrinsics.
> >>>
> >>> -Jeff



(You need to be a member of c55x -- send a blank email to c55x-subscribe@yahoogroups.com )

Re: Fast abs() function - Marko Panger AGB Lab - Jun 28 2:48:06 2007

I'll try the _abss() in the next days and I will post the results.

Thanks,
marko

Jeff Brower wrote:
> Marko-
>
>   
>> The _abs() function is listed in the CC help menu for the 55x arch.
>>     
>
> Yes I see that also...  I would just say that if CCS Help and one of the SPRUs are in
> conflict, go with the SPRU.
>
> Did you try _abss()?  Does it work?  It shouldn't matter that your result is
> saturated.
>
> -Jeff
>
>   
>> Jeff Brower wrote:
>>     
>>> Marko-
>>>
>>>
>>>       
>>>> I have already tried intrinsics but the _abs() doesn't work for me
>>>> ("corelations.cpp", line 1035: error: identifier "_abs" is
undefined).
>>>> Am I missing something ?
>>>>
>>>>         
>>> As I recall, SPRU281f mentions _abss, _labss, etc. as the intrinsic names.  The
>>> trailing 's' means a saturated result.
>>>
>>>
>>>       
>>>> In general I prefer not to stick with the assembler on the 55x due to
>>>> the silicon issues.
>>>>
>>>>         
>>> That doesn't make any sense.  In the first place, it's rare that CCS allows entry
of
>>> silicon version in the target setup, and in those cases where it does both the
>>> compiler and assembler would use the information to avoid relevant silicon
errata.
>>> Whether the compiler generates the asm instruction or you generate it isn't going
to
>>> matter.
>>>
>>> -Jeff
>>>
>>>
>>>       
>>>> Jeff Brower wrote:
>>>>
>>>>         
>>>>> Marko-
>>>>>
>>>>>
>>>>>
>>>>>           
>>>>>> I'm working on a 5509a DSP. I trying t optimize a critical function
as
>>>>>> much as possible. Analyzing the code showed that the most
>>>>>> time is spent in while calling the std::abs() function in a for loop.
>>>>>>
>>>>>> Is any of you aware of a optimized version of this function or is
there
>>>>>> any fast algorithm to compute this ?
>>>>>>
>>>>>> By consulting the assembler users guide seems that the 55x
architecture
>>>>>> has an dedicated assembler instruction for computing the abs value but
I
>>>>>> don't know how to mix C/C++ instructions.
>>>>>>
>>>>>>
>>>>>>             
>>>>> Calling asm from C/C++ code is easy and well-documented in the TI C/C++
guide docs.
>>>>> But one thing you can try as an intermediate step is intrinsics, which
allow C
>>>>> statements to be replaced by inline statements that expand into specific
asm
>>>>> instructions.  Try here:
>>>>>
>>>>>   http://focus.ti.com/lit/ug/spru281f/spru281f.pdf
>>>>>
>>>>> Section 6.5.4, Using Intrinsics to Access Assembly Language Statements,
shows some
>>>>> abs() intrinsics.
>>>>>
>>>>> -Jeff
>>>>>           
>



(You need to be a member of c55x -- send a blank email to c55x-subscribe@yahoogroups.com )