libCEED icon indicating copy to clipboard operation
libCEED copied to clipboard

Enzyme in libCEED

Open laylagi opened this issue 4 years ago • 7 comments

We have been able to reproduce examples/solids/finite-strain-neo-hookean-initial-1.h with Enzyme where Enzyme computes dSdE (\partial S / \partial E) in deltaS = dSdE:deltaE which was previously derived analytically.

CC: @KennethEJansen @wsmoses

laylagi avatar Oct 29 '21 23:10 laylagi

The changes seem fine, can you rebuild that pull request on Enzyme again, there were a few changes added which should ensure this works.

wsmoses avatar Oct 31 '21 18:10 wsmoses

The changes seem fine, can you rebuild that pull request on Enzyme again, there were a few changes added which should ensure this works.

Indeed it did work! Thanks!

laylagi avatar Oct 31 '21 18:10 laylagi

This is looking pretty good overall. This is marked draft. What's left before it's ready for review? I'd like to migrate it over to Ratel when this branch is ready.

jeremylt avatar Jan 25 '22 20:01 jeremylt

I am trying to wrap this up but I am not able to compile it. Nothing has really changed since the last time that I was able to compile and run the code. @wsmoses , do you think I need to change anything in the implementation?

/libCEED/examples/solids $ make V=1
/home/leila/git/petsc/arch-clang/bin/mpicc -L/home/leila/git/petsc/arch-clang/lib -L/home/leila/git/libCEED/lib  -Wl,-rpath,/home/leila/git/petsc/arch-clang/lib  -Wl,-rpath,/home/leila/git/libCEED/lib   build/elasticity.o build/problems/finite-strain-mooney-rivlin-initial-1.o build/problems/finite-strain-neo-hookean-current-1.o build/problems/finite-strain-neo-hookean-current-2.o build/problems/finite-strain-neo-hookean-initial-1.o build/problems/finite-strain-neo-hookean-initial-2.o build/problems/linear.o build/problems/mooney-rivlin.o build/problems/neo-hookean.o build/problems/problem-register.o build/problems/problem-weak.o build/problems/small-strain-neo-hookean.o build/src/boundary.o build/src/cl-options.o build/src/matops.o build/src/misc.o build/src/setup-dm.o build/src/setup-libceed.o build/problems/finite-strain-neo-hookean-initial-ad.o  -lpetsc -lceed -lm -o elasticity
/usr/bin/ld: build/problems/finite-strain-neo-hookean-initial-ad.o: in function `getEnzymeSize':
/home/leila/git/libCEED/examples/solids/problems/../qfunctions/finite-strain-neo-hookean-initial-ad.h:179: undefined reference to `__enzyme_augmentsize'
/usr/bin/ld: build/problems/finite-strain-neo-hookean-initial-ad.o: in function `grad_S_fwd':
/home/leila/git/libCEED/examples/solids/problems/../qfunctions/finite-strain-neo-hookean-initial-ad.h:185: undefined reference to `__enzyme_augmentfwd'
/usr/bin/ld: build/problems/finite-strain-neo-hookean-initial-ad.o: in function `grad_S_rev':
/home/leila/git/libCEED/examples/solids/problems/../qfunctions/finite-strain-neo-hookean-initial-ad.h:193: undefined reference to `__enzyme_reverse'
/usr/bin/ld: /home/leila/git/libCEED/examples/solids/problems/../qfunctions/finite-strain-neo-hookean-initial-ad.h:197: undefined reference to `__enzyme_reverse'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [Makefile:56: elasticity] Error 1

laylagi avatar Mar 01 '22 23:03 laylagi

@LeilaGhaffari, this sounds pretty close to ready. I'd like to add this work to Ratel. It think it will take a bit of effort to adapt, but it shouldn't be too bad and it would be interesting to run this at a larger scale

jeremylt avatar Apr 11 '22 17:04 jeremylt

@jeremylt , this works fine on CPU but the example runs for ever on HIP. I haven't figured out the problem yet.

laylagi avatar Apr 13 '22 03:04 laylagi

Note - this branch needs the updates in main for the latest development version of PETSc: #940

jeremylt avatar Apr 13 '22 15:04 jeremylt

Would you like to finish this branch or close it because the relevant code is in Ratel?

jedbrown avatar Sep 06 '22 02:09 jedbrown

I think we decided to close this and migrate the remaining pieces to Ratel. I'll go ahead and close it but would like to keep the branch until it is completely moved to Ratel.

laylagi avatar Sep 06 '22 14:09 laylagi