Skip to content

Commit

Permalink
Merge pull request #31 from martinjrobins/expand-ci
Browse files Browse the repository at this point in the history
* feat: test on llvm 18 and windows (just cranelift)

* try 18.1

* 18 doesnt seem supported on runners

* try 18 again

* homebrew on mac m1 different location

* try llvm action for macos latest

* match inkwell in llvm-sys versions

* fix llvm-sys verison

* match inkwell again

* mac just use the llvm action

* need to wait to next inkwell version

* macos-13 to 14

* update enzyme

* enzyme only supports llvm >= 15

* turn off mac-13

* further remove llvm 13 and 14

* setup tmate session

* add runtime activitiy

* remove inkwell internals as not needed

* remove -0

* add include dir for macos

* cargo fmt

* remove tmate
  • Loading branch information
martinjrobins authored Dec 11, 2024
2 parents 4497156 + 097cf75 commit 3653c76
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 110 deletions.
51 changes: 26 additions & 25 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,29 +24,32 @@ jobs:
- run: cargo fmt --all -- --check

unit-tests:
name: Tests - ${{ matrix.os }} - ${{ matrix.toolchain }} - ${{ matrix.llvm }}
name: Tests - ${{ matrix.os }} - ${{ matrix.toolchain }} - ${{ matrix.llvm[0] }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
llvm:
- "14"
- "15"
- "16"
- "17"
- ["15.0", "15-0"]
- ["16.0", "16-0"]
- ["17.0", "17-0"]
#- ["18.0", "18-0"] (next version of inkwell should support 18.1, then can be added here)
toolchain:
- stable
os:
- ubuntu-latest
include:
- toolchain: stable
os: windows-latest
llvm: ""
- toolchain: stable
os: macos-latest
llvm: ["16.0", "16-0"]
- toolchain: beta
os: ubuntu-latest
llvm: "14"
llvm: ["16.0", "16-0"]
- toolchain: nightly
os: ubuntu-latest
llvm: "14"
- toolchain: stable
os: macos-13
llvm: "14"
llvm: ["16.0", "16-0"]


steps:
Expand All @@ -63,25 +66,23 @@ jobs:
run: rustup default ${{ matrix.toolchain }} && rustup update ${{ matrix.toolchain }} --no-self-update && rustup component add clippy rust-docs
- name: Rust version
run: rustc -Vv
- name: Install LLVM and Clang (Ubuntu)
- name: Install LLVM and Clang
uses: KyleMayes/install-llvm-action@v2
if : matrix.os == 'ubuntu-latest'
if : matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' || matrix.os == 'macos-13'
with:
version: ${{ matrix.llvm }}.0
- name: Install LLVM and Clang (macOS)
if : matrix.os == 'macos-13'
run: |
brew install llvm@${{ matrix.llvm }}
echo "LLVM_SYS_${{ matrix.llvm }}0_PREFIX=/usr/local/opt/llvm@${{ matrix.llvm }}" >> $GITHUB_ENV
echo "LLVM_DIR=/usr/local/opt/llvm@${{ matrix.llvm }}" >> $GITHUB_ENV
version: ${{ matrix.llvm[0] }}
- name: Run tests (LLVM)
if : matrix.llvm != ''
run: cargo test --verbose --features llvm${{ matrix.llvm[1] }}
- name: Run tests
run: cargo test --verbose --features llvm${{ matrix.llvm }}-0
- name: Run Clippy
if: matrix.toolchain == 'stable'
run: cargo clippy --verbose --features llvm${{ matrix.llvm }}-0
- name: Run Docs
if : matrix.llvm == ''
run: cargo test --verbose
- name: Run Clippy (LLVM)
if: matrix.toolchain == 'nightly'
run: cargo clippy --verbose --features llvm${{ matrix.llvm[1] }}
- name: Run Docs (LLVM)
if: matrix.toolchain == 'nightly'
run: cargo rustdoc --features llvm${{ matrix.llvm }}-0
run: cargo rustdoc --features llvm${{ matrix.llvm[1] }}
book:
runs-on: ubuntu-latest
steps:
Expand Down
14 changes: 4 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@ repository = "https://github.com/martinjrobins/diffsl"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[features]
llvm13-0 = ["inkwell-130", "llvm-sys-130", "inkwell_internals", "llvm", "enzyme"]
llvm14-0 = ["inkwell-140", "llvm-sys-140", "inkwell_internals", "llvm", "enzyme"]
llvm15-0 = ["inkwell-150", "llvm-sys-150", "inkwell_internals", "llvm", "enzyme"]
llvm16-0 = ["inkwell-160", "llvm-sys-160", "inkwell_internals", "llvm", "enzyme"]
llvm17-0 = ["inkwell-170", "llvm-sys-170", "inkwell_internals", "llvm", "enzyme"]
llvm18-0 = ["inkwell-180", "llvm-sys-180", "inkwell_internals", "llvm", "enzyme"]
llvm15-0 = ["inkwell-150", "llvm-sys-150", "llvm", "enzyme"]
llvm16-0 = ["inkwell-160", "llvm-sys-160", "llvm", "enzyme"]
llvm17-0 = ["inkwell-170", "llvm-sys-170", "llvm", "enzyme"]
llvm18-0 = ["inkwell-180", "llvm-sys-180", "llvm", "enzyme"]
enzyme = ["bindgen", "cmake"]
llvm = []
test_compile = []
Expand All @@ -29,14 +27,10 @@ pest = ">=2.1.3"
pest_derive = ">=2.1.0"
itertools = ">=0.10.3"
uid = "0.1.7"
inkwell-130 = { package = "inkwell", version = ">=0.5.0", features = ["llvm13-0"], optional = true }
inkwell-140 = { package = "inkwell", version = ">=0.5.0", features = ["llvm14-0"], optional = true }
inkwell-150 = { package = "inkwell", version = ">=0.5.0", features = ["llvm15-0"], optional = true }
inkwell-160 = { package = "inkwell", version = ">=0.5.0", features = ["llvm16-0"], optional = true }
inkwell-170 = { package = "inkwell", version = ">=0.5.0", features = ["llvm17-0"], optional = true }
inkwell-180 = { package = "inkwell", version = ">=0.5.0", features = ["llvm18-0"], optional = true }
llvm-sys-130 = { package = "llvm-sys", version = "130.0.4", optional = true }
llvm-sys-140 = { package = "llvm-sys", version = "140.0.2", optional = true }
llvm-sys-150 = { package = "llvm-sys", version = "150.0.3", optional = true }
llvm-sys-160 = { package = "llvm-sys", version = "160.1.0", optional = true }
llvm-sys-170 = { package = "llvm-sys", version = "170.0.1", optional = true }
Expand Down
2 changes: 1 addition & 1 deletion Enzyme
Submodule Enzyme updated 189 files
5 changes: 5 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ mod enzyme {
for dir in inc_dirs {
builder = builder.clang_arg(format!("-I{}", dir))
}
if cfg!(target_os = "macos") {
let xcode_inc_dir = "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include";
builder = builder.clang_arg(format!("-I{}", xcode_inc_dir));
}

builder.generate()
}

Expand Down
67 changes: 1 addition & 66 deletions src/execution/llvm/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ use inkwell::values::{
GlobalValue, IntValue, PointerValue,
};
use inkwell::{AddressSpace, FloatPredicate, IntPredicate, OptimizationLevel};
use inkwell_internals::llvm_versions;
use llvm_sys::prelude::LLVMValueRef;
use std::collections::HashMap;
use std::iter::zip;
Expand Down Expand Up @@ -498,40 +497,14 @@ impl<'ctx> CodeGen<'ctx> {
self.insert_tensor(model.rhs());
}

#[llvm_versions(13.0..=14.0)]
fn pointer_type(_context: &'ctx Context, ty: BasicTypeEnum<'ctx>) -> PointerType<'ctx> {
ty.ptr_type(AddressSpace::default())
}

