Opened 9 years ago

Closed 7 years ago

#3829 closed defect (worksforme)

Memory allocation tracking produces weird statistics

Reported by: Henning Kiel Owned by: Lennart Ochel
Priority: high Milestone:
Component: Code Generation Version:
Keywords: Cc: Martin Sjölund

Description

Take this example. At the corresponding line no memory is allocated.
(Log file is from Compilation phase of compiler. SimCodeUtil.mo was translated)

Absyn.mo:

5274: public function isDerCref
5275:   input Exp exp;
5276:   output Boolean b;
5277: algorithm
5278:   b := match exp
5279:     case CALL(CREF_IDENT("der",{}),FUNCTIONARGS({CREF()},{})) then true;
5280:     else false;
5281:   end match;
5282: end isDerCref;

Absyn.c:

        case 1: {
          
          /* Pattern matching succeeded */
#line 5280 "/Users/henning/src/OpenModelica/OMCompiler/Compiler/FrontEnd/Absyn.mo"
          mmc_set_current_pos("[/Users/henning/src/OpenModelica/OMCompiler/Compiler/FrontEnd/Absyn.mo:5280:5-5281:3]");
#line 5280 "/Users/henning/src/OpenModelica/OMCompiler/Compiler/FrontEnd/Absyn.mo"
          tmp1 = 0;
#line 7157 OMC_FILE
          tmp5 = 1;
          break;
        }

omc-memory.txt:

5412416: [/Users/henning/src/OpenModelica/OMCompiler/Compiler/FrontEnd/Absyn.mo:5280:5-5281:3]

Change History (3)

comment:1 by Henning Kiel, 9 years ago

Cc: Martin Sjölund added

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

This is expected. The thing is we only record the line at the start of a statement, etc. So things like:

function f // line 1
// line 2
arrayCreate(100,f());

Becomes:

// I am at line 2
tmp=f() // f updates to say "I am at line 1"
arrayCreate(100,tmp) // Memory allocation thinks it is at line 1

So for higher-order functions and compound expressions, you need to search for the functions calling this function. You also should compile some files without tracking memory (like Flags.mo), because things depending on the Flag will record the flag function as a position of memory allocation.

I use the following:

make -j8 OMC_EXTRA_FLAGS=-d=metaModelicaRecordAllocWords || exit 1
touch Compiler/*/*Avl*.mo Compiler/*/*List*.mo Compiler/Template/Tpl.mo Compiler/FrontEnd/ComponentReference.mo Compiler/Util/Array.mo Compiler/Util/*Hash*.mo
make -j8 omc || exit 1
make -C .. -j8 omlibrary-core || exit 1

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

Milestone: Future
Resolution: worksforme
Status: newclosed
Note: See TracTickets for help on using tickets.