于 秋沣 via llvm-dev
2017-Dec-29 07:26 UTC
[llvm-dev] Retrieve grid variable name in CUDA kernel call
Hi all, I'm trying to retrieve the grid variable name inside a CUDA kernel call. For example, I have the following CUDA code: dim3 Dg(nelr / BLOCK_SIZE_1), Db(BLOCK_SIZE_1); cuda_initialize_variables<<<Dg, Db>>>(nelr, variables); getLastCudaError("initialize_variables failed"); What I need is to find the name of the grid variable, in this case, Dg. Currently, I'm able to find the CUDAKernelCallExpr, and get the CallExpr pointer by using the following code: CUDAKernelCallExpr *kce = dyn_cast<CUDAKernelCallExpr>(stmt); CallExpr *kernelConfig = kce->getConfig(); Expr *grid = kernelConfig->getArg(0); Now I'm stuck at the problem is how to find the actual name of the grid, in this case, "Dg". Here is the AST dump of the Expr *grid: CXXConstructExpr 0x564e5305f928 'dim3':'struct dim3' 'void (const struct dim3 &) throw()' `-ImplicitCastExpr 0x564e5305f910 'const dim3':'const struct dim3' lvalue <NoOp> `-DeclRefExpr 0x564e5305f7b0 'dim3':'struct dim3' lvalue Var 0x564e5305f468 'Dg' 'dim3':'struct dim3' Thank you in advance! Patrick -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20171229/b9bf081d/attachment.html>