40 #include <SkelCL/IndexVector.h>
41 #include <SkelCL/IndexMatrix.h>
42 #include <SkelCL/Matrix.h>
43 #include <SkelCL/Vector.h>
49 class DistributionTest :
public ::testing::Test {
61 TEST_F(DistributionTest, DefaultDistribution)
63 auto dist = skelcl::detail::Distribution< skelcl::Vector<int> >();
65 EXPECT_FALSE(dist.isValid());
68 TEST_F(DistributionTest, SingleDistribution)
70 auto single = skelcl::detail::SingleDistribution< skelcl::Vector<int> >();
72 EXPECT_TRUE(single.isValid());
73 EXPECT_EQ(1, single.devices().size());
74 EXPECT_EQ(skelcl::detail::globalDeviceList[0].
get(),
75 single.device(0).get());
78 TEST_F(DistributionTest, SingleDistribution2)
83 EXPECT_TRUE(single !=
nullptr);
84 EXPECT_TRUE(single->isValid());
85 EXPECT_EQ(1, single->devices().size());
86 EXPECT_EQ(skelcl::detail::globalDeviceList[0].
get(),
87 single->device(0).get());
90 TEST_F(DistributionTest, SingleDistribution3)
97 EXPECT_TRUE(dist.isValid());
98 EXPECT_EQ(1, dist.devices().size());
99 EXPECT_EQ(skelcl::detail::globalDeviceList[0].
get(),
100 dist.device(0).get());
103 TEST_F(DistributionTest, SingleDistribution4)
110 EXPECT_TRUE(dist.isValid());
111 EXPECT_EQ(1, dist.devices().size());
112 EXPECT_EQ(skelcl::detail::globalDeviceList[0].
get(),
113 dist.device(0).get());
116 TEST_F(DistributionTest, SingleDistribution5)
121 auto& dist = mi.distribution();
123 EXPECT_TRUE(dist.isValid());
124 EXPECT_EQ(1, dist.devices().size());
125 EXPECT_EQ(skelcl::detail::globalDeviceList[0].
get(),
126 dist.device(0).get());
129 TEST_F(DistributionTest, SingleDistribution6)
134 auto& dist = mi.distribution();
136 EXPECT_TRUE(dist.isValid());
137 EXPECT_EQ(1, dist.devices().size());
138 EXPECT_EQ(skelcl::detail::globalDeviceList[0].
get(),
139 dist.device(0).get());
142 TEST_F(DistributionTest, SingleDistribution7)
147 auto& dist = iv.distribution();
149 EXPECT_TRUE(dist.isValid());
150 EXPECT_EQ(1, dist.devices().size());
151 EXPECT_EQ(skelcl::detail::globalDeviceList[0].
get(),
152 dist.device(0).get());
155 TEST_F(DistributionTest, SingleDistribution8)
160 auto& dist = im.distribution();
162 EXPECT_TRUE(dist.isValid());
163 EXPECT_EQ(1, dist.devices().size());
164 EXPECT_EQ(skelcl::detail::globalDeviceList[0].
get(),
165 dist.device(0).get());
168 TEST_F(DistributionTest, BlockDistribution)
172 auto block = skelcl::detail::BlockDistribution< skelcl::Vector<int> >();
174 EXPECT_TRUE(block.isValid());
175 EXPECT_EQ(skelcl::detail::globalDeviceList.size(),
176 block.devices().size());
178 for (
auto iter = skelcl::detail::globalDeviceList.begin();
179 iter != skelcl::detail::globalDeviceList.end();
181 EXPECT_EQ( iter->get(), block.device(i++).get() );
185 TEST_F(DistributionTest, BlockDistribution2)
190 EXPECT_TRUE(block !=
nullptr);
191 EXPECT_TRUE(block->isValid());
192 EXPECT_EQ(skelcl::detail::globalDeviceList.size(),
193 block->devices().size());
195 for (
auto iter = skelcl::detail::globalDeviceList.begin();
196 iter != skelcl::detail::globalDeviceList.end();
198 EXPECT_EQ( iter->get(), block->device(i++).get() );
202 TEST_F(DistributionTest, BlockDistribution3)
209 EXPECT_TRUE(dist.isValid());
210 EXPECT_EQ(skelcl::detail::globalDeviceList.size(),
211 dist.devices().size());
213 for (
auto iter = skelcl::detail::globalDeviceList.begin();
214 iter != skelcl::detail::globalDeviceList.end();
216 EXPECT_EQ( iter->get(), dist.device(i++).get() );
220 TEST_F(DistributionTest, BlockDistribution4)
227 EXPECT_TRUE(dist.isValid());
228 EXPECT_EQ(skelcl::detail::globalDeviceList.size(),
229 dist.devices().size());
231 for (
auto iter = skelcl::detail::globalDeviceList.begin();
232 iter != skelcl::detail::globalDeviceList.end();
234 EXPECT_EQ( iter->get(), dist.device(i++).get() );
238 TEST_F(DistributionTest, BlockDistribution5)
243 auto& dist = mi.distribution();
245 EXPECT_TRUE(dist.isValid());
246 EXPECT_EQ(skelcl::detail::globalDeviceList.size(),
247 dist.devices().size());
249 for (
auto iter = skelcl::detail::globalDeviceList.begin();
250 iter != skelcl::detail::globalDeviceList.end();
252 EXPECT_EQ( iter->get(), dist.device(i++).get() );
256 TEST_F(DistributionTest, BlockDistribution6)
261 auto& dist = mi.distribution();
263 EXPECT_TRUE(dist.isValid());
264 EXPECT_EQ(skelcl::detail::globalDeviceList.size(),
265 dist.devices().size());
267 for (
auto iter = skelcl::detail::globalDeviceList.begin();
268 iter != skelcl::detail::globalDeviceList.end();
270 EXPECT_EQ( iter->get(), dist.device(i++).get() );
274 TEST_F(DistributionTest, CopyDistribution)
278 auto copy = skelcl::detail::CopyDistribution< skelcl::Vector<int> >();
280 EXPECT_TRUE(copy.isValid());
281 EXPECT_EQ(skelcl::detail::globalDeviceList.size(),
282 copy.devices().size());
284 for (
auto iter = skelcl::detail::globalDeviceList.begin();
285 iter != skelcl::detail::globalDeviceList.end();
287 EXPECT_EQ( iter->get(), copy.device(i++).get() );
291 TEST_F(DistributionTest, CopyDistribution2)
296 EXPECT_TRUE(copy !=
nullptr);
297 EXPECT_TRUE(copy->isValid());
298 EXPECT_EQ(skelcl::detail::globalDeviceList.size(),
299 copy->devices().size());
301 for (
auto iter = skelcl::detail::globalDeviceList.begin();
302 iter != skelcl::detail::globalDeviceList.end();
304 EXPECT_EQ( iter->get(), copy->device(i++).get() );
308 TEST_F(DistributionTest, CopyDistribution3)
315 EXPECT_TRUE(dist.isValid());
316 EXPECT_EQ(skelcl::detail::globalDeviceList.size(),
317 dist.devices().size());
319 for (
auto iter = skelcl::detail::globalDeviceList.begin();
320 iter != skelcl::detail::globalDeviceList.end();
322 EXPECT_EQ( iter->get(), dist.device(i++).get() );
326 TEST_F(DistributionTest, CopyDistribution4)
333 EXPECT_TRUE(dist.isValid());
334 EXPECT_EQ(skelcl::detail::globalDeviceList.size(),
335 dist.devices().size());
337 for (
auto iter = skelcl::detail::globalDeviceList.begin();
338 iter != skelcl::detail::globalDeviceList.end();
340 EXPECT_EQ( iter->get(), dist.device(i++).get() );
344 TEST_F(DistributionTest, CopyDistribution5)
349 auto& dist = mi.distribution();
351 EXPECT_TRUE(dist.isValid());
352 EXPECT_EQ(skelcl::detail::globalDeviceList.size(),
353 dist.devices().size());
355 for (
auto iter = skelcl::detail::globalDeviceList.begin();
356 iter != skelcl::detail::globalDeviceList.end();
358 EXPECT_EQ( iter->get(), dist.device(i++).get() );
362 TEST_F(DistributionTest, CopyDistribution6)
367 auto& dist = mi.distribution();
369 EXPECT_TRUE(dist.isValid());
370 EXPECT_EQ(skelcl::detail::globalDeviceList.size(),
371 dist.devices().size());
373 for (
auto iter = skelcl::detail::globalDeviceList.begin();
374 iter != skelcl::detail::globalDeviceList.end();
376 EXPECT_EQ( iter->get(), dist.device(i++).get() );
The Matrix class is a two dimensional container which makes its data accessible on the host as well a...
void setSingle(const C< T > &c)
This function sets the distribution of the given container to the SingleDistribution using the defaul...
void setDistribution(const detail::Distribution< Vector< U >> &distribution) const
Set a new distribution to the vector.
SKELCL_DLL void init(detail::DeviceProperties properties=allDevices())
Initializes the SkelCL library. This function (or another init function) has to be called prior to ev...
std::unique_ptr< skelcl::detail::Distribution< C< T > > > Block(const C< T > &c)
Factory function to create a BlockDistribution with the types of the given container.
SKELCL_DLL detail::DeviceProperties nDevices(size_t n)
Creates a detail::DeviceProperties object representing n devices. This object should be used as param...
void setBlock(const C< T > &c)
This function sets the distribution of the given container to the BlockDistribution.
detail::Distribution< Vector< T > > & distribution() const
Returns the current distribution of the vector.
The Vector class is a one dimensional container which makes its data accessible on the host as well a...
std::unique_ptr< skelcl::detail::Distribution< C< T > > > Copy(const C< T > &c, typename identity< std::function< T(const T &, const T &)>>::type combineFunc=nullptr)
Factory function to create a CopyDistribution with the types of the given container.
SKELCL_DLL void terminate()
Frees all resources allocated internally by SkelCL.
The IndexVector (a.k.a. Vector) class is a special implementation of a Vector with Elements of...
void setCopy(const C< T > &c, std::function< T(const T &, const T &)> combineFunc=nullptr)
This function sets the distribution of the given container to the CopyDistribution.
std::unique_ptr< skelcl::detail::Distribution< C< T > > > Single(const C< T > &c)
Factory function to create a SingleDistribution with the types of the given container and for the def...
The IndexMatrix (a.k.a. Matrix) class is a special implementation of a Matrix with Elemen...