Error at linking stage using mexcuda

9 visualizaciones (últimos 30 días)
PeakBragg
PeakBragg el 22 de Jul. de 2023
Comentada: PeakBragg el 23 de Jul. de 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

Respuesta aceptada

Joss Knight
Joss Knight el 22 de Jul. de 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 comentario
PeakBragg
PeakBragg el 23 de Jul. de 2023
Thank you so much ! The problem is solved

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Resizing and Reshaping Matrices en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by