~ubuntu-branches/ubuntu/utopic/nwchem/utopic

« back to all changes in this revision

Viewing changes to src/tools/ga-5-1/armci/tcgmsg/tcgmsg-mpi/collect.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
 
#include <mpi.h>
6
 
 
7
 
#include "tcgmsgP.h"
8
 
 
9
 
/* size of internal buffer for global ops */
10
 
#define DGOP_BUF_SIZE 65536 
11
 
#define IGOP_BUF_SIZE (sizeof(DoublePrecision)/sizeof(Integer))*DGOP_BUF_SIZE 
12
 
 
13
 
static DoublePrecision gop_work[DGOP_BUF_SIZE]; /**< global ops buffer */
14
 
 
15
 
/**
16
 
 * global operations -- integer version 
17
 
 */
18
 
void IGOP_(Integer *ptype, Integer *x, Integer *pn, char *op, Integer oplen)
19
 
{
20
 
    Integer *work  = (Integer *) gop_work;
21
 
    Integer nleft  = *pn;
22
 
    Integer buflen = TCG_MIN(nleft,IGOP_BUF_SIZE); /**< Try to get even sized buffers */
23
 
    Integer nbuf   = (nleft-1) / buflen + 1;
24
 
    Integer n;
25
 
 
26
 
/* #ifdef ARMCI */
27
 
    if(!_tcg_initialized){
28
 
        TCGMSG_Comm = MPI_COMM_WORLD;
29
 
        _tcg_initialized = 1;
30
 
    }
31
 
/* #endif */
32
 
 
33
 
    buflen = (nleft-1) / nbuf + 1;
34
 
 
35
 
    if (strncmp(op,"abs",3) == 0) {
36
 
        n = *pn;
37
 
        while(n--) {
38
 
            x[n] = TCG_ABS(x[n]);
39
 
        }
40
 
    }
41
 
 
42
 
    while (nleft) {
43
 
        int root = 0; 
44
 
        int ierr = MPI_SUCCESS;
45
 
        int ndo = TCG_MIN(nleft, buflen);
46
 
 
47
 
        if (strncmp(op,"+",1) == 0) {
48
 
            ierr = MPI_Reduce(x, work, ndo, TCG_INT, MPI_SUM, root, TCGMSG_Comm);
49
 
        } else if (strncmp(op,"*",1) == 0) {
50
 
            ierr = MPI_Reduce(x, work, ndo, TCG_INT, MPI_PROD, root, TCGMSG_Comm);
51
 
        } else if (strncmp(op,"max",3) == 0 || strncmp(op,"absmax",6) == 0) {
52
 
            ierr = MPI_Reduce(x, work, ndo, TCG_INT, MPI_MAX, root, TCGMSG_Comm);
53
 
        }
54
 
        else if (strncmp(op,"min",3) == 0 || strncmp(op,"absmin",6) == 0) {
55
 
            ierr = MPI_Reduce(x, work, ndo, TCG_INT, MPI_MIN, root, TCGMSG_Comm);
56
 
        }
57
 
        else if (strncmp(op,"or",2) == 0) {
58
 
            ierr = MPI_Reduce(x, work, ndo, TCG_INT, MPI_BOR, root, TCGMSG_Comm);
59
 
        } else {
60
 
            Error("IGOP: unknown operation requested", (Integer) *pn);
61
 
        }
62
 
        tcgmsg_test_statusM("IGOP: MPI_Reduce:", ierr  );
63
 
 
64
 
        ierr   = MPI_Bcast(work, ndo, TCG_INT, root, TCGMSG_Comm);
65
 
        tcgmsg_test_statusM("IGOP: MPI_Bcast:", ierr);
66
 
 
67
 
        n = ndo;
68
 
        while(n--) {
69
 
            x[n] = work[n];
70
 
        }
71
 
 
72
 
        nleft -= ndo; x+= ndo;
73
 
    }
74
 
}
75
 
 
76
 
 
77
 
 
78
 
/**
79
 
 * global operations -- DoublePrecision version 
80
 
 */
81
 
void DGOP_(Integer *ptype, DoublePrecision *x, Integer *pn, char *op, Integer oplen)
82
 
{
83
 
    DoublePrecision *work=  gop_work;
84
 
    Integer nleft  = *pn;
85
 
    Integer buflen = TCG_MIN(nleft,DGOP_BUF_SIZE); /**< Try to get even sized buffers */
86
 
    Integer nbuf   = (nleft-1) / buflen + 1;
87
 
    Integer n;
88
 
 
89
 
    buflen = (nleft-1) / nbuf + 1;
90
 
 
91
 
    if (strncmp(op,"abs",3) == 0) {
92
 
        n = *pn;
93
 
        while(n--) {
94
 
            x[n] = TCG_ABS(x[n]);
95
 
        }
96
 
    }
97
 
 
98
 
    while (nleft) {
99
 
        int root = 0; 
100
 
        int ierr = MPI_SUCCESS;
101
 
        int ndo = TCG_MIN(nleft, buflen);
102
 
 
103
 
        if (strncmp(op,"+",1) == 0) {
104
 
            ierr = MPI_Reduce(x, work, ndo, TCG_DBL, MPI_SUM, root, TCGMSG_Comm);
105
 
        } else if (strncmp(op,"*",1) == 0) {
106
 
            ierr = MPI_Reduce(x, work, ndo, TCG_DBL, MPI_PROD, root, TCGMSG_Comm);
107
 
        } else if (strncmp(op,"max",3) == 0 || strncmp(op,"absmax",6) == 0) {
108
 
            ierr = MPI_Reduce(x, work, ndo, TCG_DBL, MPI_MAX, root, TCGMSG_Comm);
109
 
        } else if (strncmp(op,"min",3) == 0 || strncmp(op,"absmin",6) == 0) {
110
 
            ierr = MPI_Reduce(x, work, ndo, TCG_DBL, MPI_MIN, root, TCGMSG_Comm);
111
 
        } else {
112
 
            Error("DGOP: unknown operation requested", (Integer) *pn);
113
 
        }
114
 
        tcgmsg_test_statusM("DGOP: MPI_Reduce:", ierr  );
115
 
 
116
 
        ierr   = MPI_Bcast(work, ndo, TCG_DBL, root, TCGMSG_Comm);
117
 
        tcgmsg_test_statusM("DGOP: MPI_Bcast:", ierr  );
118
 
 
119
 
        n = ndo;
120
 
        while(n--) {
121
 
            x[n] = work[n];
122
 
        }
123
 
 
124
 
        nleft -= ndo; x+= ndo;
125
 
    }
126
 
}
127
 
 
128
 
 
129
 
/**
130
 
 * Synchronize processes
131
 
 */
132
 
void SYNCH_(Integer *type)
133
 
{
134
 
/* #ifdef ARMCI */
135
 
    if(!_tcg_initialized){
136
 
        TCGMSG_Comm = MPI_COMM_WORLD;
137
 
        _tcg_initialized = 1;
138
 
    }
139
 
/* #endif */
140
 
    MPI_Barrier(TCGMSG_Comm);
141
 
}
142
 
 
143
 
 
144
 
 
145
 
/**
146
 
 * broadcast buffer to all other processes from process originator
147
 
 */
148
 
void BRDCST_(Integer *type, char *buf, Integer *lenbuf, Integer *originator)
149
 
{
150
 
    /*  hope that MPI int is large enough to store value in lenbuf */
151
 
    int count = (int)*lenbuf, root = (int)*originator;
152
 
 
153
 
    MPI_Bcast(buf, count, MPI_CHAR, root, TCGMSG_Comm);
154
 
}