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

Bug report potentially from loose types #188

Open
jpmedinagl opened this issue Nov 20, 2024 · 1 comment
Open

Bug report potentially from loose types #188

jpmedinagl opened this issue Nov 20, 2024 · 1 comment

Comments

@jpmedinagl
Copy link
Collaborator

I have the following minimized code (has no logic implemented) and when I run with loose types I get a bug report

This generates an error, without the LooseTypes there's no error

$ RUSTBACKTRACE=1 RUSTFLAGS="-Z autodiff=OPT2,NoTypeTree,LooseTypes -Z llvm-plugins=/u/jpmedina/rust-opt2/build/x86_64-unknown-linux-gnu/enzyme/build/Enzyme/LLVMEnzyme-19.so  -C passes=enzyme" cargo +enzyme build --release --bin rep

Here is the file that generates it

#![allow(non_snake_case, non_upper_case_globals)]
#![feature(autodiff)]

use std::autodiff::autodiff;

#[no_mangle]
pub unsafe fn int1e_ovlp(
    out: &mut [f64],
    dims: Vec<i32>,
    shls: [i32; 4],
    atm: &mut [i32],
    natm: i32,
    bas: &mut [i32],
    nbas: i32,
    env: &mut [f64],
    cache: Vec<f64>,
) -> i32 {
    let ng = [0, 0, 0, 0, 0, 1, 1, 1];
    return 0;
}

#[inline(never)]
#[no_mangle]
pub fn cint1e_ovlp(
    out: &mut [f64],
    shls: [i32; 4],
    atm: &mut [i32],
    natm: i32,
    bas: &mut [i32],
    nbas: i32,
    env: &mut [f64],
) -> i32 {
    let dims = vec![0; 0];
    let cache = vec![0.0; 0];
    unsafe {
        return int1e_ovlp(out, dims, shls, atm, natm, bas, nbas, env, cache);
    }
}

#[no_mangle]
#[autodiff(
    dcart, Reverse, Duplicated, Const, Const, Const, Const, Const, Duplicated
)]
fn cart(
    out: &mut [f64],
    shls: [i32; 4],
    atm: &mut [i32],
    natm: i32,
    bas: &mut [i32],
    nbas: i32,
    env: &mut [f64],
) {
    cint1e_ovlp(out, shls, atm, natm, bas, nbas, env);
}

fn main() {
    println!();
}

and here is the bug report:

