Experimental Physics and Industrial Control System
Hi Jeff,
Looks fine to me, don't worry about committing minor changes like this
directly to the 3.15 branch; it's the big changes that need reviewing.
- Andrew
On 2012-11-14 Hill, Jeff wrote:
> Dear All,
>
> I inadvertently committed the attached change to the main trunk on a
> checkout instead of a branch and therefore bypassed the normal review
> process. If there is (any) opposition I will back out the change and make
> a branch. I did run the epicsTime regression test, which didn't detect any
> issues, before making this commit.
>
> Jeff
>
> Commit message:
>
> After optimizing the epicsTime::addNanoSec function we now have a larger
> code which uses only unsigned integer arithmetic. This is for the benefit
> of embedded cpu's lacking a hardware floating point coprocessor at the
> expense of some additional code to maintain. I measured the cpu load
> improving from 40% free to 80% free after making this change, on a nios2
> soft core processor.
>
> Change:
>
> == modified file src/libCom/osi/epicsTime.cpp
> --- src/libCom/osi/epicsTime.cpp 2012-05-03 17:19:34 +0000
> +++ src/libCom/osi/epicsTime.cpp 2012-11-14 19:51:30 +0000
> @@ -113,8 +113,48 @@
> //
> inline void epicsTime::addNanoSec (long nSecAdj)
> {
> - double secAdj = static_cast <double> (nSecAdj) / nSecPerSec;
> - *this += secAdj;
> + // After optimizing this function we now have a larger
> + // code which uses only unsigned integer arithmetic.
> + // This is for the benefit of embedded cpu's lacking
> + // a hardware floating point coprocessor at the
> + // expense of some additional code to maintain.
> + // joh 14-11-2012
> + if ( nSecAdj >= 0 ) {
> + unsigned long nSecOffsetLong =
> + static_cast < unsigned long > ( nSecAdj );
> + while ( nSecOffsetLong >= nSecPerSec ) {
> + this->secPastEpoch++; // overflow expected
> + nSecOffsetLong -= nSecPerSec;
> + }
> + const epicsUInt32 nSecOffset =
> + static_cast < epicsUInt32 > ( nSecOffsetLong );
> + epicsUInt32 nSecPerSecRemaining = nSecPerSec - nSecOffset;
> + if ( this->nSec >= nSecPerSecRemaining ) {
> + this->secPastEpoch++; // overflow expected
> + this->nSec -= nSecPerSecRemaining;
> + }
> + else {
> + this->nSec += nSecOffset;
> + }
> + }
> + else {
> + unsigned long nSecOffsetLong =
> + static_cast <unsigned long> ( -nSecAdj );
> + while ( nSecOffsetLong >= nSecPerSec ) {
> + this->secPastEpoch--; // underflow expected
> + nSecOffsetLong -= nSecPerSec;
> + }
> + const epicsUInt32 nSecOffset =
> + static_cast < epicsUInt32 > ( nSecOffsetLong );
> + if ( this->nSec >= nSecOffset ) {
> + this->nSec -= nSecOffset;
> + }
> + else {
> + // borrow
> + this->secPastEpoch--; // underflow expected
> + this->nSec += nSecPerSec - nSecOffset;
> + }
> + }
> }
>
> //
>
>
> Jeff
> ______________________________________________________
> Jeffrey O. Hill Email [email protected]
> LANL MS H820 Voice 505 665 1831
> Los Alamos NM 87545 USA FAX 505 665 5107
>
> Message content: TSPA
>
- Andrew
--
READ CAREFULLY. By reading this email, you agree, on behalf of your
employer, to release me from all obligations and waivers arising from
any and all NON-NEGOTIATED agreements, licenses, terms-of-service,
shrink-wrap, click-wrap, browse-wrap, confidentiality, non-disclosure,
non-compete and acceptable use policies ("BOGUS AGREEMENTS") that I
have entered into with your employer, its partners, licensors, agents
and assigns, in perpetuity, without prejudice to my ongoing rights
and privileges. You further represent that you have the authority to
release me from any BOGUS AGREEMENTS on behalf of your employer.
- References:
- optimization to epicsTime Hill, Jeff
- Navigate by Date:
- Prev:
RE: optimization to epicsTime Hill, Jeff
- Next:
catch in ubuntu gcc 4.6.1 Hill, Jeff
- Index:
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
<2012>
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
- Navigate by Thread:
- Prev:
optimization to epicsTime Hill, Jeff
- Next:
RE: optimization to epicsTime Hill, Jeff
- Index:
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
<2012>
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024