[Tinyos-devel] One should make limited use of the "%" operator

Eric Decker cire831 at gmail.com
Thu Jun 25 13:02:01 PDT 2009


On Thu, Jun 25, 2009 at 12:44 PM, Philip Levis <pal at cs.stanford.edu> wrote:

>
> On Jun 25, 2009, at 12:06 PM, Eric Decker wrote:
>
>
>>
>> On Thu, Jun 25, 2009 at 11:54 AM, Philip Levis <pal at cs.stanford.edu>
>> wrote:
>>
>> On Jun 25, 2009, at 11:42 AM, Vlado Handziski wrote:
>>
>> Speaking about optimization, and looking at your example snippet: For the
>> msp430 platforms, it is always much more efficient to use word size array
>> indices. The code is a lot simpler and some nasty gcc bugs can be avoided
>> more easy.
>>
>> But this is platform independent code. The cost ratio of an inequality and
>> jump compared to a hardware modulo is much less than a software modulo and
>> an inequality and jump.
>>
>> Phil
>>
>> I'm not following the analysis because I'm not sure what is meant by
>> hardware vs. software modulo.   % on the MSP430 is implemented by a library
>> routine that takes a significant number of instructions.   Whereas the
>> comparsion, jump, assignment take much fewer.
>>
>
> By "software modulo" I mean "a library routine." By "hardware modulo" I
> mean an ALU that computes modulo, e.g., as the iMote2 has. The point is that
> making an iMote2 do a compare and jump is not a big overhead over a hardware
> modulo, while making an msp430 (or other MCUs) do a software modulo is a big
> overhead over a compare and jump. But starting to set the width of variables
> in platform-independent code due to some particulars of a popular MCU's
> compiler (as Vlado suggested) seems like a bad idea.


In general, I agree with you.



More information about the Tinyos-devel mailing list