cuda计时⌛️

xiaoxiao2021-02-28  115

可参考nvidia官方文档:

http://docs.nvidia.com/cuda/cuda-runtime-api/group__CUDART__EVENT.html#group__CUDART__EVENT_1g40159125411db92c835edb46a0989cd6

__host__ ​ cudaError_t cudaEventElapsedTime ( float*  ms,  cudaEvent_t  start,  cudaEvent_t  end ) Computes the elapsed time between events.
Parameters
ms - Time between  start and  end in ms start - Starting event end - Ending event

// create two events cudaEvent_t start, stop; cudaEventCreate(&start); cudaEventCreate(&stop); // record start event on the default stream cudaEventRecord(start); // execute kernel kernel<<<grid, block>>>(arguments); // record stop event on the default stream cudaEventRecord(stop); // wait until the stop event completes cudaEventSynchronize(stop); // calculate the elapsed time between two events float time; cudaEventElapsedTime(&time, start, stop); // clean up the two events cudaEventDestroy(start); cudaEventDestroy(stop);

转载请注明原文地址: https://www.6miu.com/read-68245.html

最新回复(0)