这次作业有个地方搞的我输出的C矩阵一直都是全000000.
然后发现原来是DimBlock设置的太大了。
//@@ Initialize the grid and block dimensions here
dim3 DimBlock(8, 8, 1); // if the threads each block is too large, say
// 32, then the C output will be all 000000000
// so fail!!!!
dim3 DimGrid((numCColumns - 1) / DimBlock.x + 1,
(numCRows - 1) / DimBlock.y + 1, 1);
这样就可以得到正确结果了。
"level":"Trace",
"message":"The dimensions of B are 64 x 64",
"file":"F:/1MOOC_SourceCode/HPP/libwb/skel/mp2.cu",
"function":"main",
"line":65,
"time":25975425239252
}]
}
,
"solution_exists": true,
"solution":{
"correctq": true,
"message": "Solution is correct."
}
}
F:\1MOOC_SourceCode\HPP\libwb\build\Debug>
本文介绍了一个在CUDA编程中遇到的问题:当DimBlock尺寸设置过大时,会导致输出的C矩阵全为零。通过调整DimBlock的大小到合适的范围(例如8x8),可以有效解决该问题并获得正确的计算结果。

被折叠的 条评论
为什么被折叠?



