Problem to access a variable copied to the GPU memory

Helle everybody,

As part of a project, I was created an octree system and I want to modify the SDK example : render volume.

So when I generated my octree, I obtain an 1D array of float4 that contains the nodes of the octree. My goal is upload this 1D array in the GPU memory in order to manipulate it.

To do this, I changed the initcuda code by adding :

cudaMalloc( ( void** ) &d_octree, size );

cudaMemcpy( d_octree, octree, size, cudaMemcpyHostToDevice );

I have in the same cu file a global variable : constant float4* d_octree;

I created two functions in order to compute the boxMin and boxMax for the ray casting.

__device__ float3 computeBoxMin( float4 node )

{

   float s = (node.w)/2;

   float x = node.x - s;

   float y = node.y - s;

   float z = node.z + s;

float3 resultat = make_float3( x, y, z );

return resultat;

}

__device__ float3 computeBoxMax( float4 node )

{

   float s = (node.w)/2;

   float x = node.x + s;

   float y = node.y + s;

   float z = node.z - s;

float3 resultat = make_float3( x, y, z );

return resultat;

}

And in the global void d_render( uint *d_output, uint imageW, uint imageH, float density, float brightness, float transferOffset, float transferScale ) kernel I added :

float3 boxMin = computeBoxMin( d_octree[0] );

float3 boxMax = computeBoxMax( d_octree[0] );

I choosed d_octree[0] because it’s the root of the octree and the values of the root are the same that the orginal code of the volume render (It’s just a test for the moment).

The problem is when I want access to d_octree, I receive a segfault message and I don’t understand why…

Thanks for your help ;)

According to your setting, I would suggest that you pass d_octree into your kernel,

__global__ void d_render( uint *d_output, uint imageW, uint imageH, float density, float brightness, float transferOffset, float transferScale,

	  float4 *d_octree )

Thanks for your reply, Now it’s works perfectly ;)