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

« back to all changes in this revision

Viewing changes to src/tools/ga-5-2/armci/src/devices/dcmf/dcmf2/armcix_rmw.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
/* begin_generated_IBM_copyright_prolog                             */
 
6
/*                                                                  */
 
7
/* ---------------------------------------------------------------- */
 
8
/* (C)Copyright IBM Corp.  2007, 2008                               */
 
9
/* IBM BSD License                                                  */
 
10
/* ---------------------------------------------------------------- */
 
11
/*                                                                  */
 
12
/* end_generated_IBM_copyright_prolog                               */
 
13
/**
 
14
 * \file armci/src/x/dcmf/armcix_rmw.c
 
15
 * \brief DCMF ARMCI Extension for rmw operations.
 
16
 */
 
17
 
 
18
#include "armcix_impl.h"
 
19
#if HAVE_STDIO_H
 
20
#   include <stdio.h>
 
21
#endif
 
22
 
 
23
typedef union ARMCIX_DCMF_RMWRequest_t
 
24
{
 
25
  DCQuad quad[2];
 
26
  struct
 
27
  {
 
28
    int        op;
 
29
    void     * ploc;
 
30
    void     * prem;
 
31
    int        extra;
 
32
    unsigned * active;
 
33
  };
 
34
}
 
35
ARMCIX_DCMF_RMWRequest_t __attribute__ ((__aligned__ (16)));
 
36
 
 
37
typedef union ARMCIX_DCMF_RMWResponse_t
 
38
{
 
39
  DCQuad quad;
 
40
  struct
 
41
  {
 
42
    int        op;
 
43
    void     * ploc;
 
44
    unsigned * active;
 
45
    union
 
46
    {
 
47
      int      ival;
 
48
      long     lval;
 
49
    };
 
50
  };
 
51
}
 
52
ARMCIX_DCMF_RMWResponse_t __attribute__ ((__aligned__ (16)));
 
53
 
 
54
 
 
55
DCMF_Protocol_t __rmw_request_protocol;
 
56
DCMF_Protocol_t __rmw_response_protocol;
 
57
 
 
58
 
 
59
 
 
60
void ARMCIX_DCMF_RecvRMWRequest (void           * clientdata,
 
61
                                 const DCQuad   * msginfo,
 
62
                                 unsigned         count,
 
63
                                 unsigned         peer,
 
64
                                 const char     * src,
 
65
                                 unsigned         bytes)
 
66
{
 
67
  ARMCIX_DCMF_RMWRequest_t * info = (ARMCIX_DCMF_RMWRequest_t *) msginfo;
 
68
 
 
69
  /* Initialize the RMW response data                                        */
 
70
  ARMCIX_DCMF_RMWResponse_t response;
 
71
  response.op = info->op;
 
72
  response.ploc = info->ploc;
 
73
  response.active = info->active;
 
74
 
 
75
  //fprintf (stderr, "ARMCIX_DCMF_RecvRMWRequest() - info->op == %d, info->ploc == %p, info->prem == %p, info->extra == %d, peer == %d\n", info->op, info->ploc, info->prem, info->extra, peer);
 
76
 
 
77
  switch (info->op) 
 
78
  {
 
79
    case ARMCI_FETCH_AND_ADD:
 
80
    case ARMCI_SWAP:
 
81
      response.ival = *((int *) info->prem);
 
82
      break;
 
83
    case ARMCI_FETCH_AND_ADD_LONG:
 
84
    case ARMCI_SWAP_LONG:
 
85
      response.lval = *((long *) info->prem);
 
86
      break;
 
87
    default: 
 
88
      armci_die("rmw: operation not supported",info->op);
 
89
      break;
 
90
  }
 
91
 
 
92
  /* Send the rmw response.                                                  */
 
93
  DCMF_Control (&__rmw_response_protocol,
 
94
                DCMF_SEQUENTIAL_CONSISTENCY,
 
95
                peer,
 
96
                (DCMF_Control_t *) &response);
 
97
 
 
98
  /* Perform the swap or add                                                 */
 
99
  switch (info->op) 
 
100
  {
 
101
    case ARMCI_FETCH_AND_ADD:
 
102
      *((int *) info->prem) += info->extra;
 
103
      break;
 
104
    case ARMCI_FETCH_AND_ADD_LONG:
 
105
      *((long *) info->prem) += info->extra;
 
106
      break;
 
107
    case ARMCI_SWAP:
 
108
      *((int *) info->prem) = info->extra;
 
109
      break;
 
110
    case ARMCI_SWAP_LONG:
 
111
      *((long *) info->prem) = info->extra;
 
112
      break;
 
113
    default: 
 
114
      armci_die("rmw: operation not supported",info->op);
 
115
      break;
 
116
  }
 
117
}
 
118
 
 
119
/**
 
120
 * \brief Receive a read-modify-write response message.
 
121
 *
 
122
 * \param[in] clientdata Registered clientdata
 
123
 * \param[in] info       Read-Modify-Write data sent from the target node
 
124
 * \param[in] peer       Rank of the node that sent this control message
 
125
 *
 
126
 * \see ARMCIX_DCMF_Connection_t
 
127
 * \see ARMCIX_DCMF_Control_t
 
128
 * \see DCMF_RecvControl
 
129
 */
 
