问题描述
我知道CUDA中有一个函数clock(),您可以在其中放入内核代码并查询GPU时间.但是我想知道OpenCL中是否存在这样的事情?有什么方法可以在OpenCL中查询GPU时间? (我正在使用NVIDIA的工具包).
I know that there is function clock() in CUDA where you can put in kernel code and query the GPU time. But I wonder if such a thing exists in OpenCL? Is there any way to query the GPU time in OpenCL? (I'm using NVIDIA's tool kit).
推荐答案
NVIDIA OpenCL SDK有一个示例将内联PTX与OpenCL一起使用.可以通过嵌入式PTX将时钟寄存器作为特殊寄存器%clock进行访问. PTX:并行线程中介绍了%clock执行ISA 手册.您应该可以将%% laneid替换为%% clock.
The NVIDIA OpenCL SDK has an example Using Inline PTX with OpenCL. The clock register is accessible through inline PTX as the special register %clock. %clock is described in PTX: Parallel Thread Execution ISA manual. You should be able to replace the %%laneid with %%clock.
我从未在OpenCL中测试过它,而是在CUDA中使用它.
I have never tested this with OpenCL but use it in CUDA.
请注意编译器可能会重新排序或删除读取的寄存器.
Please be warned that the compiler may reorder or remove the register read.
这篇关于opencl中的clock()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!