No reverse pass found for Petsc Functions
- Dominant language
- LLVM
- Stars
- 1.7k
- Forks
- 188
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 26
Description
Here is my failing code. The issue is that if I move the lines with PetscCallVoid (which are using a user struct) inside the for loop, or if I comment them out, there are no errors. However, in order to execute the for loop, I need that coneSize. I tried preprocessing it and storing it in the user struct, but when I attempted to retrieve coneSize from an array inside the struct, it failed as well. How can I solve this? (I'm using the latest release of Enzyme, v0.0.79)
Edit: I realized that if I hardcode coneSize, for example set it to 4, the code fails too. So struct might not be the thing which is triggering the failure. Petsc function are triggering the error. I tried writing a wrapper function in my source code for Petsc functions. But it didn't worked too. I added sample error. Actually these functions are not affecting my derivatives. If there is a way to tag them for that I could use it too.
```
No reverse pass found for DMPlexGetConeSize
declare !dbg !1321 i32 @DMPlexGetConeSize(%struct._p_DM* noundef, i32 noundef, i32* noundef) local_unnamed_addr #4
```
``` C
void formCellResidual(PetscReal *cellResidual, const PetscReal *x, PetscInt cellO, AppCtx *user)
{
*cellResidual = 0;
PetscReal TO = x[cellO], cellOCenter[3];
const PetscInt *cone;
PetscInt coneSize;
DMLabel faceType;
PetscCallVoid(DMPlexComputeCellGeometryFVM(user->dm, cellO, NULL, cellOCenter, NULL));
PetscCallVoid(DMPlexGetConeSize(user->dm, cellO, &coneSize));
PetscCallVoid(DMGetLabel(user->dm, "faceType", &faceType));
PetscCallVoid(DMPlexGetCone(user->dm, cellO, &cone));
for (PetscInt i = 0; i < coneSize; i++)
{
// some uber super calculations
}
}
```
```C
__enzyme_autodiff(formCellResidual, enzyme_dupnoneed, &f, &grad_f, enzyme_dup, x, grad_x, enzyme_const, cellO,
enzyme_const, user);
```
Additionally, I have a side question. I'm currently using Enzyme, which I really appreciate. However, I sometimes come across errors, and unfortunately, the error messages or LLVM IR codes are not very meaningful to me. If you could provide a starting point for me to contribute to Enzyme, I'd be eager to give it a try.
Contributor guide
Assessment
This issue has not been assessed yet.