1 #ifndef MPQC_ARRAY_FORWARD_HPP
2 #define MPQC_ARRAY_FORWARD_HPP
4 #include "mpqc/range.hpp"
5 #include "mpqc/utility/debug.hpp"
17 template<
typename T,
typename Driver>
20 template<
typename T,
class Driver>
28 static range extent(U n) {
38 virtual void _put(
const std::vector<range> &r,
const void *buffer) = 0;
39 virtual void _get(
const std::vector<range> &r,
void *buffer)
const = 0;
44 virtual void sync() = 0;
46 template<
typename Extent>
48 const std::vector<Extent> &extents)
51 for (
size_t i = 0; i < extents.size(); ++i) {
52 range r = extent(extents.at(i));
53 base_.push_back(*r.begin());
54 dims_.push_back(r.size());
58 const std::string name()
const {
63 MPQC_ASSERT(dims_.size() == base_.size());
69 for (
size_t i = 0; i < dims_.size(); ++i) {
75 void put(
const std::vector<range> &r,
const void *buffer) {
76 _put(rebase(r), buffer);
79 void get(
const std::vector<range> &r,
void *buffer)
const {
80 _get(rebase(r), buffer);
86 std::vector<size_t> dims_;
87 std::vector<size_t> base_;
89 void check_range(
const std::vector<range> &R)
const {
90 MPQC_ASSERT(this->rank() == R.size());
91 for (
size_t i = 0; i < this->rank(); ++i) {
94 MPQC_ASSERT(base_.at(i) <= *r.begin());
95 MPQC_ASSERT(*r.end() <= base_.at(i) + dims_.at(i));
99 std::vector<range> rebase(std::vector<range> R)
const {
101 for (
size_t i = 0; i < R.size(); ++i) {
103 size_t base = base_.at(i);
104 R.at(i) =
range(*r.begin()-base, *r.end()-base);