MPQC  3.0.0-alpha
file.hpp
1 #ifndef MPQC_ARRAY_FILE_HPP
2 #define MPQC_ARRAY_FILE_HPP
3 
4 #include "mpqc/range.hpp"
5 #include "mpqc/array/forward.hpp"
6 #include "mpqc/file.hpp"
7 
8 namespace mpqc {
9 namespace detail {
10 
13  };
14 
15  template<typename T>
17  : ArrayBase, boost::noncopyable
18  {
19  template<typename Extent>
20  array_impl(const std::string &name,
21  const std::vector<Extent> &extents)
22  : ArrayBase(name, extents)
23  {
24  mpqc::File file(name + ".h5");
25  data_.reset(new mpqc::File::Dataset<T>(file, "data", this->dims_));
26  }
27  void sync() {
28  //data_->flush();
29  }
30  void _put(const std::vector<range> &r, const void *buffer) {
31  //std::cout << "write: " << r << std::endl;
32  (*data_)(r).write((const T*)buffer);
33  }
34  void _get(const std::vector<range> &r, void *buffer) const {
35  //std::cout << "read: " << r << std::endl;
36  (*data_)(r).read((T*)buffer);
37  }
38  private:
39  std::auto_ptr< mpqc::File::Dataset<T> > data_;
40  };
41 
42 #ifdef H5_HAVE_PARALLEL
43 #if 0 // TODO Andrey, do we need this?
44  template<typename T>
46  : ArrayBase, boost::noncopyable
47  {
48  array_parallel_impl(const std::string &name,
49  const std::vector<size_t> &dims,
50  mpi::Comm comm)
51  : ArrayBase(dims)
52  {
53  File file = (comm == MPI_COMM_NULL) ?
54  File(name + ".h5") :
55  File(name + ".h5", File::Driver::MPIIO(comm));
56  dataset_ = new File::Dataset<T>(file, "data", this->dims_);
57  }
58  void put(const std::vector<range> &r, const void *buffer) {
59  dataset_(r).put((const void*)buffer);
60  }
61  void get(const std::vector<range> &r, void *buffer) const {
62  dataset_(r).get((void*)buffer);
63  }
64  private:
65  File::Dataset<T> dataset_;
66  };
67 #endif
68 #endif // H5_HAVE_PARALLEL
69 
70 
71 } // namespace detail
72 } // namespace mpqc
73 
74 namespace mpqc {
75 
76  static const detail::array_file_driver ARRAY_FILE;
77 
78 }
79 
80 #endif /* MPQC_ARRAY_FILE_HPP */
mpqc::detail::array_impl
Definition: forward.hpp:18
mpqc
Contains new MPQC code since version 3.
Definition: integralenginepool.hpp:37
mpqc::File
Top-level file object that holds groups.
Definition: file.hpp:196
mpqc::File::Dataset
Array-like collection of data.
Definition: file.hpp:205
mpqc::ci::write
void write(ci::Vector &V, File::Dataspace< double > F, const std::vector< mpqc::range > &local)
write local segments of V to F
Definition: direct.hpp:41
mpqc::detail::array_file_driver
Definition: file.hpp:11
mpqc::ci::read
void read(ci::Vector &V, File::Dataspace< double > F, const std::vector< mpqc::range > &local)
read local segments into V from F
Definition: direct.hpp:25
mpqc::detail::array_parallel_impl
Definition: forward.hpp:21
mpqc::detail::ArrayBase
Definition: forward.hpp:23

Generated at Sun Jan 26 2020 23:24:01 for MPQC 3.0.0-alpha using the documentation package Doxygen 1.8.16.