CUDA external class linkage and unresolved extern function in ptxas file

后端 未结 1 1711
渐次进展
渐次进展 2020-12-08 17:57

I\'m working with CUDA and I have created an int2_ class to deal with complex integer numbers.

Class declarations in the ComplexTypes.h fi

相关标签:
1条回答
  • 2020-12-08 18:21

    The procedure I have followed in my post above has two issues:

    1. The ComplexTypes.cpp filename must be turned to ComplexTypes.cu so that nvcc could intercept the CUDA keywords __device__ and __host__. This has been pointed out by Talonmies in his comment. Actually, before posting, I was already changing the filename from .cpp to .cu, but the compiler was complaining and showing the same error. Therefore, I was ingenuously stepping back;

    2. In Visual Studio 2010, one has to use View -> Property Pages; Configuration Properties -> CUDA C/C++ -> Common -> Generate Relocatable Device Code -> Yes (-rdc=true). This is necessary for separate compilation. Indeed, at NVIDIA CUDA Compiler Driver NVCC, it is said that:

    CUDA works by embedding device code into host objects. In whole program compilation, it embeds executable device code into the host object. In separate compilation, we embed relocatable device code into the host object, and run the device linker (nvlink) to link all the device code together. The output of nvlink is then linked together with all the host objects by the host linker to form the final executable. The generation of relocatable vs executable device code is controlled by the --relocatable-device-code={true,false} option, which can be shortened to –rdc={true,false}.

    0 讨论(0)
提交回复
热议问题