PSyclone icon indicating copy to clipboard operation
PSyclone copied to clipboard

matmul 2 code transformation raises an exception if it is not the only thing on the rhs of an expression

Open rupertford opened this issue 2 years ago • 3 comments

j_ls_vorticity = wqp_h(qp1) * wqp_v(qp2) * & matmul( jac, ls_vorticity_at_quad )

rupertford avatar Jan 10 '22 23:01 rupertford

Created branch 1562_matmul_rhs

rupertford avatar Aug 03 '22 14:08 rupertford

There are a couple of potential solutions here.

  1. Determine the rank of the array returned by the matmul - probably by using .datatype as has been implemented for references. Then we can allocate a new array which we assign to using matmul. This requires us to know the size of the returned array as well as the dimension and could require allocation, which is not yet supported in PSyIR (so we would have to resort to fparser2).
  2. If the rank and dimensions of the LHS and the matmul are the same then allocate matmul to the LHS and then increment it by the other values. For example: a = b * matmul(c,d) goes to a = matmul(c,d); a = a*b. I need to determine when this can be assumed. I think it is when everything is arrays with the same rank.

rupertford avatar Aug 03 '22 16:08 rupertford

It may be that we should tackle implicit arrays being mapped to colon notation first in this case. e.g. a goes to a(:)

rupertford avatar Aug 03 '22 16:08 rupertford