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

Function radixSortTest

test/OpenCL/ParallelPrimitives/main.cpp:294–342  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

292}
293
294bool radixSortTest()
295{
296 TEST_INIT;
297
298 int maxSize = 1024 * 256;
299
300 b3AlignedObjectArray<b3SortData> buf0Host;
301 buf0Host.resize(maxSize);
302 b3AlignedObjectArray<b3SortData> buf1Host;
303 buf1Host.resize(maxSize);
304 b3OpenCLArray<b3SortData> buf2CL(g_context, g_queue, maxSize);
305
306 b3RadixSort32CL* sort = new b3RadixSort32CL(g_context, g_device, g_queue, maxSize);
307
308 int dx = maxSize / NUM_TESTS;
309 for (int iter = 0; iter < NUM_TESTS; iter++)
310 {
311 int size = b3Min(128 + dx * iter, maxSize - 512);
312 size = NEXTMULTIPLEOF(size, 512); //not necessary
313
314 buf0Host.resize(size);
315
316 for (int i = 0; i < size; i++)
317 {
318 b3SortData v;
319 v.m_key = getRandom(0, 0xff);
320 v.m_value = i;
321 buf0Host[i] = v;
322 }
323
324 buf2CL.copyFromHost(buf0Host);
325
326 sort->executeHost(buf0Host);
327 sort->execute(buf2CL);
328
329 buf2CL.copyToHost(buf1Host);
330
331 for (int i = 0; i < size; i++)
332 {
333 TEST_ASSERT(buf0Host[i].m_value == buf1Host[i].m_value && buf0Host[i].m_key == buf1Host[i].m_key);
334 }
335 }
336
337 delete sort;
338
339 TEST_REPORT("radixSort");
340
341 return g_testFailed;
342}
343
344int main(int argc, char** argv)
345{

Callers 1

mainFunction · 0.85

Calls 6

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

Tested by

no test coverage detected