~ubuntu-branches/ubuntu/saucy/nwchem/saucy

« back to all changes in this revision

Viewing changes to src/tools/ga-5-1/armci/src-gemini/spinlock.h

  • Committer: Package Import Robot
  • Author(s): Michael Banck, Michael Banck, Daniel Leidert
  • Date: 2012-02-09 20:02:41 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20120209200241-jgk03qfsphal4ug2
Tags: 6.1-1
* New upstream release.

[ Michael Banck ]
* debian/patches/02_makefile_flags.patch: Updated.
* debian/patches/02_makefile_flags.patch: Use internal blas and lapack code.
* debian/patches/02_makefile_flags.patch: Define GCC4 for LINUX and LINUX64
  (Closes: #632611 and LP: #791308).
* debian/control (Build-Depends): Added openssh-client.
* debian/rules (USE_SCALAPACK, SCALAPACK): Removed variables (Closes:
  #654658).
* debian/rules (LIBDIR, USE_MPIF4, ARMCI_NETWORK): New variables.
* debian/TODO: New file.
* debian/control (Build-Depends): Removed libblas-dev, liblapack-dev and
  libscalapack-mpi-dev.
* debian/patches/04_show_testsuite_diff_output.patch: New patch, shows the
  diff output for failed tests.
* debian/patches/series: Adjusted.
* debian/testsuite: Optionally run all tests if "all" is passed as option.
* debian/rules: Run debian/testsuite with "all" if DEB_BUILD_OPTIONS
  contains "checkall".

[ Daniel Leidert ]
* debian/control: Used wrap-and-sort. Added Vcs-Svn and Vcs-Browser fields.
  (Priority): Moved to extra according to policy section 2.5.
  (Standards-Version): Bumped to 3.9.2.
  (Description): Fixed a typo.
* debian/watch: Added.
* debian/patches/03_hurd-i386_define_path_max.patch: Added.
  - Define MAX_PATH if not defines to fix FTBFS on hurd.
* debian/patches/series: Adjusted.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef SPINLOCK_H
 
2
#define SPINLOCK_H
 
3
 
 
4
#if defined(LINUX)
 
5
 
 
6
#if defined(__i386__) || defined(__alpha) || defined(__ia64) || defined(__x86_64__)
 
7
#  define SPINLOCK 
 
8
#  if defined(__GNUC__) && !defined(__INTEL_COMPILER)
 
9
#     if defined(__i386__) || defined(__x86_64__) 
 
10
#          include "tas-i386.h"
 
11
#     elif  defined(__ia64)
 
12
#          include "tas-ia64.h"
 
13
#     else
 
14
#          include "tas-alpha.h"
 
15
#     endif
 
16
#     define TESTANDSET testandset
 
17
#  else
 
18
#     define TESTANDSET gcc_testandset
 
19
#     define RELEASE_SPINLOCK gcc_clear_spinlock
 
20
#  endif
 
21
   extern int gcc_testandset();
 
22
   extern void gcc_clear_spinlock();
 
23
#endif
 
24
 
 
25
#endif
 
26
 
 
27
 
 
28
 
 
29
#ifdef SPINLOCK
 
30
 
 
31
#include <stdio.h>
 
32
#include <unistd.h>
 
33
 
 
34
#ifndef DBL_PAD
 
35
#   define DBL_PAD 16
 
36
#endif
 
37
 
 
38
/* make sure that locks are not sharing the same cache line */
 
39
typedef struct{
 
40
double  lock[DBL_PAD];
 
41
}pad_lock_t;
 
42
 
 
43
#ifndef LOCK_T
 
44
#define LOCK_T int
 
45
#endif
 
46
#define PAD_LOCK_T pad_lock_t
 
47
 
 
48
static INLINE void armci_init_spinlock(LOCK_T *mutex)
 
49
{
 
50
  *mutex =0;
 
51
}
 
52
 
 
53
static INLINE void armci_acquire_spinlock(LOCK_T *mutex)
 
54
{
 
55
#ifdef BGML
 
56
   return;
 
57
#else
 
58
int loop=0, maxloop =10;
 
59
   while (TESTANDSET(mutex)){
 
60
      loop++;
 
61
      if(loop==maxloop){ 
 
62
#if 0
 
63
         extern int armci_me;
 
64
         printf("%d:spinlock sleeping\n",armci_me); fflush(stdout);
 
65
#endif
 
66
         usleep(1);
 
67
         loop=0;
 
68
      }
 
69
  }
 
70
#endif
 
71
}
 
72
 
 
73
 
 
74
 
 
75
#ifdef  RELEASE_SPINLOCK
 
76
#ifdef MEMORY_BARRIER
 
77
#  define  armci_release_spinlock(x) MEMORY_BARRIER ();RELEASE_SPINLOCK(x)
 
78
#else
 
79
#  define  armci_release_spinlock(x) RELEASE_SPINLOCK(x)
 
80
#endif
 
81
#else
 
82
static INLINE void armci_release_spinlock(LOCK_T *mutex)
 
83
{
 
84
#ifdef BGML
 
85
   return;
 
86
#else
 
87
#ifdef MEMORY_BARRIER
 
88
  MEMORY_BARRIER ();
 
89
#endif
 
90
  *mutex =0;
 
91
#if (defined(MACX)||defined(LINUX)) && defined(__GNUC__) && defined(__ppc__)  
 
92
  __asm__ __volatile__ ("isync" : : : "memory");
 
93
#endif
 
94
#endif
 
95
}
 
96
 
 
97
#endif
 
98
 
 
99
#endif
 
100
 
 
101
 
 
102
 
 
103
 
 
104
#endif/*SPINLOCK_H*/