Cuda Refactoing

Hello everyone,

I want to write a tool to do some modification in a Cuda C program ,my program must receive a cuda c program as its input and then do some modification on its AST and then in its bitcode

I have a problem in reading such files (.cu) clang does not recognize some tokens in cuda C language (like <<<) and it does not generate a proper output for kernel functions after i try to transfer my bitcode to ptx ,

Does anyone here that have a good manual that can help me out through this pipeline ?

Special thanck in advance,

+jacques to pull in the right people to get you started

Hey Bahram,

For the first part (recognize CUDA tokens), look in the clang/test/SemaCUDA directory for how clang is invoked to parse CUDA tokens (clang/test/SemaCUDA/function-target-hd.cu shows invocation variants). There is also some support already to query the AST for CUDA nodes. For example, a kernel launch (<<<,>>>) is matched by the AST matcher cudaKernelCallExpr.

Can you expand more on the bitcode part? I’m not quite following the flow of what your tool does, i.e., what does it take as input and what do you wish to generate with it?

Best,

Jacques