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

Function prefixScanTest

test/OpenCL/ParallelPrimitives/main.cpp:251–292  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

249}
250
251void prefixScanTest()
252{
253 TEST_INIT;
254
255 int maxSize = 1024 * 256;
256
257 b3AlignedObjectArray<unsigned int> buf0Host;
258 b3AlignedObjectArray<unsigned int> buf1Host;
259
260 b3OpenCLArray<unsigned int> buf2CL(g_context, g_queue, maxSize);
261 b3OpenCLArray<unsigned int> buf3CL(g_context, g_queue, maxSize);
262
263 b3PrefixScanCL* scan = new b3PrefixScanCL(g_context, g_device, g_queue, maxSize);
264
265 int dx = maxSize / NUM_TESTS;
266 for (int iter = 0; iter < NUM_TESTS; iter++)
267 {
268 int size = b3Min(128 + dx * iter, maxSize);
269 buf0Host.resize(size);
270 buf1Host.resize(size);
271
272 for (int i = 0; i < size; i++)
273 buf0Host[i] = 1;
274
275 buf2CL.copyFromHost(buf0Host);
276
277 unsigned int sumHost, sumGPU;
278
279 scan->executeHost(buf0Host, buf1Host, size, &sumHost);
280 scan->execute(buf2CL, buf3CL, size, &sumGPU);
281
282 buf3CL.copyToHost(buf0Host);
283
284 TEST_ASSERT(sumHost == sumGPU);
285 for (int i = 0; i < size; i++)
286 TEST_ASSERT(buf1Host[i] == buf0Host[i]);
287 }
288
289 delete scan;
290
291 TEST_REPORT("scanTest");
292}
293
294bool radixSortTest()
295{

Callers 1

mainFunction · 0.85

Calls 5

copyFromHostMethod · 0.80
copyToHostMethod · 0.80
resizeMethod · 0.45
executeHostMethod · 0.45
executeMethod · 0.45

Tested by

no test coverage detected