How to create 3D memory using the driver api?

Hello,

in the runtime API there is a method cudaMalloc3D to allocate 1D, 2D or 3D objects in device memory.
When reading the driver API i cannot find a method which does somethign equivalent.

Is there an analog method for the cudaMalloc3D in the driver API.

Thanks
Martin

Is there any reason cuMemAllocPitch wouldn’t work? It’s not 3D but it will pad rows so that coalescing works properly…

Hello,

of course you are right. I only thought that there is a method in the runtime API so there must be a method to allocate a 3D linear memory also.

regards

Martin

The example for setting 3D memory with 3D texture as down:

[font="Courier New"]	

	CUarray devarr;

	CUDA_ARRAY3D_DESCRIPTOR desc;

	desc.Width	  =sizex;

	desc.Height	 =sizey;

	desc.Depth	  =sizez;

	desc.NumChannels=4;

	desc.Format	 =CU_AD_FORMAT_FLOAT;

	desc.Flags	  =0;

	CU_SAFE_CALL(cuArray3DCreate(&devarr,&desc));

	float4* voxels;

	//alloc space in device or host memory and apply source data for "voxels"

	memset(&memPro,0,sizeof(memPro));

	memPro.dstMemoryType=CU_MEMORYTYPE_ARRAY;

	memPro.dstArray		  =devarr;

	memPro.srcMemoryType=CU_MEMORYTYPE_HOST;

	memPro.srcHost		   =voxels;

	memPro.srcPitch		  =sizex*sizeof(float4);

	memPro.WidthInBytes =memPro.srcPitch;

	memPro.Height		   =sizey;

	memPro.Depth			=sizez;

	CU_SAFE_CALL(cuMemcpy3D(&memPro));

	delete [] voxels;

	CU_SAFE_CALL(cuTexRefSetArray(texref,devarr,CU_TRSA_OVERRIDE_FORMAT));	

[/font]