Open MPI logo

Open MPI Development Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all Development mailing list

Subject: Re: [OMPI devel] inline asm patch
From: Ethan Mallove (ethan.mallove_at_[hidden])
Date: 2007-12-20 12:41:52


On Thu, Dec/20/2007 08:50:41AM, Jeff Squyres wrote:
> After Ethan's inline assembly patch (to make the
> upper-level atomic.h declarations match the lower-level
> inline definitions -- if they exist), I've had a problem
> with the PGI compiler on Linux.
>
> I finally tracked down the issue this morning -- it seems
> that OMPI_GCC_INLINE_ASSEMBLY is 0 for the PGI compiler.
> Hence, none of the assembly routines are inlined. The
> logic for the lower layer to say "these functions aren't
> inlined" didn't take the value of OMPI_GCC_INLINE_ASSEMBLY
> into account, so the upper layer was still prefixing the
> declarations with "static inline", which led to linker
> problems later.
>
> The below patch fixes the problem for me, but I wanted to
> run it by others before committing because it's fairly
> tangled logic (both inline for easy reading and attached
> in case my mail client munges the formatting).

Can this logic be up-leveled into sys/atomic.h (see below)
such that we have it in one atomic.h file instead of nine
atomic.h files? This would mean that if a given lower-level
<arch>/atomic.h file defines a non-GCC-style inline atomic,
that file would have to set an OPAL_HAVE_INLINE_* macro, but
I don't see any cases like this currently (there is only
XLC-style inline assembly in powerpc/atomic.h).

Index: opal/include/opal/sys/atomic.h
===================================================================
--- opal/include/opal/sys/atomic.h (revision 17003)
+++ opal/include/opal/sys/atomic.h (working copy)
@@ -111,19 +111,27 @@
 
 /**********************************************************************
  *
- * Zero these macros in the architecture-specific atomic.h files if we
- * need to define their corresponding functions as non-inline (e.g.,
- * in an opal/asm/base/<arch>.asm file). These macros allow us to make
- * the signatures of the prototype and definition identical.
- *
+ * Set or unset these macros in the architecture-specific atomic.h
+ * files if we need to specify them as inline or non-inline
+ *
  *********************************************************************/
+#if !OMPI_GCC_INLINE_ASSEMBLY
+#define OPAL_HAVE_INLINE_ATOMIC_MEM_BARRIER 0
+#define OPAL_HAVE_INLINE_ATOMIC_CMPSET_32 0
+#define OPAL_HAVE_INLINE_ATOMIC_ADD_32 0
+#define OPAL_HAVE_INLINE_ATOMIC_SUB_32 0
+#define OPAL_HAVE_INLINE_ATOMIC_CMPSET_64 0
+#define OPAL_HAVE_INLINE_ATOMIC_ADD_64 0
+#define OPAL_HAVE_INLINE_ATOMIC_SUB_64 0
+#else
 #define OPAL_HAVE_INLINE_ATOMIC_MEM_BARRIER 1
 #define OPAL_HAVE_INLINE_ATOMIC_CMPSET_32 1
-#define OPAL_HAVE_INLINE_ATOMIC_CMPSET_64 1
 #define OPAL_HAVE_INLINE_ATOMIC_ADD_32 1
 #define OPAL_HAVE_INLINE_ATOMIC_SUB_32 1
+#define OPAL_HAVE_INLINE_ATOMIC_CMPSET_64 1
 #define OPAL_HAVE_INLINE_ATOMIC_ADD_64 1
 #define OPAL_HAVE_INLINE_ATOMIC_SUB_64 1
+#endif
 
 /**********************************************************************
  *

-Ethan

>
> --
> Jeff Squyres
> Cisco Systems
>
> Index: opal/include/opal/sys/ia32/atomic.h
> ===================================================================
> --- opal/include/opal/sys/ia32/atomic.h (revision 16997)
> +++ opal/include/opal/sys/ia32/atomic.h (working copy)
> @@ -10,6 +10,7 @@
> * Copyright (c) 2004-2005 The Regents of the University of California.
> * All rights reserved.
> * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserverd.
> + * Copyright (c) 2007 Cisco Systems, Inc. All rights reserverd.
> * $COPYRIGHT$
> *
> * Additional copyrights may follow
> @@ -51,6 +52,21 @@
> #undef OPAL_HAVE_INLINE_ATOMIC_CMPSET_64
> #define OPAL_HAVE_INLINE_ATOMIC_CMPSET_64 0
>
> +/* If we don't have GCC inline assembly, then nothing is inline */
> +#if !OMPI_GCC_INLINE_ASSEMBLY
> +#undef OPAL_HAVE_INLINE_ATOMIC_MEM_BARRIER
> +#define OPAL_HAVE_INLINE_ATOMIC_MEM_BARRIER 0
> +
> +#undef OPAL_HAVE_INLINE_ATOMIC_CMPSET_32
> +#define OPAL_HAVE_INLINE_ATOMIC_CMPSET_32 0
> +
> +#undef OPAL_HAVE_INLINE_ATOMIC_ADD_32
> +#define OPAL_HAVE_INLINE_ATOMIC_ADD_32 0
> +
> +#undef OPAL_HAVE_INLINE_ATOMIC_SUB_32
> +#define OPAL_HAVE_INLINE_ATOMIC_SUB_32 0
> +#endif
> +
> /**********************************************************************
> *
> * Memory Barriers
> Index: opal/include/opal/sys/amd64/atomic.h
> ===================================================================
> --- opal/include/opal/sys/amd64/atomic.h (revision 16997)
> +++ opal/include/opal/sys/amd64/atomic.h (working copy)
> @@ -10,6 +10,7 @@
> * Copyright (c) 2004-2005 The Regents of the University of California.
> * All rights reserved.
> * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserverd.
> + * Copyright (c) 2007 Cisco Systems, Inc. All rights reserverd.
> * $COPYRIGHT$
> *
> * Additional copyrights may follow
> @@ -44,7 +45,18 @@
>
> #define OPAL_HAVE_ATOMIC_CMPSET_64 1
>
> +/* If we don't have GCC inline assembly, then nothing is inline */
> +#if !OMPI_GCC_INLINE_ASSEMBLY
> +#undef OPAL_HAVE_INLINE_ATOMIC_CMPSET_32
> +#define OPAL_HAVE_INLINE_ATOMIC_CMPSET_32 0
>
> +#undef OPAL_HAVE_INLINE_ATOMIC_CMPSET_64
> +#define OPAL_HAVE_INLINE_ATOMIC_CMPSET_64 0
> +
> +#undef OPAL_HAVE_INLINE_ATOMIC_MEM_BARRIER
> +#define OPAL_HAVE_INLINE_ATOMIC_MEM_BARRIER 0
> +#endif
> +
> /**********************************************************************
> *
> * Memory Barriers
>
>
>
> _______________________________________________
> devel mailing list
> devel_at_[hidden]
> http://www.open-mpi.org/mailman/listinfo.cgi/devel