DisCostiC v2.0.0
Distributed Cost in Cluster: a cross-architecture simulator for massively parallel MPI programs
Loading...
Searching...
No Matches
Grid.hpp
Go to the documentation of this file.
1
7#ifndef Grid_HPP
8#define Grid_HPP
9
10#pragma once
11
12#include <map>
13#include <vector>
14#include <assert.h>
15
16#include "enum.hpp"
17#include "DataStruct.hpp"
18#include "../test/P2P.hpp"
19
20namespace DisCosTiC
21{
22 // Benchmark benchmark(&CFG_args);
23
24 class Grid
25 {
26
28 // private:
29 public:
34
35 /*class Indices
36 {
37 public:
38 std::map<std::string, DisCosTiC::AST_OP*>* indices(DisCosTiC::GraphInterface::Benchmark & benchmark)
39 {
40 std::cout << "working";
41 for (std::map<std::string, DisCosTiC::AST_OP*>::iterator itr = benchmark.indicesTable->begin(); itr != benchmark.indicesTable->end(); ++itr)
42 {
43 std::cout << '\t' << itr->first << '\t' << +itr->second->type << std::endl;
44 }
45 return benchmark.indicesTable;
46 }
47 };
48
49 Indices set()
50 {
51 return Indices{};
52 }*/
53
58 {
59 // label: 0...0(x18) 0012..0012(x18) 112..112(x18) 2323..2323(x18) 3345...3345(x18) 445..445(x18) 5656..5656(x18) 6678..6678(x18) 778...778(x18) 8989...8989 991011..991011... 101011....11121112...12121314..131314...14
60 // set().indices(benchmark);
61 // DisCosTiC::AST_OP* Nodeee= DAG->retrieveID(indicesTable, toCharPointer(label+1));
62
63 DisCosTiC::AST_OP_ Nodeee = ID[rank][label].second; // DAG->retrievedeserialID(indicesDeserializedTable, toCharPointer(label+1));
64 // DisCosTiC::AST_OP_ Nodeee = benchmark.Oneway_PositiveDisplacement()[rank][label].second;
66 N.depCount = Nodeee.depCount;
67 N.type = Nodeee.type;
68 N.target = Nodeee.target;
69 N.bufSize = Nodeee.bufSize;
70 N.tag = Nodeee.tag;
71 N.mode = Nodeee.mode;
72 N.node = Nodeee.node;
73 N.network = Nodeee.network;
74 N.label = Nodeee.label;
75 N.algorithm = Nodeee.algorithm;
79 for (auto i : DisCosTiC::getRange(Nodeee.depsCount)) // DepOperations.size()/depsCount: 2 for comp, 0 for send, 1 for recv (2..2 2201..2201 001..001 1212..1212 2201..2201 001..001 1212..1212 2201..2201 001..001 1212..1212)
80 {
81 DisCosTiC_Datatype depnode = Nodeee.depApdxStartLabel + i + 1; // 12,45,78,1011,1314 for comp 3,6,9,12 for recv (depApdxStartLabel: 0,3,6,9,12 for comp, 2,5,8,11,14 for send, 1 for recv)
82 assert(depnode < numOps);
83 N.DepOperations.push_back(depnode);
84 }
85
86 // always push_back(0) i.e., idepsCount=0 for blocking calls
87 for (auto i : DisCosTiC::getRange(Nodeee.idepsCount))
88 {
89 DisCosTiC_Datatype depnode = Nodeee.idepApdxStartLabel + i + 1; // 12,45,78,1011,1314 for comp 3,6,9,12 for recv
90 assert(depnode < numOps);
91 N.IdepOperations.push_back(depnode);
92 }
93 // std::cout<< "actual" ;
94 // print_DeserialNodeNonPointerT(N); // DepOperations.size(): 2 for comp, 0 for send, 1 for recv
95 return N;
96 }
97
98 public:
102 /*Grid(){
103 }*/
104
109 {
110 return this->numOps; // it->getnumOps()=15 (x18)
111 }
112
117 {
118 // Nodes.size(): 1...1 (x18) 02 002 0002 ... 0..0(x18)2 0...01 0..01
119 for (auto i : DisCosTiC::getRange(Nodes.size()))
120 {
122 op.target = Nodes[i].target;
123 op.bufSize = Nodes[i].bufSize;
124 op.tag = Nodes[i].tag;
125 op.node = Nodes[i].node;
126 op.mode = Nodes[i].mode;
127 op.algorithm = Nodes[i].algorithm;
128 op.collectiveType = Nodes[i].collectiveType;
129 op.collectiveRoot = Nodes[i].collectiveRoot;
130 op.collectiveNumRanks = Nodes[i].collectiveNumRanks;
131
132 op.network = Nodes[i].network;
133 op.type = Nodes[i].type;
134 op.label = Nodes[i].label;
135 // op.rank = myRank;
136 // op.time = 0;
137 opVec.push_back(op);
138 }
139
140 Nodes.clear();
141
146 // std::sort(opVec.begin(), opVec.end(), [](DisCosTiC::DisCosTiC_OP a, DisCosTiC::DisCosTiC_OP b)
147 // {
148 // if(a.target > b.target)
149 // return true;
150 // return false; });
151
152 std::sort(opVec.begin(), opVec.end(), [](DisCosTiC::DisCosTiC_OP a, DisCosTiC::DisCosTiC_OP b)
153 {
154 if(a.type < b.type)
155 return true;
156 return false; });
157 }
158
163 {
165 op.target = Nodes[0].target;
166 op.bufSize = Nodes[0].bufSize;
167 op.tag = Nodes[0].tag;
168 op.node = Nodes[0].node;
169 op.network = Nodes[0].network;
170 op.type = Nodes[0].type;
171 op.label = Nodes[0].label;
172 op.algorithm = Nodes[0].algorithm;
173 op.collectiveType = Nodes[0].collectiveType;
174 op.collectiveRoot = Nodes[0].collectiveRoot;
175 op.collectiveNumRanks = Nodes[0].collectiveNumRanks;
176 op.rank = myRank;
177 op.time = 0;
178 opVec.push_back(op);
179
180 Nodes.clear();
181
182 std::sort(opVec.begin(), opVec.end(), [](DisCosTiC::DisCosTiC_OP a, DisCosTiC::DisCosTiC_OP b)
183 {
184 if(a.type < b.type)
185 return true;
186 return false; });
187 }
188
193 {
194 // label (time-local l-1): 0..0(x18) 12...12 3...3 45..45 6...6 ... 1314...1314 (this->id_counter first for all ranks and then increase iterations)
195 // +getOp(label).type: 3...3(x18) 12...12 3...3 12...12 3...3 12...12
196 // +getOp(label).IdepOperations.size(): 0...0
197 DisCosTiC::AST_OP_TYPE N1 = getOp(benchmark, ID, rank, label);
198 // std::cout<<"Rank "<<rank<<" in setOp and label "<<label<<" and its type : "<<int(N1.type)<<" and "<<N1.IdepOperations.size()<<"independent operations : "<<std::endl;
199
200 for (auto i : DisCosTiC::getRange(N1.IdepOperations.size()))
201 {
202 DisCosTiC::AST_OP_TYPE N2 = getOp(benchmark, ID, rank, N1.IdepOperations[i]);
203
204 // std::cout<<"Rank : "<<rank<<" Independent Label : "<<N2.label<<" and its type : "<<int(N2.type)<<std::endl;
205 Nodes.push_back(N2);
206 }
207 }
208
213 {
214 // label: 0..0 1...1 2...2 3...3 4...4 ... 14...14 (this->id_counter first for all ranks and then increase iterations)
215 //+getOp(label).DepOperations.size(): 2...2(x18) 0...0 1...1 ....
216 DisCosTiC::AST_OP_TYPE N1 = getOp(benchmark, ID, rank, label);
217 // std::cout<<"Rank "<<rank<<" in unsetOp and label "<<label<<" and its type : "<<int(N1.type)<<" and "<<N1.DepOperations.size()<<"dependent operations : "<<std::endl;
218
219 for (auto i : DisCosTiC::getRange(N1.DepOperations.size()))
220 {
221 DisCosTiC::AST_OP_TYPE N2 = getOp(benchmark, ID, rank, N1.DepOperations[i]);
222 // std::cout<<"Rank : "<<rank<<" dependent Label : "<<N2.label<<" and its type : "<<int(N2.type)<<std::endl;
223
224 Nodes.push_back(N2);
225 // N.DepOperations[i]: 12...12 (x18) 3...3 (x18) 45..45 (x18) 6...6(x18) ... 1314...1314(x18)
226 }
227 }
228 };
229
230 using VecSeqGraph_t = std::vector<Grid>;
231
232}
233
234#endif
std::size_t DisCosTiC_Datatype
Definition DataType.hpp:52
end of Benchmark class
void unsetOp(DisCosTiC_Datatype rank, DisCosTiC_Datatype label, Benchmark benchmark, DisCosTiC::idNodeTypePair ID)
un set the operation, if completed
Definition Grid.hpp:212
DisCosTiC::VecDeserialNode Nodes
Definition Grid.hpp:33
void setOp(DisCosTiC_Datatype rank, DisCosTiC_Datatype label, Benchmark benchmark, DisCosTiC::idNodeTypePair ID)
set the operation, if started
Definition Grid.hpp:192
DisCosTiC::AST_OP_TYPE getOp(Benchmark benchmark, DisCosTiC::idNodeTypePair ID, DisCosTiC_Datatype rank, DisCosTiC_Datatype label)
get the nodes
Definition Grid.hpp:57
void getTypeSortedOps(DisCosTiC::Operations &opVec)
get the all operations ordered by their type for all ranks and time steps
Definition Grid.hpp:116
DisCosTiC_Datatype myRank
Definition Grid.hpp:32
void getSortedRootOps(DisCosTiC::Operations &opVec)
get the initial root operations ordered by their type for all ranks and time steps
Definition Grid.hpp:162
DisCosTiC_Datatype numRanks
Definition Grid.hpp:31
DisCosTiC_Datatype getNumOps()
default constructor
Definition Grid.hpp:108
DisCosTiC_Datatype numOps
private members of Grid class
Definition Grid.hpp:30
< benchmark test cases
std::vector< Grid > VecSeqGraph_t
Definition Grid.hpp:230
std::vector< std::vector< idNodeTypePairT > > idNodeTypePair
std::vector< AST_OP_TYPE > VecDeserialNode
iteratorRange< scalarT > getRange(scalarT begin, scalarT end)
Definition DataType.hpp:161
std::vector< DisCosTiC_OP > Operations
DisCosTiC_Indextype collectiveNumRanks
nubmer of ranks participating in collective
char mode
TODO: add blocking/non-blocking mode.
uint8_t algorithm
algo choice for collective
DisCosTiC_Indextype node
DisCosTiC_Indextype network
std::vector< DisCosTiC_Indextype > IdepOperations
DisCosTiC_Indextype depCount
std::vector< DisCosTiC_Indextype > DepOperations
DisCosTiC_Indextype tag
uint8_t collectiveType
collective operation type
DisCosTiC_Indextype label
DisCosTiC_Indextype collectiveRoot
root rank for collectives which have root (-1 if no root)
DisCosTiC_Indextype target
DisCosTiC_Datatype bufSize
DisCosTiC_Indextype depCount
DisCosTiC_Indextype depApdxStartLabel
DisCosTiC_Datatype bufSize
DisCosTiC_Indextype collectiveNumRanks
nubmer of ranks participating in collective
DisCosTiC_Indextype network
DisCosTiC_Indextype idepsCount
DisCosTiC_Indextype idepApdxStartLabel
DisCosTiC_Indextype label
DisCosTiC_Indextype target
uint8_t collectiveType
collective operation type
DisCosTiC_Indextype tag
char mode
TODO: add blocking/non-blocking mode.
DisCosTiC_Indextype collectiveRoot
root rank for collectives which have root (-1 if no root)
DisCosTiC_Indextype depsCount
uint8_t algorithm
algo choice for collective
DisCosTiC_Indextype node
char mode
TODO: add blocking/non-blocking mode.
DisCosTiC_Indextype network
uint8_t algorithm
algo choice for collective
uint8_t collectiveType
collective operation type
DisCosTiC_Indextype tag
DisCosTiC_Indextype node
DisCosTiC_Timetype time
DisCosTiC_Datatype bufSize
DisCosTiC_Indextype label
DisCosTiC_Indextype collectiveNumRanks
nubmer of ranks participating in collective
DisCosTiC_Indextype collectiveRoot
root rank for collectives which have root (-1 if no root)
DisCosTiC_Indextype target
DisCosTiC_Indextype rank
owning rank of this operation