2013年3月8日 星期五
CUDA的筆記(1)
1 In CUDA, the number of block in a single launch 不可超過65535,另外 the number threads per block 的限制要查詢maxThreadsPerBlock(on device properties structure),可參考CUDA example ,在1_utilties/deviceQuery
CUDA sample 1 vector Adder
__global__ void vectorAdder(float *result,float* src1,float *src2,int N)
{
int x=gridDim.x*blockIdx.x+threadIdx.x;
if(x
}
為何要有x<N
vectorAdder<<<1,N>>>(c_d,a_d,b_d,N);
在CUDA by Example這本書上說是為了處理當你的thread*block不等於你的data量的情況,但我
我實際上測試時發現,如果沒有if(x<N)
但用vectorAdder<<<1,N>>>(c_d,a_d,b_d,N);or vectorAdder<<
訂閱:
意見 (Atom)