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

« back to all changes in this revision

Viewing changes to src/tools/ga-5-1/armci/src/common/noncont.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: noncont.c,v 1.3.2.2 2007-05-04 16:43:35 d3p687 Exp $
6
 
 * noncont.c
7
 
 *
8
 
 * Developed by Andriy Kot <andriy.kot@pnl.gov>
9
 
 * Copyright (c) 2006 Pacific Northwest National Laboratory
10
 
 *
11
 
 * Alternative version of non-contiguous calls using non-blocking ones
12
 
 *
13
 
 * Changelog:
14
 
 * 2006-09-08 - created
15
 
 *
16
 
 */
17
 
 
18
 
#include "armcip.h"
19
 
#include "copy.h"
20
 
#include "acc.h"
21
 
#include "memlock.h"
22
 
#if HAVE_STDIO_H
23
 
#   include <stdio.h>
24
 
#endif
25
 
#ifdef PORTALS
26
 
#include "armci_portals.h"
27
 
#endif
28
 
 
29
 
 
30
 
#if 0
31
 
#   define PRN_DBG_MSG3(m,a1,a2,a3) \
32
 
           fprintf(stderr,"DBG %d: " m,armci_me,a1,a2,a3);fflush(stderr)
33
 
#   define PRN_DBG_MSG(m) PRN_DBG_MSG3(m,0,0,0)
34
 
#   define PRN_DBG_MSG1(m,a1) PRN_DBG_MSG3(m,a1,0,0)
35
 
#   define PRN_DBG_MSG2(m,a1,a2) PRN_DBG_MSG3(m,a1,a2,0)
36
 
#else
37
 
#   define PRN_DBG_MSG(m)
38
 
#   define PRN_DBG_MSG1(m,a1)
39
 
#   define PRN_DBG_MSG2(m,a1,a2)
40
 
#   define PRN_DBG_MSG3(m,a1,a2,a3)
41
 
#endif
42
 
 
43
 
#if 0
44
 
#   define CALL_IN(_func)  { if (armci_me == 0) printf("ENTERED %s\n", _func); fflush(stdout); }
45
 
#   define CALL_OUT(_func) { if (armci_me == 0) printf("EXITING %s\n", _func); fflush(stdout); }
46
 
#else
47
 
#   define CALL_IN(_func)
48
 
#   define CALL_OUT(_func)
49
 
#endif
50
 
 
51
 
#ifdef  NB_NONCONT
52
 
 
53
 
#if   defined(QUADRICS)
54
 
typedef ELAN_EVENT *HTYPE;
55
 
#define SHMEM_HANDLE_SUPPORTED
56
 
#elif defined(CRAY_SHMEM)
57
 
typedef void *HTYPE;
58
 
#else
59
 
typedef armci_ireq_t HTYPE;
60
 
#endif
61
 
 
62
 
#define MAX_SLOTS_LL    64
63
 
#define MIN_OUTSTANDING 6
64
 
static int max_pending = 16; /* throttle number of outstanding nb calls */
65
 
 
66
 
/* might have to use MAX_SLOTS_LL < MAX_PENDING due to throttling problem */
67
 
#define MAX_PENDING 6
68
 
#define ZR (HTYPE)0
69
 
 
70
 
static HTYPE put_dscr[MAX_SLOTS_LL];
71
 
static HTYPE get_dscr[MAX_SLOTS_LL];
72
 
/* static variables alreay initialize to 0 (?)
73
 
static HTYPE put_dscr[MAX_SLOTS_LL]= {
74
 
ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,
75
 
ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR};
76
 
 
77
 
static HTYPE get_dscr[MAX_SLOTS_LL] = {
78
 
ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,
79
 
ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR,ZR};
80
 
*/
81
 
 
82
 
#if defined(PORTALS)
83
 
extern ARMCI_MEMHDL_T *mhloc;
84
 
extern ARMCI_MEMHDL_T *mhrem;
85
 
#   define INI_HDL(_hdl, _op, _proc) {      \
86
 
            (_hdl).tag = GET_NEXT_NBTAG();  \
87
 
            (_hdl).op = _op;                \
88
 
            (_hdl).proc = _proc;            \
89
 
            (_hdl).bufid = NB_NONE;         \
90
 
           }
91
 
#   define CLR_HDL(_hdl) ((_hdl).tag = 0)
92
 
#   define CHK_HDL(_hdl) (_hdl.tag)
93
 
#else
94
 
#   define CLR_HDL(_hdl) ((_hdl) = ZR)
95
 
#   define CHK_HDL(_hdl) (_hdl)
96
 
#   define INI_HDL(_hdl, _op, _proc)
97
 
#endif
98
 
 
99
 
static int cur_get=0;
100
 
static int cur_put=0;
101
 
static int pending_get=0;
102
 
