Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- cudaEvent_t startGPU, stopGPU, startCPU, stopCPU;
- float GPUtime, CPUtime;
- CUDA_CALL(cudaEventCreate(&startGPU));
- CUDA_CALL(cudaEventCreate(&stopGPU));
- CUDA_CALL(cudaEventRecord(startGPU, 0));
- for (int a = 0; a < 100; a++)
- {
- //do stuff
- }
- CUDA_CALL(cudaEventRecord(stopGPU, 0));
- CUDA_CALL(cudaEventSynchronize(stopGPU));
- cudaEventElapsedTime(&GPUtime, startGPU, stopGPU);
- CUDA_CALL(cudaEventCreate(&startCPU));
- CUDA_CALL(cudaEventCreate(&stopCPU));
- CUDA_CALL(cudaEventRecord(startCPU, 0));
- for (int a = 0; a < 100; a++)
- {
- //do stuff again
- }
- CUDA_CALL(cudaEventRecord(stopCPU, 0));
- CUDA_CALL(cudaEventSynchronize(stopCPU));
- cudaEventElapsedTime(&CPUtime, startCPU, stopCPU);
- printf("%f\n", GPUtime);
- printf("%f\n", CPUtime);
- CUDA_CALL(cudaEventDestroy(startGPU));
- CUDA_CALL(cudaEventDestroy(stopGPU));
- CUDA_CALL(cudaEventDestroy(startCPU));
- CUDA_CALL(cudaEventDestroy(stopCPU));
- getchar();
- exit(EXIT_SUCCESS);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement