2013-01-31 26 views
5

私はエラーとして、以下の警告を治療するためのNVCCをしたいと思います:NVCC警告レベル

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

NVCCのドキュメント「NVIDIA CUDAコンパイラドライバNVCCは」偶数ワード「警告」が含まれていません。

+0

これは設計上のエラーではないのはなぜですか?私はちょうどnvccがこれをうまくコンパイルするのを経験しました。あなたが言及した警告だけです: '__host__ int c(){return 0; } __host__ __device__ void b(){int a = c();} __global__ void(){b();} /*...*/ a <<<1, 1 > >>(); ' c(); 'は0からの読み込みに変わります:' mov.u32%r1、0; ld.volatile.u32%r2、[%r1];それは*決して*働くことはできませんし、確かに私が意図したものではありませんでした。なぜコンパイラはこれを進めるべきですか? – masterxilo

答えて

2

CUDA COMPILER DRIVER NVCCリファレンスガイドのセクション3.2.8を引用してください。 "一般的なツールオプションは":

プロジェクト - >プロパティ - >構成プロパティ - > CUDA C/C++ - >コマンドライン - >追加の光学系 - >を追加 - :

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

したがって、次の手順を実行しますWerrorクロス実行スペース・コール

このテストプログラム

#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 

を返します。

+0

私はちょうどnvccによって引き起こされたクラッシュのために、 '__host__'関数を無意味なデバイスコード(すなわち、0からの明示的な読み込み:' mov.u32%r31,0; ld.u32%r32、 [%r31];) '' Werror cross-execution-space-call'を使わない理由はありますか? – masterxilo