Skip to content

Commit

Permalink
Merge pull request #12 from EnzymeAD/enzyme-rust
Browse files Browse the repository at this point in the history
Update Enzyme
  • Loading branch information
ZuseZ4 authored Mar 7, 2023
2 parents 70a710b + e6842be commit 467171d
Show file tree
Hide file tree
Showing 579 changed files with 53,492 additions and 8,762 deletions.
14 changes: 11 additions & 3 deletions src/tools/enzyme/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// available ubuntu versions: [18, 20]
// available llvm versions: [7, 8, 9, 10, 11, 12, 13]
// available ubuntu versions: [18, 20, 22]
// available llvm versions: [7, 8, 9, 10, 11, 12, 13, 14, 15]
{
"name": "Enzyme",
"image": "ghcr.io/enzymead/enzyme-dev-docker/ubuntu-20-llvm-12:latest",
Expand All @@ -9,5 +9,13 @@
"source=enzyme-extensions-insiders,target=/root/.vscode-server-insiders/extensions,type=volume",
"source=enzyme-build,target=${containerWorkspaceFolder}/enzyme/build,type=volume",
],
"postCreateCommand": "sudo chown vscode ./enzyme/build"
"postCreateCommand": "sudo chown vscode ./enzyme/build",
"runArgs": ["--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined"],
"customizations": {
"vscode": {
"extensions": [
"ms-vscode.cpptools-extension-pack"
]
}
}
}
4 changes: 1 addition & 3 deletions src/tools/enzyme/.github/workflows/bcload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ jobs:
sudo sed -i 's/add_executable(llvm-omp-device-info IMPORTED)//g' /usr/lib/llvm-${{matrix.llvm}}/lib/cmake/llvm/LLVMExports*.cmake
sudo sed -i 's/llvm-omp-device-info//g' /usr/lib/llvm-${{matrix.llvm}}/lib/cmake/llvm/LLVMExports*.cmake
fi
- uses: actions/checkout@v1
with:
fetch-depth: 1
- uses: actions/checkout@v3
- name: mkdir
run: cd enzyme && rm -rf build && mkdir build
- name: cmake
Expand Down
8 changes: 7 additions & 1 deletion src/tools/enzyme/.github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
matrix:
llvm: ["7", "8", "9", "10", "11", "12", "13"] #, "14"]
build: ["Release", "Debug"] # "RelWithDebInfo"
os: [self-hosted]
os: [openstack18]
timeout-minutes: 120
steps:
- name: add llvm
Expand Down Expand Up @@ -51,3 +51,9 @@ jobs:
run: cd enzyme/build && make bench-enzyme
- name: results
run: cat enzyme/benchmarks/*/*/results.txt
- name: graph results
run: |
for p in enzyme/benchmarks/ReverseMode/*/results.json; do
python3 enzyme/benchmarks/upload-results.py $p --url https://enzyme.mit.edu/cibench/api --token ${{ secrets.GRAPH_TOKEN }}
done
if: github.event_name != 'pull_request' && matrix.build == 'Release'
4 changes: 1 addition & 3 deletions src/tools/enzyme/.github/workflows/ccpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ jobs:
sudo sed -i 's/add_executable(llvm-omp-device-info IMPORTED)//g' /usr/lib/llvm-${{matrix.llvm}}/lib/cmake/llvm/LLVMExports*.cmake
sudo sed -i 's/llvm-omp-device-info//g' /usr/lib/llvm-${{matrix.llvm}}/lib/cmake/llvm/LLVMExports*.cmake
fi
- uses: actions/checkout@v1
with:
fetch-depth: 1
- uses: actions/checkout@v3
- name: mkdir
run: cd enzyme && rm -rf build && mkdir build
- name: cmake
Expand Down
2 changes: 1 addition & 1 deletion src/tools/enzyme/.github/workflows/doxygen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
docs:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: mattnotmitt/doxygen-action@v1.9.2
with:
Expand Down
55 changes: 46 additions & 9 deletions src/tools/enzyme/.github/workflows/enzyme-ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
name: Enzyme CI

on: [push]
on:
push:
branches:
- main
pull_request:

jobs:
build-linux:
Expand Down Expand Up @@ -37,7 +41,7 @@ jobs:
sudo sed -i 's/add_executable(llvm-omp-device-info IMPORTED)//g' /usr/lib/llvm-${{matrix.llvm}}/lib/cmake/llvm/LLVMExports*.cmake
sudo sed -i 's/llvm-omp-device-info//g' /usr/lib/llvm-${{matrix.llvm}}/lib/cmake/llvm/LLVMExports*.cmake
fi
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: mkdir
run: cd enzyme && rm -rf build && mkdir build
- name: cmake
Expand All @@ -51,7 +55,10 @@ jobs:
- name: make check-activityanalysis
run: cd enzyme/build && make check-activityanalysis -j`nproc`
- name: make check-enzyme
run: cd enzyme/build && make check-enzyme -j`nproc`
run: cd enzyme/build && make check-enzyme-bench -j`nproc`
- name: graph results
run: python3 enzyme/test/upload-results.py enzyme/build/test/Enzyme/results.json --url https://enzyme.mit.edu/cibench/api --token ${{ secrets.GRAPH_TOKEN }}
if: github.event_name != 'pull_request' && matrix.build == 'Release'

build-macos:
name: Enzyme CI LLVM ${{ matrix.llvm }} ${{ matrix.build }} macOS
Expand All @@ -60,28 +67,58 @@ jobs:
strategy:
fail-fast: false
matrix:
llvm: ["8", "9", "11", "12", "13"] #, "14"]
llvm: ["8", "9", "11", "12", "13", "14", "15"]
build: ["Release", "Debug"] # "RelWithDebInfo"

timeout-minutes: 30
steps:
- name: add llvm
run: |
brew update
brew install llvm@${{ matrix.llvm }} autoconf make cmake gcc libtool
sudo python3 -m pip install --upgrade pip setuptools
sudo python3 -m pip install lit
- uses: actions/checkout@v2
sudo python3 -m pip install lit requests
- uses: actions/checkout@v3
- name: mkdir
run: cd enzyme && rm -rf build && mkdir build
- name: cmake
run: |
cd enzyme/build
cmake .. -DCMAKE_BUILD_TYPE=${{ matrix.build }} -DLLVM_EXTERNAL_LIT=`which lit` -DLLVM_DIR=`brew --prefix llvm@${{ matrix.llvm }}`/lib/cmake/llvm
llvm_prefix=`brew --prefix llvm@${{ matrix.llvm }}`
cd enzyme/build
cmake .. -DCMAKE_BUILD_TYPE=${{ matrix.build }} -DLLVM_EXTERNAL_LIT=`which lit` -DLLVM_DIR=${llvm_prefix}/lib/cmake/llvm
- name: make
run: cd enzyme/build && make -j 3
- name: make check-typeanalysis
run: cd enzyme/build && make check-typeanalysis -j 3
- name: make check-activityanalysis
run: cd enzyme/build && make check-activityanalysis -j 3
- name: make check-enzyme
run: cd enzyme/build && make check-enzyme -j 3
run: cd enzyme/build && make check-enzyme-bench -j 3
- name: graph results
run: python3 enzyme/test/upload-results.py enzyme/build/test/Enzyme/results.json --url https://enzyme.mit.edu/cibench/api --token ${{ secrets.GRAPH_TOKEN }}
if: github.event_name != 'pull_request' && matrix.build == 'Release'

build-xcode:
name: Enzyme CI LLVM ${{ matrix.llvm }} ${{ matrix.build }} macOS XCode
runs-on: macos-latest

strategy:
fail-fast: false
matrix:
llvm: ["13"] #, "14"]
build: ["Release"] # "RelWithDebInfo"

timeout-minutes: 30
steps:
- name: add llvm
run: |
brew install llvm@${{ matrix.llvm }} autoconf make cmake gcc libtool
sudo python3 -m pip install --upgrade pip setuptools
sudo python3 -m pip install lit
- uses: actions/checkout@v3
- name: mkdir
run: cd enzyme && rm -rf build && mkdir build
- name: cmake
run: |
cd enzyme/build
cmake .. -GXcode -DCMAKE_BUILD_TYPE=${{ matrix.build }} -DLLVM_EXTERNAL_LIT=`which lit` -DLLVM_DIR=`brew --prefix llvm@${{ matrix.llvm }}`/lib/cmake/llvm
10 changes: 4 additions & 6 deletions src/tools/enzyme/.github/workflows/enzyme-julia.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,16 @@ jobs:
version:
- '1.6'
- '1.7'
- 'nightly'
- '1.8'
os:
- ubuntu-latest
- macOS-latest
arch:
- x64
timeout-minutes: 30
timeout-minutes: 60
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: actions/checkout@v3
with:
repository: 'wsmoses/Enzyme.jl'
path: ./jl
Expand Down
76 changes: 76 additions & 0 deletions src/tools/enzyme/.github/workflows/enzyme-mlir.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: MLIR

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build-linux:
name: MLIR ${{ matrix.build }} ${{ matrix.os }}
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
build: ["Release", "Debug"] # "RelWithDebInfo"
llbuild: ["Release"]
os: [openstack22]

timeout-minutes: 500
steps:
- name: add llvm
run: |
sudo rm -f /etc/apt/sources.list.d/*llvm*.list
sudo apt-get update
sudo apt-get install -y ninja-build git autoconf cmake gcc g++ libtool gfortran python3 python3-dev
- uses: actions/checkout@v3
- uses: actions/checkout@v3
with:
repository: 'llvm/Polygeist'
path: 'Polygeist'
submodules: true

- name: Cache MLIR
id: cache-mlir
uses: actions/cache@v2
with:
path: mlir-build
key: ${{ matrix.llbuild }}-${{ matrix.os }}-mlir-${{ hashFiles('Polygeist/.git/modules/llvm-project/HEAD') }}

- name: MLIR build
if: steps.cache-mlir.outputs.cache-hit != 'true'
run: |
mkdir mlir-build
cd mlir-build
cmake ../Polygeist/llvm-project/llvm -GNinja -DLLVM_ENABLE_PROJECTS="llvm;clang;mlir;openmp" -DCMAKE_BUILD_TYPE=${{ matrix.llbuild }} -DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_TARGETS_TO_BUILD=X86 -DLLVM_PARALLEL_LINK_JOBS=2
ninja -j2
- name: Cache Polygeist
id: cache-polygeist
uses: actions/cache@v2
with:
path: polygeist-build
key: ${{ matrix.llbuild }}-${{ matrix.os }}-polygeist-${{ hashFiles('Polygeist/.git/modules/llvm-project/HEAD') }}-${{ hashFiles('Polygeist/.git/refs/heads/main') }}

- name: Polygeist build
if: steps.cache-polygeist.outputs.cache-hit != 'true'
run: |
mkdir polygeist-build
cd polygeist-build
cmake ../Polygeist/ -GNinja -DMLIR_DIR=`pwd`/../mlir-build/lib/cmake/mlir -DLLVM_EXTERNAL_LIT=`pwd`/../mlir-build/bin/llvm-lit -DClang_DIR=`pwd`/../mlir-build/lib/cmake/clang -DCMAKE_BUILD_TYPE=${{ matrix.llbuild }}
ninja
- name: cmake
run: |
cd enzyme && mkdir build
cd build
cmake .. -GNinja -DCMAKE_BUILD_TYPE=${{ matrix.build }} -DLLVM_DIR=`pwd`/../../mlir-build -DENZYME_MLIR=ON
- name: make
run: cd enzyme/build && ninja
- name: make check-enzymemlir
run: cd enzyme/build && ninja check-enzymemlir

6 changes: 2 additions & 4 deletions src/tools/enzyme/.github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@ jobs:
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v1
with:
fetch-depth: 1
- uses: actions/checkout@v3
- uses: DoozyX/clang-format-lint-action@v0.11
with:
source: 'enzyme/Enzyme'
exclude: './CMakeLists.txt enzyme/Enzyme/SCEV'
style: 'llvm'
clangFormatVersion: 11
clangFormatVersion: 11
8 changes: 3 additions & 5 deletions src/tools/enzyme/.github/workflows/tagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,14 @@ jobs:
private_key: ${{ secrets.APP_PRIVATE_KEY }}
repository: JuliaPackaging/Yggdrasil

- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
repository: 'JuliaPackaging/Yggdrasil'
fetch-depth: 1
path: ygg

- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 1
path: enz
path: enz
- name: replace
run: |
cd ygg
Expand Down
12 changes: 6 additions & 6 deletions src/tools/enzyme/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
*.out
build
.vscode


# Added by cargo

/target
Cargo.lock
enzyme/benchmarks/ReverseMode/*/*.ll
enzyme/benchmarks/ReverseMode/*/*.bc
enzyme/benchmarks/ReverseMode/*/*.o
enzyme/benchmarks/ReverseMode/*/*.exe
enzyme/benchmarks/ReverseMode/*/results.txt
enzyme/benchmarks/ReverseMode/*/results.json
28 changes: 24 additions & 4 deletions src/tools/enzyme/.packaging/build_tarballs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@ repo = "https://github.com/EnzymeAD/Enzyme.git"
auto_version = "%ENZYME_VERSION%"
version = VersionNumber(split(auto_version, "/")[end])

llvm_versions = [v"11.0.1", v"12.0.1", v"13.0.1", v"14.0.2"]
llvm_versions = [v"11.0.1", v"12.0.1", v"13.0.1", v"14.0.2", v"15.0.7"]

# Collection of sources required to build attr
sources = [GitSource(repo, "%ENZYME_HASH%")]
sources = [
GitSource(repo, "%ENZYME_HASH%"),
ArchiveSource("https://github.com/phracker/MacOSX-SDKs/releases/download/10.15/MacOSX10.14.sdk.tar.xz",
"0f03869f72df8705b832910517b47dd5b79eb4e160512602f593ed243b28715f"),
]

# These are the platforms we will build for by default, unless further
# platforms are passed in on the command line
Expand All @@ -24,6 +28,16 @@ platforms = expand_cxxstring_abis(supported_platforms(; experimental=true))
script = raw"""
cd Enzyme
if [[ "${bb_full_target}" == x86_64-apple-darwin*llvm_version+15.asserts* ]]; then
# LLVM 15 requires macOS SDK 10.14.
pushd $WORKSPACE/srcdir/MacOSX10.*.sdk
rm -rf /opt/${target}/${target}/sys-root/System
cp -ra usr/* "/opt/${target}/${target}/sys-root/usr/."
cp -ra System "/opt/${target}/${target}/sys-root/."
export MACOSX_DEPLOYMENT_TARGET=10.14
popd
fi
# 1. Build HOST
NATIVE_CMAKE_FLAGS=()
NATIVE_CMAKE_FLAGS+=(-DENZYME_CLANG=ON)
Expand All @@ -38,13 +52,14 @@ NATIVE_CMAKE_FLAGS+=(-DBC_LOAD_FLAGS="-target ${target} --sysroot=/opt/${target}
cmake -B build-native -S enzyme -GNinja "${NATIVE_CMAKE_FLAGS[@]}"
# Only build blasheaders (and eventually tblgen)
ninja -C build-native -j ${nproc} blasheaders
# Only build blasheaders and tblgen
ninja -C build-native -j ${nproc} blasheaders enzyme-tblgen
# 2. Cross-compile
CMAKE_FLAGS=()
CMAKE_FLAGS+=(-DENZYME_EXTERNAL_SHARED_LIB=ON)
CMAKE_FLAGS+=(-DBC_LOAD_HEADER=`pwd`/build-native/BCLoad/gsl/blas_headers.h)
CMAKE_FLAGS+=(-DEnzyme_TABLEGEN_EXE=`pwd`/build-native/tools/enzyme-tblgen/enzyme-tblgen)
CMAKE_FLAGS+=(-DENZYME_CLANG=OFF)
# RelWithDebInfo for decent performance, with debugability
CMAKE_FLAGS+=(-DCMAKE_BUILD_TYPE=RelWithDebInfo)
Expand Down Expand Up @@ -94,6 +109,11 @@ for llvm_version in llvm_versions, llvm_assertions in (false, true)
LibraryProduct(["libEnzymeBCLoad-$(llvm_version.major)", "libEnzymeBCLoad"], :libEnzymeBCLoad, dont_dlopen=true),
]

if llvm_version >= v"15"
# We don't build LLVM 15 for i686-linux-musl.
filter!(p -> !(arch(p) == "i686" && libc(p) == "musl"), platforms)
end

for platform in platforms
augmented_platform = deepcopy(platform)
augmented_platform[LLVM.platform_name] = LLVM.platform(llvm_version, llvm_assertions)
Expand Down
Loading

0 comments on commit 467171d

Please sign in to comment.