【发布时间】:2011-10-18 07:09:18
【问题描述】:
我有一个 CUDA 程序,它似乎达到了某种资源的某种限制,但我不知道该资源是什么。这是核函数:
__global__ void DoCheck(float2* points, int* segmentToPolylineIndexMap,
int segmentCount, int* output)
{
int segmentIndex = threadIdx.x + blockIdx.x * blockDim.x;
int pointCount = segmentCount + 1;
if(segmentIndex >= segmentCount)
return;
int polylineIndex = segmentToPolylineIndexMap[segmentIndex];
int result = 0;
if(polylineIndex >= 0)
{
float2 p1 = points[segmentIndex];
float2 p2 = points[segmentIndex+1];
float2 A = p2;
float2 a;
a.x = p2.x - p1.x;
a.y = p2.y - p1.y;
for(int i = segmentIndex+2; i < segmentCount; i++)
{
int currentPolylineIndex = segmentToPolylineIndexMap[i];
// if not a different segment within out polyline and
// not a fake segment
bool isLegit = (currentPolylineIndex != polylineIndex &&
currentPolylineIndex >= 0);
float2 p3 = points[i];
float2 p4 = points[i+1];
float2 B = p4;
float2 b;
b.x = p4.x - p3.x;
b.y = p4.y - p3.y;
float2 c;
c.x = B.x - A.x;
c.y = B.y - A.y;
float2 b_perp;
b_perp.x = -b.y;
b_perp.y = b.x;
float numerator = dot(b_perp, c);
float denominator = dot(b_perp, a);
bool isParallel = (denominator == 0.0);
float quotient = numerator / denominator;
float2 intersectionPoint;
intersectionPoint.x = quotient * a.x + A.x;
intersectionPoint.y = quotient * a.y + A.y;
result = result | (isLegit && !isParallel &&
intersectionPoint.x > min(p1.x, p2.x) &&
intersectionPoint.x > min(p3.x, p4.x) &&
intersectionPoint.x < max(p1.x, p2.x) &&
intersectionPoint.x < max(p3.x, p4.x) &&
intersectionPoint.y > min(p1.y, p2.y) &&
intersectionPoint.y > min(p3.y, p4.y) &&
intersectionPoint.y < max(p1.y, p2.y) &&
intersectionPoint.y < max(p3.y, p4.y));
}
}
output[segmentIndex] = result;
}
这里是执行内核函数的调用:
DoCheck<<<702, 32>>>(
(float2*)devicePoints,
deviceSegmentsToPolylineIndexMap,
numSegments,
deviceOutput);
参数大小如下:
- devicePoints = 22,464 float2s = 179,712 字节
- deviceSegmentsToPolylineIndexMap = 22,463 个整数 = 89,852 个字节
- numSegments = 1 int = 4 字节
- deviceOutput = 22,463 个整数 = 89,852 个字节
当我执行这个内核时,它会导致显卡崩溃。看来我遇到了某种限制,因为如果我使用DoCheck<<<300, 32>>>(...); 执行内核,它就可以工作。明确一点,参数是一样的,只是块数不一样。
知道为什么一个会导致视频驱动程序崩溃,而另一个不会吗?失败的似乎仍在卡片的块数限制内。
更新 有关我的系统配置的更多信息:
- 显卡:nVidia 8800GT
- CUDA 版本:1.1
- 操作系统:Windows Server 2008 R2
我也在一台笔记本电脑上试了一下,配置如下,结果一样:
- 显卡:nVidia Quadro FX 880M
- CUDA 版本:1.2
- 操作系统:Windows 7 64 位
【问题讨论】:
-
如果这是显示卡,可能是挂钟时间。显示驱动程序有一个看门狗定时器,它会杀死需要几秒钟才能完成的内核。实施细节和变通方法是特定于操作系统的。您使用的是什么操作系统、卡和 CUDA 版本?
-
有趣。好的,我将使用该信息更新问题。
-
看门狗定时器在 Windows 上仍然是一个问题吗?如果是这样,您的内核可能执行时间过长。
-
那些 CUDA 版本是您卡的计算能力,而不是您使用的 CUDA 版本...但是您肯定会达到显示驱动程序看门狗计时器的限制 - 我认为您正在获得“执行时驱动程序崩溃并被重置”消息?
-
@Eric:是的,除非使用带有非 WDDM 计算驱动程序的特斯拉卡。