[Freeciv-Dev] Re: Profiling Civserver again
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
At 12:30 AM 01/08/02 +0100, Vasco Alexandre Da Silva Costa wrote:
>On Thu, 2 Aug 2001, Gaute B Strokkenes wrote:
>
>> On Wed, 1 Aug 2001, vasc@xxxxxxxxxxxxxx wrote:
>> > Well does gcc optimize it this way?
>> >
>> > #define map_adjust_x(X) \
>> > (((X) % map.xsize) + (((X >= 0) - 1) & map.xsize))
>>
>> You mean * rather than &, right?
>
>No. Try the macro and you'll see. It IS unreadable. Don't say i didn't
>warn you. :-) Tip: 0-1=a mask of ones 0xFFFFFFFF, 1-1=a mask of zeros
>0x00000000.
>
>> > This is faster. Its faster on all CPUs. Notice it doesn't have any
>> > branches. Of course its also pretty darn unreadable :-)
It is also unsafe. Boolean TRUE values are undefined by the standards, and
there is no guarantee that this is not represented by any non-zero set of
bits. You need to do this as (X >= 0 ? 1 : 0) to be 100% safe.
[...]
>---
>Vasco Alexandre da Silva Costa @ Instituto Superior Tecnico, Lisboa
My feeling is the leading % is the hot spot. But I don't know if integer
div is just like any arithmetic op on the current top-of-the-line chips.
I do know most have dual path or better internal processing units and
usually use prediction so as not to stall the pipeline on simple branches.
I favour the guard test, because I think the border cases where you need
this are a very small percentage, and it is the lightest weight for a
normal case.
But like most of us I'm not sufficiently motivated to do a 10 line
program to test this out - the discussion is more fun :-).
Cheers,
RossW
- [Freeciv-Dev] map_adjust_x (was: Profiling Civserver again), (continued)
- [Freeciv-Dev] Re: map_adjust_x (was: Profiling Civserver again), Paul Zastoupil, 2001/08/02
- [Freeciv-Dev] Re: map_adjust_x (was: Profiling Civserver again), Gaute B Strokkenes, 2001/08/02
- [Freeciv-Dev] Re: Profiling Civserver again, Reinier Post, 2001/08/02
- [Freeciv-Dev] map_adjust_x (was: Profiling Civserver again), Mike Kaufman, 2001/08/02
- [Freeciv-Dev] Re: map_adjust_x (was: Profiling Civserver again), Reinier Post, 2001/08/02
- [Freeciv-Dev] Re: Profiling Civserver again, Vasco Alexandre Da Silva Costa, 2001/08/01
- [Freeciv-Dev] Re: Profiling Civserver again,
Ross W. Wetmore <=
- [Freeciv-Dev] Re: Profiling Civserver again, Robert Brady, 2001/08/01
- [Freeciv-Dev] Re: Profiling Civserver again, Vasco Alexandre Da Silva Costa, 2001/08/01
- [Freeciv-Dev] Re: Profiling Civserver again, Trent Piepho, 2001/08/01
- [Freeciv-Dev] Re: Profiling Civserver again, Vasco Alexandre Da Silva Costa, 2001/08/01
- [Freeciv-Dev] Re: Profiling Civserver again, Trent Piepho, 2001/08/02
- [Freeciv-Dev] Re: Profiling Civserver again, Greg Wooledge, 2001/08/02
- [Freeciv-Dev] Re: Profiling Civserver again, Jules Bean, 2001/08/02
- [Freeciv-Dev] Re: Profiling Civserver again, Gaute B Strokkenes, 2001/08/06
- [Freeciv-Dev] Re: Profiling Civserver again, Gaute B Strokkenes, 2001/08/02
- [Freeciv-Dev] Re: Profiling Civserver again, Paul Zastoupil, 2001/08/02
|
|