Added missing windows thread files to distribution list.
authorSander Pronk <pronk@cbr.su.se>
Fri, 3 Sep 2010 07:08:12 +0000 (09:08 +0200)
committerSander Pronk <pronk@cbr.su.se>
Fri, 3 Sep 2010 07:08:12 +0000 (09:08 +0200)
include/thread_mpi/atomic/Makefile.am
include/thread_mpi/atomic/gcc_ppc.h
include/thread_mpi/atomic/hpux.h [deleted file]
include/thread_mpi/atomic/xlc_ppc.h
src/gmxlib/thread_mpi/Makefile.am
src/gmxlib/thread_mpi/pthreads.c
src/gmxlib/thread_mpi/winthreads.c

index 065022a0c734825ca6f4a149c4e78016ba6df58a..ca1292b75b57bdfe81e54a1cc3556a2cffc6940a 100644 (file)
@@ -3,11 +3,10 @@
 # Don't edit - this file is generated automatically from Makefile.am
 #
 
+pkgincludethread_mpidir = ${pkgincludedir}/thread_mpi/atomic
 
-pkgincludethread_mpiatomicdir = ${pkgincludedir}/thread_mpi/atomic
-
-pkgincludethread_mpiatomic_HEADERS = \
-       gcc.h            gcc_ppc.h        hpux.h           \
-       gcc_ia64.h       gcc_spinlock.h   msvc.h           xlc_ppc.h \
-       gcc_intrinsics.h gcc_x86.h        
+pkgincludethread_mpi_HEADERS = \
+       cycles.h         gcc_intrinsics.h gcc_x86.h\
+       gcc.h            gcc_ppc.h        msvc.h\
+       gcc_ia64.h       gcc_spinlock.h   xlc_ppc.h
 
index f8aa355d8fce19da4ffda91b4fdf47ccc3ce750d..bfaa43281b5ba56f695959105a6923748a805e6f 100644 (file)
@@ -36,14 +36,15 @@ files.
 */
 
 
-/* this file is not used any more. gcc intrinsics take care of it */
+/* NOTE:
 
+ ***************************************************************************
+  this file is not used any more. gcc intrinsics take care of the atomics 
+***************************************************************************
 
-/* PowerPC using proper GCC inline assembly. 
- * Recent versions of xlC (>=7.0) _partially_ support this, but since it is
- * not 100% compatible we provide a separate implementation for xlC in
- * the next section.
- */
+*/
+
+#error included gcc_ppc.h. This file is outdated
 
 
 
