Is passing and operating on an array with more than one dimension in CUDA impossible, or is it not done for performance reasons?

Is passing and operating on an array with more than one dimension in CUDA impossible, or is it not done for performance reasons?

CUDA is a dialect of C++ (mostly C++17 at the moment, with some support for C++20). Argument passing in CUDA therefore works exactly like it works in C++.

In C++ functions can certainly operate on multi-dimensional arrays, however the dimensional information may need to be passed to the function in separate arguments. This is different from Fortran where dimensional information for arrays is passed to functions behind the scenes and can be queried inside the function with the inquiry function size() along a selected dimension.

Doing an internet search for “multi-dimensional arrays in C++” will yield many tutorials and examples.

This reply doesn’t alleviate the confusion.

Why should I search “multi-dimensional arrays in C++” rather than “multi-dimensional arrays in CUDA”?

I am curious to know where confusion originates. Look at the title of the programming guide: “CUDA C++ Programming Guide”. Reading this and the “CUDA C++ Best Practices Guide” is highly recommended.

CUDA C++ is a dialect of C++ that both subsets and supersets ISO-C++. You can look at the “C++ language support” section for details of support for specific (advanced) C++11 through C++20 features.

You are, of course, also welcome to do an internet search for “multi-dimensional arrays in CUDA C++”.

It is possible, and can have or not have performance impacts. Here is a survey of some examples.