Cuda中两个不同内核之间的计算

时间:2012-11-19 23:23:09

标签: cuda kernel

这是我写的两个内核函数 - 完整的代码没有编译错误,但有警告。

该程序与生物序列比对有关。在内核1中,使用s0gpu_sample计算矩阵gpu_data,在内核2中,gpu_s0与内核1中的gpu_s0相同。 gpu_sgpu_s0及其自身计算。代码和警告来了:

__global__ void myKernel1( char** gpu_sample, char** gpu_data, float **gpu_s0)   
{
    dim3 dimGrid1;
    dim3 dimBlock1;
    dimBlock1.x = dimBlock1.y = BLOCK_SIZE;
    dimGrid1.x = dimGrid1.y = GRID_SIZE;

    int i1 = threadIdx.x + blockIdx.x * dimBlock1.x;
    int j1 = threadIdx.y + blockIdx.y * dimBlock1.y;

    if( i1 > N || j1 > M ) return;
    while ( j1 < (M+1) && i1 < (N+1) )
    {
        if(gpu_sample[0][j1] == gpu_data[i1][0])    // here is the warning part.
        {

            gpu_s0[i1+1][j1+1] = 5;
        }
        else 

            gpu_s0[i1+1][j1+1] = -3;

    i1 += blockDim.x * gridDim.x;
    j1 += blockDim.y * gridDim.y;
    }
}

__global__ void myKernel2( float **gpu_s0, float **gpu_s )
{
    dim3 dimGrid2;
    dim3 dimBlock2;
    dimBlock2.x = dimBlock2.y = BLOCK_SIZE;
    dimGrid2.x = dimGrid2.y = GRID_SIZE;

    float w = -4;                                   
    float zero = 0;


    __shared__ float shared[ threadsPerBlock ][threadsPerBlock]; 
    int i2 = threadIdx.x + blockIdx.x * dimBlock2.x;
    int j2 = threadIdx.y + blockIdx.y * dimBlock2.y;

    while( j2 < (M+1) && i2 < (N+1) )
    {
      shared[threadIdx.x][threadIdx.y] = gpu_s0[i2][j2];      // here is the warning.

      i2 += blockDim.x * gridDim.x;
      j2 += blockDim.y * gridDim.y;
    }

    __syncthreads();


    if( j2 < (M+1) && i2 < (N+1) )
    gpu_s[i2][0] = gpu_s[0][j2] = 0;


    /*if ( j2 < (M+1) && i2 < (N+1) )
    sTemp0[threadIdx.x][threadIdx.y] = gpu_s0[i2][j2]; //????????
    __syncthreads();*/


    if( i2 > N || j2 > M ) return;
    while ( j2 < (M+1) && i2 < (N+1) )
    {

        gpu_s[i2][j2] = max(gpu_s[i2-1][(j2-1)] + shared[threadIdx.x][threadIdx.y], //?????????
                          gpu_s[i2][(j2-1)] + w, 
                          gpu_s[(i2-1)][j2] + w, 
                          zero);     // here is the warning.
        i2 += blockDim.x * gridDim.x;
        j2 += blockDim.y * gridDim.y;
    }

}

警告:

./test_10_15_2012.cu(155): Warning: Cannot tell what pointer points to, assuming global memory space
./test_10_15_2012.cu(155): Warning: Cannot tell what pointer points to, assuming global memory space
./test_10_15_2012.cu(155): Warning: Cannot tell what pointer points to, assuming global memory space
./test_10_15_2012.cu(186): Warning: Cannot tell what pointer points to, assuming global memory space
./test_10_15_2012.cu(208): Warning: Cannot tell what pointer points to, assuming global memory space
./test_10_15_2012.cu(208): Warning: Cannot tell what pointer points to, assuming global memory space
./test_10_15_2012.cu(208): Warning: Cannot tell what pointer points to, assuming global memory space
./test_10_15_2012.cu(208): Warning: Cannot tell what pointer points to, assuming global memory space

有人可以帮我解决这个问题,还是给我一些建议?

0 个答案:

没有答案