Created
October 5, 2017 12:12
-
-
Save waltner/f7fd25bee8ba3708578f99a76b29e492 to your computer and use it in GitHub Desktop.
CUDA timing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// GPU timing example | |
// uses CUDA_SAFE_CALL [https://gist.github.com/waltner/ece68738c42d38c5e9bd1862c43b1146.js] | |
float elapsed_time = 0.0; | |
cudaEvent_t start, stop; | |
CUDA_SAFE_CALL(cudaEventCreate(&start)); | |
CUDA_SAFE_CALL(cudaEventCreate(&stop)); | |
CUDA_SAFE_CALL(cudaEventRecord(start,0)); | |
// DO STUFF ... | |
CUDA_SAFE_CALL(cudaEventRecord(stop,0)); | |
CUDA_SAFE_CALL(cudaEventSynchronize(stop)); | |
CUDA_SAFE_CALL(cudaEventElapsedTime(&elapsedTime,start,stop)); | |
printf("Runtime (GPU): %3.1f ms\n", elapsed_time); | |
CUDA_SAFE_CALL(cudaEventDestroy(start)); | |
CUDA_SAFE_CALL(cudaEventDestroy(stop)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment