Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Implementation of the abs() function [o.t.]

Author: Jens Kahlenberg

Date: 09:23:32 07/06/03

Go up one level in this thread


On July 06, 2003 at 05:02:50, Gerd Isenberg wrote:

>Hi Dieter,
>
>Thanks for the nice lession in macro programming and gnu/ata-assembler.
>Conclusion: branchless code on random, not predictable data is clearly
>favorable. The sar instructions is not that slow on P4.
>The five byte sequence with cdq is fastest:
>
>00401026 99                   cdq
>00401027 33 C2                xor         eax,edx
>00401029 2B C2                sub         eax,edx
>
>With mvc using math.h abs is fastest. With gcc cdq inline assembly abs or omids
>c-abs is much faster than the branching lib abs (maybe a macro from some header
>file?).
>
>Regards,
>Gerd

Hi Gerd,

abs is a builtin in gcc. As long as you don't compile with -fno-builtin compiler
doesn't take any library into account and only does lookup abs-code for target
system.

Would be interesting to know what version Dieter is using and to find out why
his version seems to have a __builtin_abs with branching target-code. Dieter
might even (with a lot of work) optimize further by compiling a new
(P4-targeted) gcc-compiler on his system with the existing one and perhaps abs
will be alright then.

Regards,
Jens



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.