But program was illegally terminated with error command “an illegal instruction was encountered”.
(however, same program normaly works when compiling with “-G” option of nvcc.)
it might be helpful if you share the cuda version you are using as well as the exact compile command lines you are using. identifying whether you are on windows or linux may also be helpful
Furthermore, for a problem such as you describe, if I personally ran into that, I would first test on the latest CUDA (12.1, currently) before I did any more head-scratching.
You have device code scattered in two different modules, calling each other. For that code structure, then, you need to enable relocatable device code with device linking.
In a simplistic fashion, something like this:
nvcc -std=c++17 -o test main.cu test.cu -rdc=true
If you require that all the compile and link steps be broken out separately, then you will need to issue the right commands at each step of the way.
Great! Thanks to tell me a solution.
As you said, an illegal istruction error was surpressed by compiliation with “-rdc=true” option.
And compilation & linking using nvcc & mpicxx was successed by using command as follows.