MPQC  2.3.1
distshpair.h
1 //
2 // distshpair.h
3 // based on mbpt/distsh.h
4 //
5 // Copyright (C) 1996 Limit Point Systems, Inc.
6 //
7 // Author: Ida Nielsen <ida@kemi.aau.dk>
8 // Updated: Edward Valeev <edward.valeev@chemistry.gatech.edu>
9 // Maintainer: LPS
10 //
11 // This file is part of the SC Toolkit.
12 //
13 // The SC Toolkit is free software; you can redistribute it and/or modify
14 // it under the terms of the GNU Library General Public License as published by
15 // the Free Software Foundation; either version 2, or (at your option)
16 // any later version.
17 //
18 // The SC Toolkit is distributed in the hope that it will be useful,
19 // but WITHOUT ANY WARRANTY; without even the implied warranty of
20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 // GNU Library General Public License for more details.
22 //
23 // You should have received a copy of the GNU Library General Public License
24 // along with the SC Toolkit; see the file COPYING.LIB. If not, write to
25 // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
26 //
27 // The U.S. Government is granted a limited license as per AL 91-7.
28 //
29 
30 #ifndef _chemistry_qc_basis_distshpair_h
31 #define _chemistry_qc_basis_distshpair_h
32 
33 #ifdef __GNUC__
34 #pragma interface
35 #endif
36 
37 #include <util/misc/regtime.h>
38 #include <util/group/message.h>
39 #include <util/group/thread.h>
40 #include <chemistry/qc/basis/basis.h>
41 
42 using namespace sc;
43 
44 namespace sc {
45 
48  public:
52  class SharedData {
53  public:
54  volatile long int shellpair_;
56  SharedData() { init(); }
60  void init() { shellpair_ = 0; }
61  };
62  private:
63  Ref<MessageGrp> msg_;
64  int nthread_;
65  Ref<ThreadLock> lock_;
68  bool bs1_eq_bs2_;
69  bool task_dynamic_;
70  bool thread_dynamic_;
71  int debug_;
72  // How often updates are printed (i.e. every 10% of total work)
73  double print_percent_;
74  SharedData *shared_;
75 
76  // Number of tasks handled by thread 0 in task 0:
77  // if dynamic == true : it will distribute all of them
78  // if dynamic == false : it will handle its share
79  long int ntask_;
80  // Print period
81  long int print_interval_;
82  // Index of the next task to be served
83  long int current_shellpair_;
84 
85  // for dynamic load balancing
86  int req_type_;
87  int ans_type_;
88  int ncpu_less_0_;
89  void serve_tasks();
90 
91  // for static load balancing
92  int S_, R_; // NOTE: S is in bs1, R is in bs2
93  int ncpu_;
94  int incS_, incR_;
95  int mythread_;
96 
97  // sorted work for dynamic load balancing
98  int *cost_;
99  int *Svec_;
100  int *Rvec_;
101  int *Ivec_;
102 
103  void init_dynamic_work();
104  public:
108  DistShellPair(const Ref<MessageGrp> &, int nthread, int mythread,
109  const Ref<ThreadLock>& lock,
110  const Ref<GaussianBasisSet>& bs1, const Ref<GaussianBasisSet>& bs2,
111  bool dynamic, SharedData *shared = 0);
112  ~DistShellPair();
114  void init();
116  void set_debug(int d) { debug_ = d; }
118  void set_print_percent(double p);
126  int get_task(int &P, int &Q);
127 };
128 
129 }
130 
131 #endif
132 
133 // //////////////////////////////////////////////////////////////////////////
134 
135 // Local Variables:
136 // mode: c++
137 // c-file-style: "CLJ-CONDENSED"
138 // End:
sc::DistShellPair::set_debug
void set_debug(int d)
How much stuff to print out.
Definition: distshpair.h:116
sc::Ref
A template class that maintains references counts.
Definition: ref.h:332
sc::DistShellPair::set_print_percent
void set_print_percent(double p)
How often to print status from node 0.
sc::DistShellPair::SharedData
This is used to store data that must be shared between all cooperating shell pairs.
Definition: distshpair.h:52
sc::DistShellPair::get_task
int get_task(int &P, int &Q)
Puts the current PQ shell pair into P and Q and returns 1.
sc::DistShellPair::SharedData::SharedData
SharedData()
Construct and initialize.
Definition: distshpair.h:56
sc::DistShellPair::SharedData::init
void init()
If this will be used to iterate through the shells again, then init must be called.
Definition: distshpair.h:60
sc::DistShellPair
Distributes shell pairs either statically or dynamically.
Definition: distshpair.h:47
sc::DistShellPair::DistShellPair
DistShellPair(const Ref< MessageGrp > &, int nthread, int mythread, const Ref< ThreadLock > &lock, const Ref< GaussianBasisSet > &bs1, const Ref< GaussianBasisSet > &bs2, bool dynamic, SharedData *shared=0)
The DistShellPair class is used to distribute shell pair indices among tasks.
sc::DistShellPair::init
void init()
Resets to the first shell pair.

Generated at Sun Jan 26 2020 23:33:03 for MPQC 2.3.1 using the documentation package Doxygen 1.8.16.