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

« back to all changes in this revision

Viewing changes to src/tools/ga-5-2/tascel/src/UniformTaskCollSplitData.cc

  • 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
#include "Comm.h"
 
2
#include "DataColl.h"
 
3
#include "FuncReg.h"
 
4
#include "UniformTaskCollSplitData.h"
 
5
#include "massert.h"
 
6
 
 
7
#include <armci.h>
 
8
 
 
9
#include <unistd.h>
 
10
 
 
11
#include <cassert>
 
12
#include <cmath>
 
13
#include <cstdio>
 
14
#include <cstring>
 
15
#include <vector>
 
16
 
 
17
using namespace std;
 
18
using namespace tascel;
 
19
using namespace comm;
 
20
 
 
21
UniformTaskCollSplitData::UniformTaskCollSplitData(const TaskCollProps &props,
 
22
    const std::vector<DataColl*>& _colls, 
 
23
    const std::vector<AccessMode>& _modes, 
 
24
    const std::vector<int>& _idxlens,
 
25
    compute_index_t _ci_fn)
 
26
  : UniformTaskCollectionSplit(props)
 
27
  , ci_fn(_ci_fn)
 
28
  , colls(_colls.begin(), _colls.end())
 
29
  , modes(_modes.begin(), _modes.end())
 
30
  , idxlens(_idxlens.begin(), _idxlens.end())
 
31
{
 
32
  assert(colls.size() == modes.size());
 
33
  assert(colls.size() == idxlens.size());
 
34
}
 
35
 
 
36
/*virtual */
 
37
UniformTaskCollSplitData::~UniformTaskCollSplitData() { }
 
38
 
 
39
void
 
40
UniformTaskCollSplitData::setupDataBufs(vector<void *> &data_bufs, vector<int> &data_lens, const vector<void *> &idxs) {
 
41
  for(int i=0; i<idxlens.size(); i++) {
 
42
    int sz = colls[i]->getSize(idxs[i],idxlens[i]);
 
43
    char *dbuf = new char[sz];
 
44
    data_bufs.push_back(dbuf);
 
45
    data_lens.push_back(sz);
 
46
 
 
47
    switch(modes[i]) {
 
48
    case MODE_RONLY:
 
49
      colls[i]->get(idxs[i], idxlens[i], dbuf, sz);
 
50
      break;
 
51
    case MODE_RDWR:  
 
52
      colls[i]->get(idxs[i], idxlens[i], dbuf, sz);
 
53
      break;
 
54
    case MODE_ACC:
 
55
      memset(dbuf, 0, sz);
 
56
      break;
 
57
    }
 
58
  }
 
59
}
 
60
 
 
61
void
 
62
UniformTaskCollSplitData::cleanupDataBufs(vector<void *> &data_bufs, 
 
63
            vector<int> &data_lens, 
 
64
            const vector<void *> &idxs) {
 
65
  for(int i=0; i<idxlens.size(); i++) {
 
66
    int sz = data_lens[i];
 
67
    char *dbuf = (char *)data_bufs[i];
 
68
 
 
69
    switch(modes[i]) {
 
70
    case MODE_RONLY:
 
71
      break;
 
72
    case MODE_RDWR:  
 
73
      colls[i]->put(idxs[i], idxlens[i], dbuf, sz);
 
74
      break;
 
75
    case MODE_ACC:
 
76
      colls[i]->add(idxs[i], idxlens[i], dbuf, sz);
 
77
      break;
 
78
    }
 
79
    delete [] dbuf;
 
80
  }
 
81
  data_bufs.clear();
 
82
  data_lens.clear();
 
83
}
 
84
 
 
85
void
 
86
UniformTaskCollSplitData::process() {
 
87
  int p;
 
88
  bool got_work;
 
89
  barrier();
 
90
  TslFunc_t fn = frt.get(tfn);
 
91
  char buf[tsk_size];
 
92
  int tasksDone=0, stealAttempts=0, steals=0;
 
93
  vector<void *> idxs;
 
94
  for(int i=0; i<idxlens.size(); i++) {
 
95
    idxs.push_back(new char[idxlens[i]]);
 
96
  }
 
97
 
 
98
  while (!sq.hasTerminated())  {
 
99
    while (sq.getTask(buf, tsk_size)) {
 
100
      tasksDone += 1;
 
101
      vector<int> data_lens;
 
102
      vector<void *> data_bufs;
 
103
      for(int i=0; i<idxlens.size(); i++) {
 
104
        ci_fn(buf, tsk_size, pldata, pldata_len, 
 
105
        i, idxs[i], idxlens[i]);
 
106
      }
 
107
      setupDataBufs(data_bufs, data_lens, idxs);
 
108
      fn(this, buf, tsk_size, pldata, pldata_len, data_bufs);
 
109
      cleanupDataBufs(data_bufs, data_lens, idxs);
 
110
    }
 
111
    sq.td_progress();
 
112
    got_work = false;
 
113
    while(got_work == false && !sq.hasTerminated()) {
 
114
      do {
 
115
        p = rand() % nproc();
 
116
      }
 
117
      while (p == me());
 
118
      got_work = sq.steal(p);
 
119
      stealAttempts += 1;
 
120
    }
 
121
    if(got_work) {
 
122
      steals += 1;
 
123
    }
 
124
  }
 
125
 
 
126
//   printf("%d: processed %d tasks attempts=%d steals=%d\n", me(), tasksDone, stealAttempts, steals);
 
127
  barrier();
 
128
}
 
129
 
 
130
 
 
131