public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug go/60790] New: libatomic convenience library selects IFUNC implementation before obtaining cpu info.
@ 2014-04-09  5:19 gary at intrepid dot com
  2014-04-09  5:28 ` [Bug go/60790] " gary at intrepid dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: gary at intrepid dot com @ 2014-04-09  5:19 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60790

            Bug ID: 60790
           Summary: libatomic convenience library selects IFUNC
                    implementation before obtaining cpu info.
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: go
          Assignee: ian at airs dot com
          Reporter: gary at intrepid dot com
                CC: nenad at intrepid dot com, PHHargrove at lbl dot gov,
                    rth at gcc dot gnu.org

Created attachment 32569
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=32569&action=edit
libatomic cpuinfo patch

We ran into this issue recently while implementing atomic memory support for
GNU UPC.  We followed an approach similar to libgo -- we included
libatomic_convenience.a into libgupc.a.  This lets libgupc access GCC's
__atomic support without requiring the user to link explicitly with libatomic.

While debugging the UPC AMO library on a modern X86-64 platform, we noticed
that the locked implementation of compare-exchange-16 was being used in spite
of the fact of that the CPU supports the CMPX16 operation directly.

We determined that the IFUNC selector function was being called before the
constructor function in init.c had run.  Thus the libat_feat1_ecx variable was
zero.  Because the feature bit wasn't set, the selector function chose the CAS
function which requires explicit locks.  Interestingly,
__atomic_is_lock_free(16, NULL) returns true, as expected on this platform
because it is called after the init_cpuid() constructor is called.

One way to fix this issue is to re-work the logic that queries the CPU feature
register value, so that it explicitly initializes the value if it is zero.  The
assumption here is that __get_cpuid() will always return a non-zero value in
the ECX feature register.  A patch that implements this approach is attached.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-04-09 15:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-09  5:19 [Bug go/60790] New: libatomic convenience library selects IFUNC implementation before obtaining cpu info gary at intrepid dot com
2014-04-09  5:28 ` [Bug go/60790] " gary at intrepid dot com
2014-04-09  5:38 ` [Bug libgcc/60790] " pinskia at gcc dot gnu.org
2014-04-09 13:32 ` ian at airs dot com
2014-04-09 13:44 ` jakub at gcc dot gnu.org
2014-04-09 15:55 ` gary at intrepid dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).