如何在'print'函數中訪問'do_sth'函數(查看代碼)?爲什麼在沒有使用cudaMemcpy的情況下,GPU可以看到'N'(查看代碼)variable/constant?從全局函數中調用設備函數
__device__ void do_sth(char *a, int N)
{
int idx = blockIdx.x * blockDim.x + threadIdx.x;
if(idx < N)
{
a[idx] = a[idx];
}
}
__global__ void print(char *a, int N)
{
//question_1: why there is an access to N, it is now in GPU memory, how?
int idx = blockIdx.x * blockDim.x + threadIdx.x;
//do_sth<<<nblock2,blocksize2>>>(a,N); //error_1: a host function call can not be configured
//do_sth(&&a,N); //error_2: expected an expression
if(idx<N)
{
a[idx]=a[idx];
}
}
你的問題是模糊的,請詳細說明 – jwdmsd 2011-03-10 06:13:23