Error at linking stage using mexcuda

9 visualizzazioni (ultimi 30 giorni)
PeakBragg
PeakBragg il 22 Lug 2023
Commentato: PeakBragg il 23 Lug 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

Risposta accettata

Joss Knight
Joss Knight il 22 Lug 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).

Più risposte (0)

Categorie

Scopri di più su Resizing and Reshaping Matrices in Help Center e File Exchange

Prodotti


Release

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by