Description
The combination of cuLaunch
requiring getting the argument list exactly right and major version changes of PTX ISA can change the argument list makes it close to impossible of being certain that a kernel is launched correctly using the driver API. One way to improve upon this would be to parse the ptx/fatbin for kernel argument list and verify the rust source against it. This would not be possible for cubin, but ptx/fatbin should cover most use cases.
There are basically two approaches to this. The runtime approach would be to add function argument list info to Cust::module::Module
which is generated when ptx/fatbin is added to the module. Then it would be passed to the cust::function::Function
when it is created.
The other alternative is a static/build.rs
alternative. We could create a dev-dependency that parses a .ptx and create rust types containing information about the argument list layout. A generic method on Module
would then return the specific type implementing some Kernel
trait and the Stream
would have a generic launch
function that would accept some <Function as Kernel>::ArgList
argument.
I'm not promising to implement this, but would love to get some feedback on the idea.