static int pending_put=0;
103
 
 
104
 
/* strided put, nonblocking */
105
 
void armcill_put2D(int proc, int bytes, int count, void* src_ptr,int src_stride,
106
 
                                                   void* dst_ptr,int dst_stride)
107
 
{
108
 
    CALL_IN("armcill_put2D");
109
 
 
110
 
    int _j, i, batch, issued=0;
111
 
    char *ps=src_ptr, *pd=dst_ptr;
112
 
 
113
 
    for (_j = 0;  _j < count;  ){
114
 
      /* how big a batch of requests can we issue */
115
 
      batch = (count - _j )<max_pending ? count - _j : max_pending;
116
 
      _j += batch;
117
 
#ifdef SHMEM_HANDLE_SUPPORTED
118
 
      for(i=0; i< batch; i++){
119
 
        if (CHK_HDL(put_dscr[cur_put])) armcill_nb_wait(put_dscr[cur_put]);
120
 
        else pending_put++;
121
 
        INI_HDL(put_dscr[cur_put], PUT, proc);
122
 
        armcill_nb_put(pd,ps,bytes,proc,put_dscr[cur_put]);
123
 
#else
124
 
      shmem_quiet();
125
 
      for(i=0; i< batch; i++){
126
 
        HTYPE dummy;
127
 
        armcill_nb_put(pd,ps,bytes,proc,dummy);
128
 
#endif
129
 
        issued++;
130
 
        ps += src_stride;
131
 
        pd += dst_stride;
132
 
        cur_put++;
133
 
        if(cur_put>=max_pending)cur_put=0;
134
 
      }
135
 
    }
136
 
 
137
 
    if(issued != count)
138
 
       armci_die2("armcill_put2D: mismatch %d %d \n", count,issued);
139
 
 
140
 
    CALL_OUT("armcill_put2D");
141
 
}
142
 
 
143
 
 
144
 
/* blocking vector put */
145
 
void armcill_putv(int proc, int bytes, int count, void* src[], void* dst[])
146
 
{
147
 
    int _j, i, batch, issued=0;
148
 
    void *ps, *pd;
149
 
 
150
 
    for (_j = 0;  _j < count;  ){
151
 
      /* how big a batch of requests can we issue */
152
 
      batch = (count - _j )<max_pending ? count - _j : max_pending;
153
 
      _j += batch;
154
 
#ifdef SHMEM_HANDLE_SUPPORTED
155
 
      for(i=0; i< batch; i++){
156
 
        if (CHK_HDL(put_dscr[cur_put])) armcill_nb_wait(put_dscr[cur_put]);
157
 
        else pending_put++;
158
 
        ps = src[issued];
159
 
        pd = dst[issued];
160
 
        INI_HDL(put_dscr[cur_put], PUT, proc);
161
 
        armcill_nb_put(pd,ps,bytes,proc,put_dscr[cur_put]);
162
 
#else
163
 
      shmem_quiet();
164
 
      for(i=0; i< batch; i++){
165
 
        HTYPE dummy;
166
 
        armcill_nb_put(pd,ps,bytes,proc,dummy);
167
 
#endif
168
 
        issued++;
169
 
        cur_put++;
170
 
        if(cur_put>=max_pending)cur_put=0;
171
 
      }
172
 
    }
173
 
    if(issued != count)
174
 
       armci_die2("armcill_putv: mismatch\n", count,issued);
175
 
 
176
 
#ifdef SHMEM_HANDLE_SUPPORTED
177
 
    for(i=0; i<max_pending; i++) if(CHK_HDL(put_dscr[i])){
178
 
        armcill_nb_wait(put_dscr[i]);
179
 
        CLR_HDL(put_dscr[i]);
180
 
    }
181
 
#else
182
 
    shmem_quiet();
183
 
#endif
184
 
}
185
 
 
186
 
 
187
 
 
188
 
 
189
 
/* strided get, nonblocking */
190
 
void armcill_get2D(int proc, int bytes, int count, void* src_ptr,int src_stride,
191
 
                                                   void* dst_ptr,int dst_stride)
192
 
{
193
 
    CALL_IN("armcill_get2D");
194
 
    PRN_DBG_MSG3("armcill_get2D: proc=%d, bytes=%d, count=%d\n", proc, bytes, count);
195
 
 
196
 
    int _j, i, batch, issued=0;
197
 
    char *ps=src_ptr, *pd=dst_ptr;
198
 
 
199
 
    for (_j = 0;  _j < count;  ){
200
 
      /* how big a batch of requests can we issue */
201
 
      batch = (count - _j )<max_pending ? count - _j : max_pending;
202
 
      _j += batch;
203
 
#ifdef SHMEM_HANDLE_SUPPORTED
204
 
      for(i=0; i< batch; i++){
205
 
        PRN_DBG_MSG2("inner loop: cur_ptr=%d, tag=%d\n", cur_get, get_dscr[cur_get].tag);
206
 
        if (CHK_HDL(get_dscr[cur_get])) armcill_nb_wait(get_dscr[cur_get]);
207
 
        else pending_get++;
208
 
        PRN_DBG_MSG1("inner loop: pending_get=%d\n", pending_get);
209
 
        INI_HDL(get_dscr[cur_get], GET, proc);
210
 
        armcill_nb_get(pd,ps,bytes,proc,get_dscr[cur_get]);
211
 
        PRN_DBG_MSG("inner loop: after get\n");
212
 
#else
213
 
      shmem_quiet();
214
 
      for(i=0; i< batch; i++){
215
 
        HTYPE dummy;
216
 
        armcill_nb_get(pd,ps,bytes,proc,dummy);
217
 
#endif
218
 
        issued++;
219
 
        ps += src_stride;
220
 
        pd += dst_stride;
221
 
        cur_get++;
222
 
        if(cur_get>=max_pending)cur_get=0;
223
 
      }
224
 
    }
225
 
 
226
 
    if(issued != count)
227
 
       armci_die2("armcill_get2D: mismatch %d %d \n", count,issued);
228
 
 
229
 
    CALL_OUT("armcill_get2D");
230
 
}
231
 
 
232
 
 
233
 
/* blocking vector get */
234
 
void armcill_getv(int proc, int bytes, int count, void* src[], void* dst[])
235
 
{
236
 
    int _j, i, batch, issued=0;
237
 
    void *ps, *pd;
238
 
 
239
 
    for (_j = 0;  _j < count;  ){
240
 
      /* how big a batch of requests can we issue */
241
 
      batch = (count - _j )<max_pending ? count - _j : max_pending;
242
 
      _j += batch;
243
 
#ifdef SHMEM_HANDLE_SUPPORTED
244
 
      for(i=0; i< batch; i++){
245
 
        if (CHK_HDL(get_dscr[cur_get])) armcill_nb_wait(get_dscr[cur_get]);
246
 
        else pending_get++;
247
 
        ps = src[issued];
248
 
        pd = dst[issued];
249
 
        INI_HDL(get_dscr[cur_get], GET, proc);
250
 
        armcill_nb_get(pd,ps,bytes,proc,get_dscr[cur_get]);
251
 
#else
252
 
      shmem_quiet();
253
 
      for(i=0; i< batch; i++){
254
 
        HTYPE dummy;
255
 
        armcill_nb_get(pd,ps,bytes,proc,dummy);
256
 
#endif
257
 
        issued++;
258
 
        cur_get++;
259
 
        if(cur_get>=max_pending)cur_get=0;
260
 
      }
261
 
    }
262
 
    if(issued != count)
263
 
       armci_die2("armcill_getv: mismatch %d %d \n", count,issued);
264
 
 
265
 
#ifdef SHMEM_HANDLE_SUPPORTED
266
 
    for(i=0; i<max_pending; i++) if(CHK_HDL(get_dscr[i])){
267
 
        armcill_nb_wait(get_dscr[i]);
268
 
        CLR_HDL(get_dscr[i]);
269
 
    }
270
 
#else
271
 
    shmem_quiet();
272
 
#endif
273
 
}
274
 
 
275
 
 
276
 
void armcill_wait_get()
277
 
{
278
 
    CALL_IN("armcill_wait_get");
279
 
#ifdef SHMEM_HANDLE_SUPPORTED
280
 
    int i;
281
 
    if(!pending_get)return;
282
 
    else pending_get=0;
283
 
    for(i=0; i<max_pending; i++) if(CHK_HDL(get_dscr[i])){
284
 
        armcill_nb_wait(get_dscr[i]);
285
 
        CLR_HDL(get_dscr[i]);
286
 
    }
287
 
#else
288
 
    shmem_quiet();
289
 
#endif
290
 
    CALL_OUT("armcill_wait_get");
291
 
}
292
 
 
293
 
 
294
 
void armcill_wait_put()
295
 
{
296
 
    CALL_IN("armcill_wait_put");
297
 
#ifdef SHMEM_HANDLE_SUPPORTED
298
 
    int i;
299
 
    if(!pending_put)return;
300
 
    else pending_put=0;
301
 
    for(i=0; i<max_pending; i++) if(CHK_HDL(put_dscr[i])){
302
 
        armcill_nb_wait(put_dscr[i]);
303
 
        CLR_HDL(put_dscr[i]);
304
 
    }
305
 
#else
306
 
    shmem_quiet();
307
 
#endif
308
 
    CALL_OUT("armcill_wait_put");
309
 
}
310
 
 
311
 
 
312
 
#endif/*NB_NONCONT*/