MCPcopy Create free account
hub / github.com/bulletphysics/bullet3 / boundSearchTest

Function boundSearchTest

test/OpenCL/ParallelPrimitives/main.cpp:138–249  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

136};
137
138void boundSearchTest()
139{
140 TEST_INIT;
141
142 int maxSize = 1024 * 256;
143 int bucketSize = 256;
144
145 b3OpenCLArray<b3SortData> srcCL(g_context, g_queue, maxSize);
146 b3OpenCLArray<unsigned int> upperCL(g_context, g_queue, maxSize);
147 b3OpenCLArray<unsigned int> lowerCL(g_context, g_queue, maxSize);
148
149 b3AlignedObjectArray<b3SortData> srcHost;
150 b3AlignedObjectArray<unsigned int> upperHost;
151 b3AlignedObjectArray<unsigned int> lowerHost;
152 b3AlignedObjectArray<unsigned int> upperHostCompare;
153 b3AlignedObjectArray<unsigned int> lowerHostCompare;
154
155 b3BoundSearchCL* search = new b3BoundSearchCL(g_context, g_device, g_queue, maxSize);
156
157 int dx = maxSize / NUM_TESTS;
158 for (int iter = 0; iter < NUM_TESTS; iter++)
159 {
160 int size = b3Min(128 + dx * iter, maxSize);
161
162 upperHost.resize(bucketSize);
163 lowerHost.resize(bucketSize);
164 upperHostCompare.resize(bucketSize);
165 lowerHostCompare.resize(bucketSize);
166
167 srcHost.resize(size);
168
169 for (int i = 0; i < size; i++)
170 {
171 b3SortData v;
172 // v.m_key = i<2? 0 : 5;
173 v.m_key = getRandom(0, bucketSize);
174
175 v.m_value = i;
176 srcHost.at(i) = v;
177 }
178
179 srcHost.quickSort(b3SortDataCompare());
180 srcCL.copyFromHost(srcHost);
181
182 {
183 for (int i = 0; i < bucketSize; i++)
184 {
185 lowerHost[i] = -1;
186 lowerHostCompare[i] = -1;
187 upperHost[i] = -1;
188 upperHostCompare[i] = -1;
189 }
190 upperCL.copyFromHost(upperHost);
191 lowerCL.copyFromHost(lowerHost);
192 }
193
194 search->execute(srcCL, size, upperCL, bucketSize, b3BoundSearchCL::BOUND_UPPER);
195 search->execute(srcCL, size, lowerCL, bucketSize, b3BoundSearchCL::BOUND_LOWER);

Callers 1

mainFunction · 0.85

Calls 9

getRandomFunction · 0.85
b3SortDataCompareClass · 0.85
copyFromHostMethod · 0.80
copyToHostMethod · 0.80
resizeMethod · 0.45
atMethod · 0.45
quickSortMethod · 0.45
executeMethod · 0.45
executeHostMethod · 0.45

Tested by

no test coverage detected