File tree Expand file tree Collapse file tree 2 files changed +8
-5
lines changed
Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -137,23 +137,20 @@ int main(int argc, char* argv[]) {
137137 printCmpResult (NPOT, b, c);
138138
139139
140- #if 0
141140 zeroArray (SIZE, c);
142141 printDesc (" thrust scan, power-of-two" );
143142 StreamCompaction::Thrust::scan (SIZE, c, a);
144143 printElapsedTime (StreamCompaction::Thrust::timer ().getGpuElapsedTimeForPreviousOperation (), " (CUDA Measured)" );
145- // printArray(SIZE, c, true);
144+ printArray (SIZE, c, true );
146145 printCmpResult (SIZE, b, c);
147146
148147 zeroArray (SIZE, c);
149148 printDesc (" thrust scan, non-power-of-two" );
150149 StreamCompaction::Thrust::scan (NPOT, c, a);
151150 printElapsedTime (StreamCompaction::Thrust::timer ().getGpuElapsedTimeForPreviousOperation (), " (CUDA Measured)" );
152- // printArray(NPOT, c, true);
151+ printArray (NPOT, c, true );
153152 printCmpResult (NPOT, b, c);
154153
155- #endif
156-
157154
158155 printf (" \n " );
159156 printf (" *****************************\n " );
Original file line number Diff line number Diff line change @@ -18,11 +18,17 @@ namespace StreamCompaction {
1818 * Performs prefix-sum (aka scan) on idata, storing the result into odata.
1919 */
2020 void scan (int n, int *odata, const int *idata) {
21+
22+ thrust::device_vector<int > d_idata (idata, idata + n);
23+ thrust::device_vector<int > d_result (n);
24+
2125 timer ().startGpuTimer ();
2226 // TODO use `thrust::exclusive_scan`
2327 // example: for device_vectors dv_in and dv_out:
2428 // thrust::exclusive_scan(dv_in.begin(), dv_in.end(), dv_out.begin());
29+ thrust::exclusive_scan (d_idata.begin (), d_idata.end (), d_result.begin ());
2530 timer ().endGpuTimer ();
31+ thrust::copy (d_result.begin (), d_result.end (), odata);
2632 }
2733 }
2834}
You can’t perform that action at this time.
0 commit comments