I have found this very useful post and I`d like to clarify something about the compiler optimizations. Lets say we have this function (same like in the original post):
template<int action>
__global__ void kernel()
{
switch(action) {
case 1:
// First code
break;
case 2:
// Second code
break;
}
}
Would the compiler do the optimization in the sense of eliminating an unreachable code even in the case I called the function with template variable unknown in the time of compiling - something like creating two separete functions? E.g.:
kernel<argv[1][0]>();