__launch_bounds__ is an NVIDIA-specific CUDA compiler attribute for setting a kernel’s maximum threads per block and optionally guiding the compiler toward a minimum number of resident blocks per multiprocessor. The second value guides register budgeting; it does not reserve space or guarantee those blocks will fit. section 14.7
A stronger occupancy target can squeeze registers per thread and cause spilling to slow local memory. Treat the attribute as one tuning option, then measure performance: maximum occupancy is not necessarily fastest. section 14.11 section 14.7
__global__ void __launch_bounds__(256, 2) #A
myKernel(float* data, int n) { #B
}This declaration shows the attribute placed between the kernel qualifier and its name, with a 256-thread limit and a target of two blocks per multiprocessor. section 14.7
Compare register budgets
A target of two blocks with 256 threads each may lead the compiler to budget 32 registers per thread; if that causes spilling, a less aggressive target may run faster. Profile both configurations rather than assuming higher occupancy wins. section 14.11 section 14.8
