DisCostiC v2.0.0
Distributed Cost in Cluster: a cross-architecture simulator for massively parallel MPI programs
Loading...
Searching...
No Matches
DataType.hpp
Go to the documentation of this file.
1
7#ifndef DataType_HPP
8#define DataType_HPP
9
10#include <set>
11#include <vector>
12
13#include "enum.hpp"
14
15namespace DataType{
16
20 template <typename Tx, typename Ty, typename Tz>
21 class vector3T {
22 public:
24 Tx type;
25 Ty addr;
26 Tz size;
27
29 vector3T() : type(0), addr(0), size(0) {};
30
31 vector3T(const vector3T &elem) : type(elem.type), addr(elem.addr), size(elem.size) {};
32
33 vector3T(Tx t, Ty a, Tz s) : type(t), addr(a), size(s) {};
34
39 vector3T& operator=(const vector3T &elem) {
40 type = elem.type;
41 addr = elem.addr;
42 size = elem.size;
43 return *this;
44 };
45 };
46}
47
48using real_t = double;
49using size_t = std::size_t;
50
51using DisCosTiC_Timetype = double;//unsigned long int;
52using DisCosTiC_Datatype = std::size_t;
53using DisCosTiC_Indextype = std::size_t;
54using idSetT = std::set<DisCosTiC_Indextype>;
55//using idMapT = std::map<unsigned long,DisCosTiC_Indextype>;
56
57
58using vec1T = std::vector<DisCosTiC_Indextype>;
59using Time = std::vector<DisCosTiC_Timetype>;
60using Real = std::vector<real_t>;
61using Timevec2T = std::vector<std::vector<DisCosTiC_Timetype>>;
63using locop_t = std::vector<std::pair<DisCosTiC_Indextype, DisCosTiC::Mode_t> >;
64using locopPair_t = std::pair<locop_t, locop_t>;
65
66namespace DisCosTiC{
68template <typename scalarT>
69struct std_iter : std::iterator<std::input_iterator_tag, scalarT>{
70 std_iter(scalarT it) : it(it) { }
71
72 scalarT operator *() const { return it; }
73
74 scalarT const* operator ->() const { return &it; }
75
77 ++it;
78 return *this;
79 }
80
82 auto tmp = *this;
83 ++*this;
84 return tmp;
85 }
86
87 bool operator ==(std_iter const& other) const {
88 return it == other.it;
89 }
90
91 bool operator !=(std_iter const& other) const {
92 return not (*this == other);
93 }
94
95protected:
96 scalarT it;
97};
98
102template <typename scalarT>
106 struct iter : std_iter<scalarT> {
107 iter(scalarT it, scalarT stepSize): std_iter<scalarT>(it), stepSize(stepSize) { }
108
111 return *this;
112 }
113
115 auto tmp = *this;
116 ++*this;
117 return tmp;
118 }
119
120 bool operator ==(iter const& other) const {
121 return stepSize > 0 ? std_iter<scalarT>::it >= other.it: std_iter<scalarT>::it < other.it;
122 }
123
124 bool operator !=(iter const& other) const {
125 return not (*this == other);
126 }
127
128 protected:
129 scalarT stepSize;
130 };
131
133
134 iter begin() const { return begin_; }
135
136 iter end() const { return end_; }
137
138 private:
141 }; // end of iteratorRangeStep struct
142
144
145 struct iter : std_iter<scalarT>{
146 iter(scalarT it) : std_iter<scalarT>(it) { }
147 };
148
149 iteratorRange(scalarT begin, scalarT end) : begin_(begin), end_(end) { }
150
151 iter begin() const{ return begin_; }
152
153 iter end() const { return end_; }
154
155 private:
158}; // end of iteratorRange struct
159
160template <typename scalarT>
161iteratorRange<scalarT> getRange(scalarT begin, scalarT end) {
162 return {begin, end};
163}
164
165template <typename scalarT>
167 return {0, end};
168}
169} //namespace DisCosTiC
170
171#endif
std::vector< real_t > Real
Definition DataType.hpp:60
std::size_t DisCosTiC_Indextype
Definition DataType.hpp:53
std::vector< DisCosTiC_Timetype > Time
Definition DataType.hpp:59
std::vector< std::vector< DisCosTiC_Timetype > > Timevec2T
Definition DataType.hpp:61
std::size_t size_t
Definition DataType.hpp:49
std::pair< locop_t, locop_t > locopPair_t
Definition DataType.hpp:64
std::size_t DisCosTiC_Datatype
Definition DataType.hpp:52
std::vector< std::pair< DisCosTiC_Indextype, DisCosTiC::Mode_t > > locop_t
identify local operations for dependencies
Definition DataType.hpp:63
std::vector< DisCosTiC_Indextype > vec1T
Definition DataType.hpp:58
double real_t
Definition DataType.hpp:48
double DisCosTiC_Timetype
Definition DataType.hpp:51
std::set< DisCosTiC_Indextype > idSetT
Definition DataType.hpp:54
a class to represent fixed-size three-dimensional vector data-type of arbitrary types with coefficien...
Definition DataType.hpp:21
vector3T(const vector3T &elem)
Definition DataType.hpp:31
vector3T(Tx t, Ty a, Tz s)
Definition DataType.hpp:33
vector3T & operator=(const vector3T &elem)
a operator=() member
Definition DataType.hpp:39
Tz size
size of data to read/write (referenced by the address addr) in bytes
Definition DataType.hpp:26
Tx type
public variables type, addr, size in three-dimensional of integer and btime_t datatype
Definition DataType.hpp:24
Ty addr
actual address in memory where to read/write
Definition DataType.hpp:25
vector3T()
constructors
Definition DataType.hpp:29
< enumerated types
Definition DataType.hpp:15
< benchmark test cases
iteratorRange< scalarT > getRange(scalarT begin, scalarT end)
Definition DataType.hpp:161
wrapper class of range-based for loop with certain step size
Definition DataType.hpp:105
iteratorRangeStep(scalarT begin, scalarT end, scalarT stepSize)
Definition DataType.hpp:132
iterator ranges for each entityTypes to support iteration with range-based for loops....
Definition DataType.hpp:103
iter begin() const
returns an iterator pointing to the begin of the range
Definition DataType.hpp:151
iteratorRange(scalarT begin, scalarT end)
Constructs an iterator range on [begin,end)
Definition DataType.hpp:149
iter end() const
returns an iterator pointing past the end of the range
Definition DataType.hpp:153
iteratorRangeStep stepSize(scalarT stepSize)
Constructs an iterator range on [begin,end) with certain stepSize.
Definition DataType.hpp:143
a time stepping loop
Definition DataType.hpp:69
scalarT operator*() const
Definition DataType.hpp:72
scalarT const * operator->() const
Definition DataType.hpp:74
bool operator!=(std_iter const &other) const
Definition DataType.hpp:91
bool operator==(std_iter const &other) const
Definition DataType.hpp:87
std_iter & operator++()
Definition DataType.hpp:76
std_iter(scalarT it)
Definition DataType.hpp:70