     // ensure the kernel running on the GPU has completed.  (Otherwise
     // you will incorrectly observe that almost no time elapses!)
     //
-    //cudaThreadSynchronize();
+    cudaThreadSynchronize();
+    double kernelEndTime = CycleTimer::currentSeconds();
 
 
     //
     // TODO: copy result from GPU using cudaMemcpy
     //
+    cudaMemcpy(resultarray, device_result, bufferSize, cudaMemcpyDeviceToHost);
 
     // end timing after result has been copied back into host memory.
     // The time elapsed between startTime and endTime is the total

    // these buffers are used in the call to saxpy_kernel below
    // without being initialized.
    //

    // start timing after allocation of device memory.
    double startTime = CycleTimer::currentSeconds();

    //
    // TODO: copy input arrays to the GPU using cudaMemcpy
    //
    cudaMemcpy(device_x, xarray, bufferSize, cudaMemcpyHostToDevice);
    cudaMemcpy(device_y, yarray, bufferSize, cudaMemcpyHostToDevice);

    //
    // TODO: insert time here to begin timing only the kernel
    //
    double kernelStartTime = CycleTimer::currentSeconds();

    // run saxpy_kernel on the GPU
    saxpy_kernel<<<blocks, threadsPerBlock>>>(N, alpha, device_x, device_y, device_result);
