代码部分
g_calculate_Fe << <(M->size_element + hfths - 1) / hfths, dim3(4, hfths, 1), 0, custr[1] >> > (Md);
g_calculate_Fb << <(M->size_frac + ths - 1) / ths, ths, 0, custr[2] >> > (Md);
src = cudaDeviceSynchronize();
if (src != cudaSuccess)
{
cout << M->step << " 计算错误 " << cudaGetErrorString(src) << endl;
break;
}
程序运行输出:
0 计算错误 an illegal memory access was encountered
之前查阅博客,线程分配时存在错误,但是对于这块不太理解,仅供参考