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

Getting faer to work with Enzyme #125

Open
ToddMCr opened this issue Jun 3, 2024 · 11 comments · Fixed by EnzymeAD/Enzyme#1921
Open

Getting faer to work with Enzyme #125

ToddMCr opened this issue Jun 3, 2024 · 11 comments · Fixed by EnzymeAD/Enzyme#1921

Comments

@ToddMCr
Copy link

ToddMCr commented Jun 3, 2024

I am trying to use the Rust library faer with Enzyme and am running into problems. I am not able to pass in references to faer::Col<T> objects for some reason and I cannot figure out how to get it to work.

Prior to these examples I exported the enzyme debug env variables:

export ENZYME_PRINT_TA=1
export ENZYME_PRINT_AA=1
export ENZYME_PRINT=1
export ENZYME_PRINT_MOD=1
export ENZYME_PRINT_MOD_AFTER=1

and then ran

cargo +enzyme build

Example: $f(\vec{x}) = \vec{c} \cdot \vec{x}$

Initial Idea

#![feature(autodiff)]
use faer::{col, Col};

#[autodiff(df, Reverse, Duplicated, Duplicated)]
fn f(x: &Col<f64>, y: &mut f64) {
    let c: Col<f64> = col![1.0, 2.0, 3.0];
    
    *y = c.transpose() * x;
}

fn main() {
    let x: Col<f64> = col![1.0, 1.0, 1.0];
    let mut y: f64 = 0.0;
    
    let mut grad: Col<f64> = col![0.0, 0.0, 0.0];
    let mut seed: f64 = 1.0;
    
    df(&x, &mut grad,
       &mut y, &mut seed);
    
    // Should be 1.0, 1.0, 1.0
    println!(" f evaluated at:");
    x.iter().enumerate()
    .for_each(|(i, e)| {
        println!("x[{i}] = {e}");
    });
    
    // Should be 1.0, 2.0, 3.0
    println!("\n gradient of f at x:");
    grad.iter().enumerate()
    .for_each(|(i, e)| {
        println!("grad[{i}] = {e}");
    });
    
    // Should be 6.0
    println!("\n f at x:");
    println!("f(x) = {y}");
}

Output: ex1.txt

Tried This Next

#![feature(autodiff)]
use faer::{col, Col, ColRef};

#[autodiff(df, Reverse, Duplicated, Duplicated)]
fn f(x: &[f64], y: &mut f64) {
    let c: Col<f64> = col![1.0, 2.0, 3.0];
    let x: ColRef<f64> = col::from_slice(x); // Shadow previous x
    
    *y = c.transpose() * x;
}

fn main() {
    let x: Col<f64> = col![1.0, 1.0, 1.0];
    let mut y: f64 = 0.0;
    
    let mut grad: Col<f64> = col![0.0, 0.0, 0.0];
    let mut seed: f64 = 1.0;
    
    df(x.as_slice(), grad.as_slice_mut(),
       &mut y, &mut seed);
    
    // Should be 1.0, 1.0, 1.0
    println!(" f evaluated at:");
    x.iter().enumerate()
    .for_each(|(i, e)| {
        println!("x[{i}] = {e}");
    });
    
    // Should be 1.0, 2.0, 3.0
    println!("\n gradient of f at x:");
    grad.iter().enumerate()
    .for_each(|(i, e)| {
        println!("grad[{i}] = {e}");
    });
    
    // Should be 6.0
    println!("\n f at x:");
    println!("f(x) = {y}");
}

Output: ex2.txt

Could not end up getting this to work.

Here is my cargo.toml file:

[package]
name = "learning-enzyme-faer"
version = "0.1.0"
edition = "2021"

[profile.release]
lto = "fat"

[profile.dev]
lto = "fat"

[toolchain]
channel = "enzyme"

[dependencies]
faer = "0.19"
@ZuseZ4
Copy link
Member

ZuseZ4 commented Jun 3, 2024

@wsmoses

