AnyDSL / thorin

The Higher-Order Intermediate Representation
https://anydsl.github.io
GNU Lesser General Public License v3.0
151 stars 15 forks source link

reserve_shared triggers assertion failure #46

Closed ergawy closed 8 years ago

ergawy commented 8 years ago

This code fragment:

extern "thorin" {
    fn cuda(i32, (i32, i32, i32), (i32, i32, i32), fn() -> ()) -> (); 
    fn reserve_shared[T](i32) -> &[3][T];
}
fn launch(size: i32) -> () {
    with cuda(0, (size, 1, 1), (size, 1, 1)) {
        let shrd = reserve_shared[f32](size);
    }   
}

fn main() -> i32 {
    @launch(128);
    @launch(256);
    0   
}

results in an assertion failure:

Expression: (!r || dynamic_cast<L*>(r)) && "cast not possible"

at:

File: W:/thesis/anydsl/thorin/src/thorin/util/cast.h, Line 29

The reserve_shared call triggers the problem. Also the problem is only triggered when more than launch calls are present.

leissa commented 8 years ago

Thanks for reporting. Can you give me a self-contained version I can easily debug?

ergawy commented 8 years ago

Sorry for the long example. I updated the issue with a shorter version.

leissa commented 8 years ago

thanks. But I was more asking for self-contained version. A file which works out-of-the-box - where all built-in functions are already declared and so forth.

ergawy commented 8 years ago

Oh my bad again. Updated the code.

richardmembarth commented 8 years ago

I've updated the code to include declarations of cuda and reserve_shared intrinsics. The code SegFaults on the master branch, but works on the alternate_evalops branch.

leissa commented 8 years ago

Thanks both of you. So, we are about to merge alternate_evalop into master. Should I open a pull request so we can discuss any remaining issues and by doing this close this bug, too?

richardmembarth commented 8 years ago

Sounds like a plan!

leissa commented 8 years ago

just looked into it. The bug should in principal also affect alternate_evalop. It's a bit hard to write a test case for that. So I'm closing this now.