MPQC 3.0.0-alpha
Loading...
Searching...
No Matches
distarray4.h
1//
2// distarray4.h
3//
4// Copyright (C) 2002 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_mbptr12_distarray4_h
29#define _chemistry_qc_mbptr12_distarray4_h
30
31#include <vector>
32#include <util/ref/ref.h>
33#include <util/state/state.h>
34#include <util/state/statein.h>
35#include <util/state/stateout.h>
36#include <util/group/memory.h>
37#include <util/group/message.h>
38
39namespace sc {
40
41 enum DistArray4Storage {DistArray4Storage_XY, DistArray4Storage_YX};
42
44 public:
45 static const DistArray4Dimensions& default_dim() { return default_dim_; }
46 DistArray4Dimensions(int num_te_types, int n1, int n2, int n3, int n4,
47 DistArray4Storage storage = DistArray4Storage_XY) :
48 num_te_types_(num_te_types), n1_(n1), n2_(n2), n3_(n3), n4_(n4),
49 storage_(storage)
50 {
51 }
52 int num_te_types() const { return num_te_types_; }
53 int n1() const { return n1_; }
54 int n2() const { return n2_; }
55 int n3() const { return n3_; }
56 int n4() const { return n4_; }
57 DistArray4Storage storage() const { return storage_; }
58 private:
59 static DistArray4Dimensions default_dim_;
60 int num_te_types_;
61 int n1_;
62 int n2_;
63 int n3_;
64 int n4_;
65 DistArray4Storage storage_;
66 };
67 bool operator==(const DistArray4Dimensions& A,
68 const DistArray4Dimensions& B);
69
71
94class DistArray4: virtual public SavableState {
95 public:
96 // mem will be used to fetch data
97 DistArray4(int num_te_types, int ni, int nj, int nx, int ny,
98 DistArray4Storage storage = DistArray4Storage_XY);
100 virtual ~DistArray4();
102
105 virtual Ref<DistArray4> clone(const DistArray4Dimensions& dim = DistArray4Dimensions::default_dim()) =0;
106
108 typedef unsigned int tbint_type;
109 static const unsigned int max_num_te_types = 14;
110
112 int num_te_types() const { return num_te_types_; };
114 int ni() const { return ni_; }
116 int nj() const { return nj_; }
118 int nx() const { return nx_; }
120 int ny() const { return ny_; }
122 const DistArray4Storage& storage() const { return storage_; }
124 size_t blocksize() const { return blocksize_; };
125 // same as blocksize(), but in bytes
126 size_t blksize() const { return blksize_; }
127
129 virtual void activate() { active_ = true; }
131 virtual void deactivate() { active_ = false; }
133 virtual bool data_persistent() const =0;
140 virtual const double * retrieve_pair_block(int i, int j, tbint_type oper_type,
141 double* buf = 0) const =0;
144 virtual void retrieve_pair_subblock(int i, int j, tbint_type oper_type,
145 int xstart, int xfence, int ystart, int yfence,
146 double* buf) const =0;
148 virtual void release_pair_block(int i, int j, tbint_type oper_type) const =0;
154 virtual void store_pair_block(int i, int j, tbint_type oper_type, const double* ints) =0;
157 virtual void store_pair_subblock(int i, int j, tbint_type oper_type,
158 int xstart, int xfence, int ystart, int yfence,
159 const double* ints) =0;
160
161 int ij_index(int i, int j) const { return i*nj_ + j; };
162
164 virtual bool is_avail(int i, int j) const =0;
166 virtual bool is_local(int i, int j) const =0;
168 virtual bool has_access(int proc) const =0;
172 int tasks_with_access(std::vector<int>& twa_map) const;
173
174 const Ref<MessageGrp>& msg() const { return msg_; }
175
176 // return active_
177 bool active() const { return active_; }
178
179 private:
181 static const int classdebug_ = 0;
182
183 int num_te_types_; // Number of types of integrals in a block
184 Ref<MessageGrp> msg_;
185 int ni_, nj_;
186 int nx_, ny_;
187 DistArray4Storage storage_;
188 size_t nxy_; // nx_ * ny_ - the number of integrals of one type in a block
189 size_t blksize_; // the same in bytes
190 size_t blocksize_; // hence the size of the block of num_te_types of integrals is blksize_ * num_te_types
191
192 bool active_;
193
194 protected:
195 // return nxy_
196 size_t nxy() const { return nxy_; }
198 int ntasks() const { return msg_->n(); }
200 int me() const { return msg_->me(); }
202 int classdebug() const { return classdebug_; }
203
204};
205
206Ref<DistArray4> make_distarray4(int num_te_types, int ni, int nj, int nx, int ny,
207 DistArray4Storage storage = DistArray4Storage_XY);
208
210Ref<DistArray4>
212 unsigned int te_type,
213 double scale = 1.0);
214
218
222
225
226
228void
230 double a,
231 const Ref<DistArray4>& Y,
232 double scale = 1.0);
233
240
247
250 double scale,
251 const Ref<DistArray4>& bra,
252 unsigned int intsetidx_bra,
253 const Ref<DistArray4>& ket,
254 unsigned int intsetidx_ket,
255 int debug = 0);
256
257class RefSCMatrix;
258
262 double scale,
263 const Ref<DistArray4>& bra,
264 unsigned int intsetidx_bra,
265 const RefSCMatrix& ket,
266 const int MatBra1Dim, const int MatBra2Dim);
267
268
276
277
279 double scale,
280 const Ref<DistArray4>& bra,
281 unsigned int intsetidx_bra,
282 const RefSCMatrix& ket,
283 const int MatBra1Dim, const int MatBra2Dim);
284
285
291
293 double scale,
294 const Ref<DistArray4>& bra,
295 unsigned int intsetidx_bra,
296 const RefSCMatrix& ket,
297 const int MatBra1Dim, const int MatBra2Dim);
298
299
301void contract3(const Ref<DistArray4>& ijxy, const RefSCMatrix& T, Ref<DistArray4>& ijzy);
302
304void contract4(const Ref<DistArray4>& ijxy, const RefSCMatrix& T, Ref<DistArray4>& ijxz);
305
306
307
311 const Ref<DistArray4>& src);
312
316 const Ref<DistArray4>& src, const int tensor_type);
317
319copy_to_RefSCMat(const Ref<DistArray4>& src, int tensor_index);
320
321
322
323
324
325
326
327namespace detail {
328
341 void store_memorygrp(Ref<DistArray4>& acc, Ref<MemoryGrp>& mem, int i_offset,
342 int ni, const size_t blksize_memgrp = 0);
343
347 void restore_memorygrp(Ref<DistArray4>& acc, Ref<MemoryGrp>& mem, int i_offset,
348 int ni, DistArray4Storage storage, const size_t blksize_memgrp = 0);
349
350}
351
352}
353
354#endif
355
356// Local Variables:
357// mode: c++
358// c-file-style: "CLJ"
359// End:
DistArray4 contains a set of one or more distributed dense 4-index arrays.
Definition distarray4.h:94
virtual void store_pair_block(int i, int j, tbint_type oper_type, const double *ints)=0
Stores an ij pair block of integrals.
size_t blocksize() const
Size of each block of the integrals of one type, in double words.
Definition distarray4.h:124
virtual Ref< DistArray4 > clone(const DistArray4Dimensions &dim=DistArray4Dimensions::default_dim())=0
how to clone.
const DistArray4Storage & storage() const
physical storage of the integrals. The default storage is XY. Storage is not mutable.
Definition distarray4.h:122
virtual bool has_access(int proc) const =0
Does this task have access to all blocks?
int ntasks() const
total number of tasks
Definition distarray4.h:198
int classdebug() const
return debug level for this class
Definition distarray4.h:202
int nj() const
Rank of index space j.
Definition distarray4.h:116
int tasks_with_access(std::vector< int > &twa_map) const
Returns the total number of tasks with access to integrals.
int ny() const
Rank of index space y.
Definition distarray4.h:120
virtual void deactivate()
call this after operations on this object are finished. May destroy data (see data_persistent()).
Definition distarray4.h:131
unsigned int tbint_type
Types of two-body operators that DistArray4 understands.
Definition distarray4.h:108
virtual bool is_avail(int i, int j) const =0
Can this block be accessed via retrieve_pair_block from this task?
virtual const double * retrieve_pair_block(int i, int j, tbint_type oper_type, double *buf=0) const =0
Retrieves an ij block of integrals.
virtual bool is_local(int i, int j) const =0
Is this block stored locally? If true, this implies that it can be retrieved efficiently (compare to ...
virtual void store_pair_subblock(int i, int j, tbint_type oper_type, int xstart, int xfence, int ystart, int yfence, const double *ints)=0
Stores an rectangular subblock of ij block of integrals.
virtual void release_pair_block(int i, int j, tbint_type oper_type) const =0
Releases the buffer that holds ij block of integrals. If it was allocated by DistArray4,...
virtual bool data_persistent() const =0
if this returns false, call to deactivate may destroy data
virtual void activate()
call this before operations on this object can begin
Definition distarray4.h:129
void save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
int nx() const
Rank of index space x.
Definition distarray4.h:118
int ni() const
Rank of index space i.
Definition distarray4.h:114
int num_te_types() const
The number of types of integrals that are being handled together.
Definition distarray4.h:112
int me() const
rank of this task
Definition distarray4.h:200
virtual void retrieve_pair_subblock(int i, int j, tbint_type oper_type, int xstart, int xfence, int ystart, int yfence, double *buf) const =0
Retrieves a rectangular subblock of ij block of integrals.
The RefSCMatrix class is a smart pointer to an SCMatrix specialization.
Definition matrix.h:135
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
Definition reftestx.h:32
Definition reftestx.h:41
std::vector< unsigned int > operator<<(const GaussianBasisSet &B, const GaussianBasisSet &A)
computes a map from basis functions in A to the equivalent basis functions in B.
bool operator==(const Atom &a, const Atom &b)
Contains all MPQC code up to version 3.
Definition mpqcin.h:14
Ref< DistArray4 > permute23(const Ref< DistArray4 > &src)
creates an array in which indices 2 and 3 are permuted
void contract4(const Ref< DistArray4 > &ijxy, const RefSCMatrix &T, Ref< DistArray4 > &ijxz)
contracts ijxy with T_yz to produce ijxz
Ref< DistArray4 > permute12(const Ref< DistArray4 > &src)
creates an array in which indices 1 and 2 are permuted
void antisymmetrize(RefSCMatrix &Aanti, const RefSCMatrix &A, const Ref< OrbitalSpace > &bra, const Ref< OrbitalSpace > &ket, bool accumulate=false)
Antisymmetrizes 4-index quantity <ij|A|kl> -> <ij|A|kl> - <ij|A|lk> and saves to Aanti.
RefSCMatrix & copy_to_RefSCMat(RefSCMatrix &dst, const Ref< DistArray4 > &src, const int tensor_type)
copy a specific tensor to RefSCMatrix
void contract34(Ref< DistArray4 > &braket, double scale, const Ref< DistArray4 > &bra, unsigned int intsetidx_bra, const Ref< DistArray4 > &ket, unsigned int intsetidx_ket, int debug=0)
contracts ijxy ("bra") with klxy ("ket") to produce ijkl ("braket")
void symmetrize(const Ref< GPetiteList2 > &plist2, const Ref< Integral > &integral, const RefSymmSCMatrix &skel, const RefSymmSCMatrix &sym)
Uses plist2 to convert the "skeleton" matrix into the full matrix. Only applicable when the two basis...
Ref< DistArray4 > extract(const Ref< DistArray4 > &A, unsigned int te_type, double scale=1.0)
extracts te_type from A
void contract_DA4_RefMat_k1b2_34(Ref< DistArray4 > &braket, double scale, const Ref< DistArray4 > &bra, unsigned int intsetidx_bra, const RefSCMatrix &ket, const int MatBra1Dim, const int MatBra2Dim)
Contract X^Aj_ik = DA^Ax_yi * M^jk_xy; procedure: DA'^Ax_iy <- DA^Ax_yi from permute34 DA''^Ai_xy <- ...
Ref< DistArray4 > permute34(const Ref< DistArray4 > &src)
creates an array in which indices 3 and 4 are permuted
void contract34_DA4_RefMat(Ref< DistArray4 > &braket, double scale, const Ref< DistArray4 > &bra, unsigned int intsetidx_bra, const RefSCMatrix &ket, const int MatBra1Dim, const int MatBra2Dim)
contracts ijxy("bra") with klxy ("ket", a RefSCMatrix) to produce ijkl ("braket"); The last two argum...
void axpy(const Ref< DistArray4 > &X, double a, const Ref< DistArray4 > &Y, double scale=1.0)
axpy followed by scaling: Y += a*X; Y *= scale.
void contract_DA4_RefMat_k2b2_34(Ref< DistArray4 > &braket, double scale, const Ref< DistArray4 > &bra, unsigned int intsetidx_bra, const RefSCMatrix &ket, const int MatBra1Dim, const int MatBra2Dim)
Contract X^Aj_ik = DA^Ax_iy * M^jk_xy; This is written for spin free[2]R12, where rdm matrices can be...
void contract3(const Ref< DistArray4 > &ijxy, const RefSCMatrix &T, Ref< DistArray4 > &ijzy)
contracts ijxy with T_xz to produce ijzy
Definition distarray4.h:43

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