rules_cuda icon indicating copy to clipboard operation
rules_cuda copied to clipboard

Generate PTX artifacts

Open graphicsMan opened this issue 3 years ago • 7 comments
trafficstars

Hi. Is there a way to use rules_cuda to generate PTX? For example, this is useful for OptiX programming.

graphicsMan avatar Nov 03 '22 17:11 graphicsMan

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)

ryanleary avatar Nov 03 '22 19:11 ryanleary

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.

graphicsMan avatar Nov 03 '22 20:11 graphicsMan

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.

cloudhan avatar Nov 04 '22 01:11 cloudhan

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.

graphicsMan avatar Nov 04 '22 15:11 graphicsMan

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.

cloudhan avatar Nov 04 '22 17:11 cloudhan

Sounds great. Thanks for considering it.

graphicsMan avatar Nov 04 '22 17:11 graphicsMan

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.

cloudhan avatar Nov 08 '22 06:11 cloudhan