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
43using namespace std;
44
45namespace sc {
46
47class MOIntsTransformFactory;
48
52class 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
61protected:
64 static constexpr double zero_integral = 1.0e-12;
66 typedef struct {
67 enum {Space1, Space2, Space3, Space4};
68 } MOSpaces;
69
70 std::string name_;
72
73 Ref<MolecularEnergy> top_mole_; // Top-level molecular energy to enable checkpointing
74 Ref<MessageGrp> msg_;
75 Ref<MemoryGrp> mem_;
76 Ref<ThreadGrp> thr_;
77 // Integrals accumulator
78 Ref<R12IntsAcc> ints_acc_;
79
80 Ref<MOIndexSpace> space1_;
81 Ref<MOIndexSpace> space2_;
82 Ref<MOIndexSpace> space3_;
83 Ref<MOIndexSpace> space4_;
84
85 int num_te_types_;
86 size_t memory_;
87 bool dynamic_;
88 double print_percent_;
90 int debug_;
92 std::string file_prefix_;
93
94 // These variables are never saved but computed every time in case environment
95 // has changed or it's a restart
96 size_t mem_static_;
97 int batchsize_;
98 int npass_;
99
101 unsigned int restart_orbital() const;
102
103 // Compute used static memory and batch size
104 void init_vars();
105 // Re-construct the integrals accumulator object
106 void reinit_acc();
107 // Allocate distributed memory
108 void alloc_mem(const size_t localmem);
109 // Deallocate distributed memory
110 void dealloc_mem();
111
112 // Compute batchsize given the amount of used static memory and
113 // the number of i-orbitals
114 int compute_transform_batchsize_(size_t mem_static, int rank_i);
115
116 // Compute the number of ij-pairs per this task
117 static int compute_nij(const int rank_i, const int rank_j, const int nproc, const int me);
118
122 void memory_report(std::ostream& os = ExEnv::out0()) const;
126 void mospace_report(std::ostream& os = ExEnv::out0()) const;
127
130 void print_header(std::ostream& os = ExEnv::out0()) const;
133 void print_footer(std::ostream& os = ExEnv::out0()) const;
134
135public:
136
138 TwoBodyMOIntsTransform(const std::string& name, const Ref<MOIntsTransformFactory>& factory,
142
144
146 std::string name() const {return name_;}
148 virtual std::string type() const =0;
163
165 double print_percent() const;
167 int batchsize() const;
169 int debug() const;
171 bool dynamic() const;
173 int num_te_types() const;
177 virtual const size_t memgrp_blksize() const =0;
178
180 void set_top_mole(const Ref<MolecularEnergy>& top_mole) { top_mole_ = top_mole; }
181
185 void set_memory(const size_t memory);
186 void set_debug(int debug) { debug_ = debug; }
187 void set_dynamic(bool dynamic) { dynamic_ = dynamic; }
188 void set_print_percent(double print_percent) { print_percent_ = print_percent; }
189
191 virtual void compute() = 0;
193 virtual void check_int_symm(double threshold = TwoBodyMOIntsTransform::zero_integral) const noexcept(false) =0;
195 virtual void obsolete();
196
200
201};
202
203}
204
205#endif
206
207// Local Variables:
208// mode: c++
209// c-file-style: "CLJ"
210// End:
211
212
This is used to store data that must be shared between all cooperating shell pairs.
Definition distshpair.h:52
static std::ostream & out0()
Return an ostream that writes from node 0.
StoreMethod
Describes the method of storing transformed MO integrals.
Definition transform_factory.h:55
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
std::string name() const
Returns the name of the transform.
Definition transform_tbint.h:146
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 > space2() const
Returns MOIndexSpace object 2.
Ref< MOIndexSpace > space4() const
Returns MOIndexSpace object 4.
double print_percent() const
Returns the update print frequency.
int debug() const
Returns the debug level.
int batchsize() const
Returns the batchsize for each pass of the transformation.
void set_top_mole(const Ref< MolecularEnergy > &top_mole)
Specifies the top-level MolecularEnergy object to use for checkpointing.
Definition transform_tbint.h:180
void set_num_te_types(const int num_te_types)
Specifies how many integral types computed by TwoBodyInt to be transformed Default is 1.
Ref< R12IntsAcc > ints_acc() const
Returns the integrals accumulator object.
DistShellPair::SharedData * shell_pair_data()
Returns a that data that must be shared between all DistShellPair objects.
Definition transform_tbint.h:199
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.
static constexpr double zero_integral
By default, integrals smaller than zero_integral are considered zero.
Definition transform_tbint.h:64
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.
Ref< MOIndexSpace > space3() const
Returns MOIndexSpace object 3.
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< MessageGrp > msg() const
Returns the MessageGrp object.
Ref< MemoryGrp > mem() const
Returns the MemoryGrp object.
virtual void check_int_symm(double threshold=TwoBodyMOIntsTransform::zero_integral) const noexcept(false)=0
Check symmetry of transformed integrals.
Ref< MOIndexSpace > space1() const
Returns MOIndexSpace object 1.
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:66

Generated at Wed Mar 13 2024 18:30:16 for MPQC 2.3.1 using the documentation package Doxygen 1.9.8.