diff --git a/include/thread_mpi/atomic/hpux.h b/include/thread_mpi/atomic/hpux.h
deleted file mode 100644 (file)
index 567b58c..0000000
+++ /dev/null
@@ -1,240 +0,0 @@
-/*
-This source code file is part of thread_mpi.  
-Written by Sander Pronk, Erik Lindahl, and possibly others. 
-
-Copyright (c) 2009, Sander Pronk, Erik Lindahl.
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-1) Redistributions of source code must retain the above copyright
-   notice, this list of conditions and the following disclaimer.
-2) Redistributions in binary form must reproduce the above copyright
-   notice, this list of conditions and the following disclaimer in the
-   documentation and/or other materials provided with the distribution.
-3) Neither the name of the copyright holders nor the
-   names of its contributors may be used to endorse or promote products
-   derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY
-EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY
-DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-If you want to redistribute modifications, please consider that
-scientific software is very special. Version control is crucial -
-bugs must be traceable. We will be happy to consider code for
-inclusion in the official distribution, but derived work should not
-be called official thread_mpi. Details are found in the README & COPYING
-files.
-*/
-
-
-/* HP compiler on ia64 */
-#include <machine/sys/inline.h>
-
-#define tMPI_Atomic_memory_barrier() _Asm_mf()
-
-#define tMPI_hpia64_fetchadd(a, i)                           \
-    _Asm_fetchadd((_Asm_fasz)_FASZ_W,(_Asm_sem)_SEM_REL,    \
-                  (UInt32*)a,(unsigned int) i,              \
-                  (_Asm_ldhint)LDHINT_NONE)
-
-typedef struct tMPI_Atomic
-{
-        volatile int       value; /*!< Volatile, to avoid compiler aliasing */
-}
-tMPI_Atomic_t;
-
-typedef struct tMPI_Atomic_ptr
-{
-        void* volatile*     value; /*!< Volatile, to avoid compiler aliasing */
-}
-tMPI_Atomic_ptr_t;
-
-
-
-typedef struct tMPI_Spinlock
-{
-    volatile unsigned int   lock; /*!< Volatile, to avoid compiler aliasing */
-}
-tMPI_Spinlock_t;
-
-
-static inline int tMPI_Atomic_cas(tMPI_Atomic_t *   a,
-                                     int              oldval,
-                                     int              newval)
-{
-    int ret;
-    
-    _Asm_mov_to_ar((_Asm_app_reg)_AREG_CCV,(Uint32)oldval,                  
-                   (_Asm_fence)(_UP_CALL_FENCE | _UP_SYS_FENCE |         
-                                _DOWN_CALL_FENCE | _DOWN_SYS_FENCE));
-                   
-    ret = _Asm_cmpxchg((_Asm_sz)SZ_W,(_Asm_sem)_SEM_ACQ,(Uint32*)a,    
-                       (Uint32)newval,(_Asm_ldhint)_LDHINT_NONE);
-                   
-    return ret==oldval;
-}
-
-
-
-static inline void* tMPI_Atomic_ptr_cas(tMPI_Atomic_ptr_t *  a,
-                                           void*               oldval,
-                                           void*               newval)
-{
-    void *ret;
-
-    /* todo: fix this */
-    
-    _Asm_mov_to_ar((_Asm_app_reg)_AREG_CCV,(Uint64)oldval,                  
-                   (_Asm_fence)(_UP_CALL_FENCE | _UP_SYS_FENCE |         
-                                _DOWN_CALL_FENCE | _DOWN_SYS_FENCE));
-                   
-    ret = _Asm_cmpxchg((_Asm_sz)SZ_W,(_Asm_sem)_SEM_ACQ,(Uint64)a,    
-                       (Uint64)newval,(_Asm_ldhint)_LDHINT_NONE);
-                   
-    return ret==oldval;
-}
-
-
-
-
-#define TMPI_SPINLOCK_INITIALIZER   { 0 }
-
-
-#define tMPI_Atomic_get(a)   ((a)->value) 
-#define tMPI_Atomic_set(a,i)  (((a)->value) = (i))
-
-
-static inline void tMPI_Atomic_add_return(tMPI_Atomic_t *       a, 
-                                         int                  i)
-{
-    int old,new;    
-    int __i = i;
-    
-    /* On HP-UX we don't know any macro to determine whether the increment
-     * is known at compile time, but hopefully the call uses something simple
-     * like a constant, and then the optimizer should be able to do the job.
-     */                         
-    if (  (__i ==   1) || (__i ==   4)  || (__i ==   8) || (__i ==  16) ||  
-          (__i ==  -1) || (__i ==  -4)  || (__i ==  -8) || (__i == -16) )
-    {
-        oldval = tMPI_hpia64_fetchadd(a,__i);
-        newval = oldval + i;
-    }
-    else
-    {
-        /* Use compare-exchange addition that works with any value */
-        do
-        {
-            oldval = tMPI_Atomic_get(a);
-            newval = oldval + i;
-        }
-        while(!tMPI_Atomic_cas(a,oldval,newval));
-    }
-    return newval;
-}
-
-
-
-static inline int tMPI_Atomic_fetch_add(tMPI_Atomic_t *     a,
-                                       int                i)
-{
-    int oldval,newval;    
-    int __i = i;
-    
-    /* On HP-UX we don't know any macro to determine whether the increment
-     * is known at compile time, but hopefully the call uses something simple
-     * like a constant, and then the optimizer should be able to do the job.
-     */                         
-    if (  (__i ==   1) || (__i ==   4)  || (__i ==   8) || (__i ==  16) ||
-          (__i ==  -1) || (__i ==  -4)  || (__i ==  -8) || (__i == -16) )
-    {
-        oldval = tMPI_hpia64_fetchadd(a,__i);
-        newval = oldval + i;
-    }
-    else
-    {
-        /* Use compare-exchange addition that works with any value */
-        do
-        {
-            oldval = tMPI_Atomic_get(a);
-            newval = oldval + i;
-        }
-        while(!tMPI_Atomic_cas(a,oldval,newval));
-    }
-    return oldval;
-}
-
-
-static inline void tMPI_Spinlock_init(tMPI_Spinlock_t *x)
-{
-    x->lock = 0;
-}
-
-
-
-
-
-static inline void tMPI_Spinlock_trylock(tMPI_Spinlock_t *x)
-{
-    int rc;
-
-    rc = _Asm_xchg((_Asm_sz)_SZ_W, (unsigned int *)x, 1        
-                    (_Asm_ldhit)_LDHINT_NONE);
-    
-    return ( (rc>0) ? 1 : 0);
-}
-
-
-static inline void tMPI_Spinlock_lock(tMPI_Spinlock_t *x)
-{
-    int      status = 1;
-    
-    do
-    {
-        if( *((unsigned int *)x->lock) == 0 ) 
-        {
-            status = tMPI_Spinlock_trylock(x);
-        }
-    } while( status != 0);
-}
-
-
-static inline void tMPI_Spinlock_unlock(tMPI_Spinlock_t *   x)
-{
-    _Asm_fetchadd((_Asm_fasz)_SZ_W,(_Asm_sem)_SEM_REL,                  
-                  (unsigned int *)x,-1,(_Asm_ldhint)_LDHINT_NONE);
-}
-
-
-
-static inline void tMPI_Spinlock_islocked(const tMPI_Spinlock_t *   x)
-{
-    return ( x->lock != 0 );
-}
-
-
-
-static inline void tMPI_Spinlock_wait(tMPI_Spinlock_t *   x)
-{
-    do
-    {
-        tMPI_Atomic_memory_barrier(); 
-    } 
-    while(spin_islocked(x));
-}
-
-
-#undef tMPI_hpia64_fetchadd
-
-
-
index 1bb7a60bed94bca5105b1a1dd925066f6cfc5532..f3df95937fbcbaa7ef27b4da1243383773fd80d4 100644 (file)
@@ -111,7 +111,7 @@ static inline int tMPI_Atomic_cas(tMPI_Atomic_t *a, int oldval, int newval)
     int ret;
 
     __fence(); /* this one needs to be here to avoid ptr. aliasing issues */
