How to pass 3D array in CUDA?

How to access 3D array in CUDA? I have searched for it in Google but have not found anything related to it.

This is a comical statement:

" I have searched for it in Google but have not found anything related to it."

There are many useful hits if you search with Google. Many of them will suggest the most sensible choice which is to flatten your data. Like the very first hit if you search on “cuda 3d array”

If you want to copy a variable dimension, dynamically allocated array to a GPU and use it in a true three-subscripted fashion, it’s quite tedious and not recommended, for performance reasons and code complexity reasons.

Nevertheless, here is a worked example how to do it (the second code example given in the answer):

[url]c - sending 3d array to CUDA kernel - Stack Overflow

The first example given in that answer demonstrates the relative simplicity of doing this if the array dimensions are not dynamically variable but instead known at compile-time – it can then be done with a single cudaMalloc and cudaMemcpy, just like a flattened array.

By the way, when I search on “cuda 3d array”, the link I’ve presented above is the third hit offered in the search.