#[llvm_versions(15.0..=latest)]
fn pointer_type(context: &'ctx Context, _ty: BasicTypeEnum<'ctx>) -> PointerType<'ctx> {
context.ptr_type(AddressSpace::default())
}

#[llvm_versions(13.0..=14.0)]
fn fn_pointer_type(_context: &'ctx Context, ty: FunctionType<'ctx>) -> PointerType<'ctx> {
ty.ptr_type(AddressSpace::default())
}

#[llvm_versions(15.0..=latest)]
fn fn_pointer_type(context: &'ctx Context, _ty: FunctionType<'ctx>) -> PointerType<'ctx> {
context.ptr_type(AddressSpace::default())
}

#[llvm_versions(13.0..=14.0)]
fn insert_indices(&mut self) {
if let Some(indices) = self.globals.indices.as_ref() {
let zero = self.context.i32_type().const_int(0, false);
let ptr = unsafe {
indices
.as_pointer_value()
.const_in_bounds_gep(&[zero, zero])
};
self.variables.insert("indices".to_owned(), ptr);
}
}

#[llvm_versions(15.0..=latest)]
fn insert_indices(&mut self) {
if let Some(indices) = self.globals.indices.as_ref() {
let i32_type = self.context.i32_type();
Expand All @@ -549,22 +522,6 @@ impl<'ctx> CodeGen<'ctx> {
self.variables.insert(name.to_owned(), value);
}

#[llvm_versions(13.0..=14.0)]
fn build_gep<T: BasicType<'ctx>>(
&self,
_ty: T,
ptr: PointerValue<'ctx>,
ordered_indexes: &[IntValue<'ctx>],
name: &str,
) -> Result<PointerValue<'ctx>> {
unsafe {
self.builder
.build_gep(ptr, ordered_indexes, name)
.map_err(|e| e.into())
}
}

#[llvm_versions(15.0..=latest)]
fn build_gep<T: BasicType<'ctx>>(
&self,
ty: T,
Expand All @@ -579,17 +536,6 @@ impl<'ctx> CodeGen<'ctx> {
}
}