130
void ARMCIX_DCMF_ReceiveRMWResponse (void                 * clientdata,
 
131
                                     const DCMF_Control_t * info,
 
132
                                     unsigned               peer)
 
133
{
 
134
  ARMCIX_DCMF_RMWResponse_t * response   = (ARMCIX_DCMF_RMWResponse_t *) info;
 
135
 
 
136
  //fprintf (stderr, "ARMCIX_DCMF_ReceiveRMWResponse() - response->op == %d, response->ploc == %p, response->ival == %d, response->lval == %d, response->active == %p\n", response->op, response->ploc, response->ival, response->lval, response->active);
 
137
 
 
138
  switch (response->op)
 
139
  {
 
140
    case ARMCI_FETCH_AND_ADD:
 
141
    case ARMCI_SWAP:
 
142
      *((int *) response->ploc) = response->ival;
 
143
      break;
 
144
    case ARMCI_FETCH_AND_ADD_LONG:
 
145
    case ARMCI_SWAP_LONG:
 
146
      *((long *) response->ploc) = response->lval;
 
147
      break;
 
148
    default: 
 
149
      armci_die("rmw: operation not supported",response->op);
 
150
      break;
 
151
  }
 
152
 
 
153
  // Complete the rmw operation
 
154
  *(response->active) = 0;
 
155
}
 
156
 
 
157
 
 
158
/**
 
159
 * \brief Register the DCMF ARMCI Extention rmw operation.
 
160
 *
 
161
 * \see DCMF_Control_register
 
162
 * \see DCMF_Send_register
 
163
 */
 
164
void ARMCIX_DCMF_Rmw_register ()
 
165
{
 
166
  DCMF_CriticalSection_enter (0);
 
167
 
 
168
  DCMF_Send_Configuration_t request_configuration = {
 
169
    DCMF_DEFAULT_SEND_PROTOCOL,
 
170
    ARMCIX_DCMF_RecvRMWRequest,
 
171
    NULL,
 
172
    NULL,
 
173
    NULL
 
174
  };
 
175
  DCMF_Send_register (&__rmw_request_protocol, &request_configuration);
 
176
 
 
177
  DCMF_Control_Configuration_t response_configuration = {
 
178
    DCMF_DEFAULT_CONTROL_PROTOCOL,
 
179
    ARMCIX_DCMF_ReceiveRMWResponse,
 
180
    NULL
 
181
  };
 
182
  DCMF_Control_register (&__rmw_response_protocol, &response_configuration);
 
183
 
 
184
  DCMF_CriticalSection_exit (0);
 
185
}
 
186
 
 
187
 
 
188
/**
 
189
 * \brief ARMCI Extension blocking read-modify-write operation.
 
190
 *
 
191
 * \param[in] op
 
192
 * \param[in] ploc
 
193
 * \param[in] prem
 
194
 * \param[in] extra
 
195
 * \param[in] proc
 
196
 *
 
197
 * \retval ???
 
198
 */
 
199
int ARMCIX_Rmw (int op, int * ploc, int * prem, int extra, int proc)
 
200
{
 
201
  DCMF_CriticalSection_enter (0);
 
202
 
 
203
  volatile unsigned active = 1;
 
204
  
 
205
  //fprintf (stderr, "ARMCIX_Rmw() - op == %d, ploc == %p, prem == %p, extra == %d, proc == %d\n", op, ploc, prem, extra, proc);
 
206
 
 
207
  /* Initialize the RMW request data                                        */
 
208
  ARMCIX_DCMF_RMWRequest_t info;
 
209
  info.op = op;
 
210
  info.ploc = ploc;
 
211
  info.prem = prem;
 
212
  switch (op)
 
213
  {
 
214
    case ARMCI_FETCH_AND_ADD:
 
215
    case ARMCI_FETCH_AND_ADD_LONG:
 
216
      info.extra = extra;
 
217
      break;
 
218
    case ARMCI_SWAP:
 
219
    case ARMCI_SWAP_LONG:
 
220
      info.extra = *ploc;
 
221
      break;
 
222
    default: 
 
223
      armci_die("rmw: operation not supported",op);
 
224
      break;
 
225
  }
 
226
 
 
227
  info.active = (unsigned *)&active;
 
228
 
 
229
  DCMF_Request_t request;
 
230
  DCMF_Callback_t cb_wait = { NULL, NULL };
 
231
 
 
232
  DCMF_Send ( &__rmw_request_protocol,
 
233
              &request,
 
234
              cb_wait,
 
235
              DCMF_SEQUENTIAL_CONSISTENCY,
 
236
              proc,
 
237
              0,
 
238
              NULL,
 
239
              (DCQuad *)&info,
 
240
              2);
 
241
 
 
242
  //fprintf (stderr, "ARMCIX_Rmw() > active == %d (&active == %p)\n", active, &active);
 
243
  while (active) DCMF_Messager_advance ();
 
244
  //fprintf (stderr, "ARMCIX_Rmw() < active == %d (&active == %p)\n", active, &active);
 
245
 
 
246
  DCMF_CriticalSection_exit  (0);
 
247
 
 
248
  return 0;
 
249
}