MPQC 3.0.0-alpha
Loading...
Searching...
No Matches
fockdist.h
1
2#ifndef _chemistry_qc_lcao_fockdist_h
3#define _chemistry_qc_lcao_fockdist_h
4
5#include <vector>
6#include <util/misc/scint.h>
7#include <util/group/message.h>
8#include <util/group/thread.h>
9#include <chemistry/qc/basis/basis.h>
10#include <chemistry/qc/basis/petite.h>
11
12namespace sc {
13
14class FockBlocks: public sc::RefCount {
15 int nblock_;
16 std::vector<int> begin_;
17 std::vector<int> end_;
18 std::vector<int> shell_to_block_;
19 public:
20 typedef enum { Shell, Atom } Method;
21
23
24 int nblock() const { return nblock_; }
25 int begin(int iblock) const {return begin_[iblock];}
26 int end(int iblock) const {return end_[iblock];}
27 int size(int iblock) const {return end_[iblock]-begin_[iblock];}
28 int shell_to_block(int ishell) const { return shell_to_block_[ishell]; }
29};
30
31class FockDist: public sc::RefCount {
32 protected:
33 sc::Ref<FockBlocks> blocks_;
34
37 int nthread_, mythread_;
38 int nproc_, myproc_;
39 // This returns true if any of the shells in block i are in p1.
40 bool in_p1(int i);
41 public:
43 const sc::Ref<FockBlocks> &,
46 int nthread, int mythread);
47 virtual ~FockDist();
48 virtual void init() = 0;
49 // This only returns canonical block indices. When symmetry is used,
50 // this returns only blocks in_p1. This can be done, since only blocks
51 // comprised of shells on the same atom are used. Checks for p2 and p4
52 // must be done on individual shell indices, since the results of those
53 // checks depend on the particular shell number, even for shells on
54 // the same atom.
55 virtual bool get_blocks(int &i, int &j, int &k, int &l) = 0;
56 int nblock() const { return blocks_->nblock(); }
57 int begin(int iblock) const {return blocks_->begin(iblock);}
58 int end(int iblock) const {return blocks_->end(iblock);}
59 int size(int iblock) const {return blocks_->size(iblock);}
60 const sc::Ref<FockBlocks> &fockblocks() const { return blocks_; }
61 // Returns true if a given shell quartet will always end up on the same
62 // node/thread.
63 virtual bool fixed_integral_map() = 0;
64};
65
66class FockDistStatic: public FockDist {
67 protected:
68 int i_, j_, k_, l_;
69 int nglobalthread_, myglobalthread_;
70 public:
72 const sc::Ref<FockBlocks> &,
75 int nthread, int mythread);
77 void init();
78 bool fixed_integral_map();
79};
80
82 private:
83 bool next_block();
84 bool next_block(int n);
85 public:
87 const sc::Ref<FockBlocks> &,
90 int nthread, int mythread);
92 bool get_blocks(int&,int&,int&,int&);
93};
94
96 private:
97 bool next_block();
98 public:
100 const sc::Ref<FockBlocks> &,
101 const sc::Ref<sc::PetiteList> &pl,
103 int nthread, int mythread);
105 bool get_blocks(int&,int&,int&,int&);
106};
107
109 protected:
110 typedef std::multimap<std::pair<int,int>, std::pair<int,int>, std::greater<std::pair<int,int> > > pairmap_t;
111
112 pairmap_t ijmap_, klmap_;
113 pairmap_t::const_iterator ij_iter_, kl_iter_;
114
115 // If there are not enough processors to use dynamic load balancing,
116 // then static load balancing must be used. These members support
117 // static load balancing.
118 FockDist *static_;
119 bool static_distribution() { return static_ != 0; }
120 public:
122 const sc::Ref<FockBlocks> &,
123 const sc::Ref<sc::PetiteList> &pl,
125 int nthread, int mythread,
126 const signed char *pmax,
128 int l2tol);
130 bool fixed_integral_map();
131};
132
134 protected:
135 int i_, j_;
136
137 bool next_block();
138 void run_server();
139 bool server_get_blocks(int&,int&);
140 public:
142 const sc::Ref<FockBlocks> &,
143 const sc::Ref<sc::PetiteList> &pl,
145 int nthread, int mythread,
146 const signed char *pmax,
148 int l2tol);
150 bool get_blocks(int&,int&,int&,int&);
151 void init();
152};
153
155 protected:
156 typedef std::vector<std::pair<int,int> > pairvec_t;
157 pairvec_t ijvec_, klvec_;
158 int a_, b_; // this are the iterators used to compute ij and kl
159 int a_end_, b_end_;
160 int nij_, nkl_;
161
164 bool requested_work_;
165 int work_[4];
166
167 bool next_block();
168 void run_server();
169 bool server_get_blocks(int&,int&,int&,int&);
170 bool ijkl(int &i, int &j, int &k, int &l);
171 public:
173 const sc::Ref<FockBlocks> &,
174 const sc::Ref<sc::PetiteList> &pl,
176 int nthread, int mythread,
177 const signed char *pmax,
179 int l2tol);
181 bool get_blocks(int&,int&,int&,int&);
182 void init();
183};
184
187class FockDistribution: virtual public sc::SavableState {
189 int dynamic_;
191 int nindex_;
193 int shell_;
195 int cache_integrals_;
196 public:
197 FockDistribution(bool dynamic = 0, bool shell = 1, int nindex = 4,
198 bool cache_integrals = 1);
205 const sc::Ref<FockBlocks> &,
206 const sc::Ref<sc::PetiteList> &pl,
208 int nthread, int mythread,
209 const signed char *pmax,
211 int l2tol);
212 void print(std::ostream&o=sc::ExEnv::out0()) const;
213 bool cache_integrals() const { return cache_integrals_; }
214};
215
216}
217
218#endif
Atom represents an atom in a Molecule.
Definition atom.h:51
static std::ostream & out0()
Return an ostream that writes from node 0.
Definition fockdist.h:14
Definition fockdist.h:133
Definition fockdist.h:154
Definition fockdist.h:108
Definition fockdist.h:95
Definition fockdist.h:81
Definition fockdist.h:66
Definition fockdist.h:31
FockDistribution is a factory for constructing the desired FockDist specialization.
Definition fockdist.h:187
void print(std::ostream &o=sc::ExEnv::out0()) const
Print the object.
void save_data_state(sc::StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
Definition message.h:135
The base class for all reference counted objects.
Definition ref.h:192
A template class that maintains references counts.
Definition ref.h:361
Base class for objects that can save/restore state.
Definition state.h:45
Restores fundamental and user-defined types from images created with StateOut.
Definition statein.h:79
Serializes fundamental and user-defined types.
Definition stateout.h:71
Contains all MPQC code up to version 3.
Definition mpqcin.h:14

Generated at Wed Sep 25 2024 02:45:29 for MPQC 3.0.0-alpha using the documentation package Doxygen 1.12.0.