IntelLabs / ParallelAccelerator.jl

The ParallelAccelerator package, part of the High Performance Scripting project at Intel Labs
BSD 2-Clause "Simplified" License
294 stars 32 forks source link

OptFramework failed to optimize function ##main#7055 in optimization pass #67

Closed sarkar1 closed 8 years ago

sarkar1 commented 8 years ago

Julia executes the following code without warning however ParallelAccelerator throws the given message.

using ParallelAccelerator
@acc function main()
    X=rand(5,3)
    theta=zeros(3,1)
    theta = theta - X'[:,1]
end
main()
OptFramework failed to optimize function ##main#7055 in optimization pass ParallelAccelerator.Driver.toParallelIR with error Array number 2 does not have the same number of resulting dimensions as the first array in findSelectedDimensions.
DrTodd13 commented 8 years ago

X'[:,1] creates a one-dimensional array so you have theta (which is 2D) subtracting a 1D array. Julia automatically broadcasts this 1D array to 2D in order to do this element-wise subtraction. ParallelAccelerator doesn't currently support this.

You can change your example to X'[:,1:1] in order to create a 2D array and then this example seems to work.

sarkar1 commented 8 years ago

Thanks @DrTodd13. I am aware of this issue and wanted to point it out. Maybe its not a priority right now.

DrTodd13 commented 8 years ago

At the moment, it is difficult for us to mimic Julia's broadcast semantics for when there is dimensional mismatch. We don't really plan on trying to fix this for 0.4 especially because there is an easy source fix such as using "1:1" instead of "1". If semantics become easier for us in 0.5 it would be nice to do it but like you say not a priority.

So, given that, what would you like to see as a result of this ticket? Is it a complaint that the error message isn't helpful enough? About the best we could easily do there is to say what kind of operation involved arrays of differing dimensionality. I could print the array name but in this particular case it is a temporary array name (a GenSym) that would not have any obvious correlation to something in the program. I could change the message to be a bit clearer that it is a dimensional mismatch between two arrays involved in some operation and I could print the dimensions that don't match as well.

sarkar1 commented 8 years ago

It is actually a warning message. Both (1:1 and 1) gives the same result. I think the warning message you suggested is great. This looks good for now. I am closing this ticket.