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

Pipe operator can cause ICE during SOAC fusion #1631

Closed
Programmerino opened this issue Apr 7, 2022 · 2 comments
Closed

Pipe operator can cause ICE during SOAC fusion #1631

Programmerino opened this issue Apr 7, 2022 · 2 comments
Assignees

Comments

@Programmerino
Copy link

I tested this bug on versions 0.20.5 and the latest git master 8067ecf65d5eca0721d9fd808f8eb1c5153c8464 on a Linux x86-64 machine and reproduced it both times. The error occurs on all backends. I'm sorry the title isn't that descriptive, but I don't really know what's going on here...

Failing code:

entry ice =
    let go _ = loop _ = [] for _ in [0,1] do [0i32]
    in
    (go 0) ++ (0 |> go) -- If the pipe operator is not used, it works

Compiler error:

[  +0.000023] Reading and type-checking source program
[  +0.227272] Defunctorising
[  +0.000731] Monomorphising
[  +0.031572] Lifting lambdas
[  +0.000227] Defunctionalising
[  +0.000449] Converting to core IR
[  +0.000703] Type-checking internalised program
[  +0.000771] Running pass simplify
[  +0.001644] Running pass Inline conservatively
[  +0.002796] Running pass simplify
[  +0.000752] Running pass Inline aggressively
[  +0.000764] Running pass simplify
[  +0.000851] Running pass CSE
[  +0.000432] Running pass simplify
[  +0.000707] Running pass Fuse SOACs
Internal compiler error.  Please report this:
  https://github.com/diku-dk/futhark/issues
Type error after pass 'Fuse SOACs':
In expression of statement
  {defunc_0_f_res_4726 : ({}, i64),
   defunc_0_f_res_4727 : ({}, [loop₂_4659]i32),
   discard_4728 : ({}, i64),
   lifted_go_res_4729 : ({}, i64),
   lifted_go_res_4730 : ({}, [loop₂_4631]i32),
   discard_4731 : ({}, i64)}
Type error:
Stream with inconsistent accumulator type in lambda.
let {loop_init_4717 : ({}, [0i64]i32)} =
  [] : []i32
let {for_in_arr_4718 : ({}, [2i64]i32)} =
  [0i32, 1i32] : []i32
let {loopres_4719 : ({}, [1i64]i32)} =
  replicate([1i64], 0i32)
let {defunc_0_f_res_4726 : ({}, i64),
     defunc_0_f_res_4727 : ({}, [loop₂_4659]i32),
     discard_4728 : ({}, i64),
     lifted_go_res_4729 : ({}, i64),
     lifted_go_res_4730 : ({}, [loop₂_4631]i32),
     discard_4731 : ({}, i64)} =
  streamSeq(2i64,
            {for_in_arr_4718},
            {0i64, loop_init_4717, 0i64, 0i64, loop_init_4717, 0i64},
            \ {chunk_size_4732 : i64, loop₂_outer_4733 : i64,
               nameless_outer_4734 : [loop₂_4659]i32, offset_4735 : i64,
               loop₂_outer_4736 : i64, nameless_outer_4737 : [loop₂_4631]i32,
               offset_4738 : i64, for_in_arr_chunk_4739 : [chunk_size_4732]i32}
              : {i64,
                 [loop₂_4659]i32,
                 i64,
                 i64,
                 [loop₂_4631]i32,
                 i64} ->
              let {x_4740 : ({}, i64),
                   x_4741 : ({loopres_4719, nameless_outer_4734},
                             [x_4740]i32)} =
                -- Result for nameless_4744 aliases loopres_4719
                loop {loop₂_4743 : i64,
                      nameless_4744 : [loop₂_4743]i32} = {loop₂_outer_4733,
                                                          nameless_outer_4734}
                for j_4742:i64 < chunk_size_4732 do {
                  {1i64, loopres_4719}
                }
              let {x_4745 : ({}, i64)} = add_nw64(chunk_size_4732, offset_4735)
              let {x_4746 : ({}, i64),
                   x_4747 : ({loopres_4719, nameless_outer_4737},
                             [x_4746]i32)} =
                -- Result for nameless_4750 aliases loopres_4719
                loop {loop₂_4749 : i64,
                      nameless_4750 : [loop₂_4749]i32} = {loop₂_outer_4736,
                                                          nameless_outer_4737}
                for j_4748:i64 < chunk_size_4732 do {
                  {1i64, loopres_4719}
                }
              let {x_4751 : ({}, i64)} = add_nw64(chunk_size_4732, offset_4738)
              in {x_4740, x_4741, x_4745, x_4746, x_4747, x_4751})
let {conc_tmp_4758 : ({}, i64)} =
  add_nw64(defunc_0_f_res_4726, lifted_go_res_4729)
let {++_res_4759 : ({}, [conc_tmp_4758]i32)} =
  concat@0(conc_tmp_4758, lifted_go_res_4730, defunc_0_f_res_4727)

entry("ice",
      {},
      {direct})
  entry_ice ()
  : {i64, [?0]i32} = {
  {conc_tmp_4758, ++_res_4759}
}
@athas
Copy link
Member

athas commented Apr 8, 2022

I can reproduce. Thanks for the concise test program.

@athas athas self-assigned this Apr 8, 2022
@athas
Copy link
Member

athas commented Apr 8, 2022

The pipe is a red herring; it's just that the two applications get CSE'd down to one if it isn't there. It's a straightforward bug in horizontal stream fusion, and present since at least 0.20.6.

@athas athas closed this as completed in e552b3b Apr 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants