2013-01-31 42 views
5

मैं NVCC एक त्रुटि के रूप में नीचे चेतावनी के इलाज के लिए करना चाहते हैं:NVCC चेतावनी स्तर

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

NVCC प्रलेखन "NVIDIA CUDA संकलक ड्राइवर NVCC" भी शब्द "चेतावनी" शामिल नहीं है।

+0

यह डिज़ाइन द्वारा कोई त्रुटि क्यों नहीं है? मैंने बस सफलतापूर्वक एनवीसीसी को संकलित किया (केवल आपके द्वारा वर्णित चेतावनी के साथ): '__host__ int c() {वापसी 0; } __host__ __device__ void b() {int a = c();} __global__ शून्य() {b();} /*...*/ <<<1, 1 > >>(); 'और रेखा' ए = सी(); '0 से पढ़ा गया है: 'mov.u32% r1, 0; ld.volatile.u32% आर 2, [% आर 1]; 'जो * कभी * काम नहीं कर सकता और निश्चित रूप से मेरा इरादा नहीं था। संकलक इस के साथ क्यों आगे बढ़ना चाहिए? – 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

मैंने सिर्फ '__host__ __device__' फ़ंक्शन को' __host__ __device__' फ़ंक्शन को संकलित करने के लिए एनओसीसी द्वारा किए गए क्रैश के लिए शिकार किया है, जो '__host__' फ़ंक्शन को गैर-डिवाइस डिवाइस कोड (जिसे' 0 से एक स्पष्ट पढ़ा जाता है: 'mov.u32% r31, 0; ld.u32% r32, [% R31]; ')। क्या कभी भी कोई कारण नहीं है - 'आतंक क्रॉस-निष्पादन-अंतरिक्ष-कॉल' का उपयोग न करें? – masterxilo