We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
代码5中,使用到cpu printMatrix代码中有误,应将C[j] 改为 ic[j]: void printMatrix(float * C,const int nx,const int ny) { float *ic=C; printf("Matrix<%d,%d>:",ny,nx); for(int i=0;i<ny;i++) { for(int j=0;j<nx;j++) { printf("%6f ",ic[j]); // change C[j] -> ic[j] } ic+=nx; printf("\n"); } }
代码5中,使用到gpu printThreadIndex代码中有误,应将最后的格式化%d 改为 %f, 否则输出全为0: global void printThreadIndex(float *A, const int nx, const int ny){ int ix = threadIdx.x + blockIdx.x * blockDim.x; int iy = threadIdx.y + blockIdx.y * blockDim.y; unsigned int idx = iy * nx + ix; printf("thread_id(%d,%d) block_id(%d,%d) coordinate(%d,%d)" "global index %2d ival %2f\n",threadIdx.x,threadIdx.y, // change %2d -> %2f blockIdx.x,blockIdx.y,ix,iy,idx,A[idx]); }
The text was updated successfully, but these errors were encountered:
正想说这个问题!
Sorry, something went wrong.
No branches or pull requests
代码5中,使用到cpu printMatrix代码中有误,应将C[j] 改为 ic[j]:
void printMatrix(float * C,const int nx,const int ny)
{
float *ic=C;
printf("Matrix<%d,%d>:",ny,nx);
for(int i=0;i<ny;i++)
{
for(int j=0;j<nx;j++)
{
printf("%6f ",ic[j]); // change C[j] -> ic[j]
}
ic+=nx;
printf("\n");
}
}
代码5中,使用到gpu printThreadIndex代码中有误,应将最后的格式化%d 改为 %f, 否则输出全为0:
global void printThreadIndex(float *A, const int nx, const int ny){
int ix = threadIdx.x + blockIdx.x * blockDim.x;
int iy = threadIdx.y + blockIdx.y * blockDim.y;
unsigned int idx = iy * nx + ix;
printf("thread_id(%d,%d) block_id(%d,%d) coordinate(%d,%d)"
"global index %2d ival %2f\n",threadIdx.x,threadIdx.y, // change %2d -> %2f
blockIdx.x,blockIdx.y,ix,iy,idx,A[idx]);
}
The text was updated successfully, but these errors were encountered: