Closed minansys closed 2 months ago
I can't reproduce here, it works for me on llvm12 at O1 and latest main. what did you use to compile
wmoses@beast:~/git/Enzyme/enzyme/build12 (utload) $ /home/wmoses/llvms/llvm12/buildD/bin/clang++ at.cpp -fplugin=Enzyme/ClangEnzyme-12.so $CXXFLAGS -O1 && ./a.out
warning: didn't implement memmove, using memcpy as fallback which can result in errors
freeing without malloc %"class.std::vector.0"* %__p
freeing without malloc %"class.std::vector.0"* %__p
FD 33.6251
adjoint 33.6251
ratio 1
Hi @wsmoses,
Thanks for taking a look at this. The issue was only reproducible in my original project in O0 and O3. I was using clang15 with the latest build. I can not reproduce it in this striped case, although the key routine is pretty much similar. In the original code, it is not a 2D matrix, it is 1D array in unstructured mesh. It is hard to mimic that here. I thought you might quickly identify the issue once you see the pattern here. I will close this defect since I can not make a reproducible case. Thanks for the help!
I had a C++ program using enzymeAd to compute the gradient and comparing with a finite difference. The results do not match.
The problem is due to the following code in void in_work(int i, int j, std::vector<std::vector> &phi, DataType& min_max)
If I change it to be
then the gradient matches with the finite difference. Here is a simplified version of the code from the original project, although this code can not reproduce the issue. However, you can get a sense of the background.