-
Notifications
You must be signed in to change notification settings - Fork 67
/
Copy pathAllocationDescriptorMPI.h
67 lines (53 loc) · 2.59 KB
/
AllocationDescriptorMPI.h
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
/*
* Copyright 2022 The DAPHNE Consortium
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef SRC_RUNTIME_LOCAL_DATASTRUCTURE_ALLOCATION_DESCRIPTORMPH_H
#define SRC_RUNTIME_LOCAL_DATASTRUCTURE_ALLOCATION_DESCRIPTORMPH_H
#include <ir/daphneir/Daphne.h>
#include <runtime/local/context/DaphneContext.h>
#include <runtime/local/datastructures/Structure.h>
#include <memory>
#include <runtime/local/datastructures/DistributedAllocationHelpers.h>
class AllocationDescriptorMPI : public IAllocationDescriptor {
ALLOCATION_TYPE type = ALLOCATION_TYPE::DIST_MPI;
int processRankID;
DaphneContext *ctx;
DistributedData distributedData;
std::shared_ptr<std::byte> data;
public:
AllocationDescriptorMPI(){};
AllocationDescriptorMPI(int id, DaphneContext *ctx, DistributedData data)
: processRankID(id), ctx(ctx), distributedData(data){};
~AllocationDescriptorMPI() override{};
[[nodiscard]] ALLOCATION_TYPE getType() const override { return type; };
std::string getLocation() const override { return std::to_string(processRankID); };
void createAllocation(size_t size, bool zero) override {};
std::shared_ptr<std::byte> getData() override { return nullptr; };
bool operator==(const IAllocationDescriptor *other) const override {
if (getType() == other->getType())
return (getLocation() == dynamic_cast<const AllocationDescriptorMPI *>(other)->getLocation());
return false;
};
[[nodiscard]] std::unique_ptr<IAllocationDescriptor> clone() const override {
return std::make_unique<AllocationDescriptorMPI>(*this);
}
void transferTo(std::byte *src, size_t size) override { /* TODO */ };
void transferFrom(std::byte *src, size_t size) override { /* TODO */ };
const DistributedIndex getDistributedIndex() { return distributedData.ix; }
const DistributedData getDistributedData() { return distributedData; }
void updateDistributedData(DistributedData data_) { distributedData = data_; }
int getRank() { return processRankID; }
};
#endif // SRC_RUNTIME_LOCAL_DATASTRUCTURE_ALLOCATION_DESCRIPTORMPH_H