diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f8f5abe..fbff161 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,9 +37,12 @@ jobs: strategy: matrix: llvm: - - ["15.0", "15-0"] - - ["16.0", "16-0"] - - ["17.0", "17-0"] + - ["15.0", "15-0", "150"] + - ["16.0", "16-0", "160"] + - ["17.0", "17-0", "170"] + - ["19.1", "19-1", "191", "19"] + - ["20.1", "20-1", "201", "20"] + - ["21.1", "21-1", "211", "21"] toolchain: - stable os: @@ -57,12 +60,12 @@ jobs: - false basename: - Tests - + include: - toolchain: stable os: ubuntu-latest - llvm: ["18.1", "18-1"] - features: "cranelift" + llvm: ["18.1", "18-1", "181"] + features: "rayon cranelift" tests: true clippy: false rustdoc: false @@ -71,8 +74,8 @@ jobs: - toolchain: stable os: macos-latest - llvm: ["18.1", "18-1"] - features: "cranelift" + llvm: ["18.1", "18-1", "181"] + features: "rayon cranelift" tests: true clippy: false rustdoc: false @@ -91,7 +94,7 @@ jobs: - toolchain: beta os: ubuntu-latest - llvm: ["16.0", "16-0"] + llvm: ["16.0", "16-0", "160"] features: "rayon cranelift" tests: true clippy: false @@ -101,7 +104,7 @@ jobs: - toolchain: nightly os: ubuntu-latest - llvm: ["16.0", "16-0"] + llvm: ["16.0", "16-0", "160"] features: "rayon cranelift" tests: true clippy: false @@ -121,7 +124,7 @@ jobs: - toolchain: stable os: ubuntu-latest - llvm: ["16.0", "16-0"] + llvm: ["16.0", "16-0", "160"] features: "rayon cranelift" tests: false clippy: true @@ -131,7 +134,7 @@ jobs: - toolchain: nightly os: ubuntu-latest - llvm: ["16.0", "16-0"] + llvm: ["16.0", "16-0", "160"] features: "rayon cranelift" tests: false clippy: false @@ -154,11 +157,35 @@ 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 + - name: Install LLVM and Clang (LLVM >= 19.1 & macos) + if : matrix.llvm != '' && matrix.os == 'macos-latest' && (matrix.llvm[0] >= '19.1') + run: | + brew install llvm@${{ matrix.llvm[3] }} + echo "LLVM_PATH=$(brew --prefix llvm@${{ matrix.llvm[3] }})" >> $GITHUB_ENV + - name: Install LLVM and Clang (LLVM >= 19.1 & ubuntu) + if : matrix.llvm != '' && (matrix.os == 'ubuntu-latest'|| matrix.os == 'ubuntu-24.04-arm') && (matrix.llvm[0] >= '19.1') + run: | + sudo apt install --no-install-recommends -y lsb-release wget software-properties-common gnupg + wget https://apt.llvm.org/llvm.sh + chmod +x llvm.sh + sudo ./llvm.sh ${{ matrix.llvm[3] }} + sudo apt-get update + sudo apt install --no-install-recommends -y libllvm${{ matrix.llvm[3] }} \ + llvm-${{ matrix.llvm[3] }} \ + llvm-${{ matrix.llvm[3] }}-dev \ + llvm-${{ matrix.llvm[3] }}-runtime \ + libpolly-${{ matrix.llvm[3] }}-dev + sudo update-alternatives --install /usr/bin/llvm-config llvm-config /usr/bin/llvm-config-${{ matrix.llvm[3] }} 10 + echo "LLVM_PATH=/usr/lib/llvm-${{ matrix.llvm[3] }}" >> $GITHUB_ENV + - name: Install LLVM and Clang (LLVM < 19.1) uses: KyleMayes/install-llvm-action@v2 - if : matrix.llvm != '' && (matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' || matrix.os == 'ubuntu-24.04-arm') + if : matrix.llvm != '' && (matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' || matrix.os == 'ubuntu-24.04-arm') && (matrix.llvm[0] < '19.1') with: version: ${{ matrix.llvm[0] }} + - name: Set LLVM_SYS_XXX_DIR and CC, CXX environment variables + if : matrix.llvm != '' + run: | + echo "LLVM_SYS_${{ matrix.llvm[2] }}_DIR=${LLVM_PATH}" >> $GITHUB_ENV - name: Install LLVM 16 (macos-13) if : matrix.os == 'macos-13' run: diff --git a/diffsl/Cargo.toml b/diffsl/Cargo.toml index 30d805f..86d874d 100644 --- a/diffsl/Cargo.toml +++ b/diffsl/Cargo.toml @@ -16,6 +16,9 @@ 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-1 = ["inkwell-181", "llvm-sys-181", "llvm", "enzyme"] +llvm19-1 = ["inkwell-191", "llvm-sys-191", "llvm", "enzyme"] +llvm20-1 = ["inkwell-201", "llvm-sys-201", "llvm", "enzyme"] +llvm21-1 = ["inkwell-211", "llvm-sys-211", "llvm", "enzyme"] enzyme = ["bindgen", "cmake"] llvm = [] cranelift = ["dep:cranelift", "dep:cranelift-module", "dep:cranelift-object", "dep:cranelift-jit", "dep:cranelift-native"] @@ -30,14 +33,20 @@ pest = "2.8" pest_derive = "2.8" itertools = "0.14.0" uid = "0.1.8" -inkwell-150 = { package = "inkwell", version = "0.6.0", features = ["llvm15-0"], optional = true } -inkwell-160 = { package = "inkwell", version = "0.6.0", features = ["llvm16-0"], optional = true } -inkwell-170 = { package = "inkwell", version = "0.6.0", features = ["llvm17-0"], optional = true } -inkwell-181 = { package = "inkwell", version = "0.6.0", features = ["llvm18-1"], optional = true } +inkwell-150 = { package = "inkwell", version = "0.7.1", features = ["llvm15-0"], optional = true } +inkwell-160 = { package = "inkwell", version = "0.7.1", features = ["llvm16-0"], optional = true } +inkwell-170 = { package = "inkwell", version = "0.7.1", features = ["llvm17-0"], optional = true } +inkwell-181 = { package = "inkwell", version = "0.7.1", features = ["llvm18-1"], optional = true } +inkwell-191 = { package = "inkwell", version = "0.7.1", features = ["llvm19-1"], optional = true } +inkwell-201 = { package = "inkwell", version = "0.7.1", features = ["llvm20-1"], optional = true } +inkwell-211 = { package = "inkwell", version = "0.7.1", features = ["llvm21-1"], optional = true } llvm-sys-150 = { package = "llvm-sys", version = "150.2.1", optional = true } llvm-sys-160 = { package = "llvm-sys", version = "160.2.1", optional = true } -llvm-sys-170 = { package = "llvm-sys", version = "170.2.0", optional = true } -llvm-sys-181 = { package = "llvm-sys", version = "181.2.0", optional = true } +llvm-sys-170 = { package = "llvm-sys", version = "170.4.0", optional = true } +llvm-sys-181 = { package = "llvm-sys", version = "181.3.0", optional = true } +llvm-sys-191 = { package = "llvm-sys", version = "191.1.0", optional = true } +llvm-sys-201 = { package = "llvm-sys", version = "201.0.0", optional = true } +llvm-sys-211 = { package = "llvm-sys", version = "211.0.0", optional = true } inkwell_internals = { version = "0.11.0", optional = true } cranelift = { version = "0.125", optional = true} cranelift-module = { version = "0.125", optional = true} diff --git a/diffsl/Enzyme b/diffsl/Enzyme index df197be..ebfdfd0 160000 --- a/diffsl/Enzyme +++ b/diffsl/Enzyme @@ -1 +1 @@ -Subproject commit df197be4f1909067ac3bc68b746ce9f3e406476f +Subproject commit ebfdfd08ee7427f7de2f8184442d39dc8ea29b76 diff --git a/diffsl/src/execution/llvm/codegen.rs b/diffsl/src/execution/llvm/codegen.rs index f4b033f..6be1e10 100644 --- a/diffsl/src/execution/llvm/codegen.rs +++ b/diffsl/src/execution/llvm/codegen.rs @@ -1360,8 +1360,7 @@ impl<'ctx> CodeGen<'ctx> { .build_float_add( exp_negx .try_as_basic_value() - .left() - .unwrap() + .unwrap_basic() .into_float_value(), one, name, @@ -1412,8 +1411,7 @@ impl<'ctx> CodeGen<'ctx> { ) .unwrap() .try_as_basic_value() - .left() - .unwrap() + .unwrap_basic() .into_float_value(); let x_plus_sqrt_one_plus_x_squared = self .builder @@ -1431,8 +1429,7 @@ impl<'ctx> CodeGen<'ctx> { ) .unwrap() .try_as_basic_value() - .left() - .unwrap() + .unwrap_basic() .into_float_value(); self.builder.build_return(Some(&result)).ok(); self.builder.position_at_end(current_block); @@ -1506,11 +1503,10 @@ impl<'ctx> CodeGen<'ctx> { let expx_minus_exp_negx = self .builder .build_float_sub( - expx.try_as_basic_value().left().unwrap().into_float_value(), + expx.try_as_basic_value().unwrap_basic().into_float_value(), exp_negx .try_as_basic_value() - .left() - .unwrap() + .unwrap_basic() .into_float_value(), name, ) @@ -1518,11 +1514,10 @@ impl<'ctx> CodeGen<'ctx> { let expx_plus_exp_negx = self .builder .build_float_add( - expx.try_as_basic_value().left().unwrap().into_float_value(), + expx.try_as_basic_value().unwrap_basic().into_float_value(), exp_negx .try_as_basic_value() - .left() - .unwrap() + .unwrap_basic() .into_float_value(), name, ) @@ -2415,8 +2410,7 @@ impl<'ctx> CodeGen<'ctx> { .builder .build_call(function, args.as_slice(), name)? .try_as_basic_value() - .left() - .unwrap() + .unwrap_basic() .into_float_value(); Ok(ret_value) } @@ -3098,12 +3092,14 @@ impl<'ctx> CodeGen<'ctx> { CDerivativeMode_DEM_ForwardMode, // return value, dret_used, top_level which was 1 1, // free memory 0, // runtime activity + 0, // strong zero 1, // vector mode width - std::ptr::null_mut(), - fn_type_info, // additional_arg, type info (return + args) - args_uncacheable.as_mut_ptr(), - args_uncacheable.len(), // uncacheable arguments - std::ptr::null_mut(), // write augmented function to this + std::ptr::null_mut(), // additional argument + fn_type_info, // additional_arg, type info (return + args) + 1, // subsequent calls may write + args_uncacheable.as_mut_ptr(), // overwritten args + args_uncacheable.len(), // overwritten args length + std::ptr::null_mut(), // write augmented function to this ) }, CompileMode::Reverse | CompileMode::ReverseSens => { @@ -3121,15 +3117,17 @@ impl<'ctx> CodeGen<'ctx> { diff_ret as u8, CDerivativeMode_DEM_ReverseModeCombined, 0, + 0, // strong zero 1, 1, std::ptr::null_mut(), - 0, + 0, // force annonymous tape fn_type_info, + 0, // subsequent calls may write args_uncacheable.as_mut_ptr(), args_uncacheable.len(), std::ptr::null_mut(), - if self.threaded { 1 } else { 0 }, + if self.threaded { 1 } else { 0 }, // atomic add ) }; if self.threaded { diff --git a/diffsl/src/lib.rs b/diffsl/src/lib.rs index f439074..be1fb75 100644 --- a/diffsl/src/lib.rs +++ b/diffsl/src/lib.rs @@ -29,6 +29,12 @@ extern crate inkwell_160 as inkwell; extern crate inkwell_170 as inkwell; #[cfg(feature = "inkwell-181")] extern crate inkwell_181 as inkwell; +#[cfg(feature = "inkwell-191")] +extern crate inkwell_191 as inkwell; +#[cfg(feature = "inkwell-201")] +extern crate inkwell_201 as inkwell; +#[cfg(feature = "inkwell-211")] +extern crate inkwell_211 as inkwell; #[cfg(feature = "inkwell-150")] extern crate llvm_sys_150 as llvm_sys; @@ -38,3 +44,9 @@ extern crate llvm_sys_160 as llvm_sys; extern crate llvm_sys_170 as llvm_sys; #[cfg(feature = "inkwell-181")] extern crate llvm_sys_181 as llvm_sys; +#[cfg(feature = "inkwell-191")] +extern crate llvm_sys_191 as llvm_sys; +#[cfg(feature = "inkwell-201")] +extern crate llvm_sys_201 as llvm_sys; +#[cfg(feature = "inkwell-211")] +extern crate llvm_sys_211 as llvm_sys;