~ubuntu-branches/ubuntu/trusty/nwchem/trusty-proposed

« back to all changes in this revision

Viewing changes to src/tools/ga-5-1/armci/src-gemini/threads.c

  • Committer: Package Import Robot
  • Author(s): Michael Banck, Daniel Leidert, Andreas Tille, Michael Banck
  • Date: 2013-07-04 12:14:55 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20130704121455-5tvsx2qabor3nrui
Tags: 6.3-1
* New upstream release.
* Fixes anisotropic properties (Closes: #696361).
* New features include:
  + Multi-reference coupled cluster (MRCC) approaches
  + Hybrid DFT calculations with short-range HF 
  + New density-functionals including Minnesota (M08, M11) and HSE hybrid
    functionals
  + X-ray absorption spectroscopy (XAS) with TDDFT
  + Analytical gradients for the COSMO solvation model
  + Transition densities from TDDFT 
  + DFT+U and Electron-Transfer (ET) methods for plane wave calculations
  + Exploitation of space group symmetry in plane wave geometry optimizations
  + Local density of states (LDOS) collective variable added to Metadynamics
  + Various new XC functionals added for plane wave calculations, including
    hybrid and range-corrected ones
  + Electric field gradients with relativistic corrections 
  + Nudged Elastic Band optimization method
  + Updated basis sets and ECPs 

[ Daniel Leidert ]
* debian/watch: Fixed.

[ Andreas Tille ]
* debian/upstream: References

[ Michael Banck ]
* debian/upstream (Name): New field.
* debian/patches/02_makefile_flags.patch: Refreshed.
* debian/patches/06_statfs_kfreebsd.patch: Likewise.
* debian/patches/07_ga_target_force_linux.patch: Likewise.
* debian/patches/05_avoid_inline_assembler.patch: Removed, no longer needed.
* debian/patches/09_backported_6.1.1_fixes.patch: Likewise.
* debian/control (Build-Depends): Added gfortran-4.7 and gcc-4.7.
* debian/patches/10_force_gcc-4.7.patch: New patch, explicitly sets
  gfortran-4.7 and gcc-4.7, fixes test suite hang with gcc-4.8 (Closes:
  #701328, #713262).
* debian/testsuite: Added tests for COSMO analytical gradients and MRCC.
* debian/rules (MRCC_METHODS): New variable, required to enable MRCC methods.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#if HAVE_CONFIG_H
2
 
#   include "config.h"
3
 
#endif
4
 
 
5
 
/* $Id: threads.c,v 1.1.2.5 2007-08-28 21:29:46 manoj Exp $ */
6
 
 
7
 
#if 0
8
 
#   define PRNDBG3(m,a1,a2,a3) \
9
 
           fprintf(stderr,"DBG %d: " m,armci_me,a1,a2,a3);fflush(stderr)
10
 
#   define PRNDBG(m) PRNDBG3(m,0,0,0)
11
 
#   define PRNDBG1(m,a1) PRNDBG3(m,a1,0,0)
12
 
#   define PRNDBG2(m,a1,a2) PRNDBG3(m,a1,a2,0)
13
 
#else
14
 
#   define PRNDBG(m)
15
 
#   define PRNDBG1(m,a1)
16
 
#   define PRNDBG2(m,a1,a2)
17
 
#   define PRNDBG3(m,a1,a2,a3)
18
 
#endif
19
 
 
20
 
 
21
 
#include <stdio.h>
22
 
#include "armcip.h"
23
 
 
24
 
armci_user_threads_t armci_user_threads;
25
 
 
26
 
void armci_init_threads()
27
 
{
28
 
    int i, bytes;
29
 
    char *uval = getenv("ARMCI_MAX_THREADS");
30
 
    
31
 
    armci_user_threads.max   = 1;
32
 
    armci_user_threads.avail = 0;
33
 
 
34
 
    if (uval != NULL) sscanf(uval, "%d", &armci_user_threads.max);
35
 
    
36
 
    if (armci_user_threads.max < 1 ||
37
 
        armci_user_threads.max > ARMCI_THREADS_LIMIT)
38
 
    {
39
 
       printf("Error: Only 1-%d threads are supported. ",ARMCI_THREADS_LIMIT);
40
 
       printf("Set ARMCI_MAX_THREADS appropriately\n"); fflush(stdout);
41
 
       armci_die("armci_init_threads: failed", 0);
42
 
    }
43
 
 
44
 
    bytes = sizeof(thread_id_t) * armci_user_threads.max;
45
 
    if ( !(armci_user_threads.ids = (thread_id_t*) malloc(bytes)) )
46
 
    {
47
 
       armci_die("armci_init_threads: armci_user_threads.ids malloc failed",
48
 
                 armci_user_threads.max);
49
 
    }
50
 
    memset(armci_user_threads.ids, 0, bytes);
51
 
 
52
 
#if 0 /* spinlock has void return value */
53
 
    if (THREAD_LOCK_INIT(armci_user_threads.lock)     ||
54
 
        THREAD_LOCK_INIT(armci_user_threads.buf_lock) ||
55
 
        THREAD_LOCK_INIT(armci_user_threads.net_lock))
56
 
        armci_die("armci_init_threads:locks initialization failed", 0);
57
 
#else
58
 
    THREAD_LOCK_INIT(armci_user_threads.lock);
59
 
    THREAD_LOCK_INIT(armci_user_threads.buf_lock);
60
 
    THREAD_LOCK_INIT(armci_user_threads.net_lock);
61
 
#endif
62
 
    
63
 
#if 0
64
 
    /* using one lock per socket for now, it might be feasible (and usefull)
65
 
     * to use two (one for sending and one for receiving) */
66
 
    armci_user_threads.sock_locks = malloc(armci_nclus *sizeof(thread_lock_t));
67
 
    for (i = 0; i < armci_nclus; i++)
68
 
       if (THREAD_LOCK_INIT(armci_user_threads.sock_locks[i]))
69
 
          armci_die("armci_init_threads:sock locks initialization failed", i);
70
 
#endif
71
 
}
72
 
 
73
 
void armci_finalize_threads()
74
 
{
75
 
    THREAD_LOCK_DESTROY(armci_user_threads.lock);
76
 
    THREAD_LOCK_DESTROY(armci_user_threads.net_lock);
77
 
    THREAD_LOCK_DESTROY(armci_user_threads.buf_lock);
78
 
    free(armci_user_threads.ids);
79
 
}
80
 
 
81
 
/* calling armci_thread_idx for every function that accesses thread-private data
82
 
 * might be expensive -- needs optiomization */
83
 
INLINE int armci_thread_idx()
84
 
{
85
 
    int i, n = ARMCI_MIN(armci_user_threads.avail, armci_user_threads.max);
86
 
    thread_id_t id = THREAD_ID_SELF();
87
 
 
88
 
    for (i = 0; i < n; i++) if (id == armci_user_threads.ids[i]) {
89
 
        /*PRNDBG2("thread id=%ld already registered, idx=%d\n", id, i);*/
90
 
        return i;
91
 
    }
92
 
 
93
 
    /* see this thread for the first time */
94
 
    return armci_register_thread(id);
95
 
}
96
 
 
97
 
INLINE int armci_register_thread(thread_id_t id)
98
 
{
99
 
    int i;
100
 
 
101
 
    THREAD_LOCK(armci_user_threads.lock);
102
 
 
103
 
    i = armci_user_threads.avail;
104
 
    armci_user_threads.avail++;
105
 
 
106
 
    THREAD_UNLOCK(armci_user_threads.lock);
107
 
 
108
 
    if (i < armci_user_threads.max)
109
 
        armci_user_threads.ids[i] = id;
110
 
    else
111
 
        armci_die("armci_thread_idx: too many threads, adjust ARMCI_MAX_THREADS",
112
 
                  armci_user_threads.avail);
113
 
 
114
 
    PRNDBG2("registered a new thread: idx=%d, id=%ld\n", i, id);
115
 
    return i;
116
 
}
117