NVCC Warning Level

I would like NVCC to treat the warning below as an error:

warning : calling a __host__ function("foo") from a __host__ __device__ function("bar")

The NVCC "NVIDIA CUDA NVCC Compiler Driver" documentation does not even contain the word "warning."

+5
source share
1 answer

Indication of the CUDA COMPILER DRIVER NVCC Reference Manual, Section 3.2.8. "General tool parameters":

--Werror kindMake warnings about these types of errors. The following is a list of alert types accepted by this option:

cross-execution-space-callBe more stringent about unsupported firewall calls. The compiler will generate an error instead of a warning to call the __host__ __device__to function __host__.

Therefore, do the following:

→ → → CUDA C/++ → → → add --Werror cross-execute-space-call

#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) { }

warning : calling a __host__ function("foo") from a __host__ __device__ function("test") is not allowed

Error   3   error : calling a __host__ function("foo") from a __host__ __device__ function("test") is not allowed

.

+2

All Articles