I’d like to create a PR to allow the @cuda.jit decorator’s link field to accommodate in-memory PTX.
Currently, if a user want to create PTX code dynamically, they need to create a temporary file, and pass the path to the link field of the @cuda.jit decorator. I propose creating a new class (PTXCode) that will store code as a string. Such an object could be added to the link list.
The only other change needed to existing code would be at line 183 of numba/cuda/codegen.py
for path in self._linking_files:
if isinstance(path, PTXCode):
linker.add_ptx(path._ptx.encode(encoding='ascii'))
else :
linker.add_file_guess_ext(path)
Does this sound like a good and/or desirable improvement?
It’s also not clear to me where the best place to put the new PTXCode class is. Any guidance on that would be appreciated.
@ed-o-saurus thanks for the link!
Could you please look at this issue https://numba.discourse.group/t/extending-numba-for-cuda-inside-cppyy/2644 and guide me further.