MPQC 3.0.0-alpha
Loading...
Searching...
No Matches
distarray4_mpiiofile.h
1//
2// distarray4_mpiiofile.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_mpiiofile_h
29#define _chemistry_qc_mbptr12_distarray4_mpiiofile_h
30
31#define OMPI_SKIP_MPICXX
32#define MPICH_SKIP_MPICXX
33#include <mpi.h>
34#include <util/ref/ref.h>
35#include <util/group/memory.h>
36#include <util/misc/registry.h>
37#include <math/distarray4/distarray4.h>
38
41#define AVOID_XLC_BUG 1
42
43namespace sc {
44
46
56
57 protected:
58
59 size_t nints_per_block_; // number of integrals per block = num_te_types*nbasis__2_
60 char *filename_;
61 MPI_File datafile_;
62
63 // keep track of clones of this object to be able to create unique names
65 Ref<ListOfClones> clonelist_;
66 void set_clonelist(const Ref<ListOfClones>& cl);
67
68 struct PairBlkInfo {
69 mutable double* ints_[max_num_te_types]; // blocks corresponding to each operator type
70 mutable bool manage_[max_num_te_types]; // am I managing memory of this ints_?
71 mutable int refcount_[max_num_te_types]; // number of references
72 MPI_Offset offset_; // location in file (in bytes)
73 } *pairblk_;
74
76 void check_error_code_(int errcod) const;
78 void init(bool restart);
79 // Utility functions
80 int ij_proc(int i, int j) const { return 0;};
81
82#ifndef AVOID_XLC_BUG
84 template <typename Derived> Ref<DistArray4> clone(const DistArray4Dimensions& dim =
85 DistArray4Dimensions::default_dim());
86#endif
87
88 public:
89 DistArray4_MPIIOFile(const char *filename, int num_te_types,
90 int ni, int nj, int nx, int ny,
91 DistArray4Storage storage = DistArray4Storage_XY);
95
97 void activate();
99 void deactivate();
101 bool data_persistent() const { return true; }
103 void release_pair_block(int i, int j, tbint_type oper_type) const;
104
106 bool is_local(int i, int j) const { return true; }
108 bool is_avail(int i, int j) const { return true; }
110 bool has_access(int proc) const { return true; }
111};
112
113namespace detail {
114 void clone_filename(std::string& result, const char* original, int id);
115}
116
117#ifndef AVOID_XLC_BUG
118template <typename Derived>
119 Ref<DistArray4> DistArray4_MPIIOFile::clone(const DistArray4Dimensions& dim) {
120
121 int id = 0;
122 std::string clonename;
123 using detail::clone_filename;
124 clone_filename(clonename, this->filename_, id);
125 if (clonelist_) {
126 while (clonelist_->key_exists(clonename)) {
127 ++id;
128 clone_filename(clonename, this->filename_, id);
129 }
130 } else {
131 clonelist_ = ListOfClones::instance();
132 }
133 clonelist_->add(clonename, id);
134
135 Ref<Derived> result;
136 if (dim == DistArray4Dimensions::default_dim())
137 result = new Derived(clonename.c_str(), num_te_types(),
138 ni(), nj(),
139 nx(), ny(),
140 storage());
141 else
142 result = new Derived(clonename.c_str(), dim.num_te_types(),
143 dim.n1(), dim.n2(),
144 dim.n3(), dim.n4(),
145 dim.storage());
146
147 result->set_clonelist(clonelist_);
148 return result;
149 }
150#endif
151
153
162
163 public:
164 DistArray4_MPIIOFile_Ind(const char *filename, int num_te_types,
165 int ni, int nj, int nx, int ny,
166 DistArray4Storage storage = DistArray4Storage_XY);
170
171 Ref<DistArray4> clone(const DistArray4Dimensions& dim = DistArray4Dimensions::default_dim());
172
173 void store_pair_block(int i, int j, tbint_type oper_type, const double *ints);
174 void store_pair_subblock(int i, int j, tbint_type oper_type,
175 int xstart, int xfence, int ystart, int yfence,
176 const double* ints);
177 const double* retrieve_pair_block(int i, int j, tbint_type oper_type,
178 double* buf = 0) const;
179 void retrieve_pair_subblock(int i, int j, tbint_type oper_type,
180 int xstart, int xfence, int ystart, int yfence,
181 double* buf) const;
182};
183
184}
185
186#endif
187
188// Local Variables:
189// mode: c++
190// c-file-style: "CLJ"
191// End:
DistArray4_MPIIOFile_Ind handles transformed integrals stored in a binary file accessed through MPI-I...
Definition distarray4_mpiiofile.h:161
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 store_pair_block(int i, int j, tbint_type oper_type, const double *ints)
Stores an ij pair block of integrals.
void retrieve_pair_subblock(int i, int j, tbint_type oper_type, int xstart, int xfence, int ystart, int yfence, double *buf) const
Retrieves a rectangular subblock of ij block of integrals.
void store_pair_subblock(int i, int j, tbint_type oper_type, int xstart, int xfence, int ystart, int yfence, const double *ints)
Stores an rectangular subblock of ij block of integrals.
Ref< DistArray4 > clone(const DistArray4Dimensions &dim=DistArray4Dimensions::default_dim())
how to clone.
const double * retrieve_pair_block(int i, int j, tbint_type oper_type, double *buf=0) const
Retrieves an ij block of integrals.
DistArray4_MPIIOFile handles transformed integrals stored in a binary file accessed through MPI-IO.
Definition distarray4_mpiiofile.h:55
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 activate()
implementation of DistArray4::activate()
void check_error_code_(int errcod) const
Utility function to check MPI I/O error codes.
void release_pair_block(int i, int j, tbint_type oper_type) const
Releases an ij pair block of integrals.
bool has_access(int proc) const
Does this task have access to all the integrals?
Definition distarray4_mpiiofile.h:110
bool data_persistent() const
implementation of DistArray4::data_persistent()
Definition distarray4_mpiiofile.h:101
void deactivate()
implementation of DistArray4::deactivate()
bool is_avail(int i, int j) const
In this implementation blocks are available everywhere.
Definition distarray4_mpiiofile.h:108
void init(bool restart)
Initialization tasks common to all constructors.
bool is_local(int i, int j) const
Is this block stored locally?
Definition distarray4_mpiiofile.h:106
DistArray4 contains a set of one or more distributed dense 4-index arrays.
Definition distarray4.h:94
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
int nj() const
Rank of index space j.
Definition distarray4.h:116
int ny() const
Rank of index space y.
Definition distarray4.h:120
unsigned int tbint_type
Types of two-body operators that DistArray4 understands.
Definition distarray4.h:108
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
A template class that maintains references counts.
Definition ref.h:361
Registry wraps std::map and can be policy-configured to act as a Singleton or a regular object.
Definition registry.h:112
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
Definition distarray4.h:43
Definition distarray4_mpiiofile.h:68

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