-    __eieio(); /* these memory barriers are neccesary */
+    __eieio(); 
     ret=(__compare_and_swap(&(a->value), &oldval, newval));
     __isync();
     __fence(); /* and this one needs to be here to avoid aliasing issues */
@@ -142,7 +142,7 @@ static inline int tMPI_Atomic_ptr_cas(tMPI_Atomic_ptr_t *a, void* oldval,
     volatile char* volatile* newv=newval;
 
     __fence(); /* this one needs to be here to avoid ptr. aliasing issues */
-    __eieio(); /* these memory barriers are neccesary */
+    __eieio(); 
 #if (!defined (__LP64__) ) && (!defined(__powerpc64__) ) 
     ret=__compare_and_swap((int *)&(a->value), (int*)&oldv, (int)newv);
 #else
@@ -230,37 +230,48 @@ static inline int tMPI_Atomic_fetch_add(tMPI_Atomic_t *a, int i)
 
 static inline void tMPI_Spinlock_init(tMPI_Spinlock_t *x)
 {
+    __fence();
     __clear_lock_mp((const int*)x,0);
+    __fence();
 }
 
 
 static inline void tMPI_Spinlock_lock(tMPI_Spinlock_t *x)
 {
+    __fence();
     do
     {
-        tMPI_Atomic_memory_barrier();
     }
     while(__check_lock_mp((int*)&(x->lock), 0, 1));
+    tMPI_Atomic_memory_barrier_acq();
 }
 
 
 static inline int tMPI_Spinlock_trylock(tMPI_Spinlock_t *x)
 {
+    int ret;
     /* Return 0 if we got the lock */
-    return (__check_lock_mp((int*)&(x->lock), 0, 1) != 0);
+    __fence();
+    ret=__check_lock_mp((int*)&(x->lock), 0, 1) != 0;
+    tMPI_Atomic_memory_barrier_acq();
+    return ret;
 }
 
 
 static inline void tMPI_Spinlock_unlock(tMPI_Spinlock_t *x)
 {
+    tMPI_Atomic_memory_barrier_rel();
     __clear_lock_mp((int*)&(x->lock),0);
 }
 
 
 static inline int tMPI_Spinlock_islocked(const tMPI_Spinlock_t *x)
 {
-    tMPI_Atomic_memory_barrier();
-    return ((x->lock) != 0);
+    int ret;
+    __fence();
+    ret=((x->lock) != 0);
+    tMPI_Atomic_memory_acq();
+    return ret;
 }
 
 
@@ -268,7 +279,6 @@ static inline void tMPI_Spinlock_wait(tMPI_Spinlock_t *x)
 {
     do
     {
-        tMPI_Atomic_memory_barrier();
     }
     while(spin_islocked(x));
 }
index f3a620361ff99f0ddf4b5645a97a136a005de63d..51a7cac1e57b06ed7feebfd417c95d4892c653b1 100644 (file)
@@ -10,17 +10,18 @@ AM_CPPFLAGS= -I$(top_srcdir)/include
 noinst_LTLIBRARIES = libthread_mpi.la
 
 # again, we assume that we're using pthreads if we're using autotools.
-libthread_mpi_la_SOURCES = alltoall.c      lock.c          reduce_fast.c \
-                          barrier.c       scatter.c       bcast.c \
-                          once.c          settings.h      collective.c \
-                          p2p.h           collective.h \
+libthread_mpi_la_SOURCES = alltoall.c      impl.h          pthreads.h \
+                          barrier.c       list.c          reduce.c \
+                          bcast.c         lock.c          reduce_fast.c \
+                          collective.c    once.c          scatter.c \
+                          collective.h    p2p.h           settings.h \
                           comm.c          p2p_protocol.c  tmpi_init.c \
                           errhandler.c    p2p_send_recv.c tmpi_ops.h \
                           event.c         p2p_wait.c      topology.c \
                           gather.c        profile.c       type.c \
-                          group.c         profile.h       hwinfo.c \
-                          pthreads.c      impl.h          pthreads.h \
-                          list.c          reduce.c
+                          group.c         profile.h       winthreads.c \
+                          hwinfo.c        pthreads.c      winthreads.h
+
 
 CLEANFILES     = *.la *~ \\\#*
 
index f87fda797d20216af749c8ff427c6d0e953587aa..22a3dd35cb116f9cc55e4efd9661e78097ef5949 100644 (file)
@@ -629,5 +629,10 @@ int tMPI_Thread_barrier_wait(tMPI_Thread_barrier_t *   barrier)
     return rc;
 }
 
+#else
+
+/* just to have some symbols */
+int tMPI_Thread_pthreads=0;
 
 #endif /* THREAD_PTHREADS */
+
index 83de6fa23c8171a99ad9e63db60facd61838591e..64993ae237e5f9f39c12b762cc273547350a75f5 100644 (file)
@@ -847,4 +847,10 @@ int tMPI_Thread_barrier_wait(tMPI_Thread_barrier_t *barrier)
     return ret;
 }
 
+#else
+
+/* just to have some symbols */
+int tMPI_Thread_winthreads=0;
+
 #endif /* THREAD_WINDOWS  */
+