This project is read-only.

GridDimensions limited to 2D

Jul 2, 2014 at 3:17 PM
First, managedCUDA is excellent. I have found it a pleasure to work with.

Now, to my issue. While trying to launch a kernel using a 3-D grid, I stumbled upon the following code in the CudaKernel class:
        /// <summary>
        /// Get or set the thread grid dimensions. Grid dimenions must be set before the first kernel launch.
        /// z component is set to 1
        /// </summary>
        public dim3 GridDimensions
            get { return _gridDim; }
                _gridDim = value;
                _gridDim.z = 1;
I was surprised to see that the z-dimension is ignored. Is there some workaround for launching kernels with 3-D grids? Is this just a limitation carried over from older versions of the CUDA API?

Thanks, and keep up the good work!
Jul 2, 2014 at 3:40 PM
Hi Robert,

yes, this is a leftover from the old days with devices of compute capability less then 2.0: those devices only supported 2D-grids. Till today I haven't realized this change, at least not to the point that I would have to adopt managedCuda...
As all the constructors of CudaKernel ignore the z-component, too, there's no workaround, except modifying directly the source code.

Jul 13, 2014 at 10:58 AM
Edited Jul 13, 2014 at 11:05 AM
The Constructors might ignore the Z dimension, but cuLaunchKernel does not. A quick compile without that restriction should fix the problem, since cuLaunchKernel takes in the Z dimension explicitly. (that is of course if I recall correctly). This is exactly the reason I chose to use managedCuda over other Cuda wrappers, so I hope it's true. I've seen it working, but can't remember what I did (if anything).

Actually, just looking at the code momentarily, you can set the Z dimension on CudaKernel after you've called the constructor, or after you've set the GridDimensions property.
Jul 13, 2014 at 4:06 PM

if you remove all the lines in the CudaKernel class with
_gridDim.z = 1;
everything will work as expected. These are only leftovers from versions for CUDA 3, where grid dimensions were only 2D.

I will fix the issue with new release for CUDA 6.5 which will be available soon.