StanfordLegion / legion

The Legion Parallel Programming System
https://legion.stanford.edu
Apache License 2.0
676 stars 145 forks source link

Regent: Unable to assign ispace to declaration of variable type ispace #785

Open syamajala opened 4 years ago

syamajala commented 4 years ago
import "regent"
local c = regentlib.c

task main()
  var colors : ispace(int3d)
  var dim = 0

  if dim == 0 then
    colors = ispace(int3d, int3d{2, 1, 1})
  elseif dim == 1 then
    colors = ispace(int3d, int3d{1, 2, 1})
  elseif dim == 2 then
    colors = ispace(int3d, int3d{1, 1, 2})
  end
end

regentlib.start(main)

The above example results in the following:

/home/seshu/dev/legion/language/src/regent/type_check.t:4235: Errors reported during typechecking.
index_space_bug.rg:9: type mismatch in assignment: expected ispace(int3d) but got ispace(int3d)
    colors = ispace(int3d, int3d{2, 1, 1})
         ^

stack traceback:
        [C]: in function 'error'
        /home/seshu/dev/terra/src/terralib.lua:388: in function 'finishandabortiferrors'
        /home/seshu/dev/legion/language/src/common/report.t:56: in function 'error'
        /home/seshu/dev/legion/language/src/regent/type_check.t:4235: in function 'fn'
        /home/seshu/dev/terra/src/asdl.lua:16: in function 'map'
        /home/seshu/dev/legion/language/src/regent/type_check.t:3884: in function 'block'
        /home/seshu/dev/legion/language/src/regent/type_check.t:3902: in function 'fn'
        /home/seshu/dev/terra/src/asdl.lua:16: in function 'map'
        /home/seshu/dev/legion/language/src/regent/type_check.t:3884: in function 'block'
        /home/seshu/dev/legion/language/src/regent/type_check.t:4612: in function </home/seshu/dev/legion/language/src/regent/type_check.t:4545>
        /home/seshu/dev/legion/language/src/regent/passes.t:69: in function </home/seshu/dev/legion/language/src/regent/passes.t:57>
        index_space_bug.rg:4: in main chunk

If this is in fact invalid code the error message should probably be fixed because right now it is nonsensical to a user.

elliottslaughter commented 4 years ago

The error message is an instance of https://github.com/StanfordLegion/legion/issues/491. It may be fixed by https://github.com/StanfordLegion/legion/pull/583 but there are still some blocking issues around that one.

For now, you have to do this by making the dims conditional. Assignment on "special" types such as ispaces and regions isn't supported (until https://github.com/StanfordLegion/legion/pull/583 merges).