cuda无限内核 [英] cuda infinite kernel

查看:193
本文介绍了cuda无限内核的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个需要无限期运行CUDA内核的应用程序。我有一个CPU线程在列表中写入stg,gpu读取该列表并重置(至少为启动)。当我在内核中写时

  while(true)
{
//内核代码
}

系统挂起。我知道GPU仍在处理,但没有发生任何事情。我不知道列表中的重置是否发生。



我不得不提到用于计算的GPU不用于显示,所以没有看门狗的问题。 / p>

操作系统是Ubuntu 11.10和cuda工具包4.1。
我可以使用任何帮助/示例/链接成功编写无限内核。

解决方案

CUDA编程语言和CUDA架构目前不支持无限内核。我建议你考虑Roger的建议。



如果你想追求这个,我建议你添加以下调试代码到你的内核:


  1. 每N个时钟在固定内存中增加一个变量(可能需要不同的位置),

  2. 定期读取一个内存位置可以通过CPU更新来告诉内核退出。

这是一个软件看门狗。





您可以使用cuda-gdb调试您的问题。



语言不支持无限循环。编译器可能会清除代码。您可能需要查看PTX和SASS。如果编译器生成错误代码,你可以通过让编译器认为有一个有效的退出条件来伪造它。


I am working on an application for which it is necessary to run a CUDA kernel indefinitely. I have one CPU thread that writes stg on a list and gpu reads that list and resets (at least for start). When I write inside the kernel

while(true)
{
//kernel code
}

the system hangs up. I know that the GPU is still processing but nothing happens of course. And I am not sure that the reset at the list happens.

I have to mention that the GPU used for calculations is not used for display, so no watchdog problem.

The OS is Ubuntu 11.10 and cuda toolkit 4.1. I could use any help/examples/links on writing infinite kernel successfully.

解决方案

The CUDA programming language and the CUDA architecture do not currently support infinite kernels. I suggest you consider Roger's suggestion.

If you want to pursue this I suggest you add the following debug code to your kernel:

  1. Increment a variable in pinned memory every N clocks (may want a different location for each SM) and,
  2. Periodically read a memory location that can be updated by CPU to tell the kernel to exit.

This is a software watchdog.

You can use clock() or clock64() to control how often you do (1) and (2).

You can use cuda-gdb to debug your problem.

Infinite loops are not supported in the language. The compiler may be stripping code. You may want to review the PTX and SASS. If the compiler is generating bad code you can fake it out by making the compiler think there is a valid exit condition.

这篇关于cuda无限内核的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