MPQC  2.3.1
transform_tbint.h
1 //
2 // transform_tbint.h
3 //
4 // Copyright (C) 2004 Edward Valeev
5 //
6 // Author: Edward Valeev <edward.valeev@chemistry.gatech.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 #ifdef __GNUG__
29 #pragma interface
30 #endif
31 
32 #ifndef _chemistry_qc_mbptr12_transformtbint_h
33 #define _chemistry_qc_mbptr12_transformtbint_h
34 
35 #include <string>
36 #include <util/ref/ref.h>
37 #include <util/class/scexception.h>
38 #include <chemistry/qc/basis/distshpair.h>
39 #include <chemistry/qc/mbptr12/r12ia.h>
40 #include <chemistry/qc/mbptr12/moindexspace.h>
41 #include <chemistry/qc/mbptr12/transform_factory.h>
42 
43 using namespace std;
44 
45 namespace sc {
46 
47 class MOIntsTransformFactory;
48 
52 class TwoBodyMOIntsTransform : virtual public SavableState {
53 
54  // Construct the integrals accumulator object
55  // This function depends on the particulars of the transformation
56  virtual void init_acc() = 0;
57  // Compute required dynamic memory for a given batch size
58  // implementation depends on the particulars of the concrete type
59  virtual distsize_t compute_transform_dynamic_memory_(int ni) const = 0;
60 
61 protected:
64  static
65 #if __cplusplus >= 201103L
66  constexpr
67 #else
68  const
69 #endif
70  double zero_integral = 1.0e-12;
72  typedef struct {
73  enum {Space1, Space2, Space3, Space4};
74  } MOSpaces;
75 
76  std::string name_;
78 
79  Ref<MolecularEnergy> top_mole_; // Top-level molecular energy to enable checkpointing
80  Ref<MessageGrp> msg_;
81  Ref<MemoryGrp> mem_;
82  Ref<ThreadGrp> thr_;
83  // Integrals accumulator
84  Ref<R12IntsAcc> ints_acc_;
85 
86  Ref<MOIndexSpace> space1_;
87  Ref<MOIndexSpace> space2_;
88  Ref<MOIndexSpace> space3_;
89  Ref<MOIndexSpace> space4_;
90 
91  int num_te_types_;
92  size_t memory_;
93  bool dynamic_;
94  double print_percent_;
96  int debug_;
98  std::string file_prefix_;
99 
100  // These variables are never saved but computed every time in case environment
101  // has changed or it's a restart
102  size_t mem_static_;
103  int batchsize_;
104  int npass_;
105 
107  unsigned int restart_orbital() const;
108 
109  // Compute used static memory and batch size
110  void init_vars();
111  // Re-construct the integrals accumulator object
112  void reinit_acc();
113  // Allocate distributed memory
114  void alloc_mem(const size_t localmem);
115  // Deallocate distributed memory
116  void dealloc_mem();
117 
118  // Compute batchsize given the amount of used static memory and
119  // the number of i-orbitals
120  int compute_transform_batchsize_(size_t mem_static, int rank_i);
121 
122  // Compute the number of ij-pairs per this task
123  static int compute_nij(const int rank_i, const int rank_j, const int nproc, const int me);
124 
128  void memory_report(std::ostream& os = ExEnv::out0()) const;
132  void mospace_report(std::ostream& os = ExEnv::out0()) const;
133 
136  void print_header(std::ostream& os = ExEnv::out0()) const;
139  void print_footer(std::ostream& os = ExEnv::out0()) const;
140 
141 public:
142 
144  TwoBodyMOIntsTransform(const std::string& name, const Ref<MOIntsTransformFactory>& factory,
145  const Ref<MOIndexSpace>& space1, const Ref<MOIndexSpace>& space2,
146  const Ref<MOIndexSpace>& space3, const Ref<MOIndexSpace>& space4);
148 
150 
152  std::string name() const {return name_;}
154  virtual std::string type() const =0;
169 
171  double print_percent() const;
173  int batchsize() const;
175  int debug() const;
177  bool dynamic() const;
179  int num_te_types() const;
183  virtual const size_t memgrp_blksize() const =0;
184 
186  void set_top_mole(const Ref<MolecularEnergy>& top_mole) { top_mole_ = top_mole; }
187 
190  void set_num_te_types(const int num_te_types);
191  void set_memory(const size_t memory);
192  void set_debug(int debug) { debug_ = debug; }
193  void set_dynamic(bool dynamic) { dynamic_ = dynamic; }
194  void set_print_percent(double print_percent) { print_percent_ = print_percent; }
195 
197  virtual void compute() = 0;
199  virtual void check_int_symm(double threshold = TwoBodyMOIntsTransform::zero_integral) const throw (ProgrammingError) =0;
201  virtual void obsolete();
202 
206 
207 };
208 
209 }
210 
211 #endif
212 
213 // Local Variables:
214 // mode: c++
215 // c-file-style: "CLJ"
216 // End:
217 
218 
This is used to store data that must be shared between all cooperating shell pairs.
Definition: distshpair.h:52
StoreMethod
Describes the method of storing transformed MO integrals.
Definition: transform_factory.h:55
This is thrown when a situations arises that should be impossible.
Definition: scexception.h:87
A template class that maintains references counts.
Definition: ref.h:332
Base class for objects that can save/restore state.
Definition: state.h:46
Restores objects that derive from SavableState.
Definition: statein.h:70
Serializes objects that derive from SavableState.
Definition: stateout.h:61
TwoBodyMOIntsTransform computes two-body integrals in MO basis using parallel integrals-direct AO->MO...
Definition: transform_tbint.h:52
DistShellPair::SharedData * shell_pair_data()
Returns a that data that must be shared between all DistShellPair objects.
Definition: transform_tbint.h:205
std::string name() const
Returns the name of the transform.
Definition: transform_tbint.h:152
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
Ref< MOIndexSpace > space1() const
Returns MOIndexSpace object 1.
double print_percent() const
Returns the update print frequency.
Ref< MOIndexSpace > space2() const
Returns MOIndexSpace object 2.
Ref< MessageGrp > msg() const
Returns the MessageGrp object.
int debug() const
Returns the debug level.
int batchsize() const
Returns the batchsize for each pass of the transformation.
Ref< MemoryGrp > mem() const
Returns the MemoryGrp object.
void set_top_mole(const Ref< MolecularEnergy > &top_mole)
Specifies the top-level MolecularEnergy object to use for checkpointing.
Definition: transform_tbint.h:186
void set_num_te_types(const int num_te_types)
Specifies how many integral types computed by TwoBodyInt to be transformed Default is 1.
virtual const 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 ...
void memory_report(std::ostream &os=ExEnv::out0()) const
Generates a report on memory for the transform : user-specified limits, projected and actual use.
int num_te_types() const
Returns the number of types of two body integrals computed.
void print_header(std::ostream &os=ExEnv::out0()) const
Prints out standard header.
virtual void compute()=0
Computes transformed integrals.
void print_footer(std::ostream &os=ExEnv::out0()) const
Prints out standard footer.
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.
Ref< R12IntsAcc > ints_acc() const
Returns the integrals accumulator object.
Ref< MOIndexSpace > space3() const
Returns MOIndexSpace object 3.
virtual void check_int_symm(double threshold=TwoBodyMOIntsTransform::zero_integral) const =0
Check symmetry of transformed integrals.
Ref< MOIndexSpace > space4() const
Returns MOIndexSpace object 4.
virtual std::string type() const =0
Returns a short label which uniquely identifies the type of transform.
Definition: memory.h:44
Predefined enumerated type for the MO spaces.
Definition: transform_tbint.h:72

Generated at Thu Jan 20 2022 00:00:00 for MPQC 2.3.1 using the documentation package Doxygen 1.9.1.