3D arrays

Is possible to define, allocate memory and use 3D arrays ? ( Matrix[100][100][100] )

Sure, it’s just like C in that regard. Do watch out that things like shared and constant memory are severely limited, and you might be able to fit only a very small volume into it. If your algorithm is separable into a pass for each direction, that is usually the better choice.

I just wanted to make something clear: Is it possible to allocate 3D arrays in global memory using “cudaMalloc” from the host?

Thanks.

You don’t have eg a 3D cudaMallocPitch(), but if you cudaMallocPitch( …, width, height*depth, …) and do index arithmetic or pointer arithmetic with 3 index variables to address a 2D array … then you have a 3D array with aligned rows. :magic:

Or do same with just cudaMalloc() but you don’t I think have aligned rows.

I may have the order of the width * height params to cudaMallocPitch() reversed: I’m at work my docs are at home.