Hello,
I was going to move the CUDA environment to 11.3 from 11.2 but I met an internal compiler error for tex2DLod().
Internal Compiler Error (codegen): unexpected operand in tex/surf handler
I tried to identify the root of cause and found that removing “-std=c++17” flag makes the code compilable. However I need this flag to compile the code to use C++ metaprogramming feature like folding expression.
This is the minimum code to reproduce the issue.
#include <cuda.h>
template <typename T>
__device__ __forceinline__ constexpr size_t getNumDwords() {
return (sizeof(T) + 3) / 4;
}
template <typename... Types>
__device__ __forceinline__ constexpr size_t calcSumDwords() {
return (0 + ... + getNumDwords<Types>());
}
extern "C" __global__ void test(CUtexObject texture) {
calcSumDwords<int32_t>(); // requires -std=c++17 to be compiled with MSVC 16.9.4 as the host compiler.
float4 color = tex2DLod<float4>(texture, 0.0f, 0.0f, 0.0f); // -std=c++17 causes the error with CUDA 11.3.
}
I also uploaded the VS solution for this repro here:
https://drive.google.com/file/d/1XwKZkPogKCsDR_suswjoB9jIgibXXNME/view?usp=sharing
ICE disappers by removing “-std=c++17” from the project’s property but folding expression starts to cause an error.
With CUDA 11.2 the code above was fine.
Thanks,
Windows 10 20H2
CUDA 11.3
NVIDIA Driver 466.11
Visual Studio 2019 Community 16.9.4