clad
clad copied to clipboard
Failure to build when using #include "clad/Differentiator/Differentiator.h" and a .cu file
Hi all, I want to use the clad implementation on the GPU, the problem however is that when I use the #include and build the .cu file I get the following errors using LLVM-v15.
Could anyone direct me in how to address these errors or if there is a more "compatible" version for CUDA ?
FAILED: src/external_function/CMakeFiles/external_function.dir/gradientExecution.cu.o
CLAD/include/clad/Differentiator/CladConfig.h(60): error: function "trap" has already been defined void trap(int code) { ^ CLAD/include/clad/Differentiator/CladConfig.h(75): error: function template "clad_addressof" has already been defined T* clad_addressof(T& r) { ^
CLAD/include/clad/Differentiator/BuiltinDerivatives.h(35): error: attributes are not permitted in a function definition size_t d_count) attribute((host)) { ^
CLAD/include/clad/Differentiator/BuiltinDerivatives.h(41): error: attributes are not permitted in a function definition attribute((host)) { ^
CLAD/include/clad/Differentiator/Tape.h(132): error: calling a device function("_Z4trap1?") from a host device function("grow") is not allowed trap(1); ^
5 errors detected in the compilation of "external_function/gradientExecution.cu". ninja: build stopped: subcommand failed.
Which version of clad are you using?
clad 1.2
Can you try with the master as I believe I've fixed a similar problem?
Hi @vgvassilev , I have tried it with the master branch and I get the same errors
Hi All, I have been looking into the issue, and I realised that the .bashrc file used for the computation engine automatically specifies the cuda compiler to be nvcc, and not clang. and this got me thinking, may this be a possible answer to the error arising ? I know that in the post it states that this may not be an issue with Clang ? (https://llvm.org/docs/CompileCudaWithLLVM.html)
And if this is the case, could someone please possibly assist me with the various specifications required in CMake required to run CUDA code with clang++ and what needs to be done in the CMake file, I feel like there is very limited information on this.
I hope this helps
Thanks all