Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Enzyme AD support #23

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

AVanDeBrook
Copy link

This PR adds a script to pull down specific releases of LLVM and Enzyme and build local versions of both.

On my machines LLVM compiles without issue, however, at run time it depends on gcc and/or g++ headers. I found that gcc-12 and g++-12 provide the most stability with llvm-16.

With the versions pinned in the shell script, Enzyme should compile without issue and the tests will output 2 errors; these errors do not affect the functionality of Enzyme.

Programs can be compiled like the following:

clang test.c -fplugin=.enzyme_build/Enzyme/enzyme/build/Enzyme/ClangEnzyme-16.so

Note(s):

  • Enzyme has had a recent burst in development, so the most current version is ahead of the one I've tested and verified
  • This uses LLVM version 16.0.0, Enzyme version 0.0.133, and depends on GCC/G++ version 12

@pelesh pelesh added the enhancement New feature or request label Sep 13, 2024
@reid-g
Copy link
Collaborator

reid-g commented Sep 16, 2024

Running the enzyme_support.sh script starting from nothing only clones in the Enzyme repo. The llvm repo does not clone. Then crashes since there is no llvm repo.

@stonecoldhughes
Copy link
Collaborator

stonecoldhughes commented Sep 28, 2024

The two Dockerfiles below and associated shell scripts ilustrate 2 builds of Enzyme that pass all or most of the Enzyme builtin tests: "check-enzyme-integration" and "check-enzyme". One dockerfile passes one set of tests, and the other passes the other set of tests. The file extensions have all been converted to ".txt" so that Github will allow me to attach them in this comment. This is not in a PR because it is incomplete work; these illustrate the ENZYME tests. Next steps:

  1. build a sample program and take the df/dx with ENZYME
  2. build GridKit in the container; apply enzyme to gridkit as desired

resolve_enzyme_1.txt
resolve_enzyme_0.txt
run_1.txt
build_1.txt
build_0.txt
run_0.txt

container_1:

check_integration:
image
check enzyme:
image

container_0:

image

Copy link
Collaborator

@stonecoldhughes stonecoldhughes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR represents a good collection of Enzyme AD build/test examples using LLVM built from scratch or by package managers. I think it should be converted into an issue, since the scope is broad and exploratory, and what we want to do is still being investigated.
Some questions:

  1. How can users get EnzymeAD? It is not a trivial installation process. Can a spack package handle it? Or a container environment? I have not attempted to build LLVM from scratch; with package managers, the installation is very sensitive to OS version. Is this also true when building from scratch, as in the build script?
  2. How do we want to use Enzyme in the source code? Is there existing functionality that enzyme could replace, and a test to ensure that functionality remains operational?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants