मैं सीयूडीए के साथ काम कर रहा हूं और मैंने जटिल पूर्णांक संख्याओं से निपटने के लिए int2_
कक्षा बनाई है।सीयूडीए बाहरी वर्ग लिंकेज और पीटीएक्सएएस फ़ाइल में अनसुलझा बाहरी समारोह
ComplexTypes.h
फ़ाइल में
कक्षा घोषणाओं इस प्रकार है:
ComplexTypes.cpp
फ़ाइल में
namespace LibraryNameSpace
{
class int2_ {
public:
int x;
int y;
// Constructors
__host__ __device__ int2_(const int,const int);
__host__ __device__ int2_();
// etc.
// Equalities with other types
__host__ __device__ const int2_& operator=(const int);
__host__ __device__ const int2_& operator=(const float);
// etc.
};
}
क्लास कार्यान्वयन इस प्रकार है:
#include "ComplexTypes.h"
__host__ __device__ LibraryNameSpace::int2_::int2_(const int x_,const int y_) { x=x_; y=y_;}
__host__ __device__ LibraryNameSpace::int2_::int2_() {}
// etc.
__host__ __device__ const LibraryNameSpace::int2_& LibraryNameSpace::int2_::operator=(const int a) { x = a; y = 0.; return *this; }
__host__ __device__ const LibraryNameSpace::int2_& LibraryNameSpace::int2_::operator=(const float a) { x = (int)a; y = 0.; return *this; }
// etc.
सब कुछ अच्छी तरह काम करता है। main
में (जिसमें ComplexTypes.h
शामिल है) मैं int2_
संख्याओं से निपट सकता हूं।
CudaMatrix.cu
फ़ाइल में, मैं अब ComplexTypes.h
शामिल कर रहा हूँ और परिभाषित करने और ठीक से __global__
समारोह instantiating:
template <class T1, class T2>
__global__ void evaluation_matrix(T1* data_, T2* ob, int NumElements)
{
const int i = blockDim.x * blockIdx.x + threadIdx.x;
if(i < NumElements) data_[i] = ob[i];
}
template __global__ void evaluation_matrix(LibraryNameSpace::int2_*,int*,int);
CudaMatrix.cu
फ़ाइल की स्थिति main
कार्य करने के लिए सममित हो रहा है। फिर भी, संकलक शिकायत:
Error 19 error : Unresolved extern function '_ZN16LibraryNameSpace5int2_aSEi' C:\Users\Documents\Project\Test\Testing_Files\ptxas simpleTest
कृपया, कि विचार करें:
- अलग फ़ाइलों के लिए कार्यान्वयन जाने से पहले, सब कुछ सही ढंग से काम किया गया था जब दोनों घोषणाओं और
main
फ़ाइल में कार्यान्वयन भी शामिल है। - समस्याग्रस्त निर्देश
data_[i] = ob[i]
है।
किसी को भी पता चल रहा है कि क्या हो रहा है?
शायद आप एक 'ComplexTypes.cpp' फ़ाइल नहीं है, बल्कि एक' ComplexTypes.cu' फ़ाइल जो आप NVCC करने से गुजर रहे हैं, नहीं तो '__host__ __device__' संकलन नहीं करना चाहिए ... – talonmies
मुझे अपने मुद्दे का समाधान मिला है। मैंने इसे एक उत्तर के रूप में पोस्ट किया है कि यह अन्य उपयोगकर्ताओं के लिए उपयोगी हो सकता है। – JackOLantern