This repository was archived by the owner on Jan 26, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathPVSlice.hpp
More file actions
98 lines (83 loc) · 3.1 KB
/
PVSlice.hpp
File metadata and controls
98 lines (83 loc) · 3.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
// SPDX-License-Identifier: BSD-3-Clause
// deprecated
#pragma once
#include <array>
#include <memory>
#include <vector>
#include "NDSlice.hpp"
#include "Transceiver.hpp" // rank_type
namespace SHARPY {
using offsets_type = std::vector<uint64_t>;
constexpr static int NOSPLIT = 1;
class BasePVSlice {
uint64_t _offset;
uint64_t _tile_size;
shape_type _shape;
int _split_dim;
public:
BasePVSlice() = delete;
BasePVSlice(const BasePVSlice &) = delete;
BasePVSlice(BasePVSlice &&) = default;
BasePVSlice(const shape_type &shape, int split = 0);
BasePVSlice(shape_type &&shape, int split = 0);
bool is_equally_tiled() const;
uint64_t offset() const;
uint64_t tile_size(rank_type rank = getTransceiver()->rank()) const;
shape_type tile_shape(rank_type rank = getTransceiver()->rank()) const;
int split_dim() const;
const shape_type &shape() const;
rank_type owner(const NDSlice &slice) const;
};
using BasePVSlicePtr = std::shared_ptr<BasePVSlice>;
class PVSlice {
NDSlice _slice; // must go before _base
BasePVSlicePtr _base;
mutable shape_type _shape;
public:
PVSlice() = delete;
PVSlice(const PVSlice &) = default;
PVSlice(PVSlice &&) = default;
PVSlice(const shape_type &shp, int split = 0);
PVSlice(shape_type &&shp, int split = 0);
PVSlice(const shape_type &shp, const NDSlice &slc, int split = 0);
PVSlice(shape_type &&shp, NDSlice &&slc, int split = 0);
PVSlice(const PVSlice &org, const NDSlice &slice);
PVSlice(const PVSlice &org, rank_type rank);
private:
PVSlice(BasePVSlicePtr bp, const NDSlice &slice);
public:
uint64_t ndims() const;
int split_dim() const;
bool is_sliced() const;
bool local_is_contiguous(rank_type rank = getTransceiver()->rank()) const;
bool is_equally_tiled() const;
rank_type owner(const NDSlice &slice) const;
const shape_type &base_shape() const;
// global slice
const NDSlice &slice() const;
// global shape
const shape_type &shape() const;
// global size
uint64_t size() const;
// size of rank's tile, e.g. the allocated memory
uint64_t tile_size(rank_type rank = getTransceiver()->rank()) const;
// shape of rank's tile, e.g. the allocated memory
shape_type tile_shape(rank_type rank = getTransceiver()->rank()) const;
// ranks's slice of local tile
NDSlice tile_slice(rank_type rank = getTransceiver()->rank()) const;
// size of rank's slice
uint64_t local_size(rank_type rank = getTransceiver()->rank()) const;
// shape of rank's slice
shape_type local_shape(rank_type rank = getTransceiver()->rank()) const;
// rank's slice
NDSlice local_slice(rank_type rank = getTransceiver()->rank()) const;
NDSlice map_slice(const NDSlice &slc) const;
// Compute overlapping slices for every (rank,rank) pair for mapping o_slc
// onto this. Returns a 2 lists of size number-of-ranks:
// 0. which local slice to send to rank i
// 1. which local slice maps to a slice of o_slc on rank i
std::array<std::vector<NDSlice>, 2> map_ranks(const PVSlice &o_slc) const;
bool need_reduce(const dim_vec_type &dims) const;
friend std::ostream &operator<<(std::ostream &output, const PVSlice &slc);
};
} // namespace SHARPY