Can't launch 3d grid?

I use CUDA8.0 and VS2015, with GTX980.

I tried to launch a kernel using 3D grid and 1D block.

dim3 radiance_gird = (4, 4, 4);
dim3 radiance_block = (FirePresets::TOTAL_SAMPLES); // 5
radianceKernel << <radiance_gird, radiance_block >> > (dev_le, dev_l, dev_le_mean, dev_T, dev_xm, dev_ym, dev_zm);

In NVIDIA NSight CUDA Focus it says my valid grid dimension is (4,0,0). Why?

Buildable code or it didn’t happen :-) Now would be a good time to familiarize yourself with the concept of an MCVE (see:

Does the actual code (with proper error checking!) compile and run outside of Nsight? Are you compiling for the correct target architecture (-arch=sm_52)? What is the exact error message returned by Nsight?

According to what I believe your intent to be, this will not accomplish what you want.

dim3 radiance_gird = (4, 4, 4);

According to what I believe your intent to be, it should be either:

dim3 radiance_gird = dim3(4, 4, 4);


dim3 radiance_gird(4, 4, 4);

You can look up what the C or C++ rules are for evaluation of this construct:


The net is that the comma operator and parenthesis reduce it to:


And you can certainly initialize a dim3 item with a scalar quantity of 4, in which case it will result in:


cross posting:

demonstrating that the grid in question is reported as (4,1,1) (which is valid) not (4,0,0) which OP stated in original post of this thread (which is not a valid grid dimension)

I would not use the word “invalid” to describe the initialization. It has well-defined semantics, which were explained in detail by txbob. So the initialization is valid, but not what the programmer intended.

The intent is clear (in my opinion). For that implied intent, the method chosen is invalid. Wordsmithing applied.