I am confused why changes in a header file doesn’t always cause recompilation of cuda file. I’m currently messing around with an OptiX based renderer https://github.com/voldemarz/OppositeRenderer
For example if add a field in the Light class “RenderEngine\renderer\Light.h” I get an error at runtime that “buffer element size doesn’t match ptx” because cuda files that use the Light buffer haven’t been recompiled.
But if for example I add a field in Vector3 class “RenderEngine\math\Vector3.h”, the cuda file that uses it get recompiled.
Why the difference?
The project is built using MSBuild (e.g. regular Visual Studio project) not CMake and uses Nvidia provided Cuda build targets:
1>Skipping target “AddCudaCompilePropsDeps” because all output files are up-to-date with respect to the input files.
1>Skipping target “CudaBuild” because all output files are up-to-date with respect to the input files.
Am I missing something? I haven’t noticed regular VS C++ preprocessor behaving this way.
Sounds like Light.h is not part of some dependencies.
I would read through the *.vcxproj file in a plain text editor and check where Vector3.h and Light.h appear in any dependencies to see where Light.h is missing.
If this is a custom build step, check the compilation properties of the file which includes Light.h.
Both of them are in the project file. The build step is from “CUDA 5.5.targets” which is included at the end of the project file:
<Import Project="$(VCTargetsPath)\BuildCustomizations\CUDA 5.5.targets" />
Actually the only file that gets recompiled after change in Vector3.h is the cuda file that is being compiled as “hybrid object, --compile flag”, it contains few class methods, cuda kernels (not used as OptiX programs) and function templates that return Vector3. Not sure which of those things cause recompilation, don’t have time to pinpoint currently.
But cuda files compiled as ptx that simply contain Light buffer or variable declaration doesn’t get recompiled and that cause errors (or just undefined behavior) at runtime.