This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: notes on current atomics config and usage


Hi Benjamin,

Here's another approach.

The attached patch clarifies the atomics config. In a nutshell, if
there exists a config/cpu/*/atomicity.h file, it's used. If there
isn't, either the builtins are used (and inlined) if they are proved to
exist, or the mutex fall-back is used.


There should never be the case where the cpu has both builtins and a
configure atomicity.h. Thus, this patch removes
config/cpu/i486 because the builtin atomics for this cpu are better.

As-is, this changes the default behavior for default x86 compiles. What
happens? Well, say the host is i686, check. But, the i386 atomicity.h
is skipped over, and there is no i686 atomicity.h, since there are
actually builtins for this host. However, the check for builtins fails,
since the default -march for this host is i386. Thus, mutex-ville.


I'm not sure to understand: you mean, by default we are going to use mutexes?!? Sorry, but if this what you are really saying, it's unacceptable performance-wise: by default everyone (on x86_64 too!) will notice a huge regression, please-please let's not do that. In my opinion, on i686 by default we should simply provide out of line __atomic_add and __exchange_and_add implemented in terms of the builtins (we should use builtins instead of assembly, like you are correctly suggesting elsewhere).

Note essentially the same issue affects Sparc (Jakub prepared the builtins, only they are not exploited by the current configury): sufficiently recent machines by default should have out of line code using the builtins.

I did some performance testing, original vs. patch +
CXXFLAGS="-march=i686". Results are attached. Surprisingly, there is
some slight degradation,

Well, I'm seeing more-than-slight degradations, some numbers, in string_append for example, are horrible (10x !?!), I cannot believe we are talking about the same machine!?! Are you really-really sure we are talking about the right config? Not even mutexes would explain such huge differences...

Benjamin, I would be happy to carry out some performance tests and whatelse, but the patch doesn't apply cleanly here, lots of problems... Anyway, in a few days I will be away for a week of vacations: please, please, let's proceed carefully, separate well tested steps, in case we can leave alone the i386/i686 (and Sparc v7/newer) case for now, and deal with it separately.

Paolo.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]