Defines/Macros.
shader code stub
[numthreads(NUMX,NUMY,NUMZ)]
void CS(uint3 threadId: SV_DispatchThreadID)
{
// do your thing
}
And then provide those defines through the shader compilation process. For the command line compiler it's
-DNUMX=8 etc. For
D3DCompile it's the pDefines parameter.
I occasionally grant defaults for such things, so I can check-compile without providing those values (again shader code)
#ifndef NUMX
#define NUMX 8
#endif
Edit: Don't know if you can get numthreads from a compiled shader easily through shader reflection, never tried. There's dcl_thread_group declaration in the assembly, but from a quick glance at the shader reflection interface it doesn't look like it's conveniently retrievable.
Edit2: Blind in the morning
. See below, Thanks Tiago.