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

Internal Compiler Error: unknown variable after Fuse SOACs #1858

Closed
poeface opened this issue Jan 24, 2023 · 3 comments
Closed

Internal Compiler Error: unknown variable after Fuse SOACs #1858

poeface opened this issue Jan 24, 2023 · 3 comments

Comments

@poeface
Copy link

poeface commented Jan 24, 2023

I found a new compiler bug today. The start of the complaint was:

Internal compiler error.  Please report this:                                                                                                                                                                      
  https://github.com/diku-dk/futhark/issues                                                                                                                                                                        
Type error after pass 'Fuse SOACs':                                                                                                                                                                                
In function entry_main                                                                                                                                                                                             
When checking function body                                                                                                                                                                                        
In expression of statement                                                                                                                                                                                         
  {replicate_14296 : ({}, [MN2_13061][MN2_13061]f64)}                                                                                                                                                              
In subexp defunc_1_map_res_13270                                                                                                                                                                                   
Use of unknown variable defunc_1_map_res_13270.

I'm just putting the start because it then proceeded to print out a bunch of IR information (I think) which would be too long for this format.

Here is the futhark commit I am using: git: 3f2a2ef (Sat Jan 21 22:23:55 2023 +0100).

Here is a test program that produces the bug: SOAC_bug.zip

Apologies that it's so long! I tried to shorten it as much as possible, but since this bug is happening comparatively late in the compilation process, it seems to depend on a lot of overlapping pieces of code.

@athas
Copy link
Member

athas commented Jan 24, 2023

Reduced example.

def matmul_diag_full [n][m] (ds: [n]f64) (A: [n][m]f64): [n][m]f64 =
  map2 (\d as -> map (*d) as) ds A

def matmul_full_diag [n][m] (A: [n][m]f64) (ds: [m]f64): [n][m]f64 =
  transpose (map2 (\d as -> map (*d) as) ds (transpose A))

entry calcS (k0: f64) (D: []f64) (W: [][]f64)  =
  let X = map (\d -> f64.exp (f64.neg d * k0 * 1)) D
  let temp = X `matmul_diag_full` W `matmul_full_diag` X
  in temp

@athas
Copy link
Member

athas commented Jan 24, 2023

Introduced with the new fusion engine in 0.21.13. Probably not a very deep bug. I might not have time to fix it this evening, though.

@athas
Copy link
Member

athas commented Jan 24, 2023

It is almost certainly related to the optimisation that allows fusion through transpositions.

@athas athas closed this as completed in 6ced0c6 Jan 24, 2023
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