2013-01-31 4 views
5

Vorrei NVCC per trattare l'avvertimento di seguito come un errore:NVCC livello di avviso

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

NVCC documentazione "NVIDIA CUDA Compiler driver NVCC" non contiene neppure la parola "avvertimento".

+0

Perché non si tratta di un errore di progettazione? Ho appena provato nvcc a compilarlo correttamente (con solo l'avvertenza che hai menzionato): '__host__ int c() {return 0; } __host__ __device__ void b() {int a = c();} __global__ void a() {b();} /*...*/ a <<<1, 1 > >>(); 'e la riga' a = c(); 'è trasformato in una lettura da 0:' mov.u32% r1, 0; ld.volatile.u32% r2, [% r1]; "che non può * mai * funzionare e certamente non è quello che intendevo. Perché il compilatore dovrebbe procedere con questo? – masterxilo

risposta

2

Citando la guida di riferimento del CCDA COMPILER DRIVER NVCC, Sezione 3.2.8. "Opzioni strumento generico":

--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.

Pertanto, effettuare le seguenti operazioni:

Progetto -> Proprietà -> Proprietà di configurazione -> CUDA C/C++ -> Command Line -> Ottica aggiuntivi -> aggiungi - Werror cross-esecuzione-spazio-chiamare

Questo programma di test

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

restituisce il seguente avviso

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

senza l'opzione sopra menzionato compilazione aggiuntiva e restituisce il seguente errore

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

con la suddetta opzione di compilazione aggiuntiva.

+0

Ho appena cercato un arresto causato da nvcc che compila una funzione '__host__ __device__' che chiama una funzione' __host__' in un codice dispositivo non sensato (ovvero una lettura esplicita da 0: 'mov.u32% r31, 0; ld.u32% r32, [R31%]; '). C'è mai qualche ragione per non usare '--Werror cross-execution-space-call'? – masterxilo