[compiler/rustc_codegen_llvm/src/back/write.rs:674:9] "Setting loose types to true" = "Setting loose types to true"
thread 'coordinator' panicked at compiler/rustc_codegen_llvm/src/back/write.rs:676:9:
not yet implemented
stack backtrace:
   0:     0x7ff6a4028016 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h1b64ac153c69d3ba
   1:     0x7ff6a40a0c43 - core::fmt::write::h6085b7dde82a8903
   2:     0x7ff6a405b21f - std::io::Write::write_fmt::h8ca7429f7521e415
   3:     0x7ff6a4027eb3 - std::sys::backtrace::BacktraceLock::print::h85deb265ad68346c
   4:     0x7ff6a40243fe - std::panicking::default_hook::{{closure}}::h44a8c36d20afaeb1
   5:     0x7ff6a4024213 - std::panicking::default_hook::h97ee5f8ea6db5a90
   6:     0x7ff6a0a65109 - <alloc[7bf7e58430c422aa]::boxed::Box<rustc_driver_impl[9a79e0146ab9ffbc]::install_ice_hook::{closure#0}> as core[ef683fd1bfc1e11a]::ops::function::Fn<(&dyn for<'a, 'b> core[ef683fd1bfc1e11a]::ops::function::Fn<(&'a std[79583edb3da6641a]::panic::PanicHookInfo<'b>,), Output = ()> + core[ef683fd1bfc1e11a]::marker::Sync + core[ef683fd1bfc1e11a]::marker::Send, &std[79583edb3da6641a]::panic::PanicHookInfo)>>::call
   7:     0x7ff6a402493f - std::panicking::rust_panic_with_hook::h1dddf71ed59d9999
   8:     0x7ff6a40283a6 - std::panicking::begin_panic_handler::{{closure}}::h38909d766908af90
   9:     0x7ff6a4028219 - std::sys::backtrace::__rust_end_short_backtrace::h12db1f028922a810
  10:     0x7ff6a402449c - rust_begin_unwind
  11:     0x7ff6a0a15030 - core::panicking::panic_fmt::hd64fd3b896853ace
  12:     0x7ff6a0a150bc - core::panicking::panic::h0828f6c7569b16e1
  13:     0x7ff6a0e6896b - rustc_codegen_llvm[263a41044495d437]::back::write::differentiate
  14:     0x7ff6a0ee8143 - <rustc_codegen_llvm[263a41044495d437]::LlvmCodegenBackend as rustc_codegen_ssa[c708f8658054a07c]::traits::write::WriteBackendMethods>::autodiff
  15:     0x7ff6a0e0a73f - <rustc_codegen_ssa[c708f8658054a07c]::back::lto::LtoModuleCodegen<rustc_codegen_llvm[263a41044495d437]::LlvmCodegenBackend>>::autodiff
  16:     0x7ff6a0ed685d - std[79583edb3da6641a]::sys::backtrace::__rust_begin_short_backtrace::<<rustc_codegen_llvm[263a41044495d437]::LlvmCodegenBackend as rustc_codegen_ssa[c708f8658054a07c]::traits::backend::ExtraBackendMethods>::spawn_named_thread<rustc_codegen_ssa[c708f8658054a07c]::back::write::start_executing_work<rustc_codegen_llvm[263a41044495d437]::LlvmCodegenBackend>::{closure#5}, core[ef683fd1bfc1e11a]::result::Result<rustc_codegen_ssa[c708f8658054a07c]::back::write::CompiledModules, ()>>::{closure#0}, core[ef683fd1bfc1e11a]::result::Result<rustc_codegen_ssa[c708f8658054a07c]::back::write::CompiledModules, ()>>
  17:     0x7ff6a0ee3334 - <<std[79583edb3da6641a]::thread::Builder>::spawn_unchecked_<<rustc_codegen_llvm[263a41044495d437]::LlvmCodegenBackend as rustc_codegen_ssa[c708f8658054a07c]::traits::backend::ExtraBackendMethods>::spawn_named_thread<rustc_codegen_ssa[c708f8658054a07c]::back::write::start_executing_work<rustc_codegen_llvm[263a41044495d437]::LlvmCodegenBackend>::{closure#5}, core[ef683fd1bfc1e11a]::result::Result<rustc_codegen_ssa[c708f8658054a07c]::back::write::CompiledModules, ()>>::{closure#0}, core[ef683fd1bfc1e11a]::result::Result<rustc_codegen_ssa[c708f8658054a07c]::back::write::CompiledModules, ()>>::{closure#1} as core[ef683fd1bfc1e11a]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  18:     0x7ff6a402876b - std::sys::pal::unix::thread::Thread::new::thread_start::h33697399bbf72b20
  19:     0x7ff697846609 - start_thread
                               at /build/glibc-LcI20x/glibc-2.31/nptl/pthread_create.c:477:8
  20:     0x7ff6a00d2353 - clone
                               at /build/glibc-LcI20x/glibc-2.31/misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:95
  21:                0x0 - <unknown>

error: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: please make sure that you have updated to the latest nightly

note: please attach the file at `/h/332/jpmedina/libcint/librint/rustc-ice-2024-11-20T20_32_04-996038.txt` to your bug report

note: compiler flags: --crate-type bin -C opt-level=3 -C lto=fat -C strip=debuginfo -Z autodiff=OPT2,NoTypeTree,LooseTypes -Z llvm-plugins=/u/jpmedina/rust-opt2/build/x86_64-unknown-linux-gnu/enzyme/build/Enzyme/LLVMEnzyme-19.so -C passes=enzyme

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
thread 'rustc' panicked at /h/332/jpmedina/rust-opt2/compiler/rustc_codegen_ssa/src/back/write.rs:2080:17:
/h/332/jpmedina/rust-opt2/compiler/rustc_codegen_ssa/src/back/write.rs:2080:17: panic during codegen/LLVM phase
stack backtrace:
   0:     0x7ff6a4028016 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h1b64ac153c69d3ba
   1:     0x7ff6a40a0c43 - core::fmt::write::h6085b7dde82a8903
   2:     0x7ff6a405b21f - std::io::Write::write_fmt::h8ca7429f7521e415
   3:     0x7ff6a4027eb3 - std::sys::backtrace::BacktraceLock::print::h85deb265ad68346c
   4:     0x7ff6a40243fe - std::panicking::default_hook::{{closure}}::h44a8c36d20afaeb1
   5:     0x7ff6a4024213 - std::panicking::default_hook::h97ee5f8ea6db5a90
   6:     0x7ff6a0a65109 - <alloc[7bf7e58430c422aa]::boxed::Box<rustc_driver_impl[9a79e0146ab9ffbc]::install_ice_hook::{closure#0}> as core[ef683fd1bfc1e11a]::ops::function::Fn<(&dyn for<'a, 'b> core[ef683fd1bfc1e11a]::ops::function::Fn<(&'a std[79583edb3da6641a]::panic::PanicHookInfo<'b>,), Output = ()> + core[ef683fd1bfc1e11a]::marker::Sync + core[ef683fd1bfc1e11a]::marker::Send, &std[79583edb3da6641a]::panic::PanicHookInfo)>>::call
   7:     0x7ff6a402493f - std::panicking::rust_panic_with_hook::h1dddf71ed59d9999
   8:     0x7ff6a3966aa1 - std[79583edb3da6641a]::panicking::begin_panic::<alloc[7bf7e58430c422aa]::string::String>::{closure#0}
   9:     0x7ff6a3965d36 - std[79583edb3da6641a]::sys::backtrace::__rust_end_short_backtrace::<std[79583edb3da6641a]::panicking::begin_panic<alloc[7bf7e58430c422aa]::string::String>::{closure#0}, !>
  10:     0x7ff6a09ce5ff - std[79583edb3da6641a]::panicking::begin_panic::<alloc[7bf7e58430c422aa]::string::String>
  11:     0x7ff6a393fec9 - rustc_middle[72685351840cfc15]::util::bug::opt_span_bug_fmt::<rustc_span[535367b496bfa699]::span_encoding::Span>::{closure#0}
  12:     0x7ff6a393fc9e - rustc_middle[72685351840cfc15]::ty::context::tls::with_opt::<rustc_middle[72685351840cfc15]::util::bug::opt_span_bug_fmt<rustc_span[535367b496bfa699]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  13:     0x7ff6a393fc5b - rustc_middle[72685351840cfc15]::ty::context::tls::with_context_opt::<rustc_middle[72685351840cfc15]::ty::context::tls::with_opt<rustc_middle[72685351840cfc15]::util::bug::opt_span_bug_fmt<rustc_span[535367b496bfa699]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  14:     0x7ff6a09ce9c2 - rustc_middle[72685351840cfc15]::util::bug::bug_fmt
  15:     0x7ff6a0ee98ce - <rustc_codegen_llvm[263a41044495d437]::LlvmCodegenBackend as rustc_codegen_ssa[c708f8658054a07c]::traits::backend::CodegenBackend>::join_codegen
  16:     0x7ff6a0da40db - <rustc_interface[f375b6f7422b9b66]::queries::Linker>::link
  17:     0x7ff6a0a67af8 - rustc_span[535367b496bfa699]::create_session_globals_then::<core[ef683fd1bfc1e11a]::result::Result<(), rustc_span[535367b496bfa699]::ErrorGuaranteed>, rustc_interface[f375b6f7422b9b66]::util::run_in_thread_with_globals<rustc_interface[f375b6f7422b9b66]::util::run_in_thread_pool_with_globals<rustc_interface[f375b6f7422b9b66]::interface::run_compiler<core[ef683fd1bfc1e11a]::result::Result<(), rustc_span[535367b496bfa699]::ErrorGuaranteed>, rustc_driver_impl[9a79e0146ab9ffbc]::run_compiler::{closure#0}>::{closure#1}, core[ef683fd1bfc1e11a]::result::Result<(), rustc_span[535367b496bfa699]::ErrorGuaranteed>>::{closure#0}, core[ef683fd1bfc1e11a]::result::Result<(), rustc_span[535367b496bfa699]::ErrorGuaranteed>>::{closure#0}::{closure#0}::{closure#0}>
  18:     0x7ff6a0a4b1a2 - std[79583edb3da6641a]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[f375b6f7422b9b66]::util::run_in_thread_with_globals<rustc_interface[f375b6f7422b9b66]::util::run_in_thread_pool_with_globals<rustc_interface[f375b6f7422b9b66]::interface::run_compiler<core[ef683fd1bfc1e11a]::result::Result<(), rustc_span[535367b496bfa699]::ErrorGuaranteed>, rustc_driver_impl[9a79e0146ab9ffbc]::run_compiler::{closure#0}>::{closure#1}, core[ef683fd1bfc1e11a]::result::Result<(), rustc_span[535367b496bfa699]::ErrorGuaranteed>>::{closure#0}, core[ef683fd1bfc1e11a]::result::Result<(), rustc_span[535367b496bfa699]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[ef683fd1bfc1e11a]::result::Result<(), rustc_span[535367b496bfa699]::ErrorGuaranteed>>
  19:     0x7ff6a0a4bc68 - <<std[79583edb3da6641a]::thread::Builder>::spawn_unchecked_<rustc_interface[f375b6f7422b9b66]::util::run_in_thread_with_globals<rustc_interface[f375b6f7422b9b66]::util::run_in_thread_pool_with_globals<rustc_interface[f375b6f7422b9b66]::interface::run_compiler<core[ef683fd1bfc1e11a]::result::Result<(), rustc_span[535367b496bfa699]::ErrorGuaranteed>, rustc_driver_impl[9a79e0146ab9ffbc]::run_compiler::{closure#0}>::{closure#1}, core[ef683fd1bfc1e11a]::result::Result<(), rustc_span[535367b496bfa699]::ErrorGuaranteed>>::{closure#0}, core[ef683fd1bfc1e11a]::result::Result<(), rustc_span[535367b496bfa699]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[ef683fd1bfc1e11a]::result::Result<(), rustc_span[535367b496bfa699]::ErrorGuaranteed>>::{closure#1} as core[ef683fd1bfc1e11a]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  20:     0x7ff6a402876b - std::sys::pal::unix::thread::Thread::new::thread_start::h33697399bbf72b20
  21:     0x7ff697846609 - start_thread
                               at /build/glibc-LcI20x/glibc-2.31/nptl/pthread_create.c:477:8
  22:     0x7ff6a00d2353 - clone
                               at /build/glibc-LcI20x/glibc-2.31/misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:95
  23:                0x0 - <unknown>

error: the compiler unexpectedly panicked. this is a bug.

here is the rustc file: rustc-ice-2024-11-20T20_32_04-996038.txt

@ZuseZ4
Copy link
Member

ZuseZ4 commented Nov 20, 2024

Implemented. But not 100% sure if Enzyme recognizes the LooseTypes flag correctly now, so let me know if you get an error related to it.

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

No branches or pull requests

2 participants