8#ifndef SRC_PACKER_UNIT_TESTS_HPP_
9#define SRC_PACKER_UNIT_TESTS_HPP_
11#include "util/cudify/cudify.hpp"
12#include "Pack_selector.hpp"
14#include "Unpacker.hpp"
15#include "Grid/grid_util_test.hpp"
17#include "Vector/vector_test_util.hpp"
18#include "data_type/aggregate.hpp"
20BOOST_AUTO_TEST_SUITE( packer_unpacker )
22BOOST_AUTO_TEST_CASE ( packer_unpacker_test )
27 BOOST_REQUIRE_EQUAL(val,PACKER_PRIMITIVE);
29 BOOST_REQUIRE_EQUAL(val,PACKER_PRIMITIVE);
31 BOOST_REQUIRE_EQUAL(val,PACKER_PRIMITIVE);
33 BOOST_REQUIRE_EQUAL(val,PACKER_PRIMITIVE);
35 BOOST_REQUIRE_EQUAL(val,PACKER_PRIMITIVE);
37 BOOST_REQUIRE_EQUAL(val,PACKER_PRIMITIVE);
39 BOOST_REQUIRE_EQUAL(val,PACKER_PRIMITIVE);
41 BOOST_REQUIRE_EQUAL(val,PACKER_PRIMITIVE);
43 BOOST_REQUIRE_EQUAL(val,PACKER_PRIMITIVE);
45 BOOST_REQUIRE_EQUAL(val,PACKER_PRIMITIVE);
48 BOOST_REQUIRE_EQUAL(val,PACKER_OBJECTS_WITH_POINTER_CHECK);
52 BOOST_REQUIRE_EQUAL(val,PACKER_GENERAL);
54 BOOST_REQUIRE_EQUAL(val,PACKER_GRID);
56 BOOST_REQUIRE_EQUAL(val,PACKER_ENCAP_OBJECTS);
63 static bool noPointers() {
return true;}
67 BOOST_REQUIRE_EQUAL(val,PACKER_OBJECTS_WITH_POINTER_CHECK);
81 unsigned short us = 4;
85 unsigned long int uli = 8;
94 size_t sz[] = {16,16,16};
105 size_t size_total = 0;
106 size_t size_total_old = 0;
109 BOOST_REQUIRE_EQUAL(size_total,
sizeof(
unsigned char));
110 size_total_old = size_total;
113 BOOST_REQUIRE_EQUAL(size_total - size_total_old,
sizeof(
char));
114 size_total_old = size_total;
117 BOOST_REQUIRE_EQUAL(size_total - size_total_old,
sizeof(
short));
118 size_total_old = size_total;
121 BOOST_REQUIRE_EQUAL(size_total - size_total_old,
sizeof(
unsigned short));
122 size_total_old = size_total;
125 BOOST_REQUIRE_EQUAL(size_total - size_total_old,
sizeof(
int));
126 size_total_old = size_total;
129 BOOST_REQUIRE_EQUAL(size_total - size_total_old,
sizeof(
unsigned int));
130 size_total_old = size_total;
133 BOOST_REQUIRE_EQUAL(size_total - size_total_old,
sizeof(
long int));
134 size_total_old = size_total;
137 BOOST_REQUIRE_EQUAL(size_total - size_total_old,
sizeof(
long unsigned int));
138 size_total_old = size_total;
141 BOOST_REQUIRE_EQUAL(size_total - size_total_old,
sizeof(
float));
142 size_total_old = size_total;
145 BOOST_REQUIRE_EQUAL(size_total - size_total_old,
sizeof(
double));
146 size_total_old = size_total;
151 BOOST_REQUIRE_EQUAL(size_total - size_total_old,(
sizeof(
float)*4 +
sizeof(
float[3]) +
sizeof(
float[3][3])));
153 size_total_old = size_total;
157 BOOST_REQUIRE_EQUAL(size_total - size_total_old,(
sizeof(
float) +
sizeof(
float[3])) * v.size() +
sizeof(v.size()));
159 size_total_old = size_total;
163 BOOST_REQUIRE_EQUAL(size_total - size_total_old,(
sizeof(
float) +
sizeof(
float[3])) * sub.getVolume());
211 unsigned long int uli2;
224 v_test.resize(v.size());
229 BOOST_REQUIRE_EQUAL(uc2,uc);
230 BOOST_REQUIRE_EQUAL(c2,c);
231 BOOST_REQUIRE_EQUAL(s2,s);
232 BOOST_REQUIRE_EQUAL(us2,us);
233 BOOST_REQUIRE_EQUAL(i2,i);
234 BOOST_REQUIRE_EQUAL(ui2,ui);
235 BOOST_REQUIRE_EQUAL(li2,li);
236 BOOST_REQUIRE_EQUAL(uli2,uli);
237 BOOST_REQUIRE_EQUAL(f2,f);
238 BOOST_REQUIRE_EQUAL(d2,d);
240 bool val = (p_test == p);
241 BOOST_REQUIRE_EQUAL(
true,val);
243 auto it = v_test.getIterator();
247 float f1 = v_test.template get<pt::x>(it.get());
248 float f2 = v.template get<pt::x>(it.get());
250 BOOST_REQUIRE_EQUAL(f1,f2);
252 for (
size_t i = 0 ; i < 3 ; i++)
254 f1 = v_test.template get<pt::v>(it.get())[i];
255 f2 = v.template get<pt::v>(it.get())[i];
257 BOOST_REQUIRE_EQUAL(f1,f2);
265 size_t sz2[] = {16,16,16};
272 Unpacker<grid_cpu<3,Point_test<float>>,
HeapMemory>::unpack<decltype(sub2),int,pt::x,pt::v>(mem,sub2,g_test,ps,ctx,rem_copy_opt::NONE_OPT);
277 while (sub2.isNext())
279 float f1 = g_test.template get<pt::x>(sub2.get());
280 float f2 = g.template get<pt::x>(sub2.get());
282 BOOST_REQUIRE_EQUAL(f1,f2);
284 for (
size_t i = 0 ; i < 3 ; i++)
286 f1 = g_test.template get<pt::v>(sub2.get())[i];
287 f2 = g.template get<pt::v>(sub2.get())[i];
289 BOOST_REQUIRE_EQUAL(f1,f2);
304BOOST_AUTO_TEST_CASE ( packer_selector_test )
311 BOOST_REQUIRE_EQUAL(
Pack_selector<
int[3]>::value,PACKER_ARRAY_CP_PRIMITIVE);
312 BOOST_REQUIRE_EQUAL(
Pack_selector<
float[3][3]>::value,PACKER_ARRAY_CP_PRIMITIVE);
313 BOOST_REQUIRE_EQUAL(
Pack_selector<
double[5][6]>::value,PACKER_ARRAY_CP_PRIMITIVE);
314 BOOST_REQUIRE_EQUAL(
Pack_selector<
long int[5][8][9]>::value,PACKER_ARRAY_CP_PRIMITIVE);
318 BOOST_REQUIRE_EQUAL(aa,PACKER_GENERAL);
320 BOOST_REQUIRE_EQUAL(aa,PACKER_GENERAL);
323 BOOST_REQUIRE_EQUAL(aa,PACKER_GRID);
328 BOOST_REQUIRE_EQUAL(aa,PACKER_ENCAP_OBJECTS);
330 size_t sz[3] = {6,6,6};
333 BOOST_REQUIRE_EQUAL(aa,PACKER_ENCAP_OBJECTS);
350 static bool noPointers() {
return true;}
356BOOST_AUTO_TEST_CASE ( packer_memory_traits_inte )
361BOOST_AUTO_TEST_SUITE_END()
virtual void decRef()
Decrement the reference counter.
virtual void incRef()
Increment the reference counter.
This class allocate, and destroy CPU memory.
virtual bool allocate(size_t sz)
allocate memory
static void pack(ExtPreAlloc< Mem >, const T &obj)
Error, no implementation.
static size_t packRequest(const T &obj, size_t &req)
Error, no implementation.
Test structure used for several test.
static void unpack(ExtPreAlloc< Mem >, T &obj)
Error, no implementation.
Declaration grid_key_dx_iterator_sub.
grid_key_dx is the key to access any element in the grid
Implementation of 1-D std::vector like structure.
Transform the boost::fusion::vector into memory specification (memory_traits)