FLAMEGPU2 icon indicating copy to clipboard operation
FLAMEGPU2 copied to clipboard

Name headers .cuh and .h as appropriate

Open ptheywood opened this issue 6 years ago • 2 comments

Cmake uses the appropriate compiler based on the extension of teh file. i.e .cpp files will use g++ while .cu files will use nvcc. Visual studio with cuda enabled will pass all files through nvcc.

This means that including cuda related headers in a .cpp file will work under windows but not linux.

I.e.

In file included from /home/ptheywood/code/flamegpu/flamegpu2_dev/include/flamegpu/runtime/flame_functions_api.h:14:0,
                 from /home/ptheywood/code/flamegpu/flamegpu2_dev/include/flamegpu/model/AgentFunctionDescription.h:22,
                 from /home/ptheywood/code/flamegpu/flamegpu2_dev/include/flamegpu/model/AgentDescription.h:22,
                 from /home/ptheywood/code/flamegpu/flamegpu2_dev/include/flamegpu/model/ModelDescription.h:22,
                 from /home/ptheywood/code/flamegpu/flamegpu2_dev/include/flamegpu/io/statereader.h:15,
                 from /home/ptheywood/code/flamegpu/flamegpu2_dev/include/flamegpu/io/xmlReader.h:14,
                 from /home/ptheywood/code/flamegpu/flamegpu2_dev/src/flamegpu/io/xmlReader.cpp:16:
/home/ptheywood/code/flamegpu/flamegpu2_dev/include/flamegpu/gpu/CUDAErrorChecking.h:16:26: fatal error: cuda_runtime.h: No such file or directory

The file xmlReader.cpp is compiled by g++, but tthrough the inclusion chain it attempts to include cuda_runtime.h which is not available.

Using the appropriate naming convention should help us to not include cuda files in cpp files.

ptheywood avatar Nov 02 '18 16:11 ptheywood

I hope you aren't suggesting we rename cuda_runtime.h, that's part of the CUDA toolkit!

Robadob avatar Oct 10 '19 12:10 Robadob

Renaming flame_functions_api.h to flame_functions_api.cuh would let cmake correctly handle it as a cuda file and use nvcc rather than a host c compiler, with appropriate flags to actually find cuda_runtime.h

ptheywood avatar Oct 10 '19 12:10 ptheywood