PSyclone
PSyclone copied to clipboard
matmul 2 code transformation raises an exception if it is not the only thing on the rhs of an expression
j_ls_vorticity = wqp_h(qp1) * wqp_v(qp2) * & matmul( jac, ls_vorticity_at_quad )
Created branch 1562_matmul_rhs
There are a couple of potential solutions here.
- 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). - 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 toa = 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.
It may be that we should tackle implicit arrays being mapped to colon notation first in this case. e.g. a
goes to a(:)