-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdomain_v1.hpp
152 lines (136 loc) · 3.3 KB
/
domain_v1.hpp
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#include <hpx/config.hpp>
//#include <hpx/traits/is_domain.hpp>
#include <utility>
#include <vector>
namespace hpx{
namespace reimplement{
struct domain{
public:
domain()
{
HPX_ASSERT(false);
}
explicit domain(std::size_t const& first_ , std::size_t const & last_ )
:
boundary (std::make_pair(first_, last_)),
range(last_ - first_)
{
static_assert(last_ > first_ ,"Wrong domain range is specified");
}
explicit domain(std::size_t && first_, std::size_t && last_ ) :
:
boundary(std::make_pair(first_, last_ )),
range(last_ - first_)
{
static_assert(last_ > first_, "Wrong domain range is specified");
}
explicit domain(std::pair<std::size_t,std::size_t> const& pair)
:
boundary(pair),
range(pair.second - pair.first)
{
static_assert(pair.second > pair.first, "wrong domain range is specified");
}
bool find(const std::size_t&value) const
{
if(value >= boundary.first && value <= boundary.second)
return true;
else
return false;
}
unsigned int first() const
{
return boundary.first;
}
unsigned int last() const
{
return boundary.second;
}
unsigned int next(const unsigned int a) const
{
if(find(a) && a != last())
return a++;
else
HPX_ASSERT_MSG(false,"Next operation exceeds boundary");
}
std::size_t size() const
{
return range;
}
hpx::id_type residing_locality() const
{
return hpx::find_here();
}
};
}
namespace reimplement{
struct block_partitioned_domain
{
struct block_sub_domain
{
std::pair<unsigned int, unsigned int> part;
std::size_t size;
block_sub_domain()
{
}
block_sub_domain(unsigned int const& start, unsigned int const& end)
:
part(std::make_pair(start,end)),
size(end - start)
{}
};
std::size_t size() const
{
return holder.size();
}
private:
std::vector<block_sub_domain> holder;
};
struct block_cyclic_partitioned_domain
{
struct block_cyclic_domain
{
std::vector<std::pair<unsigned int, unsigned int> > part;
block_cyclic_domain()
{}
block_cyclic_domain(std::pair<unsigned int, unsigned int> const& pairs)
:
part(pairs)
{}
void add_pairs(std::pair<unsigned int, unsigned int> const& pairs)
{
part.emplace_back(pairs);
}
};
std::size_t size() const
{
return holder.size();
}
private:
std::vector<block_cyclic_domain> holder;
};
struct cyclic_partitioned_domain
{
struct cyclic_domain
{
std::vector<unsigned int> part;
cyclic_domain()
{}
cyclic_domain(unsigned int const& index)
:
part(index)
{}
void add_index(unsigned int const& idx)
{
part.emplace_back(idx);
}
};
private:
std::vector<cyclic_domain> holder;
public:
std::size_t size() const
{
return holder.size();
}
};
}