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

« back to all changes in this revision

Viewing changes to src/tools/ga-5-2/armci/testing/msgcheck.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
#if HAVE_STDIO_H
 
6
#   include <stdio.h>
 
7
#endif
 
8
#if HAVE_STDLIB_H
 
9
#   include <stdlib.h>
 
10
#endif
 
11
 
 
12
#include "armci.h"
 
13
#include "message.h"
 
14
 
 
15
#define armci_msg_brdcst__ armci_msg_bcast_lapi
 
16
 
 
17
int me, nproc;
 
18
 
 
19
#define LOOP 20
 
20
 
 
21
void time_gop(double *test, int len)
 
22
{
 
23
  int i;
 
24
  double t;
 
25
 
 
26
  t = armci_timer();
 
27
  for (i = 0; i < LOOP; i++) {
 
28
    armci_msg_dgop(test, len, "+");
 
29
  }
 
30
  t = armci_timer() - t;
 
31
 
 
32
  t /= LOOP;
 
33
 
 
34
  if (me == 0) {
 
35
    printf("Time per gop %f len=%d doubles\n", t, len);
 
36
    fflush(stdout);
 
37
  }
 
38
}
 
39
 
 
40
 
 
41
void time_reduce(double *test, int len)
 
42
{
 
43
  int i;
 
44
  double t;
 
45
 
 
46
  t = armci_timer();
 
47
  for (i = 0; i < LOOP; i++) {
 
48
    armci_msg_reduce(test, len, "+", ARMCI_DOUBLE);
 
49
  }
 
50
  t = armci_timer() - t;
 
51
 
 
52
  t /= LOOP;
 
53
 
 
54
  if (me == 0) {
 
55
    printf("Time per reduce %f len=%d doubles\n", t, len);
 
56
    fflush(stdout);
 
57
  }
 
58
}
 
59
 
 
60
 
 
61
 
 
62
void TestGlobals()
 
