DisCostiC v2.0.0
Distributed Cost in Cluster: a cross-architecture simulator for massively parallel MPI programs
Loading...
Searching...
No Matches
macro.hpp
Go to the documentation of this file.
1
7
8#ifndef MACRO_HPP
9#define MACRO_HPP
10
11#pragma once
12
13#include "DataType.hpp"
14#include <iostream>
18
19/*
20 * \brief return the print of the 1 dimensional vector
21 * \return print 1D vector
22 */
23#define print_vec1T(vec) \
24 { \
25 std::cout << "{"; \
26 for (auto i : DisCosTiC::getRange(vec.size())) \
27 std::cout << (i ? " , " : "") << vec[i]; \
28 std::cout << " }" << std::endl; \
29 }
30
31/*
32 * \brief return the print of the 2 dimensional vector
33 * \return print 2D vector
34 */
35#define print_vec2T(vec) \
36 { \
37 for (auto i : DisCosTiC::getRange(vec[0].size())) \
38 { \
39 for (auto j : DisCosTiC::getRange(vec[i].size())) \
40 { \
41 std::cout << "[" << i << "][" << j << "]=" << vec[i][j] << std::endl; \
42 } \
43 } \
44 }
45
46/*
47 * \brief return the print of the 2 dimensional paired vector
48 * \return print 2D paired vector
49 */
50#define print_pairedVec2T(vec) \
51 { \
52 for (auto i : DisCosTiC::getRange(vec.size())) \
53 { \
54 for (auto j : DisCosTiC::getRange(vec[i].size())) \
55 { \
56 std::cout << "[" << i << "][" << j << "]:" \
57 << "\t label = " << vec[i][j].first << "\t AST_OP info : "; \
58 print_DeserialNodeT(+vec[i][j].second); \
59 } \
60 } \
61 }
62
63#define print_pairedVecNonPointer2T(vec) \
64 { \
65 for (auto i : DisCosTiC::getRange(vec.size())) \
66 for (auto j : DisCosTiC::getRange(vec[i].size())) \
67 std::cout << "[" << i << "][" << j << "]:" \
68 << "\t label = " << vec[i][j].first << "\t AST_OP info : "; \
69 print_DeserialNodeNonPointerT(+vec[i][j].second); \
70 } \
71 } \
72 }
73
74#define print_pairedVec_NonPointer2T(vec) \
75 { \
76 for (auto i : DisCosTiC::getRange(vec.size())) \
77 { \
78 for (auto j : DisCosTiC::getRange(vec[i].size())) \
79 { \
80 std::cout << "[" << i << "][" << j << "]:" \
81 << "\t label = " << vec[i][j].first << "\t AST_OP info : "; \
82 print_AST_OP_NonPointerT(+vec[i][j].second); \
83 } \
84 } \
85 }
86
87/*
88 * \brief the print of the first value of 2 dimensional paired vector
89 * \return print/read second value of 2D paired vector
90 */
91#define itFirst_Vec2T(vec) \
92 { \
93 for (auto &row : vec) \
94 { \
95 for (auto &col : row) \
96 std::cout << col.first << std::endl; \
97 } \
98 }
99/*for(vector< vector<int> >::iterator row = vec.begin(); row != vec.end(); ++row) {
100 for(vector<int>::iterator col = row->begin(); col != row->end(); ++col) {
101 std::cout << *col.first << std::endl; }
102}*/
103
104/*
105 * \brief the print of the second value of 2 dimensional paired vector
106 * \return read second value of 2D paired vector
107 */
108#define iqueueOpecond_Vec2T(vec) \
109 { \
110 for (auto &row : vec) \
111 { \
112 for (auto &col : row) \
113 col.second; \
114 } \
115 }
116
117/*
118 * \brief Return the print of the 3 dimensional vector
119 * \return print 3D vector
120 */
121#define print_vec3T(vec) \
122 { \
123 for (auto i : DisCosTiC::getRange(vec[0].size())) \
124 { \
125 for (auto j : DisCosTiC::getRange(vec[i].size())) \
126 { \
127 for (auto k : DisCosTiC::getRange(vec[j].size())) \
128 { \
129 std::cout << "[" << i << "][" << j << "][" << k << "]=" << vec[i][j][k] << std::endl; \
130 } \
131 } \
132 } \
133 }
134
135/*
136 * \brief print of the Operation struct type
137 */
138// for(DisCosTiC::VecOperation::iterator op=operations.begin(); op != operations.end(); ++op) {
139#define print_OpPropertiesT(op) \
140 { \
141 std::cout << "time: " << op->time \
142 << " starttime: " << op->starttime \
143 << " syncstart: " << op->syncstart \
144 << " numOpsInQueue: " << op->numOpsInQueue \
145 << " bufSize: " << op->bufSize \
146 << " target: " << op->target \
147 << " rank: " << op->rank \
148 << " label: " << op->label \
149 << " tag: " << op->tag \
150 << " node: " << +op->node \
151 << " network: " << +op->network \
152 << " type: " << +op->type << std::endl; \
153 }
154
155/*
156 * \brief print of the non-pointer Operation struct type
157 */
158#define print_OpPropertiesNonPointerT(op) \
159 { \
160 std::cout << " rank: " << op.rank \
161 << " time: " << op.time \
162 << " starttime: " << op.starttime \
163 << " syncstart: " << op.syncstart \
164 << " numOpsInQueue: " << op.numOpsInQueue \
165 << " bufSize: " << op.bufSize \
166 << " target: " << op.target << " label: " << op.label \
167 << " tag: " << op.tag \
168 << " node: " << +op.node \
169 << " network: " << +op.network \
170 << " type: " << +op.type \
171 << " mode : " << +op.mode << std::endl; \
172 }
173
174/*
175 * \brief print of the DeserialNodeT struct type
176 */
177#define print_DeserialNodeT(op) \
178 { \
179 std::cout << "DepOperations: " << op->DepOperations.size() \
180 << " IdepOperations: " << op->IdepOperations.size() \
181 << " depCount: " << op->depCount \
182 << " target: " << op->target \
183 << " label: " << op->label \
184 << " tag: " << op->tag \
185 << " node: " << +op->node \
186 << " network: " << +op->network \
187 << " type: " << +op->type \
188 << " bufSize: " << op->bufSize \
189 << std::endl; \
190 }
191
192/*
193 * \brief print of the non-pointer DeserialNodeT struct type
194 */
195#define print_DeserialNodeNonPointerT(op) \
196 { \
197 std::cout << "DepOperations.size(): " << op.DepOperations.size() \
198 << " IdepOperations.size(): " << op.IdepOperations.size() \
199 << " depCount: " << op.depCount \
200 << " target: " << op.target \
201 << " label: " << op.label \
202 << " tag: " << op.tag \
203 << " node: " << +op.node \
204 << " network: " << +op.network \
205 << " type: " << +op.type \
206 << " bufSize: " << op.bufSize \
207 << std::endl; \
208 }
209
210/*
211 * \brief print of the non-pointer DeserialNodeT struct type
212 */
213#define print_AST_OP_NonPointerT(op) \
214 { \
215 std::cout << "num_deps: " << op.num_deps \
216 << " deps_startlabel_in_apdx: " << op.deps_startlabel_in_apdx \
217 << " num_startdeps.bufSize(): " << op.num_startdeps \
218 << " startdeps_startlabel_in_apdx: " << op.startdeps_startlabel_in_apdx \
219 << " depCount: " << op.depCount \
220 << " target: " << op.target \
221 << " label: " << op.label \
222 << " tag: " << op.tag \
223 << " node: " << +op.node \
224 << " network: " << +op.network \
225 << " type: " << +op.type \
226 << " bufSize: " << op.bufSize \
227 << std::endl; \
228 }
229
233#define fileopen(myfile, filename) \
234 { \
235 try \
236 { \
237 myfile.open(filename); \
238 } \
239 catch (std::ifstream::failure const &e) \
240 { \
241 std::cerr << "error: opening file definition of " \
242 << this->filename << " for reading, with message '" \
243 << e.what() << std::endl; \
244 std::exit(EXIT_FAILURE); \
245 } \
246 }
247
251#define fileclose(myfile, filename) \
252 { \
253 if (myfile.is_open()) \
254 { \
255 try \
256 { \
257 myfile.close(); \
258 } \
259 catch (std::ofstream::failure const &e) \
260 { \
261 std::cerr << "error: closing file definition of " << this->filename << " for writing" << std::endl; \
262 std::exit(EXIT_FAILURE); \
263 } \
264 } \
265 }
266
271#define AppendString(str, content) \
272 { \
273 this->content.append(str); \
274 }
275
280#define toCharPointer(content) \
281 { \
282 const_cast<char *>(("l" + std::to_string(content)).c_str()) \
283 }
284
288#define max_vec1T(vec) \
289 { \
290 DisCosTiC_Datatype max = 0; \
291 for (auto i : DisCosTiC::getRange(vec.size())) \
292 max = std::max(max, vec[i].size()); \
293 std::cout << max; \
294 }
295
299#define progessPrint(progress, qCounter, q1, q2, q3) \
300 { \
301 std::cout << "Discostic Progress: " << progress \
302 << " % (queue counter: " << qCounter << ") "; \
303 std::cout << "[Queue bufSize: " << q1.size() << " Max Receive Queue bufSize: "; \
304 max_vec1T(q2); \
305 std::cout << " Max Unexpected Message Queue bufSize: "; \
306 max_vec1T(q3); \
307 std::cout << "]" << std::endl; \
308 }
309
313#define queues_empty_check(check, q) \
314 for (auto rank : DisCosTiC::getRange(numRanks)) \
315 { \
316 if (!q[rank].empty()) \
317 { \
318 std::cerr << " queue on rank " << rank \
319 << " contains " << q[rank].size() \
320 << " operations!"; \
321 for (DisCosTiC::ListqueueOp::iterator iter = q[rank].begin(); iter != q[rank].end(); ++iter) \
322 std::cerr << "\t [ source ==> " << iter->src \
323 << ", tag ==> " << iter->tag \
324 << "]" << std::endl; \
325 check = false; \
326 } \
327 }
328
332#define allRanksTime(numRanks, nexto) \
333 std::cout << "\nFULL APPLICATION PERFORMANCE (for all ranks):" << std::endl; \
334 std::cout << "----------------------------------------------------------------" << std::endl; \
335 std::cout << "rank runtime [ns] runtime [s]" << std::endl; \
336 std::cout << "----------------------------------------------------------------" << std::endl; \
337 for (auto rank : DisCosTiC::getRange(numRanks)) \
338 { \
339 DisCosTiC_Timetype maxo = *(std::max_element(nexto[rank].begin(), nexto[rank].end())); \
340 std::cout << rank << " " << maxo << " " << maxo / 1e9 << std::endl; \
341 }
342
346#define slowRankTime(numRanks, nexto) \
347 std::cout << "\nFULL APPLICATION PERFORMANCE (for slowest rank):" << std::endl; \
348 DisCosTiC_Timetype max = 0; \
349 DisCosTiC_Datatype rank = 0; \
350 for (auto rank : DisCosTiC::getRange(numRanks)) \
351 { \
352 DisCosTiC_Timetype maxo = *(std::max_element(nexto[rank].begin(), nexto[rank].end())); \
353 DisCosTiC_Timetype cur = maxo; \
354 if (cur > max) \
355 { \
356 rank = rank; \
357 max = cur; \
358 } \
359 } \
360 std::cout << "----------------------------------------------------------------" << std::endl; \
361 std::cout << "rank runtime [ns] runtime [s]" << std::endl; \
362 std::cout << "----------------------------------------------------------------" << std::endl; \
363 std::cout << rank << " \t\t " << max << " \t\t " << max / 1e9 << std::endl;
364
368#define verboseCompInitPrint(rank, operation) \
369 std::cout << "initialize rank: " << rank \
370 << " [ node: " << +operation.node \
371 << ", network: " << +operation.network \
372 << "] computation: " << operation.bufSize << std::endl;
373
374#define verboseCompFinalPrint(rank, operation) \
375 std::cout << "rank: " << rank \
376 << " [ node: " << +operation.node \
377 << ", network: " << +operation.network \
378 << "] computation: " << operation.bufSize \
379 << ", time: " << operation.time \
380 << ", label: " << operation.label << std::endl;
381
382#define verboseSendInitPrint(rank, operation) \
383 std::cout << "initialize rank: " << rank \
384 << " [ node: " << +operation.node \
385 << ", network: " << +operation.network \
386 << "] send to: " << operation.target \
387 << "tag: " << operation.tag \
388 << " bufSize: " << operation.bufSize << std::endl;
389
390#define verboseSendFinalPrint(rank, operation) \
391 std::cout << "rank: " << rank \
392 << " [ node: " << +operation.node \
393 << ", network: " << +operation.network \
394 << "] send to: " << operation.target \
395 << ", tag: " << operation.tag \
396 << ", bufSize: " << operation.bufSize \
397 << ", time: " << operation.time \
398 << ", label: " << operation.label << std::endl;
399
400#define verboseRecvInitPrint(rank, operation) \
401 std::cout << "initialize rank: " << rank \
402 << " [ node: " << +operation.node \
403 << ", network: " << +operation.network \
404 << "] receive from: " << operation.target \
405 << "tag: " << operation.tag \
406 << " bufSize: " << operation.bufSize << std::endl;
407
408#define verboseRecvFinalPrint(rank, operation) \
409 std::cout << "rank: " << rank \
410 << " [ node: " << +operation.node \
411 << ", network: " << +operation.network \
412 << "] receive from: " << operation.target \
413 << ", tag: " << operation.tag \
414 << ", bufSize: " << operation.bufSize \
415 << ", time: " << operation.time \
416 << ", label: " << operation.label << std::endl;
417
418#define verboseCompPrint(operation) \
419 { \
420 std::cout << "\n[rank: " << operation.rank \
421 << ", node: " << +operation.node \
422 << "]:" << std::endl; \
423 std::cout << "local operation bufSize= " << operation.bufSize \
424 << " ns, total time= " << operation.time \
425 << " ns" << std::endl; \
426 }
427
428#define verboseSendPrint(operation) \
429 { \
430 std::cout << "\n[rank: " << operation.rank \
431 << ", node: " << +operation.node \
432 << "]:" << std::endl; \
433 std::cout << "send to rank " << operation.target \
434 << ", total time= " << operation.time \
435 << " ns" << std::endl; \
436 }
437
438#define verboseSendIrequiresPrint(operation) \
439 { \
440 std::cout << "satisfy local non-blocking dependencies" << std::endl; \
441 std::cout << "send inserting msg to rank " << operation.rank \
442 << ", total time= " << operation.time << " ns" << std::endl; \
443 }
444
445#define verboseEagerSendPrint(o, operation) \
446 std::cout << "eager satisfy local requires at total time = " << operation.starttime + o \
447 << " ns" << std::endl;
448
449#define verboseRendezvousSendPrint(operation) \
450 std::cout << "start rendezvous message to: " << operation.rank \
451 << " (label: " << operation.label \
452 << ")" << std::endl;
453
454#define verboseRecvPrint(operation) \
455 { \
456 std::cout << "\n[rank: " << operation.rank \
457 << ", node: " << +operation.node \
458 << "]:" << std::endl; \
459 std::cout << "receive from rank " << operation.target \
460 << " , total time= " << operation.time \
461 << " ns" << std::endl; \
462 }
463
464#define verboseRendezvousRecvPrint(operation) \
465 std::cout << "satisfy remote requires at rank " << operation.target \
466 << " (label: " << operation.label \
467 << ")" << std::endl;
468
469#define verboseMsgPrint(operation, oSuccessor, grSuccessor) \
470 { \
471 std::cout << "\n[rank: " << operation.rank \
472 << ", node: " << +operation.node \
473 << "]:" << std::endl; \
474 std::cout << "receive msg from rank " << operation.target \
475 << ", total time= " << operation.time \
476 << " ns" << std::endl; \
477 std::cout << "o= " << oSuccessor[operation.rank][operation.node] \
478 << " ns, successor gr= " << grSuccessor[operation.rank][operation.network] \
479 << " ns" << std::endl; \
480 }
481
482#define help() \
483 { \
484 version() \
485 std::cout \
486 << "\n==================================================" << std::endl \
487 << " Parameter for config.cfg" << std::endl \
488 << "==================================================" << std::endl \
489 << std::endl; \
490 std::cout \
491 << "\t task_per_node" \
492 << "\t\t\t number of runing processes on one node" << std::endl; \
493 std::cout \
494 << "\t number_of_processes" \
495 << "\t\t number of runing processes on all nodes" << std::endl; \
496 std::cout \
497 << "\t idlewave" \
498 << "\t\t\t 1 to insert delay and create idlewave." << std::endl; \
499 std::cout \
500 << "\t which_rank" \
501 << "\t\t\t which rank should introduce the disturbance" << std::endl; \
502 std::cout \
503 << "\t at_timestep" \
504 << "\t\t\t at which timestep the given rank should introduce the disturbance" << std::endl; \
505 std::cout \
506 << "\t desync" \
507 << "\t\t\t\t 0 to turn off the desynchronization feature and 1 to turn on." << std::endl; \
508 std::cout \
509 << "\t comm_model" \
510 << "\t\t\t 0 for LogGP model and 1 for HOCKNEY model" << std::endl; \
511 std::cout \
512 << "\t filename" \
513 << "\t\t\t [optional: for debug puspose] output file name that contain details of the generated graph" << std::endl; \
514 std::cout \
515 << "\t timeunit_conv" \
516 << "\t\t\t time multiplier for conversation from baseline unit of nanoseconds to some other unit" << std::endl; \
517 std::cout \
518 << "\t chromevizfilename" \
519 << "\t\t the name of the output file contains all time rank tracing data for visulization with Chrome tracing browser" << std::endl; \
520 std::cout \
521 << "\t Verbose" \
522 << "\t\t\t enable/disable more verbose output (0=disable, 1=enable)" << std::endl; \
523 std::cout \
524 << "\t batchmode" \
525 << "\t\t\t enable/disable batchmode (0=disable i.e., printing performance for each rank, 1=enable i.e., never print detailed all rank info)" << std::endl; \
526 std::cout \
527 << "\t micro_architecture" \
528 << "\t\t\t " << std::endl; \
529 std::cout \
530 << "\t FP_instructions_per_cycle" \
531 << "\t\t\t " << std::endl; \
532 std::cout \
533 << "\t benchmark_kernel" \
534 << "\t\t\t " << std::endl; \
535 std::cout \
536 << "\t P2P_mode" \
537 << "\t\t\t choose either of FILE, SRC, LBL, SRC modes. Concatenated with benchmark kernel during runtime to determine which P2P file to use." << std::endl; \
538 std::cout \
539 << "\t FLOPs_per_iteration" \
540 << "\t\t number of flops in one iteration" << std::endl; \
541 std::cout \
542 << "\t R_streams" \
543 << "\t\t\t number of read streams" << std::endl; \
544 std::cout \
545 << "\t W_streams" \
546 << "\t\t\t number of write streams" << std::endl; \
547 std::cout \
548 << "\t datasize_in_GB" \
549 << "\t\t\t number of array elements * (R_streams + W_streams) * size of datatype" << std::endl; \
550 std::cout \
551 << "\t penalty" \
552 << "\t\t\t penalty in nanoseconds. Used only in LBL and COMP mode." << std::endl; \
553 std::cout \
554 << "\t compiler-flags" \
555 << "\t\t\t " << std::endl; \
556 std::cout \
557 << "\t pmodel" \
558 << "\t\t\t " << std::endl; \
559 std::cout \
560 << "\t vvv" \
561 << "\t\t\t " << std::endl; \
562 std::cout \
563 << "\t cache-predictor" \
564 << "\t\t\t " << std::endl; \
565 std::cout \
566 << "\n\t Other user defined P2P file parameters for domain size etc. etc." \
567 << std::endl; \
568 }
569#define version() \
570 { \
571 std::cout << "\nDistributed CosT in Cluster ( DisCosTiC )" << std::endl; \
572 std::cout << "Version : v2.0.0 (second release)" << std::endl; \
573 std::cout << "Author : Ayesha Afzal <ayesha.afzal@fau.de>" << std::endl; \
574 std::cout << "Copyright : 2023 HPC, FAU Erlangen-Nuremberg. All rights reserved" << std::endl; \
575 }
576#endif
std::size_t DisCosTiC_Indextype
Definition DataType.hpp:53
static const DisCosTiC_Indextype MPI_ANY_SOURC
Definition macro.hpp:16
static const DisCosTiC_Indextype INVALID_ID
< data types
Definition macro.hpp:15
static const DisCosTiC_Indextype MPI_ANY_TA
Definition macro.hpp:17