CoreNEURON
check_constructors.cpp
Go to the documentation of this file.
1 /*
2 # =============================================================================
3 # Copyright (c) 2016 - 2022 Blue Brain Project/EPFL
4 #
5 # See top-level LICENSE file for details.
6 # =============================================================================.
7 */
9 
10 #define BOOST_TEST_MODULE cmdline_interface
11 #include <boost/test/included/unit_test.hpp>
12 
13 using namespace coreneuron;
14 
15 BOOST_AUTO_TEST_CASE(interleave_info_test) {
16  size_t nwarp = 4;
17  size_t nstride = 6;
18 
19  InterleaveInfo info1;
20 
21  int data1[] = {11, 37, 45, 2, 18, 37, 7, 39, 66, 33};
22  size_t data2[] = {111, 137, 245, 12, 118, 237, 199, 278, 458};
23 
24  info1.nwarp = nwarp;
25  info1.nstride = nstride;
26 
27  // to avoid same values, different sub-array is used to initialize different members
28  copy_align_array(info1.stridedispl, data1, nwarp + 1);
29  copy_align_array(info1.stride, data1 + 1, nstride);
30  copy_align_array(info1.firstnode, data1 + 1, nwarp + 1);
31  copy_align_array(info1.lastnode, data1 + 1, nwarp + 1);
32 
33  // check if copy_array works
34  BOOST_CHECK_NE(info1.firstnode, info1.lastnode);
35  BOOST_CHECK_EQUAL_COLLECTIONS(info1.firstnode,
36  info1.firstnode + nwarp + 1,
37  info1.lastnode,
38  info1.lastnode + nwarp + 1);
39 
40  copy_align_array(info1.cellsize, data1 + 4, nwarp);
41  copy_array(info1.nnode, data2, nwarp);
42  copy_array(info1.ncycle, data2 + 1, nwarp);
43  copy_array(info1.idle, data2 + 2, nwarp);
44  copy_array(info1.cache_access, data2 + 3, nwarp);
45  copy_array(info1.child_race, data2 + 4, nwarp);
46 
47  // copy constructor
48  InterleaveInfo info2(info1);
49 
50  // assignment operator
51  InterleaveInfo info3;
52  info3 = info1;
53 
54  std::vector<InterleaveInfo*> infos;
55 
56  infos.push_back(&info2);
57  infos.push_back(&info3);
58 
59  // test few members
60  for (size_t i = 0; i < infos.size(); i++) {
61  BOOST_CHECK_EQUAL(info1.nwarp, infos[i]->nwarp);
62  BOOST_CHECK_EQUAL(info1.nstride, infos[i]->nstride);
63 
64  BOOST_CHECK_EQUAL_COLLECTIONS(info1.stridedispl,
65  info1.stridedispl + nwarp + 1,
66  infos[i]->stridedispl,
67  infos[i]->stridedispl + nwarp + 1);
68 
69  BOOST_CHECK_EQUAL_COLLECTIONS(info1.stride,
70  info1.stride + nstride,
71  infos[i]->stride,
72  infos[i]->stride + nstride);
73 
74  BOOST_CHECK_EQUAL_COLLECTIONS(info1.cellsize,
75  info1.cellsize + nwarp,
76  infos[i]->cellsize,
77  infos[i]->cellsize + nwarp);
78 
79  BOOST_CHECK_EQUAL_COLLECTIONS(info1.child_race,
80  info1.child_race + nwarp,
81  infos[i]->child_race,
82  infos[i]->child_race + nwarp);
83  }
84 }
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(interleave_info_test)
Definition: check_constructors.cpp:15
coreneuron::InterleaveInfo::nnode
size_t * nnode
Definition: cellorder.hpp:65
coreneuron::InterleaveInfo::nstride
int nstride
Definition: cellorder.hpp:57
coreneuron::copy_align_array
void copy_align_array(T *&dest, T *src, size_t n)
Definition: cellorder.hpp:118
coreneuron::InterleaveInfo::lastnode
int * lastnode
Definition: cellorder.hpp:61
coreneuron::InterleaveInfo::nwarp
int nwarp
Definition: cellorder.hpp:56
coreneuron
THIS FILE IS AUTO GENERATED DONT MODIFY IT.
Definition: corenrn_parameters.cpp:12
coreneuron::i
int i
Definition: cellorder.cpp:485
coreneuron::InterleaveInfo::stridedispl
int * stridedispl
Definition: cellorder.hpp:58
coreneuron::InterleaveInfo::cellsize
int * cellsize
Definition: cellorder.hpp:62
coreneuron::InterleaveInfo::firstnode
int * firstnode
Definition: cellorder.hpp:60
coreneuron::InterleaveInfo::cache_access
size_t * cache_access
Definition: cellorder.hpp:68
coreneuron::InterleaveInfo::idle
size_t * idle
Definition: cellorder.hpp:67
coreneuron::InterleaveInfo::stride
int * stride
Definition: cellorder.hpp:59
cellorder.hpp
coreneuron::copy_array
void copy_array(T *&dest, T *src, size_t n)
Definition: cellorder.hpp:111
coreneuron::nstride
int nstride
Definition: cellorder.cpp:641
coreneuron::InterleaveInfo::ncycle
size_t * ncycle
Definition: cellorder.hpp:66
coreneuron::InterleaveInfo
Definition: cellorder.hpp:50
coreneuron::InterleaveInfo::child_race
size_t * child_race
Definition: cellorder.hpp:69