Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
PetroZarytskyi committed Aug 19, 2024
1 parent f5f56a1 commit 9202340
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test/Gradient/Pointers.C
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,21 @@ double cStyleMemoryAlloc(double x, size_t n) {
// CHECK-NEXT: free(_d_t);
// CHECK-NEXT: }

double* ptrValFn (double* x, int n) {
x += n;
return x;
}

// CHECK: lksahf

double nestedPtrFn (double x, double y) {
double arr[] = {x, y};
double* z = ptrValFn(arr, 1);
return *z;
}

// CHECK: lksahf

#define NON_MEM_FN_TEST(var)\
res[0]=0;\
var.execute(5,res);\
Expand Down Expand Up @@ -573,4 +588,9 @@ int main() {
d_x = 0;
d_cStyleMemoryAlloc.execute(5, 7, &d_x);
printf("%.2f\n", d_x); // CHECK-EXEC: 4.00

auto d_nestedPtrFn = clad::gradient(nestedPtrFn);
d_i = 0; d_j = 0;
d_nestedPtrFn.execute(5, 7, &d_i, &d_j);
printf("%.2f %.2f\n", d_i, d_j); // CHECK-EXEC: 7.00 5.00
}

0 comments on commit 9202340

Please sign in to comment.