updating analysis of val:   %1 = alloca i128, align 8 current: {} new {[-1]:Pointer} from   %1 = alloca i128, align 8 Changed=1 legal=1
updating analysis of val:   %2 = alloca i128, align 8 current: {} new {[-1]:Pointer} from   %2 = alloca i128, align 8 Changed=1 legal=1
updating analysis of val:   %3 = alloca i128, align 8 current: {} new {[-1]:Pointer} from   %3 = alloca i128, align 8 Changed=1 legal=1
rustc: /home/ubuntu/rust/build/build/x86_64-unknown-linux-gnu/llvm/include/llvm/ADT/APInt.h:1510: int64_t llvm::APInt::getSExtValue() const: Assertion `getSignificantBits() <= 64 && "Too many bits for int64_t"' failed.

Any thoughts, is that an LLVM bug, or do we feed some incorrect things to it?

@ToddMCr
Copy link
Author

ToddMCr commented Jun 6, 2024

It may be relevant that the * operation in:

*y = c.transpose() * x;
//                ^^^

eventually calls

inner_prod_with_conj_arch(E::Simd::default(), lhs, conj_lhs, rhs, conj_rhs)

which does look like it inserts simd instructions directly using the pulp crate.

@ZuseZ4
Copy link
Member

ZuseZ4 commented Jun 8, 2024

bump @wsmoses.
Could the assertion be hit due to an Enzyme or rather LLVM Bug?

@wsmoses
Copy link
Member

wsmoses commented Jun 8, 2024

do you have the full backtrace

@ZuseZ4
Copy link
Member

ZuseZ4 commented Jun 8, 2024

do you have the full backtrace

Yes both output1. and output 2 have it as well as different print information

@wsmoses
Copy link
Member

wsmoses commented Jun 8, 2024

The backtrace of ex2 only was at the llvm location where the assertion happened so it’s unclear what code is around it.

presumably a debug build of relevant stuff would have the full backtrace, if you can get it to crash in one

@wsmoses
Copy link
Member

wsmoses commented Jun 8, 2024

That also said while this should definitely work, I think long term the way to get best perf is to extend Enzyme’s blas support to recognize faer operations as BLAS like and generate relevant code accordingly

@ZuseZ4
Copy link
Member

ZuseZ4 commented Jun 8, 2024

It will be interesting bc. e.g. dot/gemv/gemm are merged into one function for convenience, but yes we should do that long term.

For now, @ToddMCr are you able to reduce this a bit e.g. by commenting out some code inside of inner_prod_with_conj_arch? Building debug builds of llvm and rustc takes a lot of time and storage, so I can create one on a server.

@wsmoses
Copy link
Member

wsmoses commented Jun 8, 2024 via email

@ZuseZ4
Copy link
Member

ZuseZ4 commented Jun 10, 2024

@wsmoses A couple of bugs here.

Release mode + loose types gives this as a new error:
rel_error.ll.txt

But let's keep looking at this llvm bug. gdb gives:

#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x00007ffff1fa9859 in __GI_abort () at abort.c:79
#2  0x00007ffff1fa9729 in __assert_fail_base (fmt=0x7ffff213f588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", 
    assertion=0x7ffff1bebf58 "getSignificantBits() <= 64 && \"Too many bits for int64_t\"", 
    file=0x7ffff1bebe88 "/h/344/drehwald/prog/rust-dbg/build/x86_64-unknown-linux-gnu/llvm/include/llvm/ADT/APInt.h", line=1510, function=<optimized out>) at assert.c:92
#3  0x00007ffff1fbafd6 in __GI___assert_fail (assertion=0x7ffff1bebf58 "getSignificantBits() <= 64 && \"Too many bits for int64_t\"", 
    file=0x7ffff1bebe88 "/h/344/drehwald/prog/rust-dbg/build/x86_64-unknown-linux-gnu/llvm/include/llvm/ADT/APInt.h", line=1510, 
    function=0x7ffff1bebf28 "int64_t llvm::APInt::getSExtValue() const") at assert.c:101
#4  0x00007ffff15aa8a2 in llvm::APInt::getSExtValue (this=0x7fff7a979018) at /h/344/drehwald/prog/rust-dbg/build/x86_64-unknown-linux-gnu/llvm/include/llvm/ADT/APInt.h:1510
#5  0x00007ffff15ae1d8 in llvm::ConstantInt::getSExtValue (this=0x7fff7a979000)
    at /h/344/drehwald/prog/rust-dbg/build/x86_64-unknown-linux-gnu/llvm/include/llvm/IR/Constants.h:151
#6  0x00007ffff1b7b548 in getConstantAnalysis (Val=0x7fff7a979000, TA=..., analysis=...)
    at /h/344/drehwald/prog/rust-dbg/src/tools/enzyme/enzyme/Enzyme/TypeAnalysis/TypeAnalysis.cpp:715
#7  0x00007ffff1b7ceae in TypeAnalyzer::getAnalysis (this=0x7fff4ccbd700, Val=0x7fff7a979000)
    at /h/344/drehwald/prog/rust-dbg/src/tools/enzyme/enzyme/Enzyme/TypeAnalysis/TypeAnalysis.cpp:924
#8  0x00007ffff1b83d1e in TypeAnalyzer::visitStoreInst (this=0x7fff4ccbd700, I=...)
    at /h/344/drehwald/prog/rust-dbg/src/tools/enzyme/enzyme/Enzyme/TypeAnalysis/TypeAnalysis.cpp:1733
#9  0x00007ffff1bb9b51 in llvm::InstVisitor<TypeAnalyzer, void>::visitStore (this=0x7fff4ccbd700, I=...)
    at /h/344/drehwald/prog/rust-dbg/build/x86_64-unknown-linux-gnu/llvm/include/llvm/IR/Instruction.def:173
#10 0x00007ffff1bb4239 in llvm::InstVisitor<TypeAnalyzer, void>::visit (this=0x7fff4ccbd700, I=...)
    at /h/344/drehwald/prog/rust-dbg/build/x86_64-unknown-linux-gnu/llvm/include/llvm/IR/Instruction.def:173
#11 0x00007ffff1b82fd3 in TypeAnalyzer::visitValue (this=0x7fff4ccbd700, val=...)
    at /h/344/drehwald/prog/rust-dbg/src/tools/enzyme/enzyme/Enzyme/TypeAnalysis/TypeAnalysis.cpp:1637
#12 0x00007ffff1b82aa6 in TypeAnalyzer::run (this=0x7fff4ccbd700) at /h/344/drehwald/prog/rust-dbg/src/tools/enzyme/enzyme/Enzyme/TypeAnalysis/TypeAnalysis.cpp:1572
#13 0x00007ffff1baf1dc in TypeAnalysis::analyzeFunction (this=0x7fff4cb19d60, fn=...)
    at /h/344/drehwald/prog/rust-dbg/src/tools/enzyme/enzyme/Enzyme/TypeAnalysis/TypeAnalysis.cpp:5846
#14 0x00007ffff1bae6f4 in TypeAnalyzer::visitIPOCall (this=0x7fff4cca3690, call=..., fn=...)
    at /h/344/drehwald/prog/rust-dbg/src/tools/enzyme/enzyme/Enzyme/TypeAnalysis/TypeAnalysis.cpp:5759
#15 0x00007ffff1bad158 in TypeAnalyzer::visitCallBase (this=0x7fff4cca3690, call=...)
    at /h/344/drehwald/prog/rust-dbg/src/tools/enzyme/enzyme/Enzyme/TypeAnalysis/TypeAnalysis.cpp:5553
#16 0x00007ffff1bbffb7 in llvm::InstVisitor<TypeAnalyzer, void>::visitCallInst (this=0x7fff4cca3690, I=...)
    at /h/344/drehwald/prog/rust-dbg/build/x86_64-unknown-linux-gnu/llvm/include/llvm/IR/InstVisitor.h:220
#17 0x00007ffff1bbff8d in llvm::InstVisitor<TypeAnalyzer, void>::delegateCallInst (this=0x7fff4cca3690, I=...)
    at /h/344/drehwald/prog/rust-dbg/build/x86_64-unknown-linux-gnu/llvm/include/llvm/IR/InstVisitor.h:304
#18 0x00007ffff1bb9f17 in llvm::InstVisitor<TypeAnalyzer, void>::visitCall (this=0x7fff4cca3690, I=...)
    at /h/344/drehwald/prog/rust-dbg/build/x86_64-unknown-linux-gnu/llvm/include/llvm/IR/Instruction.def:209
#19 0x00007ffff1bb4461 in llvm::InstVisitor<TypeAnalyzer, void>::visit (this=0x7fff4cca3690, I=...)
    at /h/344/drehwald/prog/rust-dbg/build/x86_64-unknown-linux-gnu/llvm/include/llvm/IR/Instruction.def:209
#20 0x00007ffff1b82fd3 in TypeAnalyzer::visitValue (this=0x7fff4cca3690, val=...)
    at /h/344/drehwald/prog/rust-dbg/src/tools/enzyme/enzyme/Enzyme/TypeAnalysis/TypeAnalysis.cpp:1637
#21 0x00007ffff1b82afc in TypeAnalyzer::run (this=0x7fff4cca3690) at /h/344/drehwald/prog/rust-dbg/src/tools/enzyme/enzyme/Enzyme/TypeAnalysis/TypeAnalysis.cpp:1578
#22 0x00007ffff1baf1dc in TypeAnalysis::analyzeFunction (this=0x7fff4cb19d60, fn=...)
    at /h/344/drehwald/prog/rust-dbg/src/tools/enzyme/enzyme/Enzyme/TypeAnalysis/TypeAnalysis.cpp:5846
#23 0x00007ffff1bae6f4 in TypeAnalyzer::visitIPOCall (this=0x7fff4cc8e750, call=..., fn=...)
    at /h/344/drehwald/prog/rust-dbg/src/tools/enzyme/enzyme/Enzyme/TypeAnalysis/TypeAnalysis.cpp:5759
#24 0x00007ffff1bad158 in TypeAnalyzer::visitCallBase (this=0x7fff4cc8e750, call=...) at /h/344/drehwald/prog/rust-dbg/src/tools/enzyme/enzyme/Enzyme/TypeAnalysis/TypeAnalysis.cpp:5553
#25 0x00007ffff1bbffb7 in llvm::InstVisitor<TypeAnalyzer, void>::visitCallInst (this=0x7fff4cc8e750, I=...) at /h/344/drehwald/prog/rust-dbg/build/x86_64-unknown-linux-gnu/llvm/include/llvm/IR/InstVisitor.h:220
#26 0x00007ffff1bbff8d in llvm::InstVisitor<TypeAnalyzer, void>::delegateCallInst (this=0x7fff4cc8e750, I=...) at /h/344/drehwald/prog/rust-dbg/build/x86_64-unknown-linux-gnu/llvm/include/llvm/IR/InstVisitor.h:304
#27 0x00007ffff1bb9f17 in llvm::InstVisitor<TypeAnalyzer, void>::visitCall (this=0x7fff4cc8e750, I=...) at /h/344/drehwald/prog/rust-dbg/build/x86_64-unknown-linux-gnu/llvm/include/llvm/IR/Instruction.def:209
#28 0x00007ffff1bb4461 in llvm::InstVisitor<TypeAnalyzer, void>::visit (this=0x7fff4cc8e750, I=...) at /h/344/drehwald/prog/rust-dbg/build/x86_64-unknown-linux-gnu/llvm/include/llvm/IR/Instruction.def:209
#29 0x00007ffff1b82fd3 in TypeAnalyzer::visitValue (this=0x7fff4cc8e750, val=...) at /h/344/drehwald/prog/rust-dbg/src/tools/enzyme/enzyme/Enzyme/TypeAnalysis/TypeAnalysis.cpp:1637
#30 0x00007ffff1b82afc in TypeAnalyzer::run (this=0x7fff4cc8e750) at /h/344/drehwald/prog/rust-dbg/src/tools/enzyme/enzyme/Enzyme/TypeAnalysis/TypeAnalysis.cpp:1578
#31 0x00007ffff1baf1dc in TypeAnalysis::analyzeFunction (this=0x7fff4cb19d60, fn=...) at /h/344/drehwald/prog/rust-dbg/src/tools/enzyme/enzyme/Enzyme/TypeAnalysis/TypeAnalysis.cpp:5846
#32 0x00007ffff1bae6f4 in TypeAnalyzer::visitIPOCall (this=0x7fff4cc85b50, call=..., fn=...) at /h/344/drehwald/prog/rust-dbg/src/tools/enzyme/enzyme/Enzyme/TypeAnalysis/TypeAnalysis.cpp:5759
#33 0x00007ffff1bad158 in TypeAnalyzer::visitCallBase (this=0x7fff4cc85b50, call=...) at /h/344/drehwald/prog/rust-dbg/src/tools/enzyme/enzyme/Enzyme/TypeAnalysis/TypeAnalysis.cpp:5553
#34 0x00007ffff1bbfb6f in llvm::InstVisitor<TypeAnalyzer, void>::visitInvokeInst (this=0x7fff4cc85b50, I=...) at /h/344/drehwald/prog/rust-dbg/build/x86_64-unknown-linux-gnu/llvm/include/llvm/IR/InstVisitor.h:221
#35 0x00007ffff1bb96b9 in llvm::InstVisitor<TypeAnalyzer, void>::visitInvoke (this=0x7fff4cc85b50, I=...) at /h/344/drehwald/prog/rust-dbg/build/x86_64-unknown-linux-gnu/llvm/include/llvm/IR/Instruction.def:131
#36 0x00007ffff1bb3f99 in llvm::InstVisitor<TypeAnalyzer, void>::visit (this=0x7fff4cc85b50, I=...) at /h/344/drehwald/prog/rust-dbg/build/x86_64-unknown-linux-gnu/llvm/include/llvm/IR/Instruction.def:131
#37 0x00007ffff1b82fd3 in TypeAnalyzer::visitValue (this=0x7fff4cc85b50, val=...) at /h/344/drehwald/prog/rust-dbg/src/tools/enzyme/enzyme/Enzyme/TypeAnalysis/TypeAnalysis.cpp:1637
#38 0x00007ffff1b82afc in TypeAnalyzer::run (this=0x7fff4cc85b50) at /h/344/drehwald/prog/rust-dbg/src/tools/enzyme/enzyme/Enzyme/TypeAnalysis/TypeAnalysis.cpp:1578
#39 0x00007ffff1baf1dc in TypeAnalysis::analyzeFunction (this=0x7fff4cb19d60, fn=...) at /h/344/drehwald/prog/rust-dbg/src/tools/enzyme/enzyme/Enzyme/TypeAnalysis/TypeAnalysis.cpp:5846
#40 0x00007ffff1bae6f4 in TypeAnalyzer::visitIPOCall (this=0x7fff4c8d13b0, call=..., fn=...) at /h/344/drehwald/prog/rust-dbg/src/tools/enzyme/enzyme/Enzyme/TypeAnalysis/TypeAnalysis.cpp:5759
#41 0x00007ffff1bad158 in TypeAnalyzer::visitCallBase (this=0x7fff4c8d13b0, call=...) at /h/344/drehwald/prog/rust-dbg/src/tools/enzyme/enzyme/Enzyme/TypeAnalysis/TypeAnalysis.cpp:5553
#42 0x00007ffff1bbfb6f in llvm::InstVisitor<TypeAnalyzer, void>::visitInvokeInst (this=0x7fff4c8d13b0, I=...) at /h/344/drehwald/prog/rust-dbg/build/x86_64-unknown-linux-gnu/llvm/include/llvm/IR/InstVisitor.h:221
#43 0x00007ffff1bb96b9 in llvm::InstVisitor<TypeAnalyzer, void>::visitInvoke (this=0x7fff4c8d13b0, I=...) at /h/344/drehwald/prog/rust-dbg/build/x86_64-unknown-linux-gnu/llvm/include/llvm/IR/Instruction.def:131
#44 0x00007ffff1bb3f99 in llvm::InstVisitor<TypeAnalyzer, void>::visit (this=0x7fff4c8d13b0, I=...) at /h/344/drehwald/prog/rust-dbg/build/x86_64-unknown-linux-gnu/llvm/include/llvm/IR/Instruction.def:131
#45 0x00007ffff1b82fd3 in TypeAnalyzer::visitValue (this=0x7fff4c8d13b0, val=...) at /h/344/drehwald/prog/rust-dbg/src/tools/enzyme/enzyme/Enzyme/TypeAnalysis/TypeAnalysis.cpp:1637
#46 0x00007ffff1b82afc in TypeAnalyzer::run (this=0x7fff4c8d13b0) at /h/344/drehwald/prog/rust-dbg/src/tools/enzyme/enzyme/Enzyme/TypeAnalysis/TypeAnalysis.cpp:1578
#47 0x00007ffff1baf1dc in TypeAnalysis::analyzeFunction (this=0x7fff4cb19d60, fn=...) at /h/344/drehwald/prog/rust-dbg/src/tools/enzyme/enzyme/Enzyme/TypeAnalysis/TypeAnalysis.cpp:5846
#48 0x00007ffff1bae6f4 in TypeAnalyzer::visitIPOCall (this=0x7fff4ad2b2d0, call=..., fn=...) at /h/344/drehwald/prog/rust-dbg/src/tools/enzyme/enzyme/Enzyme/TypeAnalysis/TypeAnalysis.cpp:5759
#49 0x00007ffff1bad158 in TypeAnalyzer::visitCallBase (this=0x7fff4ad2b2d0, call=...) at /h/344/drehwald/prog/rust-dbg/src/tools/enzyme/enzyme/Enzyme/TypeAnalysis/TypeAnalysis.cpp:5553
#50 0x00007ffff1bbffb7 in llvm::InstVisitor<TypeAnalyzer, void>::visitCallInst (this=0x7fff4ad2b2d0, I=...) at /h/344/drehwald/prog/rust-dbg/build/x86_64-unknown-linux-gnu/llvm/include/llvm/IR/InstVisitor.h:220
#51 0x00007ffff1bbff8d in llvm::InstVisitor<TypeAnalyzer, void>::delegateCallInst (this=0x7fff4ad2b2d0, I=...) at /h/344/drehwald/prog/rust-dbg/build/x86_64-unknown-linux-gnu/llvm/include/llvm/IR/InstVisitor.h:304
#52 0x00007ffff1bb9f17 in llvm::InstVisitor<TypeAnalyzer, void>::visitCall (this=0x7fff4ad2b2d0, I=...) at /h/344/drehwald/prog/rust-dbg/build/x86_64-unknown-linux-gnu/llvm/include/llvm/IR/Instruction.def:209
#53 0x00007ffff1bb4461 in llvm::InstVisitor<TypeAnalyzer, void>::visit (this=0x7fff4ad2b2d0, I=...) at /h/344/drehwald/prog/rust-dbg/build/x86_64-unknown-linux-gnu/llvm/include/llvm/IR/Instruction.def:209
#54 0x00007ffff1b82fd3 in TypeAnalyzer::visitValue (this=0x7fff4ad2b2d0, val=...) at /h/344/drehwald/prog/rust-dbg/src/tools/enzyme/enzyme/Enzyme/TypeAnalysis/TypeAnalysis.cpp:1637
#55 0x00007ffff1b82afc in TypeAnalyzer::run (this=0x7fff4ad2b2d0) at /h/344/drehwald/prog/rust-dbg/src/tools/enzyme/enzyme/Enzyme/TypeAnalysis/TypeAnalysis.cpp:1578
#56 0x00007ffff1baf1dc in TypeAnalysis::analyzeFunction (this=0x7fff4cb19d60, fn=...) at /h/344/drehwald/prog/rust-dbg/src/tools/enzyme/enzyme/Enzyme/TypeAnalysis/TypeAnalysis.cpp:5846
#57 0x00007ffff187765f in DiffeGradientUtils::CreateFromClone (Logic=..., mode=DerivativeMode::ReverseModeCombined, width=1, todiff=0x7fff9618dfd8, TLI=..., TA=..., oldTypeInfo=..., retType=DIFFE_TYPE::CONSTANT, diffeReturnArg=false, constant_args=..., returnValue=ReturnType::Args, additionalArg=0x0, omp=false) at /h/344/drehwald/prog/rust-dbg/src/tools/enzyme/enzyme/Enzyme/DiffeGradientUtils.cpp:156
#58 0x00007ffff19a9d41 in EnzymeLogic::CreatePrimalAndGradient (this=0x7fff493836a0, context=..., key=..., TA=..., augmenteddata=0x0, omp=false) at /h/344/drehwald/prog/rust-dbg/src/tools/enzyme/enzyme/Enzyme/EnzymeLogic.cpp:4133
#59 0x00007ffff15b84d8 in EnzymeCreatePrimalAndGradient (Logic=0x7fff493836a0, request_req=0x0, request_ip=0x0, todiff=0x7fff9618dfd8, retType=DFT_CONSTANT, constant_args=0x7fff568b0280, constant_args_size=3, TA=0x7fff4cb19d60, returnValue=0 '\000', dretUsed=0 '\000', mode=DEM_ReverseModeCombined, width=1, freeMemory=1 '\001', additionalArg=0x0, forceAnonymousTape=0 '\000', typeInfo=..., _overwritten_args=0x7fff4a41a770 "", overwritten_args_size=3, augmented=0x0, AtomicAdd=0 '\000') at /h/344/drehwald/prog/rust-dbg/src/tools/enzyme/enzyme/Enzyme/CApi.cpp:622
#60 0x00007ffff332f9b8 in _RNvNtNtCsiA0FFhWH4jN_18rustc_codegen_llvm5llvm_3ffi24enzyme_rust_reverse_diff () at compiler/rustc_codegen_llvm/src/llvm/ffi.rs:994
#61 0x00007ffff33af725 in _RNvNtNtCsiA0FFhWH4jN_18rustc_codegen_llvm4back5write9enzyme_ad () at compiler/rustc_codegen_llvm/src/back/write.rs:1047
#62 0x00007ffff33b2d23 in _RNvNtNtCsiA0FFhWH4jN_18rustc_codegen_llvm4back5write13differentiate () at compiler/rustc_codegen_llvm/src/back/write.rs:1157
#63 0x00007ffff33a7545 in _RNvXs1_CsiA0FFhWH4jN_18rustc_codegen_llvmNtB5_18LlvmCodegenBackendNtNtNtCs3bKYnD5z5HT_17rustc_codegen_ssa6traits5write19WriteBackendMethods8autodiff () at compiler/rustc_codegen_llvm/src/lib.rs:271
#64 _RNvMs_NtNtCs3bKYnD5z5HT_17rustc_codegen_ssa4back3ltoINtB4_16LtoModuleCodegenNtCsiA0FFhWH4jN_18rustc_codegen_llvm18LlvmCodegenBackendE8autodiffB1e_ () at compiler/rustc_codegen_ssa/src/back/lto.rs:91
#65 0x00007ffff32b5f40 in _RINvNtNtCs3bKYnD5z5HT_17rustc_codegen_ssa4back5write17generate_lto_workNtCsiA0FFhWH4jN_18rustc_codegen_llvm18LlvmCodegenBackendEB19_ () at compiler/rustc_codegen_ssa/src/back/write.rs:395
#66 _RNCINvNtNtCs3bKYnD5z5HT_17rustc_codegen_ssa4back5write20start_executing_workNtCsiA0FFhWH4jN_18rustc_codegen_llvm18LlvmCodegenBackendEs3_0B1e_ () at compiler/rustc_codegen_ssa/src/back/write.rs:1399
#67 0x00007ffff32acf26 in _RNCINvXs0_CsiA0FFhWH4jN_18rustc_codegen_llvmNtB8_18LlvmCodegenBackendNtNtNtCs3bKYnD5z5HT_17rustc_codegen_ssa6traits7backend19ExtraBackendMethods18spawn_named_threadNCINvNtNtB1b_4back5write20start_executing_workBG_Es3_0INtNtCs3GuNEaDWhTL_4core6result6ResultNtB2H_15CompiledModulesuEE0B8_ () at compiler/rustc_codegen_llvm/src/lib.rs:168
#68 _RINvNtNtCs3ZyGyicr358_3std10sys_common9backtrace28___rust_begin_short_backtraceNCINvXs0_CsiA0FFhWH4jN_18rustc_codegen_llvmNtB1o_18LlvmCodegenBackendNtNtNtCs3bKYnD5z5HT_17rustc_codegen_ssa6traits7backend19ExtraBackendMethods18spawn_named_threadNCINvNtNtB2s_4back5write20start_executing_workB1W_Es3_0INtNtCs3GuNEaDWhTL_4core6result6ResultNtB3Y_15CompiledModulesuEE0B4M_EB1o_ () at library/std/src/sys_common/backtrace.rs:155
#69 0x00007ffff32ba866 in _RNCNCINvMNtCs3ZyGyicr358_3std6threadNtB7_7Builder16spawn_unchecked_NCINvXs0_CsiA0FFhWH4jN_18rustc_codegen_llvmNtB1c_18LlvmCodegenBackendNtNtNtCs3bKYnD5z5HT_17rustc_codegen_ssa6traits7backend19ExtraBackendMethods18spawn_named_threadNCINvNtNtB2g_4back5write20start_executing_workB1K_Es3_0INtNtCs3GuNEaDWhTL_4core6result6ResultNtB3M_15CompiledModulesuEE0B4A_Es_00B1c_ () at library/std/src/thread/mod.rs:529
#70 _RNvXsl_NtNtCs3GuNEaDWhTL_4core5panic11unwind_safeINtB5_16AssertUnwindSafeNCNCINvMNtCs3ZyGyicr358_3std6threadNtB1h_7Builder16spawn_unchecked_NCINvXs0_CsiA0FFhWH4jN_18rustc_codegen_llvmNtB2n_18LlvmCodegenBackendNtNtNtCs3bKYnD5z5HT_17rustc_codegen_ssa6traits7backend19ExtraBackendMethods18spawn_named_threadNCINvNtNtB3r_4back5write20start_executing_workB2V_Es3_0INtNtB9_6result6ResultNtB4X_15CompiledModulesuEE0B5L_Es_00EINtNtNtB9_3ops8function6FnOnceuE9call_onceB2n_ () at library/core/src/panic/unwind_safe.rs:272
#71 _RINvNvNtCs3ZyGyicr358_3std9panicking3try7do_callINtNtNtCs3GuNEaDWhTL_4core5panic11unwind_safe16AssertUnwindSafeNCNCINvMNtB6_6threadNtB1T_7Builder16spawn_unchecked_NCINvXs0_CsiA0FFhWH4jN_18rustc_codegen_llvmNtB2K_18LlvmCodegenBackendNtNtNtCs3bKYnD5z5HT_17rustc_codegen_ssa6traits7backend19ExtraBackendMethods18spawn_named_threadNCINvNtNtB3O_4back5write20start_executing_workB3i_Es3_0INtNtBR_6result6ResultNtB5k_15CompiledModulesuEE0B68_Es_00EB68_EB2K_ () at library/std/src/panicking.rs:552
#72 _RINvNtCs3ZyGyicr358_3std9panicking3tryINtNtCs3GuNEaDWhTL_4core6result6ResultNtNtNtCs3bKYnD5z5HT_17rustc_codegen_ssa4back5write15CompiledModulesuEINtNtNtBF_5panic11unwind_safe16AssertUnwindSafeNCNCINvMNtB4_6threadNtB3c_7Builder16spawn_unchecked_NCINvXs0_CsiA0FFhWH4jN_18rustc_codegen_llvmNtB43_18LlvmCodegenBackendNtNtNtB1i_6traits7backend19ExtraBackendMethods18spawn_named_threadNCINvB1e_20start_executing_workB4B_Es3_0BA_E0BA_Es_00EEB43_ () at library/std/src/panicking.rs:516
#73 _RINvNtCs3ZyGyicr358_3std5panic12catch_unwindINtNtNtCs3GuNEaDWhTL_4core5panic11unwind_safe16AssertUnwindSafeNCNCINvMNtB4_6threadNtB1P_7Builder16spawn_unchecked_NCINvXs0_CsiA0FFhWH4jN_18rustc_codegen_llvmNtB2G_18LlvmCodegenBackendNtNtNtCs3bKYnD5z5HT_17rustc_codegen_ssa6traits7backend19ExtraBackendMethods18spawn_named_threadNCINvNtNtB3K_4back5write20start_executing_workB3e_Es3_0INtNtBN_6result6ResultNtB5g_15CompiledModulesuEE0B64_Es_00EB64_EB2G_ () at library/std/src/panic.rs:142
#74 _RNCINvMNtCs3ZyGyicr358_3std6threadNtB5_7Builder16spawn_unchecked_NCINvXs0_CsiA0FFhWH4jN_18rustc_codegen_llvmNtB1a_18LlvmCodegenBackendNtNtNtCs3bKYnD5z5HT_17rustc_codegen_ssa6traits7backend19ExtraBackendMethods18spawn_named_threadNCINvNtNtB2e_4back5write20start_executing_workB1I_Es3_0INtNtCs3GuNEaDWhTL_4core6result6ResultNtB3K_15CompiledModulesuEE0B4y_Es_0B1a_ () at library/std/src/thread/mod.rs:528
#75 _RNSNvYNCINvMNtCs3ZyGyicr358_3std6threadNtBa_7Builder16spawn_unchecked_NCINvXs0_CsiA0FFhWH4jN_18rustc_codegen_llvmNtB1f_18LlvmCodegenBackendNtNtNtCs3bKYnD5z5HT_17rustc_codegen_ssa6traits7backend19ExtraBackendMethods18spawn_named_threadNCINvNtNtB2j_4back5write20start_executing_workB1N_Es3_0INtNtCs3GuNEaDWhTL_4core6result6ResultNtB3P_15CompiledModulesuEE0B4D_Es_0INtNtNtB4I_3ops8function6FnOnceuE9call_once6vtableB1f_ () at library/core/src/ops/function.rs:250
#76 0x00007ffff21fbaec in <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once () at library/alloc/src/boxed.rs:2015
#77 <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once () at library/alloc/src/boxed.rs:2015
#78 0x00007ffff221d8c5 in std::sys::unix::thread::Thread::new::thread_start () at library/std/src/sys/unix/thread.rs:108
#79 0x00007fffe1df1609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#80 0x00007ffff20a6353 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

@ZuseZ4
Copy link
Member

ZuseZ4 commented Jun 11, 2024

I kind of get that extending 128 bit to 64 bit causes issues. Shall I write an inline fn check that trunc >64 bit to 64, since we mainly care about < -1, not how much -1 it is? Also assuming that i128 will probably also not be handled elsewhere.

713	    // Constants explicitly marked as negative that aren't -1 are considered
714	    // integral
715	    if (ci->isNegative() && ci->getSExtValue() < -1) {
716	      analysis[Val].insert({-1}, BaseType::Integer);
717	      return;
718	    }
719	
(gdb) p ci
$1 = (llvm::ConstantInt *) 0x7fff7a979000
(gdb) p ci->dump()
i128 -12078052328127107563834081753142289173
$2 = void

ZuseZ4 added a commit to EnzymeAD/Enzyme that referenced this issue Jun 11, 2024
github-merge-queue bot pushed a commit to EnzymeAD/Enzyme that referenced this issue Jun 11, 2024
github-merge-queue bot pushed a commit to EnzymeAD/Enzyme that referenced this issue Jun 11, 2024
* Update TypeAnalysis.cpp

improves EnzymeAD/rust#125

* add TA test
@ZuseZ4 ZuseZ4 reopened this Jun 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants