Advisory: Cannot tell what pointer points to, assuming global memory space

来源:互联网 发布:50个摄像头网络结构 编辑:程序博客网 时间:2024/06/05 18:29
//C code(hello.c):
typedef struct g_states_t 
{
    
int i; 
    
struct g_states_t *pnext;
}
g_state;

typedef 
struct ST
{
    g_states_t 
**cur;
    g_states_t 
*ctx[4];
}
ST;

void setstates(ST *ps, g_states_t states[4])
{
    
for (int i = 0; i < 4 ; i++)
    
{
        ps
->ctx[i] = &states[i];
    }

}
 

void main(int argc, char * argv[])
{

    g_states_t states[
4= 
    
{
        
{400&states[1]},
        
{401&states[2]},
        
{402&states[3]},
        
{403&states[0]}
    }
;

    ST s1, 
*ps1;
    ps1 
= &s1;

    setstates(ps1, states);
    ps1
->ctx[2]->= 123;
    ps1
->ctx[2]->pnext = &states[0];
    ps1
->ctx[3]->pnext->= 456;

    printf(
"%d ", ps1->ctx[2]->i);//ok,output:123
    printf("%d ", ps1->ctx[2]->pnext->i);//ok,output:456
    printf("%d ", ps1->ctx[3]->pnext->i);////ok,output:456

    printf(
"hello");
}


/////////////////////////////////////////////
GPU code(kernel.cu):
typedef 
struct g_states_t 
{
    
int i; 
    
struct g_states_t *pnext;
}
g_state;

typedef 
struct ST
{
    g_states_t 
**cur;
    g_states_t 
*ctx[4];
}
ST;


__device__ 
void setstates(ST *ps, g_states_t states[4])
{
    
for (int i = 0; i < 4 ; i++)
    
{
        ps
->ctx[i] = &states[i];
    }

}



__global__ 
void kernel()
{
    g_states_t states[
4= 
    
{
        
{400&states[1]},
        
{401&states[2]},
        
{402&states[3]},
        
{403&states[0]}
    }
;

    ST s1, 
*ps1;
    ps1 
= &s1;

    setstates(ps1, states);
    ps1
->ctx[2]->= 123;//err    
    ps1->ctx[2]->pnext = &states[0];//err
    ps1->ctx[3]->pnext->= 456;//err
}

 

////////////////////////////////////
When compile the GPU code in Release mode,prompt:

1>正在执行自定义生成步骤
1>cu_host.cu
1>tmpxft_00001ae8_00000000-3.gpu
1>tmpxft_00001ae8_00000000-7.gpu
1>"E:/MYWIND~1/TEMP/tmpxft_00001ae8_00000000-8.i", line 43: Advisory: Cannot tell what pointer points to, assuming global memory space
1>"E:/MYWIND~1/TEMP/tmpxft_00001ae8_00000000-8.i", line 44: Advisory: Cannot tell what pointer points to, assuming global memory space
1>"E:/MYWIND~1/TEMP/tmpxft_00001ae8_00000000-8.i", line 45: Advisory: Cannot tell what pointer points to, assuming global memory space
1>"E:/MYWIND~1/TEMP/tmpxft_00001ae8_00000000-8.i", line 45: Advisory: Cannot tell what pointer points to, assuming global memory space
1>tmpxft_00001ae8_00000000-3.c
1>tmpxft_00001ae8_00000000-12.i

What's the reason?
Advisory: Cannot tell what pointer points to, assuming global memory space
////

Would you please explain the reason of the problem?
And how to implement the state machine in device code?
Can you tell me the restrict in operation of device memory,such as pointer:
"ps1->ctx[3]->pnext->i"
is this usage legal?


Please read my code in:  
http://forums.nvidia.com/index.php?showtopic=61188