OpenMP reductions seem unsupported
- Dominant language
- LLVM
- Stars
- 1.7k
- Forks
- 188
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 26
Description
Consider this program:
```C++
#include
#include
#include
extern int enzyme_dup;
extern int enzyme_dupnoneed;
extern int enzyme_out;
extern int enzyme_const;
void __enzyme_autodiff(...) noexcept;
void primal(size_t n, const double* x, double* out) {
double sum = 0;
#pragma omp parallel for reduction(+:sum)
for (size_t i = 0; i < n; i++) {
sum += x[i];
}
*out = sum;
}
int main() {
size_t n = 10;
double input[10];
double output[10];
double dummy, unit = 1;
__enzyme_autodiff(primal,
enzyme_const, n,
enzyme_dup, input, output,
enzyme_dupnoneed, &dummy, &unit);
}
```
When compiled with Enzyme I get a long error, but the important part is this:
```
ld.lld: /build/source/enzyme/Enzyme/CallDerivatives.cpp:2345: bool AdjointGenerator::handleKnownCallDerivatives(CallInst &, Function *, StringRef, bool, const std::vector &, CallInst *const): Assertion `0 && "unhandled openmp function"' failed.
```
This has been reported earlier in #1246, but that issue was closed and migrated to a discussion: https://github.com/EnzymeAD/Enzyme/discussions/1251
I was [encouraged by wmoses to open an issue](https://github.com/gradbench/gradbench/pull/571#discussion_r2091795815), so here it is. Supporting OpenMP reductions would certainly be very nice, but it is not a dealbreaker, as it is not very difficult to write your own using the parts of OpenMP that Enzyme does support.
Contributor guide
Assessment
This issue has not been assessed yet.