     // 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

    }

    double overallDuration = endTime - startTime;
    printf("Overall time: %.3f ms\t\t[%.3f GB/s]\n", 1000.f * overallDuration, toBW(totalBytes, overallDuration));

    //
    // TODO free memory buffers on the GPU
    //
}

void
printCudaInfo() {

    // for fun, just print out some stats on the machine



extern float toBW(int bytes, float sec);

__global__ void saxpy_kernel(int N, float alpha, float* x, float* y, float* result) {

    // compute overall index from position of thread in current block,
    // and given the block we are in
