I would like NVCC to treat the warning below as an error:
warning : calling a __host__ function("foo") from a __host__ __device__ function("bar")
NVCC documentation "NVIDIA CUDA Compiler Driver NVCC" doesn't even contain the word "warning".
Quoting the CUDA COMPILER DRIVER NVCC reference guide, Section 3.2.8. "Generic Tool Options":
--Werror kind
Make warnings of the specified kinds into errors. The following is the list of warning kinds accepted by this option:
cross-execution-space-call
Be more strict about unsupported cross execution space calls. The compiler will generate an error instead of a warning for a call from a__host__ __device__
to a__host__
function.
Therefore, do the following:
Project -> Properties -> Configuration Properties -> CUDA C/C++ -> Command Line -> Additional Optics -> add --Werror cross-execution-space-call
This test program
#include <cuda.h>
#include <cuda_runtime.h>
void foo() { int a = 2;}
__host__ __device__ void test() {
int tId = 1;
foo();
}
int main(int argc, char **argv) { }
returns the following warning
warning : calling a __host__ function("foo") from a __host__ __device__ function("test") is not allowed
without the above mentioned additional compilation option and returns the following error
Error 3 error : calling a __host__ function("foo") from a __host__ __device__ function("test") is not allowed
with the above mentioned additional compilation option.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With