Hello everyone, I’m having a little problem with Copying/Allocating memory to the GPU.
Here’s my problem:
// I’m creating a Bounding Volume Hierarchy, basicaly a Binary Tree on a Raytracing program using interoprability with DirectX9
// (using a texture to display the raytracer’s rendering)
The Program:
device CBVH *cuda_BVH; // Tree on GPU
BVH bvh; // Tree on CPU
// Build the Tree on CPU
BuildBHV(spheres, nbSpheres, bvhDepth, bvh);
// Allocate the Structure on GPU
cutilSafeCall(cudaMalloc((void**) &cuda_BVH, sizeof(CBVH))); -----------------------------------------------------------> WORKS
// Copy the depth attribute of the Tree to GPU
cutilSafeCall(cudaMemcpy(&cuda_BVH->depth, &bvh.depth, sizeof(unsigned int), cudaMemcpyHostToDevice) ); —> WORKS
// Allocate the root node on GPU
cutilSafeCall(cudaMalloc((void**) &cuda_BVH->root, sizeof(CBVHNode))); ----------------------------------------------> DOESN’T WORK
Whenever I try to add the last line, VisualStudio pops up on execution, a window when entering the Message Loop saying an error occured and pointing the
debug pointer to the int __cdecl _write_nolock (int fh, const void *buf,unsigned cnt) function of “write.c - write to a file handle”, at line 335:
/* write the lf buf and update total */
if ( WriteFile( (HANDLE)_osfhnd(fh),
lfbuf,
(int)(q - lfbuf),
(LPDWORD)&written,
NULL) )
-----> {
charcount += written;
if (written < q - lfbuf)
break;
Important point : I don’t execute any kernel. This is just the memory initialisation.
THX for your help.