MPQC 2.3.1

- Main Page
- Related Pages
- Classes
- Files

- File List

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
47 class DistShellPair {
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_;
66 Ref<GaussianBasisSet> bs1_;
67 Ref<GaussianBasisSet> bs2_;
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: