Opened 14 years ago

Closed 4 years ago

Last modified 4 years ago

#1447 closed defect (fixed)

Vectorization does not work in front end

Reported by: dhedberg Owned by: dhedberg
Priority: high Milestone: 1.14.0
Component: Frontend Version:
Keywords: Cc: dhedberg, Henrik Tidefelt

Description

I tested the following model in the latest nightly build of OpenModelica and it does not work.

function Foo
  input Integer x[:];
  output Integer y[size(x,1)];
algorithm 
  y := abs(x);
end Foo;

model MyTest
  Integer a[2] = {1, -1};
  Integer b[2];
algorithm
  b := Foo(a);
end MyTest;

I get the following error:

$ omc MyTest.mo
Error processing file: MyTest.mo
[MyTest.mo:5:3-5:14:writable] Error: No matching function found for abs in component <NO COMPONENT>
candidates are function(x:Integer) => Integer
 -function(x:Real) => Real

# Error encountered! Exiting...
# Please check the error message and the flags.

Execution failed!

Change History (12)

comment:2 by Martin Sjölund, 14 years ago

Yes, Adrian didn't port this stuff to the trunk

comment:3 by Peter Aronsson, 14 years ago

Note that this is required by Modelica.Matrices

comment:4 by Martin Sjölund, 13 years ago

Have you finished work on this in the branch? Or should we add the proper rewrite rule to the trunk?
abs(x) => array(abs(x[i]) for i in 1:size(x))

comment:5 by Martin Sjölund, 13 years ago

In order to solve this properly, the environment needs to return size(x,1) as the dimension. Not unknown (it is partially known, and we need this knowledge... but OMC does not store this as of yet)

comment:6 by Martin Sjölund, 13 years ago

This is now working for calls with only one foreach argument (general case requires aforementioned larger changes in the compiler)

comment:7 by Henrik Tidefelt, 10 years ago

Cc: dhedberg, → dhedberg
Component: Backend

Just to make it explicit, here's a minor modification of the original model, which still exhibits the problem:

function Foo
  input Integer x[:, :];
  output Integer y[size(x, 1), size(x, 2)];
algorithm
  y := abs(x);
end Foo;

model MyTest
  Integer a[2, 2] = {{1, -1}, {2, -2}};
  Integer b[2, 2];
algorithm
  b := Foo(a);
end MyTest;

comment:8 by Henrik Tidefelt, 10 years ago

Component: BackendFrontend

Replacing the automatically set Component with one that makes more sense.

comment:9 by Henrik Tidefelt, 10 years ago

Cc: Henrik Tidefelt added

comment:10 by Dietmar Winkler, 9 years ago

Milestone: Future

comment:11 by Per Östlund, 4 years ago

Resolution: fixed
Status: newclosed

All the example models work with both the old and the new frontend, so I guess this was fixed some time ago.

comment:12 by Francesco Casella, 4 years ago

Milestone: Future1.14.0
Note: See TracTickets for help on using tickets.