Skip to content

Commit

Permalink
Clone printf and fprintf calls
Browse files Browse the repository at this point in the history
  • Loading branch information
kchristin22 committed Nov 20, 2024
1 parent 8d916fe commit 0e87928
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/Differentiator/ReverseModeVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1456,6 +1456,9 @@ Expr* getArraySizeExpr(const ArrayType* AT, ASTContext& context,
return StmtDiff(Clone(CE));
}

if (FD->getNameAsString() == "printf" || FD->getNameAsString() == "fprintf")
return StmtDiff(Clone(CE));

Expr* CUDAExecConfig = nullptr;
if (const auto* KCE = dyn_cast<CUDAKernelCallExpr>(CE))
CUDAExecConfig = Clone(KCE->getConfig());
Expand Down
2 changes: 2 additions & 0 deletions test/CUDA/GradientKernels.cu
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,7 @@ double fn_memory(double *out, double *in) {
//CHECK-NEXT:}

void launch_add_kernel_4(int *out, int *in, const int N) {
printf("Launching add_kernel_4 for size: %d\n", N);
int *in_dev = nullptr;
cudaMalloc(&in_dev, N * sizeof(int));
cudaMemcpy(in_dev, in, N * sizeof(int), cudaMemcpyHostToDevice);
Expand All @@ -520,6 +521,7 @@ void launch_add_kernel_4(int *out, int *in, const int N) {

// CHECK: void launch_add_kernel_4_grad_0_1(int *out, int *in, const int N, int *_d_out, int *_d_in) {
//CHECK-NEXT: int _d_N = 0;
//CHECK-NEXT: printf("Launching add_kernel_4 for size: %d\n", N);
//CHECK-NEXT: int *_d_in_dev = nullptr;
//CHECK-NEXT: int *in_dev = nullptr;
//CHECK-NEXT: cudaMalloc(&_d_in_dev, N * sizeof(int));
Expand Down

0 comments on commit 0e87928

Please sign in to comment.