MPQC  3.0.0-alpha
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 <evaleev@vt.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 #include <util/misc/regtime.h>
34 #include <util/group/message.h>
35 #include <util/group/thread.h>
36 #include <chemistry/qc/basis/basis.h>
37 
38 namespace sc {
39 
42  public:
46  class SharedData {
47  public:
48  volatile long int shellpair_;
50  SharedData() { init(); }
54  void init() { shellpair_ = 0; }
55  };
56  private:
57  Ref<MessageGrp> msg_;
58  int nthread_;
59  Ref<ThreadLock> lock_;
62  bool bs1_eq_bs2_;
63  bool task_dynamic_;
64  bool thread_dynamic_;
65  int debug_;
66  // How often updates are printed (i.e. every 10% of total work)
67  double print_percent_;
68  SharedData *shared_;
69 
70  // Number of tasks handled by thread 0 in task 0:
71  // if dynamic == true : it will distribute all of them
72  // if dynamic == false : it will handle its share
73  long int ntask_;
74  // Print period
75  long int print_interval_;
76  // Index of the next task to be served
77  long int current_shellpair_;
78 
79  // for dynamic load balancing
80  int req_type_;
81  int ans_type_;
82  int ncpu_less_0_;
83  void serve_tasks();
84 
85  // for static load balancing
86  int S_, R_; // NOTE: S is in bs1, R is in bs2
87  int ncpu_;
88  int incS_, incR_;
89  int mythread_;
90 
91  // sorted work for dynamic load balancing
92  int *cost_;
93  int *Svec_;
94  int *Rvec_;
95  int *Ivec_;
96 
97  void init_dynamic_work();
98  public:
102  DistShellPair(const Ref<MessageGrp> &, int nthread, int mythread,
103  const Ref<ThreadLock>& lock,
104  const Ref<GaussianBasisSet>& bs1, const Ref<GaussianBasisSet>& bs2,
105  bool dynamic, SharedData *shared = 0);
106  ~DistShellPair();
108  void init();
110  void set_debug(int d) { debug_ = d; }
113  void set_print_percent(double p);
121  int get_task(int &P, int &Q);
122 };
123 
124 }
125 
126 #endif
127 
128 // //////////////////////////////////////////////////////////////////////////
129 
130 // Local Variables:
131 // mode: c++
132 // c-file-style: "CLJ-CONDENSED"
133 // End:
sc::DistShellPair::set_debug
void set_debug(int d)
How much stuff to print out.
Definition: distshpair.h:110
sc::Ref
A template class that maintains references counts.
Definition: ref.h:361
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:46
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:50
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:54
sc::DistShellPair
Distributes shell pairs either statically or dynamically.
Definition: distshpair.h:41
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.
sc
Contains all MPQC code up to version 3.
Definition: mpqcin.h:14

Generated at Sun Jan 26 2020 23:23:57 for MPQC 3.0.0-alpha using the documentation package Doxygen 1.8.16.