即使编译正常,cuPrintf也不会打印任何内容
cuPrintf does not print anything even if the compilation is ok
以下是我的产品:
#include "cuPrintf.cu"
#include "cuPrintf.cuh"
我的内核:
__global__ void testKernel()
{
cuPrintf("Test");
}
和我的主要:
int main( int argc, char** argv)
{
dim3 threads(1,1);
dim3 blocks(1, 1);
testKernel<<<blocks, threads>>>();
}
有人能向我解释为什么cuPrintf
没有打印任何东西吗?编译还可以,我正在使用Cuda 5.5
如果您有cc 2.0或更高版本的设备,那么直接从内核使用printf
会更容易。只要您的compile命令为实际设备指定-arch=sm_20
或类似内容,就可以执行此操作。
如果您真的想使用cuPrintf
,那么请研究相关的示例代码。main
例程中缺少cuPrintf
正常工作所需的几个函数调用。
最后,无论何时从内核打印,都应该确保在程序退出之前具有一些同步功能。如果在内核之后没有其他东西,那么以下操作就可以了:
cudaDeviceSynchronize();
在main
例程中,在最后一次内核调用之后。
如果您这样修改main
例程:
int main( int argc, char** argv)
{
dim3 threads(1,1);
dim3 blocks(1, 1);
cudaPrintfInit();
testKernel<<<blocks, threads>>>();
cudaDeviceSynchronize();
cudaPrintfDisplay(stdout,true);
cudaPrintfEnd();
}
我相信它会起作用的。
相关文章:
- 打印时有二叉树问题.用户输入不打印任何内容
- main() 中的 std::cout 在调试期间不会在调试控制台中打印任何内容
- cout 不打印任何内容到控制台
- 为什么字符串没有更新并且最终没有打印任何内容
- 我如何处理 TMP 以避免打印任何东西
- 是否有任何内置的哈希图函数来处理 c++ 中的值输入?
- 泛型函数反向打印任何矢量,编译器出错
- 是否有任何内置函数可以检查给定的两个数字在给定整数数组中的顺序是否相同?
- Cout 一个字符串可以打印任何内容到屏幕上
- "cout<<count<<endl;"没有打印任何内容
- C++ 中是否有任何内置阶乘函数?
- 为什么循环迭代不打印任何东西?
- 函数不打印任何 c++
- 下面的代码没有打印任何东西
- 我的 c++ 程序中的字符数组不会打印任何内容
- 如果否则错误:如何使其打印任何数字
- 在 C++ 中声明向量后无法打印任何内容
- 在模板功能中打印任何结构
- 如果找不到解决方案,我如何留下递归循环,而不会打印任何东西
- 是否有任何内置函数可以告诉编译器分支是否可预测