63
{
 
64
#define MAXLENG 256*1024
 
65
  double *dtest;
 
66
  int *itest;
 
67
  long *ltest;
 
68
  int len;
 
69
  int ifrom = nproc - 1, lfrom = 1, dfrom = 1;
 
70
 
 
71
  if (me == 0) {
 
72
    printf("Global test ... broadcast and reduction for int, long, double\n----------\n");
 
73
    fflush(stdout);
 
74
  }
 
75
 
 
76
  if (!(dtest = (double *) malloc((unsigned)(MAXLENG * sizeof(double))))) {
 
77
    ARMCI_Error("TestGlobals: failed to allocated dtest", MAXLENG);
 
78
  }
 
79
  if (!(ltest = (long *) malloc((unsigned)(MAXLENG * sizeof(long))))) {
 
80
    ARMCI_Error("TestGlobals: failed to allocated ltest", MAXLENG);
 
81
  }
 
82
  if (!(itest = (int *) malloc((unsigned)(MAXLENG * sizeof(int))))) {
 
83
    ARMCI_Error("TestGlobals: failed to allocated itest", MAXLENG);
 
84
  }
 
85
 
 
86
  for (len = 1; len < MAXLENG; len *= 2) {
 
87
    int ilen = len * sizeof(int);
 
88
    int dlen = len * sizeof(double);
 
89
    int llen = len * sizeof(long);
 
90
    int i;
 
91
 
 
92
    ifrom = (ifrom + 1) % nproc;
 
93
    lfrom = (lfrom + 1) % nproc;
 
94
    dfrom = (lfrom + 1) % nproc;
 
95
 
 
96
#if 0
 
97
    printf("%d:ifrom=%d lfrom=%d dfrom=%d\n", me, ifrom, lfrom, dfrom);
 
98
    fflush(stdout);
 
99
#endif
 
100
 
 
101
    if (me == 0) {
 
102
      printf("Test length = %d ... ", len);
 
103
      fflush(stdout);
 
104
    }
 
105
 
 
106
    if (me == ifrom)for (i = 0; i < len; i++) {
 
107
        itest[i] = i;
 
108
      }
 
109
    else for (i = 0; i < len; i++) {
 
110
        itest[i] = 0;
 
111
      }
 
112
    if (me == lfrom)for (i = 0; i < len; i++) {
 
113
        ltest[i] = (long)i;
 
114
      }
 
115
    else for (i = 0; i < len; i++) {
 
116
        ltest[i] = 0L;
 
117
      }
 
118
    if (me == dfrom)for (i = 0; i < len; i++) {
 
119
        dtest[i] = (double)i;
 
120
      }
 
121
    else for (i = 0; i < len; i++) {
 
122
        dtest[i] = 0.0;
 
123
      }
 
124
 
 
125
    /* Test broadcast */
 
126
    armci_msg_brdcst(itest, ilen, ifrom);
 
127
    armci_msg_brdcst(ltest, llen, lfrom);
 
128
    armci_msg_brdcst(dtest, dlen, dfrom);
 
129
 
 
130
    for (i = 0; i < len; i++) {
 
131
      if (itest[i] != i) {
 
132
        printf("int broadcast failed %d", itest[i]);
 
133
        ARMCI_Error("int broadcast failed %d", itest[i]);
 
134
      }
 
135
      if (ltest[i] != (long)i) {
 
136
        printf("long broadcast failed %ld", ltest[i]);
 
137
        ARMCI_Error("long broadcast failed %ld", ltest[i]);
 
138
      }
 
139
      if (dtest[i] != (double)i) {
 
140
        printf("double broadcast failed %f", dtest[i]);
 
141
        ARMCI_Error("double broadcast failed %f", dtest[i]);
 
142
      }
 
143
    }
 
144
 
 
145
    if (me == 0) {
 
146
      printf("broadcast OK ...");
 
147
      fflush(stdout);
 
148
    }
 
149
 
 
150
    /* Test global sum */
 
151
    for (i = 0; i < len; i++) {
 
152
      itest[i] = i * me;
 
153
      ltest[i] = (long) itest[i];
 
154
      dtest[i] = (double) itest[i];
 
155
    }
 
156
 
 
157
 
 
158
    armci_msg_igop(itest, len, "+");
 
159
    armci_msg_lgop(ltest, len, "+");
 
160
    armci_msg_dgop(dtest, len, "+");
 
161
 
 
162
 
 
163
    for (i = 0; i < len; i++) {
 
164
      int iresult = i * nproc * (nproc - 1) / 2;
 
165
      if (itest[i] != iresult || ltest[i] != (long)iresult ||
 
166
          dtest[i] != (double) iresult) {
 
167
        ARMCI_Error("TestGlobals: global sum failed", (int) i);
 
168
      }
 
169
    }
 
170
 
 
171
 
 
172
    if (me == 0) {
 
173
      printf("global sums OK\n");
 
174
      fflush(stdout);
 
175
    }
 
176
  }
 
177
 
 
178
 
 
179
  /* now we get timing data */
 
180
  time_gop(dtest, MAXLENG);
 
181
  time_reduce(dtest, MAXLENG);
 
182
 
 
183
  free((char *) itest);
 
184
  free((char *) ltest);
 
185
  free((char *) dtest);
 
186
}
 
187
 
 
188
 
 
189
int main(int argc, char **argv)
 
190
{
 
191
 
 
192
  armci_msg_init(&argc, &argv);
 
193
  /* initialize ARMCI */
 
194
  ARMCI_Init_args(&argc, &argv);
 
195
  me = armci_msg_me();
 
196
  nproc = armci_msg_nproc();
 
197
 
 
198
  if (nproc < 2) {
 
199
    if (me == 0)
 
200
      fprintf(stderr,
 
201
              "USAGE: 2 <= processes < %d\n", nproc);
 
202
    ARMCI_Barrier();
 
203
    armci_msg_finalize();
 
204
    exit(0);
 
205
  }
 
206
 
 
207
  if (me == 0) {
 
208
    printf("Test of ARMCI Wrappers to Basic Message Passing Operations\n");
 
209
    fflush(stdout);
 
210
  }
 
211
 
 
212
 
 
213
  ARMCI_Barrier();
 
214
 
 
215
  TestGlobals();
 
216
 
 
217
  /* done */
 
218
  ARMCI_Finalize();
 
219
  armci_msg_finalize();
 
220
  return(0);
 
221
}
 
222
 
 
223