diff --git a/config/ompi_check_package.m4 b/config/ompi_check_package.m4 index 7e818ce8c3..1438a4cafd 100644 --- a/config/ompi_check_package.m4 +++ b/config/ompi_check_package.m4 @@ -38,8 +38,7 @@ AC_DEFUN([_OMPI_CHECK_PACKAGE_HEADER], [ AS_IF([test "$3" = "/usr" -o "$3" = "/usr/local"], [ # try as is... AC_VERBOSE([looking for header without includes]) - AC_CHECK_HEADER([$2], [ompi_check_package_header_happy="yes"], - [ompi_check_package_header_happy="no"]) + AC_CHECK_HEADERS([$2], [ompi_check_package_header_happy="yes"], []) AS_IF([test "$ompi_check_package_header_happy" = "no"], [# no go on the as is - reset the cache and try again unset ompi_Header])]) @@ -48,7 +47,8 @@ AC_DEFUN([_OMPI_CHECK_PACKAGE_HEADER], [ [AS_IF([test "$3" != ""], [$1_CPPFLAGS="$$1_CPPFLAGS -I$3/include" CPPFLAGS="$CPPFLAGS -I$3/include"]) - AC_CHECK_HEADER([$2], [$4], [$5], [$6])], + AC_CHECK_HEADERS([$2], [ompi_check_package_header_happy="yes"], [], [$6]) + AS_IF([test "$ompi_check_package_header_happy" = "yes"], [$4], [$5])], [$4]) unset ompi_check_package_header_happy diff --git a/ompi/mca/btl/vader/btl_vader.h b/ompi/mca/btl/vader/btl_vader.h index 261b994727..6af85e6a8b 100644 --- a/ompi/mca/btl/vader/btl_vader.h +++ b/ompi/mca/btl/vader/btl_vader.h @@ -12,7 +12,7 @@ * All rights reserved. * Copyright (c) 2006-2007 Voltaire. All rights reserved. * Copyright (c) 2009-2010 Cisco Systems, Inc. All rights reserved. - * Copyright (c) 2010-2013 Los Alamos National Security, LLC. + * Copyright (c) 2010-2014 Los Alamos National Security, LLC. * All rights reserved. * $COPYRIGHT$ * @@ -43,8 +43,16 @@ #endif /* HAVE_UNISTD_H */ #if OMPI_BTL_VADER_HAVE_XPMEM -/* xpmem is required by vader atm */ -#include + #if defined(HAVE_XPMEM_H) + #include + + typedef struct xpmem_addr xpmem_addr_t; + #elif defined(HAVE_SN_XPMEM_H) + #include + + typedef int64_t xpmem_segid_t; + typedef int64_t xpmem_apid_t; + #endif #else #include "opal/mca/shmem/base/base.h" #endif @@ -153,19 +161,19 @@ OMPI_MODULE_DECLSPEC extern mca_btl_vader_t mca_btl_vader; /* This only works for finding the relative address for a pointer within my_segment */ -static inline int64_t virtual2relative (char *addr) +static inline intptr_t virtual2relative (char *addr) { - return (int64_t)(uintptr_t) (addr - mca_btl_vader_component.my_segment) | ((int64_t)MCA_BTL_VADER_LOCAL_RANK << 32); + return (intptr_t) (addr - mca_btl_vader_component.my_segment) | ((int64_t)MCA_BTL_VADER_LOCAL_RANK << 32); } -static inline int64_t virtual2relativepeer (struct mca_btl_base_endpoint_t *endpoint, char *addr) +static inline intptr_t virtual2relativepeer (struct mca_btl_base_endpoint_t *endpoint, char *addr) { - return (int64_t)(uintptr_t) (addr - endpoint->segment_base) | ((int64_t)endpoint->peer_smp_rank << 32); + return (intptr_t) (addr - endpoint->segment_base) | ((int64_t)endpoint->peer_smp_rank << 32); } -static inline void *relative2virtual (int64_t offset) +static inline void *relative2virtual (intptr_t offset) { - return (void *)(uintptr_t)((offset & 0xffffffffull) + mca_btl_vader_component.endpoints[offset >> 32].segment_base); + return (void *)((offset & 0xffffffffull) + mca_btl_vader_component.endpoints[offset >> 32].segment_base); } /* memcpy is faster at larger sizes but is undefined if the diff --git a/ompi/mca/btl/vader/btl_vader_fifo.h b/ompi/mca/btl/vader/btl_vader_fifo.h index 351b95fba4..9115235c56 100644 --- a/ompi/mca/btl/vader/btl_vader_fifo.h +++ b/ompi/mca/btl/vader/btl_vader_fifo.h @@ -12,7 +12,7 @@ * All rights reserved. * Copyright (c) 2006-2007 Voltaire. All rights reserved. * Copyright (c) 2009-2010 Cisco Systems, Inc. All rights reserved. - * Copyright (c) 2010-2013 Los Alamos National Security, LLC. + * Copyright (c) 2010-2014 Los Alamos National Security, LLC. * All rights reserved. * $COPYRIGHT$ * @@ -30,7 +30,15 @@ #include "btl_vader_endpoint.h" #include "btl_vader_frag.h" -#define VADER_FIFO_FREE ((int64_t)-2) +#if OPAL_HAVE_ATOMIC_MATH_64 +#define vader_item_cmpset(x, y, z) opal_atomic_cmpset_64((volatile int64_t *)(x), (int64_t)(y), (int64_t)(z)) +#define vader_item_swap(x, y) opal_atomic_swap_64((volatile int64_t *)(x), (int64_t)(y)) +#else +#define vader_item_cmpset(x, y, z) opal_atomic_cmpset_32((volatile int32_t *)(x), (int32_t)(y), (int32_t)(z)) +#define vader_item_swap(x, y) opal_atomic_swap_32((volatile int32_t *)(x), (int32_t)(y)) +#endif + +#define VADER_FIFO_FREE ((intptr_t)-2) /* * Shared Memory FIFOs @@ -48,8 +56,8 @@ /* lock free fifo */ typedef struct vader_fifo_t { - volatile int64_t fifo_head; - volatile int64_t fifo_tail; + volatile intptr_t fifo_head; + volatile intptr_t fifo_tail; } vader_fifo_t; /* large enough to ensure the fifo is on its own cache line */ @@ -58,11 +66,11 @@ typedef struct vader_fifo_t { static inline mca_btl_vader_hdr_t *vader_fifo_read (vader_fifo_t *fifo) { mca_btl_vader_hdr_t *hdr; - int64_t value; + intptr_t value; opal_atomic_rmb (); - value = opal_atomic_swap_64 (&fifo->fifo_head, VADER_FIFO_FREE); + value = vader_item_swap (&fifo->fifo_head, VADER_FIFO_FREE); if (VADER_FIFO_FREE == value) { /* fifo is empty or we lost the race with another thread */ return NULL; @@ -75,8 +83,7 @@ static inline mca_btl_vader_hdr_t *vader_fifo_read (vader_fifo_t *fifo) if (OPAL_UNLIKELY(VADER_FIFO_FREE == hdr->next)) { opal_atomic_rmb(); - if (!opal_atomic_cmpset_ptr (&fifo->fifo_tail, (void *)value, - (void *)VADER_FIFO_FREE)) { + if (!vader_item_cmpset (&fifo->fifo_tail, value, VADER_FIFO_FREE)) { while (VADER_FIFO_FREE == hdr->next) { opal_atomic_rmb (); } @@ -100,12 +107,12 @@ static inline int vader_fifo_init (vader_fifo_t *fifo) return OMPI_SUCCESS; } -static inline void vader_fifo_write (vader_fifo_t *fifo, int64_t value) +static inline void vader_fifo_write (vader_fifo_t *fifo, intptr_t value) { - int64_t prev; + intptr_t prev; opal_atomic_wmb (); - prev = opal_atomic_swap_64 (&fifo->fifo_tail, value); + prev = vader_item_swap (&fifo->fifo_tail, value); opal_atomic_rmb (); assert (prev != value); diff --git a/ompi/mca/btl/vader/btl_vader_xpmem.c b/ompi/mca/btl/vader/btl_vader_xpmem.c index 8208c6d9f3..6d85c4fb30 100644 --- a/ompi/mca/btl/vader/btl_vader_xpmem.c +++ b/ompi/mca/btl/vader/btl_vader_xpmem.c @@ -1,6 +1,6 @@ /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* - * Copyright (c) 2011-2013 Los Alamos National Security, LLC. All rights + * Copyright (c) 2011-2014 Los Alamos National Security, LLC. All rights * reserved. * $COPYRIGHT$ * @@ -26,7 +26,7 @@ mca_mpool_base_registration_t *vader_get_registation (struct mca_btl_base_endpoi { struct mca_rcache_base_module_t *rcache = endpoint->rcache; mca_mpool_base_registration_t *regs[10], *reg = NULL; - struct xpmem_addr xpmem_addr; + xpmem_addr_t xpmem_addr; uintptr_t base, bound; int rc, i; @@ -82,8 +82,12 @@ mca_mpool_base_registration_t *vader_get_registation (struct mca_btl_base_endpoi reg->base = (unsigned char *) base; reg->bound = (unsigned char *) bound; reg->flags = flags; - + +#if defined(HAVE_SN_XPMEM_H) + xpmem_addr.id = endpoint->apid; +#else xpmem_addr.apid = endpoint->apid; +#endif xpmem_addr.offset = base; reg->alloc_base = xpmem_attach (xpmem_addr, bound - base, NULL); diff --git a/ompi/mca/btl/vader/configure.m4 b/ompi/mca/btl/vader/configure.m4 index a98f81a104..f34e6db951 100644 --- a/ompi/mca/btl/vader/configure.m4 +++ b/ompi/mca/btl/vader/configure.m4 @@ -4,8 +4,8 @@ # of Tennessee Research Foundation. All rights # reserved. # Copyright (c) 2009-2010 Cisco Systems, Inc. All rights reserved. -# Copyright (c) 2011 Los Alamos National Security, LLC. -# All rights reserved. +# Copyright (c) 2011-2014 Los Alamos National Security, LLC. All rights +# reserved. # $COPYRIGHT$ # # Additional copyrights may follow @@ -23,28 +23,34 @@ AC_DEFUN([OMPI_CHECK_XPMEM], [ AC_ARG_WITH([xpmem], [AC_HELP_STRING([--with-xpmem(=DIR)], [Build with XPMEM kernel module support, searching for headers in DIR])]) - OMPI_CHECK_WITHDIR([xpmem], [$with_xpmem], [include/xpmem.h]) + OMPI_CHECK_WITHDIR([xpmem], [$with_xpmem], [include/xpmem.h include/sn/xpmem.h]) AC_ARG_WITH([xpmem-libdir], [AC_HELP_STRING([--with-xpmem-libdir=DIR], [Search for XPMEM library in DIR])]) OMPI_CHECK_WITHDIR([xpmem-libdir], [$with_xpmem_libdir], [libxpmem.*]) - AS_IF([test "$with_xpmem" != "no"], - [AS_IF([test ! -z "$with_xpmem" -a "$with_xpmem" != "yes"], - [ompi_check_xpmem_dir="$with_xpmem"]) - AS_IF([test ! -z "$with_xpmem_libdir" -a "$with_xpmem_libdir" != "yes"], - [ompi_check_xpmem_libdir="$with_xpmem_libdir"]) - OMPI_CHECK_PACKAGE([$1],[xpmem.h],[xpmem],[xpmem_make],[], - [$ompi_check_xpmem_dir],[$ompi_check_xpmem_libdir], - [ompi_check_xpmem_happy="yes"], [ompi_check_xpmem_happy="no"])], - [ompi_check_xpmem_happy="no"]) + ompi_check_xpmem_happy="no" + + if test ! "$with_xpmem" = "no" ; then + if test ! -z "$with_xpmem" -a "$with_xpmem" != "yes" ; then + ompi_check_xpmem_dir="$with_xpmem" + fi + + if test ! -z "$with_xpmem_libdir" -a "$with_xpmem_libdir" != "yes" ; then + ompi_check_xpmem_libdir="$with_xpmem_libdir" + fi + + OMPI_CHECK_PACKAGE([$1],[xpmem.h sn/xpmem.h],[xpmem],[xpmem_make],[], + [$ompi_check_xpmem_dir],[$ompi_check_xpmem_libdir], [ompi_check_xpmem_happy="yes"], []) + + if test "$ompi_check_xpmem_happy" = "no" -a -n "$with_xpmem" -a "$with_xpmem" != "yes" ; then + AC_MSG_ERROR([XPMEM support requested but not found. Aborting]) + fi + fi + + AS_IF([test "$ompi_check_xpmem_happy" = "yes"], [$2], [$3]) - AS_IF([test "$ompi_check_xpmem_happy" = "yes"], - [$2], - [AS_IF([test ! -z "$with_xpmem" -a "$with_xpmem" != "no"], - [AC_MSG_ERROR([XPMEM support requested but not found. Aborting])]) - $3]) OPAL_VAR_SCOPE_POP ])dnl