rules_cuda
rules_cuda copied to clipboard
Generate PTX artifacts
Hi. Is there a way to use rules_cuda to generate PTX? For example, this is useful for OptiX programming.
Can you share more about what you'd then do with them?
It'd be pretty easy to keep around the intermediate ptx files, but I want to better understand the workflow to see if what you really need is a different set of rules (if you intend to modify the ptx and continue compilation, etc)
Sure. Currently I'm using Buck, BTW, not Bazel, so concepts are close but not 1:1. I have an offline process using a simple Makefile to build PTX output. via nvcc Then I use filegroups to make those available to other targets, and I use that to set an environment variable for where to find the PTX files, which I then pass to OptiX functions.
This is quite reasonable usage, it just skip the stage1 compilation and only use the stage2 compilation. But this does not fit well into the actions.compile design. Becase it support generate multiple virtual archs.
Is that something you'd consider adding, either as a separate rule or as some kind of setting for an existing rule? Agreed, it would be ideal to be also able to select the generated archs.
It seems that what we need is actions.ptxas, that is, a new rule that calls ptxas directly, instead of trying to mold it into actions.compile. If it is the case, then the problem will be much easier. Then all you need is to feed the generated objects into a cuda_library.
Maybe do it in the future.
Sounds great. Thanks for considering it.
Oops, I took it as generate from PTX. But OP is requiring generate to PTX. That is, we need to extend actions.compile to support produce ptx. But as well as add actions.ptxas to support consuming it after all.