Loading multiple modules in JCuda

Hello all,
According to this question: here
I implemented this code to load multiple related modules:

JITOptions jitOptions = new JITOptions();
cuLinkCreate(jitOptions, linkState);

cuLinkAddFile(linkState, CUjitInputType.CU_JIT_INPUT_PTX, ptxFileName4, jitOptions);
cuLinkAddFile(linkState, CUjitInputType.CU_JIT_INPUT_PTX, ptxFileName3, jitOptions);
cuLinkAddFile(linkState, CUjitInputType.CU_JIT_INPUT_PTX, ptxFileName2, jitOptions);
cuLinkAddFile(linkState, CUjitInputType.CU_JIT_INPUT_PTX, ptxFileName1, jitOptions);

long sizeOut = 32768;
byte[] image = new byte[32768];
Pointer cubinOut = Pointer.to(image);

cuLinkComplete(linkState, cubinOut, (new long[]{sizeOut}));

module = new CUmodule();

// Load the module from the image buffer
cuModuleLoadData(module, cubinOut.getByteBuffer(0, 32768).array());


But I think I am doing the instruction of cuLinkComplete in a wrong way, because after calling it, the image array which is a output parameter passed to this is still empty. So, the next instruction which is cuModuleLoadData returns with this error : CUDA_ERROR_INVALID_IMAGE

How I can load multiple modules in JCuda? Is it the right way?

EDIT: This was written before I noticed cuda - JIT in JCuda, loading multiple ptx modules - Stack Overflow - Is this resolved now?


First of all, a short disclaimer: The “JITOptions” class is basically the only class in JCuda that does not have a 1:1 counterpart in CUDA. The JIT compilation/linking makes heavy use of things that could hardly be emulated sensibly in Java, so I felt the necessity to introduce this class to keep things managable. But it was not (yet) tested extensively, for various reasons. One of the main reasons is that I only recently switched from a CC-1.1-card to a newer one, and most of the JIT-features are only available with CC-2.0 and higher.

So if something that should work does not work, then don’t spend toooo much time fiddling around with it: I’ll have a look at it first, to see whether I got something wrong with the JITOptions class.

Unfortunately, at the moment, I’m at a PC with a CC-1.1-card again, so I can’t test it right now, but will try to do this ASAP (Monday/Tuesday, hopefully). From my first tests, I noticed that there is likely something wrong in the driver bindings: When I tried to add a PTX file for linking with cuLinkAddFile, I received a CUDA_ERROR_NO_BINARY_FOR_GPU - even if the SAME file could be loaded with cuModuleLoad. This should not be the case.

Sorry for the inconveniences, I’ll post more infos here ASAP.


Thanks for your quick answer.
Yes it is resolved now.