19 {
20
21
24 util::io::print(fmt::format(
"Initialized MPI. MPI size = {}, MPI rank = {}\n", mpiSize, mpiRank));
26
28
29 if (input.cmdOptionExists("-h") or !input.cmdOptionExists("-i")) {
30
33 << ") -i <num-points> -o <select-test; 0 - test with different lattice, 1 - profile nanoflann, 2 - test closest point search>" << std::endl;
34
35 }
36
37
38 int N;
39 if (input.cmdOptionExists("-i")) N = std::stoi(input.getCmdOption("-i"));
40 else {
41 N = 20;
42 std::cout << "Running test with default num-points = " << N << "\n";
43 }
44
45 int testSelect;
46 if (input.cmdOptionExists("-o")) testSelect = std::stoi(input.getCmdOption("-o"));
47 else {
48 testSelect = 0;
49 std::cout << "Running test with default test selection = " << testSelect << "\n";
50 }
51
52 std::vector<int> leafMaxSizes = {2, 5, 8, 10, 12, 15, 20};
53 std::vector<double> L_test = {1., 0.01};
54 std::vector<double> dL_test = {0.2, 0.5};
55 std::vector<int> seeds = {1093};
56 std::vector<int> N_test = {N};
57 std::vector<int> dims{2, 3};
58 std::vector<int> numTags{4, 8, 12};
59 int test_count = 0;
60
61
62 if (testSelect == 0) {
63
64 std::cout << "\n\nTesting Exclude and Include tag for different lattice sizes\n\n";
65
66 for (auto L: L_test) {
67 for (auto dL: dL_test) {
68 for (auto seed: seeds) {
69 for (auto n: N_test) {
70 for (auto dim: dims) {
71
72 std::string msg;
77
78 std::cout << "\n**** Test number = " << test_count++ << " ****\n";
79 std::cout << fmt::format("Test parameters: L = {}, lattice "
80 "perturbation = {}, seed = {}, "
81 "N = {}, leafMaxSize = {}, num_tags = {}, "
82 "dim = {}\n\n",
83 L, dL * L, seed, n,
86
87
88 if (dim == 2)
89 msg = test::testNanoflannExcludeInclude<2>(n, L, dL * L, seed,
90 data);
91 else if (dim == 3)
92 msg = test::testNanoflannExcludeInclude<3>(n, L, dL * L, seed,
93 data);
94
95 std::cout << msg;
96
97 }
98 }
99 }
100 }
101 }
102 }
103 else if (testSelect == 1) {
104
105 std::cout
106 << "\n\nTesting Exclude and Include tag type neighbor search for different leaf sizes and number of tags\n\n";
107
108 test_count = 0;
109 std::vector<std::vector<std::vector<test::testNSearchData> > > data_set(
110 leafMaxSizes.size());
111
112 for (size_t i = 0; i < leafMaxSizes.size(); i++) {
113
114 data_set[i].resize(numTags.size());
115
116 for (size_t j = 0; j < numTags.size(); j++) {
117
118 data_set[i][j].resize(dims.size());
119
120 for (size_t k = 0; k < dims.size(); k++) {
121
122 auto L = L_test[0];
123 auto dL = dL_test[0];
124 auto seed = seeds[0];
125 auto n = N_test[0];
126
127 std::string msg;
129 data.
d_dim = dims[k];
132
133 std::cout << "\n**** Test number = " << test_count++ << " ****\n";
134 std::cout << fmt::format("Test parameters: L = {}, lattice "
135 "perturbation = {}, seed = {}, "
136 "N = {}, leafMaxSize = {}, num_tags = {}, "
137 "dim = {}\n\n",
138 L, dL * L, seed, n,
141
142
144 msg = test::testNanoflannExcludeInclude<2>(n, L, dL * L, seed,
145 data);
146 else if (data.
d_dim == 3)
147 msg = test::testNanoflannExcludeInclude<3>(n, L, dL * L, seed,
148 data);
149
150 std::cout << msg;
151
152 data_set[i][j][k] = data;
153 }
154 }
155 }
156
157 std::cout << "\n\nSummarize results of test 2\n\n";
158 for (size_t k = 0; k < dims.size(); k++) {
159 std::cout << "Dim = " << dims[k] << "\n";
160 for (size_t j = 0; j < numTags.size(); j++) {
161 std::cout << fmt::format(" numTag = {:2d}\n", numTags[j]);
162 for (size_t i = 0; i < leafMaxSizes.size(); i++) {
163 const auto &data = data_set[i][j][k];
164 std::cout << fmt::format(
165 " leafMaxSize = {:2d}, numPoints = {:8d}, bld_time = {:8d}\n"
166 " (brute-search) def_time = {:8d}, exc_time = {:8d}, inc_time = {:8d}\n"
167 " (nflan-search) def_time = {:8d}, exc_time = {:8d}, inc_time = {:8d}\n",
168 data.d_leafMaxSize,
169 data.d_numPoints,
170 int(data.d_treeBuildTime),
171 int(data.d_defaultBruteSearchTime),
172 int(data.d_excludeBruteSearchTime),
173 int(data.d_includeBruteSearchTime),
174 int(data.d_defaultNFlannSearchTime),
175 int(data.d_excludeNFlannSearchTime),
176 int(data.d_includeNFlannSearchTime));
177 }
178 }
179 }
180 }
181 else if (testSelect == 2) {
182
183 std::cout << "\n\nTesting closest point search for different lattice sizes\n\n";
184
185
186
187 for (auto L: L_test) {
188 for (auto dL: dL_test) {
189 for (auto seed: seeds) {
190 for (auto n: N_test) {
191
192 std::string msg;
197
198 std::cout << "\n**** Test number = " << test_count++ << " ****\n";
199 std::cout << fmt::format("Test parameters: L = {}, lattice "
200 "perturbation = {}, seed = {}, "
201 "N = {}, leafMaxSize = {}, num_tags = {}"
202 "\n\n",
203 L, dL * L, seed, n,
206
207
209
210 std::cout << msg;
211
212 }
213 }
214 }
215 }
216 }
217
218 return EXIT_SUCCESS;
219}
size_t const MINOR_VERSION
size_t const UPDATE_VERSION
size_t const MAJOR_VERSION
std::string testNanoflannClosestPoint(size_t N, double L, double dL, int seed)
Perform test on nsearch.
std::string printStr(const T &msg, int nt=print_default_tab)
Returns formatted string for output.
void print(const T &msg, int nt=print_default_tab, int printMpiRank=print_default_mpi_rank)
Prints formatted information.
const MpiStatus * getMpiStatus()
Returns pointer to MpiStatus struct.
void initMpi(int argc=0, char *argv[]=nullptr)
Initializes MPI and also creates MpiStatus struct.
int mpiSize()
Get size (number) of processors.
int mpiRank()
get rank (id) of this processor