Hello !
I have a .cpp, compiled with the MSVC c++ compiler, which includes a .cuh file. The cuh file defines a templated class and calls a kernel. (So the definition is indeed in the .cuh file)
My cuh file:
#pragma once
#include "cuda_runtime.h"
...
template<typename INPUT, typename OUTPUT>
class OffsetMapper : public ZMapper<INPUT, OUTPUT> {
...
OffsetMapperKernel<INPUT, OUTPUT> << < matOutput->dimGrid, matOutput->dimBlock >> > (
...
}
If the .cpp file is compiled with MSVC and I indicate the the .cuh is a CUDA file, compilation fails (syntax error “<”).
I really must flag my cpp file for compilation with nvcc (making it a .cu file, essentially) for it to work. Is that expected behaviour ? I can imagine it is, because the .cuh file gets compiled together with the .cpp file. But is there a workaround ?
Including a .cuh with a declaration and having an equivalent .cu file for the definition works perfectly well - when called from a .cpp file that is compiled with the MSVC toolchain.
Thanks so much your help !