Skip to content

Commit 62b514c

Browse files
committed
Better CI for LLVM and Julia (#3)
* Try without ubuntu mods * Fix python lit install * Reduce fetch depth for CI * Try relpath * Force llvm findpackage * add no default path * add cmake path * Force LLVM path * actually force llvm path * install usual way * add llvm spaces * add llvm spaces * add llvm spaces * add llvm spaces * add llvm spaces * Fix tools * try julia build too * update build_llvm * Fix julia issue (LLVM.cmake has hardcoded bad path) * Ensure filecheck and opt are in julia path * add llvm config for julia * Put enzyme test after julia one * show paths * fix enzyme.jl tests * ensure ENZYME_PATH is set * add workspace var? * add workspace var? * add reversediff
1 parent 79fa2ed commit 62b514c

File tree

4 files changed

+93
-10
lines changed

4 files changed

+93
-10
lines changed

.github/workflows/ccpp.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,22 @@ jobs:
1010
strategy:
1111
fail-fast: false
1212
matrix:
13-
llvm: ["6.0", "7", "8", "9"]
14-
build: ["Release", "RelWithDebInfo", "Debug"]
13+
llvm: ["7", "8"]
14+
build: ["Release", "Debug"] # "RelWithDebInfo"
1515
os: [ubuntu-18.04]
1616

1717
steps:
1818
- name: add llvm
19-
run: sudo add-apt-repository 'deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-${{ matrix.llvm }} main'
20-
- name: update ubuntu
21-
run: sudo apt-get update -y && sudo apt-get remove -y llvm* libllvm* libgl* php* mono* msbuild* libmono*
22-
- name: install llvm
23-
run: sudo apt-get install -y --no-install-recommends build-essential llvm-${{ matrix.llvm }}-tools llvm-${{ matrix.llvm }}-dev cmake
19+
run: sudo apt-get install -y llvm-${{ matrix.llvm }}-dev llvm-${{ matrix.llvm }}-tools
2420
- uses: actions/checkout@v1
21+
with:
22+
fetch-depth: 1
2523
- name: mkdir
2624
run: cd enzyme && mkdir build
2725
- name: cmake
28-
run: cd enzyme/build && cmake .. -DLLVM_EXTERNAL_LIT=/usr/lib/llvm-${{ matrix.llvm }}/build/utils/lit/lit.py -DCMAKE_BUILD_TYPE=${{ matrix.build }}
26+
run: |
27+
cd enzyme/build
28+
cmake .. -DLLVM_EXTERNAL_LIT=/usr/lib/llvm-${{ matrix.llvm }}/build/utils/lit/lit.py -DCMAKE_BUILD_TYPE=${{ matrix.build }} -DLLVM_DIR=/usr/lib/llvm-${{ matrix.llvm }}/lib/cmake/llvm
2929
- name: make
3030
run: cd enzyme/build && make
3131
- name: make check-enzyme

.github/workflows/julia.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Julia CI
2+
3+
on: [push]
4+
5+
jobs:
6+
test:
7+
name: Test on os ${{ matrix.os }} and Julia ${{ matrix.julia-version }}
8+
runs-on: ${{ matrix.os }}
9+
strategy:
10+
fail-fast: false
11+
matrix:
12+
julia-version: [1.2.0]
13+
os: [ubuntu-18.04]
14+
15+
steps:
16+
- name: "Checkout Enzyme.jl code"
17+
uses: actions/checkout@v1
18+
with:
19+
repository: wsmoses/Enzyme.jl
20+
clean: false
21+
path: Enzyme.jl
22+
token: ${{secrets.enzymejl_secret}}
23+
ref: master
24+
- name: "Checkout Enzyme code"
25+
uses: actions/checkout@v1
26+
with:
27+
fetch-depth: 1
28+
- name: "Set up Julia"
29+
uses: julia-actions/setup-julia@v0.2
30+
with:
31+
version: ${{ matrix.julia-version }}
32+
- name: "Download LLVM"
33+
run: |
34+
julia --project=contrib -e 'using Pkg; pkg"instantiate"'
35+
julia --project=contrib contrib/build_LLVM.v6.0.1.jl
36+
sudo mkdir -p /workspace
37+
sudo ln -s `pwd`/contrib/usr /workspace/destdir
38+
sudo ln -s `pwd`/contrib/usr/tools/opt `pwd`/contrib/usr/bin/opt
39+
sudo ln -s `pwd`/contrib/usr/tools/FileCheck `pwd`/contrib/usr/bin/FileCheck
40+
sudo ln -s `pwd`/contrib/usr/tools/llvm-config `pwd`/contrib/usr/bin/llvm-config
41+
env:
42+
NO_DEPS: true
43+
- name: "Build Enzyme"
44+
run: |
45+
mkdir build
46+
cd build
47+
cmake -DLLVM_DIR=../contrib/usr/lib/cmake/llvm -DLLVM_EXTERNAL_LIT=../contrib/usr/tools/lit/lit.py ../enzyme
48+
make -j
49+
- name: "Julia tests"
50+
run: |
51+
cd ../Enzyme.jl
52+
julia --project=. -e 'using Pkg; pkg"instantiate"; pkg"add ReverseDiff"'
53+
julia --project=. test/runtests.jl
54+
env:
55+
ENZYME_PATH: "../Enzyme/build/Enzyme"
56+
- name: "Check Enzyme"
57+
run: |
58+
cd build
59+
make check-enzyme

enzyme/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ get_filename_component(LLVM_ABSOLUTE_LIT
2929
set(LLVM_EXTERNAL_LIT "${LLVM_ABSOLUTE_LIT}" CACHE FILEPATH "a" FORCE)
3030
message("found llvm lit " ${LLVM_EXTERNAL_LIT})
3131

32+
33+
list(INSERT CMAKE_PREFIX_PATH 0 "${LLVM_DIR}")
34+
message("CMAKE_PREFIX_PATH " ${CMAKE_PREFIX_PATH})
3235
find_package(LLVM REQUIRED CONFIG)
3336
list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}")
3437
include(AddLLVM)

enzyme/Enzyme/Enzyme.cpp

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5054,17 +5054,37 @@ PHINode* canonicalizeIVs(Type *Ty, Loop *L, ScalarEvolution &SE, DominatorTree &
50545054
//return pn;
50555055

50565056

5057-
{ SCEVExpander(SE, L->getHeader()->getParent()->getParent()->getDataLayout(), "ad"); }
5057+
PHINode *CanonicalIV;
5058+
5059+
/*
5060+
{
5061+
SCEVExpander e(SE, L->getHeader()->getParent()->getParent()->getDataLayout(), "ad");
5062+
5063+
assert(Ty->isIntegerTy() && "Can only insert integer induction variables!");
5064+
5065+
// Build a SCEV for {0,+,1}<L>.
5066+
// Conservatively use FlagAnyWrap for now.
5067+
const SCEV *H = SE.getAddRecExpr(SE.getConstant(Ty, 0),
5068+
SE.getConstant(Ty, 1), L, SCEV::FlagAnyWrap);
5069+
5070+
// Emit code for it.
5071+
e.setInsertPoint(&L->getHeader()->front());
5072+
Value *V = e.expand(H);
5073+
5074+
CanonicalIV = cast<PHINode>(V); //e.expandCodeFor(H, nullptr));
5075+
}
5076+
*/
50585077

50595078
BasicBlock* Header = L->getHeader();
50605079
Module* M = Header->getParent()->getParent();
50615080
const DataLayout &DL = M->getDataLayout();
50625081
SmallVector<Instruction*, 16> DeadInsts;
5063-
PHINode *CanonicalIV;
50645082

50655083
{
50665084
SCEVExpander Exp(SE, DL, "ad");
5085+
50675086
CanonicalIV = Exp.getOrInsertCanonicalInductionVariable(L, Ty);
5087+
50685088
assert (CanonicalIV && "canonicalizing IV");
50695089
//DEBUG(dbgs() << "Canonical induction variable " << *CanonicalIV << "\n");
50705090

@@ -5073,6 +5093,7 @@ PHINode* canonicalizeIVs(Type *Ty, Loop *L, ScalarEvolution &SE, DominatorTree &
50735093
for (WeakTrackingVH V : DeadInst0) {
50745094
//DeadInsts.push_back(cast<Instruction>(V));
50755095
}
5096+
50765097
}
50775098

50785099
for (Instruction* I : DeadInsts) {

0 commit comments

Comments
 (0)