#[llvm_versions(13.0..=14.0)]
fn build_load<T: BasicType<'ctx>>(
&self,
_ty: T,
ptr: PointerValue<'ctx>,
name: &str,
) -> Result<BasicValueEnum<'ctx>> {
self.builder.build_load(ptr, name).map_err(|e| e.into())
}

#[llvm_versions(15.0..=latest)]
fn build_load<T: BasicType<'ctx>>(
&self,
ty: T,
Expand All @@ -599,18 +545,6 @@ impl<'ctx> CodeGen<'ctx> {
self.builder.build_load(ty, ptr, name).map_err(|e| e.into())
}

#[llvm_versions(13.0..=14.0)]
fn get_ptr_to_index<T: BasicType<'ctx>>(
builder: &Builder<'ctx>,
_ty: T,
ptr: &PointerValue<'ctx>,
index: IntValue<'ctx>,
name: &str,
) -> PointerValue<'ctx> {
unsafe { builder.build_in_bounds_gep(*ptr, &[index], name).unwrap() }
}

#[llvm_versions(15.0..=latest)]
fn get_ptr_to_index<T: BasicType<'ctx>>(
builder: &Builder<'ctx>,
ty: T,
Expand Down Expand Up @@ -2278,6 +2212,7 @@ impl<'ctx> CodeGen<'ctx> {
ret_primary_ret as u8,
CDerivativeMode_DEM_ForwardMode, // return value, dret_used, top_level which was 1
1, // free memory
0, // runtime activity
1, // vector mode width
std::ptr::null_mut(),
fn_type_info, // additional_arg, type info (return + args)
Expand Down
8 changes: 0 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ pub use execution::cranelift::codegen::CraneliftModule;
#[cfg(feature = "llvm")]
pub use execution::llvm::codegen::LlvmModule;

#[cfg(feature = "inkwell-130")]
extern crate inkwell_130 as inkwell;
#[cfg(feature = "inkwell-140")]
extern crate inkwell_140 as inkwell;
#[cfg(feature = "inkwell-150")]
extern crate inkwell_150 as inkwell;
#[cfg(feature = "inkwell-160")]
Expand All @@ -29,10 +25,6 @@ extern crate inkwell_170 as inkwell;
#[cfg(feature = "inkwell-180")]
extern crate inkwell_180 as inkwell;

#[cfg(feature = "inkwell-130")]
extern crate llvm_sys_130 as llvm_sys;
#[cfg(feature = "inkwell-140")]
extern crate llvm_sys_140 as llvm_sys;
#[cfg(feature = "inkwell-150")]
extern crate llvm_sys_150 as llvm_sys;
#[cfg(feature = "inkwell-160")]
Expand Down

0 comments on commit 3653c76

Please sign in to comment.