Multiple ptx/cubin files merge and calls

Hi,

I have two ptx files and I need to call functions from one file to another.
Currently, I can load a single ptx file (does not have any call to functions in different file) using driver api and run it (following the samples in cuda toolkit 5.5 - ptxjit).

I was thinking to merge two ptx files into a single cubin and then using CUDA driver API to run the final cubin. My problems:

  1. I could not find a way to merge two ptx files into a single cubin. Anyone knows how to do that?
  2. Is there an alternate way to load two ptx files and run them using the API?

Thanks

Have you looked at the cuModule*() and cuLink*() functions?

Do you want to “merge” the PTX files primarily to avoid performing multiple module loads? Or are you actually trying to link the two files because there are dependencies?

I have a similar challenge, but involving Optix7 and MDL. I can get the MDL to compile to PTX, but there’s a bunch of extern function in the PTX that I must create myself (like how to access a texture for example, which I might want to control in some ways). With the cuLink* function, you can only get a cubin file. But to create an Optix7 module, it requires the direct PTX code (it does some optimization).

So I do have the compiled PTX file with my functions that must be combined with the compiled PTX of the MDL that I’m loading. I can think of a tricky solution involving RegExes to remove the .extern .func definitions in the MDL PTX file and put the PTX source of my functions at the beginning… but I’d like to avoid any kind of hacky solution.