2929/* *****************************************************************************
3030 * Simple example of DeviceScan::ExclusiveSum().
3131 *
32- * Computes an exclusive sum of float keys.
32+ * Computes an exclusive sum of int keys.
3333 *
3434 * To compile using the command line:
3535 * nvcc -arch=sm_XX example_device_scan.cu -I../.. -lcudart -O3
@@ -66,7 +66,7 @@ CachingDeviceAllocator g_allocator(true); // Caching allocator for device memo
6666 * Initialize problem
6767 */
6868void Initialize (
69- float *h_in,
69+ int *h_in,
7070 int num_items)
7171{
7272 for (int i = 0 ; i < num_items; ++i)
@@ -83,13 +83,13 @@ void Initialize(
8383/* *
8484 * Solve exclusive-scan problem
8585 */
86- float Solve (
87- float *h_in,
88- float *h_reference,
86+ int Solve (
87+ int *h_in,
88+ int *h_reference,
8989 int num_items)
9090{
91- float inclusive = 0.0 ;
92- float aggregate = 0.0 ;
91+ int inclusive = 0.0 ;
92+ int aggregate = 0.0 ;
9393
9494 for (int i = 0 ; i < num_items; ++i)
9595 {
@@ -134,27 +134,27 @@ int main(int argc, char** argv)
134134 CubDebugExit (args.DeviceInit ());
135135
136136 printf (" cub::DeviceScan::ExclusiveSum %d items (%d-byte elements)\n " ,
137- num_items, (int ) sizeof (float ));
137+ num_items, (int ) sizeof (int ));
138138 fflush (stdout);
139139
140140 // Allocate host arrays
141- float * h_in = new float [num_items];
142- float * h_reference = new float [num_items];
141+ int * h_in = new int [num_items];
142+ int * h_reference = new int [num_items];
143143
144144 // Initialize problem and solution
145145 Initialize (h_in, num_items);
146146 Solve (h_in, h_reference, num_items);
147147
148148 // Allocate problem device arrays
149- float *d_in = NULL ;
150- CubDebugExit (g_allocator.DeviceAllocate ((void **)&d_in, sizeof (float ) * num_items));
149+ int *d_in = NULL ;
150+ CubDebugExit (g_allocator.DeviceAllocate ((void **)&d_in, sizeof (int ) * num_items));
151151
152152 // Initialize device input
153- CubDebugExit (cudaMemcpy (d_in, h_in, sizeof (float ) * num_items, cudaMemcpyHostToDevice));
153+ CubDebugExit (cudaMemcpy (d_in, h_in, sizeof (int ) * num_items, cudaMemcpyHostToDevice));
154154
155155 // Allocate device output array
156- float *d_out = NULL ;
157- CubDebugExit (g_allocator.DeviceAllocate ((void **)&d_out, sizeof (float ) * num_items));
156+ int *d_out = NULL ;
157+ CubDebugExit (g_allocator.DeviceAllocate ((void **)&d_out, sizeof (int ) * num_items));
158158
159159 // Allocate temporary storage
160160 void *d_temp_storage = NULL ;
0 commit comments