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

Function TimedSort

test/OpenCL/RadixSortBenchmark/main.cpp:103–183  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

101 */
102template <typename K>
103void TimedSort(
104 unsigned int num_elements,
105 K *h_keys,
106 unsigned int iterations)
107{
108 printf("Keys only, %d iterations, %d elements\n", iterations, num_elements);
109
110 int max_elements = num_elements;
111 b3AlignedObjectArray<unsigned int> hostData;
112 hostData.resize(num_elements);
113 for (int i = 0; i < num_elements; i++)
114 {
115 hostData[i] = h_keys[i];
116 }
117
118 b3RadixSort32CL sorter(g_cxMainContext, g_device, g_cqCommandQueue);
119
120 b3OpenCLArray<unsigned int> gpuData(g_cxMainContext, g_cqCommandQueue);
121 gpuData.copyFromHost(hostData);
122 //sorter.executeHost(gpuData);
123 sorter.execute(gpuData);
124
125 b3AlignedObjectArray<unsigned int> hostDataSorted;
126 gpuData.copyToHost(hostDataSorted);
127
128 clFinish(g_cqCommandQueue);
129
130 {
131 //printf("Key-values, %d iterations, %d elements", iterations, num_elements);
132
133 // Create sorting enactor
134
135 // Perform the timed number of sorting iterations
136 double elapsed = 0;
137 float duration = 0;
138 b3Clock watch;
139
140 //warm-start
141 gpuData.copyFromHost(hostData);
142 clFinish(g_cqCommandQueue);
143 sorter.execute(gpuData);
144
145 watch.reset();
146
147 for (int i = 0; i < iterations; i++)
148 {
149 // Move a fresh copy of the problem into device storage
150 gpuData.copyFromHost(hostData);
151 clFinish(g_cqCommandQueue);
152
153 // Start GPU timing record
154 double startMs = watch.getTimeMicroseconds() / 1e3;
155
156 // Call the sorting API routine
157 sorter.execute(gpuData);
158
159 clFinish(g_cqCommandQueue);
160

Callers

nothing calls this directly

Calls 6

copyFromHostMethod · 0.80
copyToHostMethod · 0.80
resizeMethod · 0.45
executeMethod · 0.45
resetMethod · 0.45
getTimeMicrosecondsMethod · 0.45

Tested by

no test coverage detected