MPQC 3.0.0-alpha
Loading...
Searching...
No Matches
transform_tbint.h
1//
2// transform_tbint.h
3//
4// Copyright (C) 2004 Edward Valeev
5//
6// Author: Edward Valeev <evaleev@vt.edu>
7// Maintainer: EV
8//
9// This file is part of the SC Toolkit.
10//
11// The SC Toolkit is free software; you can redistribute it and/or modify
12// it under the terms of the GNU Library General Public License as published by
13// the Free Software Foundation; either version 2, or (at your option)
14// any later version.
15//
16// The SC Toolkit is distributed in the hope that it will be useful,
17// but WITHOUT ANY WARRANTY; without even the implied warranty of
18// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19// GNU Library General Public License for more details.
20//
21// You should have received a copy of the GNU Library General Public License
22// along with the SC Toolkit; see the file COPYING.LIB. If not, write to
23// the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
24//
25// The U.S. Government is granted a limited license as per AL 91-7.
26//
27
28#ifndef _chemistry_qc_lcao_transformtbint_h
29#define _chemistry_qc_lcao_transformtbint_h
30
31#include <string>
32#include <util/ref/ref.h>
33#include <util/misc/scexception.h>
34#include <chemistry/molecule/energy.h>
35#include <chemistry/qc/basis/intdescr.h>
36#include <chemistry/qc/basis/distshpair.h>
37#include <math/distarray4/distarray4.h>
38#include <chemistry/qc/wfn/orbitalspace.h>
39#include <chemistry/qc/lcao/transform_factory.h>
40
41namespace sc {
42
49class TwoBodyMOIntsTransform : virtual public SavableState {
50private:
51
52 // Construct the integrals accumulator object
53 // This function depends on the particulars of the transformation
54 virtual void init_acc() = 0;
55 // Compute required dynamic memory for a given batch size
56 // implementation depends on the particulars of the concrete type
57 virtual distsize_t compute_transform_dynamic_memory_(int ni) const = 0;
58
59protected:
62 static double zero_integral;
64 typedef struct {
65 enum {Space1, Space2, Space3, Space4};
66 } MOSpaces;
67
68 std::string name_;
70
71 Ref<MolecularEnergy> top_mole_; // Top-level molecular energy to enable checkpointing
72 Ref<MessageGrp> msg_;
73 Ref<MemoryGrp> mem_; // Initially taken from Factory, but may decide to create another MemoryGrp object
74 // e.g. MemoryGrpRegion object created from Factory's MemoryGrp object. The choice of MemoryGrp
75 // is finialized in the derived class constructor (\sa init_acc())
76 Ref<ThreadGrp> thr_;
77 Ref<TwoBodyIntDescr> tbintdescr_;
78 // Integrals accumulator
79 Ref<DistArray4> ints_acc_;
80
81 Ref<OrbitalSpace> space1_;
82 Ref<OrbitalSpace> space2_;
83 Ref<OrbitalSpace> space3_;
84 Ref<OrbitalSpace> space4_;
85
86 int restart_orbital_; // when restarting, this recalls where to start transform
87 size_t peak_memory_; // actual maximum memory (per process) used by this transform during its lifetime
88 size_t memory_; // memory (per process) used by this transform after compute() has been called
89 bool dynamic_;
91 MOIntsTransform::StoreMethod::type ints_method_;
92 std::string file_prefix_;
93 double log2_epsilon_;
94
95 // These variables computed every time in case environment has changed or it's a restart
96 size_t max_memory_; // max memory given to this object
97 size_t static_memory_; // memory used to hold persistent quantities
98 int batchsize_;
99 int npass_;
100
102 unsigned int restart_orbital() const;
103
104 // Compute used static memory and batch size
105 void init_vars();
106 // Re-construct the integrals accumulator object
107 void reinit_acc();
108 // Allocate distributed memory
109 void alloc_mem(const size_t localmem);
110 // Deallocate distributed memory
111 void dealloc_mem();
112 // Reset mem_ to point to new_mem
113 void set_memgrp(const Ref<MemoryGrp>& new_mem);
114
115 // Compute batchsize given the amount of used static memory and
116 // the number of i-orbitals
117 int compute_transform_batchsize_(size_t mem_static, int rank_i);
118
119 // Compute the number of ij-pairs per this task
120 static int compute_nij(const int rank_i, const int rank_j, const int nproc, const int me);
121
125 void memory_report(std::ostream& os = ExEnv::out0()) const;
129 void mospace_report(std::ostream& os = ExEnv::out0()) const;
130
133 void print_header(std::ostream& os = ExEnv::out0()) const;
136 void print_footer(std::ostream& os = ExEnv::out0()) const;
137
138#if 0
140 void check_tbint(const Ref<TwoBodyInt>& tbint) const;
141#endif
142
143public:
144
147 const Ref<TwoBodyIntDescr>& tbintdescr,
150 virtual ~TwoBodyMOIntsTransform();
151
153
155 const Ref<MOIntsTransformFactory>& factory() const { return factory_; }
157 std::string name() const {return name_;}
159 virtual std::string type() const =0;
161 const Ref<MemoryGrp>& mem() const;
163 const Ref<MessageGrp>& msg() const;
169 const Ref<OrbitalSpace>& space1() const;
171 const Ref<OrbitalSpace>& space2() const;
173 const Ref<OrbitalSpace>& space3() const;
175 const Ref<OrbitalSpace>& space4() const;
181 double log2_epsilon() const { return log2_epsilon_; }
183 void set_log2_epsilon(double prec);
184
187
188
190 size_t memory() const;
192 size_t peak_memory() const;
193
195 int batchsize() const;
197 bool dynamic() const;
199 unsigned int num_te_types() const;
203 virtual size_t memgrp_blksize() const =0;
204
206 void set_top_mole(const Ref<MolecularEnergy>& top_mole) { top_mole_ = top_mole; }
207 void set_dynamic(bool dynamic) { dynamic_ = dynamic; }
208
210 virtual void compute() = 0;
212 virtual void check_int_symm(double threshold = TwoBodyMOIntsTransform::zero_integral) =0;
214 virtual void obsolete();
215
219
220public:
221 static void set_print_percent(double pp) { print_percent_ = pp; }
222 static double print_percent() { return print_percent_; }
223 static void set_debug(int d) { debug_ = d; }
224 static int debug() { return debug_; }
225
226private:
227 static double print_percent_;
228 static int debug_;
229
230};
231
232
241 public:
243 TwoBodyThreeCenterMOIntsTransform(const std::string& name,
245 const Ref<TwoBodyThreeCenterIntDescr>& tbintdescr,
251
253 std::string name() const { return name_; }
255 virtual std::string type() const =0;
256
258 const Ref<MOIntsTransformFactory>& factory() const { return factory_; }
260 const Ref<MemoryGrp>& mem() const { return mem_; }
262 const Ref<TwoBodyThreeCenterIntDescr>& intdescr() const { return tbintdescr_; }
266 const Ref<OrbitalSpace>& space1() const { return space1_; }
268 const Ref<OrbitalSpace>& space2() const { return space2_; }
270 const Ref<OrbitalSpace>& space3() const { return space3_; }
276 double log2_epsilon() const { return log2_epsilon_; }
278 void set_log2_epsilon(double prec);
279
281 size_t memory() const;
283 size_t peak_memory() const;
285 unsigned int num_te_types() const;
286
288 virtual void compute() =0;
290 void obsolete();
291
292 protected:
293
294 std::string name_;
296 Ref<MemoryGrp> mem_;
298 // Integrals accumulator
299 Ref<DistArray4> ints_acc_;
300
301 Ref<OrbitalSpace> space1_;
302 Ref<OrbitalSpace> space2_;
303 Ref<OrbitalSpace> space3_;
304
305 int restart_orbital_; // when restarting, this recalls where to start transform
306 size_t peak_memory_; // actual maximum memory (per process) used by this transform during its lifetime
307 size_t memory_; // memory (per process) used by this transform after compute() has been called
308 MOIntsTransform::StoreMethod::type ints_method_;
309 std::string file_prefix_;
310 double log2_epsilon_;
311
312 // These variables computed every time in case environment has changed or it's a restart
313 size_t max_memory_; // max memory given to this object
314 size_t static_memory_; // memory used to hold persistent quantities
315 int batchsize_;
316 int npass_;
317
319 unsigned int restart_orbital() const;
320
321 // Compute used static memory and batch size
322 virtual void init_vars();
323 // Construct the integrals accumulator object
324 virtual void init_acc() =0;
325 // Re-construct the integrals accumulator object
326 void reinit_acc();
327 // Allocate distributed memory
328 void alloc_mem(const size_t localmem);
329 // Deallocate distributed memory
330 void dealloc_mem();
331 // Reset mem_ to point to new_mem
332 void set_memgrp(const Ref<MemoryGrp>& new_mem);
333
337 virtual distsize_t compute_transform_dynamic_memory(int batchsize = -1) const =0;
338
342 void memory_report(std::ostream& os = ExEnv::out0()) const;
346 void mospace_report(std::ostream& os = ExEnv::out0()) const;
347
350 void print_header(std::ostream& os = ExEnv::out0()) const;
353 void print_footer(std::ostream& os = ExEnv::out0()) const;
354
355 public:
356 static void set_print_percent(double pp) { print_percent_ = pp; }
357 static double print_percent() { return print_percent_; }
358 static void set_debug(int d) { debug_ = d; }
359 static int debug() { return debug_; }
360
361 private:
362 static double print_percent_;
363 static int debug_;
364
366 virtual void extra_memory_report(std::ostream& os = ExEnv::out0()) const =0;
367
368};
369
370}
371
372#endif
373
374// Local Variables:
375// mode: c++
376// c-file-style: "CLJ"
377// End:
378
379
This is used to store data that must be shared between all cooperating shell pairs.
Definition distshpair.h:46
static std::ostream & out0()
Return an ostream that writes from node 0.
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
TwoBodyMOIntsTransform computes two-body integrals in MO basis using parallel integrals-direct AO->MO...
Definition transform_tbint.h:49
std::string name() const
Returns the name of the transform.
Definition transform_tbint.h:157
bool dynamic() const
Returns whether to use dynamic load balancing.
unsigned int restart_orbital() const
returns index in range of space1_ where to start the transformation
const Ref< OrbitalSpace > & space4() const
Returns OrbitalSpace object 4.
const Ref< MemoryGrp > & mem() const
Returns the MemoryGrp object.
const Ref< OrbitalSpace > & space2() const
Returns OrbitalSpace object 2.
int batchsize() const
Returns the batchsize for each pass of the transformation.
const Ref< OrbitalSpace > & space3() const
Returns OrbitalSpace object 3.
const Ref< OrbitalSpace > & space1() const
Returns OrbitalSpace object 1.
virtual void check_int_symm(double threshold=TwoBodyMOIntsTransform::zero_integral)=0
Check symmetry of transformed integrals.
void set_top_mole(const Ref< MolecularEnergy > &top_mole)
Specifies the top-level MolecularEnergy object to use for checkpointing.
Definition transform_tbint.h:206
const Ref< DistArray4 > & ints_distarray4()
Returns the DistArray4 object that holds the integrals.
double log2_epsilon() const
Definition transform_tbint.h:181
DistShellPair::SharedData * shell_pair_data()
Returns a that data that must be shared between all DistShellPair objects.
Definition transform_tbint.h:218
virtual size_t memgrp_blksize() const =0
Returns the number of bytes allocated for each ij-block of integrals of one type in MemoryGrp.
void save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
const Ref< MessageGrp > & msg() const
Returns the MessageGrp object.
size_t peak_memory() const
Returns the maximum amount of memory that will be used by this object.
void memory_report(std::ostream &os=ExEnv::out0()) const
Generates a report on memory for the transform : user-specified limits, projected and actual use.
void print_header(std::ostream &os=ExEnv::out0()) const
Prints out standard header.
virtual void compute()=0
Computes transformed integrals.
void set_log2_epsilon(double prec)
virtual void partially_transformed_ints(const Ref< DistArray4 > &)
Supplies the partially transformed integrals.
static double zero_integral
By default, integrals smaller than zero_integral are considered zero.
Definition transform_tbint.h:62
void print_footer(std::ostream &os=ExEnv::out0()) const
Prints out standard footer.
unsigned int num_te_types() const
Returns the number of types of two body integrals computed.
void mospace_report(std::ostream &os=ExEnv::out0()) const
Generates a report on MO spaces for the transform.
virtual void obsolete()
Make the transform obsolete. Next call to compute() will recompute.
size_t memory() const
Returns amount of memory used by this object after compute() has been called.
const Ref< MOIntsTransformFactory > & factory() const
factory who created this
Definition transform_tbint.h:155
const Ref< TwoBodyIntDescr > & intdescr() const
Returns the integral set descriptor.
virtual std::string type() const =0
Returns a short label which uniquely identifies the type of transform.
TwoBodyThreeCenterMOIntsTransform computes (xy|z) integrals, using parallel integral-direct AO->MO tr...
Definition transform_tbint.h:240
virtual std::string type() const =0
Returns a short label which uniquely identifies the type of transform.
size_t memory() const
Returns amount of memory used by this object after compute() has been called.
void memory_report(std::ostream &os=ExEnv::out0()) const
Generates a report on memory for the transform : user-specified limits, projected and actual use.
double log2_epsilon() const
Definition transform_tbint.h:276
const Ref< OrbitalSpace > & space2() const
Returns OrbitalSpace object 2.
Definition transform_tbint.h:268
unsigned int num_te_types() const
Returns the number of types of two body integrals computed.
unsigned int restart_orbital() const
returns index in range of space1_ where to start the transformation
const Ref< TwoBodyThreeCenterIntDescr > & intdescr() const
Returns the integral set descriptor.
Definition transform_tbint.h:262
const Ref< OrbitalSpace > & space1() const
Returns OrbitalSpace object 1.
Definition transform_tbint.h:266
const Ref< OrbitalSpace > & space3() const
Returns OrbitalSpace object 3.
Definition transform_tbint.h:270
std::string name() const
Returns the name of the transform.
Definition transform_tbint.h:253
const Ref< MOIntsTransformFactory > & factory() const
factory who created this
Definition transform_tbint.h:258
void mospace_report(std::ostream &os=ExEnv::out0()) const
Generates a report on MO spaces for the transform.
void print_header(std::ostream &os=ExEnv::out0()) const
Prints out standard header.
virtual void compute()=0
Computes transformed integrals.
const Ref< DistArray4 > & ints_acc()
Returns the integrals accumulator object.
virtual distsize_t compute_transform_dynamic_memory(int batchsize=-1) const =0
Compute required dynamic memory for the given batchsize.
void print_footer(std::ostream &os=ExEnv::out0()) const
Prints out standard footer.
void obsolete()
Make the transform obsolete. Next call to compute() will recompute.
void save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
const Ref< MemoryGrp > & mem() const
MemoryGrp object.
Definition transform_tbint.h:260
size_t peak_memory() const
Returns the maximum amount of memory that will be used by this object.
Contains all MPQC code up to version 3.
Definition mpqcin.h:14
Predefined enumerated type for the MO spaces.
Definition transform_tbint.h:64

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