Opened 9 years ago

Last modified 9 years ago

#3538 new discussion

function outputs array slice

Reported by: Volker Waurich Owned by: somebody
Priority: normal Milestone: Future
Component: Backend Version:
Keywords: Cc: Lennart Ochel, Mahder Alemseged Gebremedhin, Per Östlund, Willi Braun

Description

Hi,

A model of mine has a function call that outputs an array slice, which is part of a 2-dimensional array. This call is inside a for-loop:
Something like: (_,x[:,i],_) := f(a);

When compiling, I get the template-error from daeExpCrefLhsSimContext:

Template error: This should have been handled in indexed assign and should not have gotten here x[:,i]

Can anybody explain where exactly these things have to be handled?
I dont know what is meant with "indexed assign".

Thanks.

Change History (5)

comment:1 by Willi Braun, 9 years ago

I'm not sure if the following helps:

wbraun@CELSIUS:~/workspace/GitHubMaster/OMCompiler$ grep "This should have been handled" Compiler/Template/*.tpl -n
Compiler/Template/CodegenCFunctions.tpl:4561:                error(sourceInfo(),'This should have been handled in the new daeExpCrefRhsSimContext function. <%printExpStr(ecr)%>')
Compiler/Template/CodegenCFunctions.tpl:4652:        error(sourceInfo(),'daeExpCrefLhsSimContext: This should have been handled in indexed assign and should not have gotten here <%ExpressionDump.printExpStr(ecr)%>')
Compiler/Template/CodegenCFunctions.tpl:4695:             error(sourceInfo(),'This should have been handled in the new daeExpCrefLhsSimContext function. <%printExpStr(ecr)%>')
Compiler/Template/CodegenCFunctions.tpl:4698:        error(sourceInfo(),'This should have been handled in indexed assign and should not have gotten here. <%printExpStr(ecr)%>')

comment:2 by Volker Waurich, 9 years ago

These are the template functions from where this message comes from. But I would like to know how and especially where array slices as lhs-crefs should have been processed as indicated by this message.

comment:3 by Martin Sjölund, 9 years ago

You need to create a temporary array for these variables and handle it either by rewriting the expression, or making the template do the temporary array+copy. You can't simply pass the contiguous memory for these assignments since the slice might not be contiguous.

in reply to:  3 comment:4 by Volker Waurich, 9 years ago

Replying to sjoelund.se:

You need to create a temporary array for these variables and handle it either by rewriting the expression, or making the template do the temporary array+copy. You can't simply pass the contiguous memory for these assignments since the slice might not be contiguous.

I see.Thanks for the answer.

comment:5 by Mahder Alemseged Gebremedhin, 9 years ago

I think the problem is in the FrontEnd or BackEnd somewhere. I put that error message there to just remind you to check what is actually causing the assignment to reach that point.

That specific assignemtn should have been handled differently. Normally you generate the lhs (daeExpCrefLhs*) and rhs (daeExpCrefLhs*) separately and assign them. However assignments involving slices are handled differently since we need to generate extra code handling the slices.

If you could give me a simplified version of your model I can take a look.

Note: See TracTickets for help on using tickets.