global void Kernel(float Ad, float Bd, floatCd,int data_size,int block_size)
{
int bx=blockIdx.x;
int by=blockIdx.y;
int tx=thresdIdx.x;
int ty=threafIdx.y;
int aBegin=data_sizeblock_sizeby;
int aEnd=aBegin+data_size-1;
int bBegin=block_sizebx;
int bEnd=block_sizedata_size;
float sub=0;
for(int a=aBegin,b=bBegin;a<=aEnd;a+=block_size,b+=block_size)
{
shared float A[block_size][block_size];
shared float B[block_size][block_size];
A[tx][ty]=Ad[a+data_sizety+tx];
B[tx][ty]=Bd[b+data_size*ty+tx];
_syncthreads();
for(int k=0;k<block_size:k++)
{
sub+=A[k][ty]B[tx][k];
}
_syncthreads();
}
int c=data_sizeblock_sizeby+block_sizetx;
Cd[c+data_size*ty+tx]=sub;
}
这是矩阵乘法
编译后出错
1>------ Build started: Project: CUDA, Configuration: Debug Win32 ------
1>Compiling with CUDA Build Rule…
1>“C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.0\bin\nvcc.exe” -arch sm_10 -ccbin “D:\Program Files\Microsoft Visual Studio 8\VC\bin” -Xcompiler "/EHsc /W3 /nologo /O2 /Zi /MD " -maxrregcount=32 --compile -o “Debug\CUDA_Guest.cu.obj” “c:\Documents and Settings\Owner\桌面\CUDA\CUDA\CUDA_Guest.cu”
1>CUDA_Guest.cu
1>c:/Documents and Settings/Owner/桌面/CUDA/CUDA/CUDA_Guest.cu(7): error: identifier “thresdIdx” is undefined
1>c:/Documents and Settings/Owner/桌面/CUDA/CUDA/CUDA_Guest.cu(8): error: identifier “threafIdx” is undefined
1>c:/Documents and Settings/Owner/桌面/CUDA/CUDA/CUDA_Guest.cu(16): error: identifier “shared” is undefined
1>c:/Documents and Settings/Owner/桌面/CUDA/CUDA/CUDA_Guest.cu(16): error: expected a “;”
1>c:/Documents and Settings/Owner/桌面/CUDA/CUDA/CUDA_Guest.cu(17): error: expected a “;”
1>c:/Documents and Settings/Owner/桌面/CUDA/CUDA/CUDA_Guest.cu(18): error: identifier “A” is undefined
1>c:/Documents and Settings/Owner/桌面/CUDA/CUDA/CUDA_Guest.cu(19): error: identifier “B” is undefined
1>c:/Documents and Settings/Owner/桌面/CUDA/CUDA/CUDA_Guest.cu(20): error: identifier “_syncthreads” is undefined
1>c:/Documents and Settings/Owner/桌面/CUDA/CUDA/CUDA_Guest.cu(21): error: expected a “;”
1>c:/Documents and Settings/Owner/桌面/CUDA/CUDA/CUDA_Guest.cu(12): warning: variable “bEnd” was declared but never referenced
1>9 errors detected in the compilation of “C:/DOCUME~1/Owner/LOCALS~1/Temp/tmpxft_000015cc_00000000-6_CUDA_Guest.cpp1.ii”.
1>Project : error PRJ0019: A tool returned an error code from “Compiling with CUDA Build Rule…”
1>Build log was saved at “file://c:\Documents and Settings\Owner\桌面\CUDA\CUDA\Debug\BuildLog.htm”
1>CUDA - 10 error(s), 1 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
不知什么原因??
我用的是4.0
不要在中文目录下。。
[
?
什么意思?
能说具体点吗
就你的代码而言,你的程序存在拼写错误。
threadIdx.x;threadIdx.y;shared;所有标记都是双下划线才对,微软的自家函数时但下划线。
如果去掉这些基本的语法错误,你不能正确编译的话,建议你看看我的环境配置的CSDN博客。aban-mtd-CSDN博客