Effacer les filtres
Effacer les filtres

Error at linking stage using mexcuda

8 vues (au cours des 30 derniers jours)
PeakBragg le 22 Juil 2023
Commenté : PeakBragg le 23 Juil 2023
I have a large scale simulation project using mexcuda interface. In the past I put all the codes in a few files mixed with declaration and initialization in the header file, obviously this is not good practise, but it comiles ok and runs without problem. Now the work is getting more complicated and I decided to do it properly with header file and code file sperately, compile into obj files and link them together. But I am having issue at the last linking stage. It is complaining about:
error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary
It is probably related to the compile settings, I do have to use the NVCC_FLAGS=-rdc=true flag to turn on "Generate Relocatable Device Code" since some host function and device kernels are seperated into different files. The other potential solution is to turn on "Generate hybrid object file", based on the following post, but I am not sure how exactly to set that in NVCC_FLAGS.
I have attached the error log from mexcuda here, any ideas to resolve this issue is greatly appreciated. Thanks

Réponse acceptée

Joss Knight
Joss Knight le 22 Juil 2023
Relocatable device code needs to be linked by nvcc using -dlink before it can be linked to host code using the C linker, so you'd need to call mexcuda multiple times, first with -c -rdc to generate relocatable object files, then with -dlink to create executable object files, then one more time passing all the object files so they can be linked.
Instead, you can try just calling mexcuda with the -dynamic flag (and without setting -rdc yourself), which essentially does all this for you (although it will also statically link the cudadevrt library which may cause some bloat).
  1 commentaire
PeakBragg le 23 Juil 2023
Thank you so much ! The problem is solved

Connectez-vous pour commenter.

Plus de réponses (0)


En savoir plus sur Resizing and Reshaping Matrices dans Help Center et File Exchange




Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by