当前位置:   article > 正文

Stream && Event

Stream && Event

Stream Tips

1.       for()  cudaStreamCreate()

2.       cudaMallocHost()

3.       for()  cudaMemcpyAsync(,,,stream[i]);

for()  kernel<<<,,,stream[i]>>>()

for()  cudaMemcpyAsync(,,,stream[i]);

cudaThreadSynchronize();

4.       for()  cudaStreamDestroy();

stream && event

 

Figure 1. Stream && event demo

Event Tips:

1.       cudaEventCreate(&start);

cudaEventCreate(&stop);

2.       cudaEventRecord(start,0);

for()  cudaMemcpyAsync(,,,stream[i]);

for()  kernel<<<,,,stream[i]>>>()

for()  cudaMemcpyAsync(,,,stream[i]);

cudaEventRecord(stop,0);

cudaEventSynchronize(stop);

cudaEventElapsedTime(&elapsedTime, start, stop);

3.       cudaEventDestroy(start);

cudaEventDestroy(stop);

 

Examples:

1.       cudaEventCreate(&start);

cudaEventCreate(&stop);

2.       cutCreateTimer(&timer);

cutResetTimer(timer);

cudaThreadSynchronize();

3.       cutStartTimer(timer);

cudaEventRecord(start,0);

cudaMemcpyAsync();

kernel<<<>>>();

cudaMemcpyAsync();

cudaEventRecord(stop,0);

cutStopTimer(timer);

4.       cudaEventQuery(stop)==true, cudaEventElapsedTimer();

5.       gpu_time = 29.39  (time spent executing by GPU)

cutGetTimerValue(timer) = 0.05  (time spent by CPU in CUDA calls)

More about stream&&event, please visit: http://www.hpctech.com/

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/黑客灵魂/article/detail/752575
推荐阅读
相关标签
  

闽ICP备14008679号