[great-users] Udm CopyObjectHierarchy function duration increases during transformation

Belschner, Tim tim.belschner at ils.uni-stuttgart.de
Tue Sep 26 13:50:55 CDT 2017


Hi Kevin,

thanks a lot for your help! Both solutions reduced the runtime of the CopyObjectHierarchy function significantly.
We thought that swiching-off the roll-back capability would accelerate a GReAT transformation in general, but the tests we conducted did not reveal any benefits beside the ones with the CopyObjectHierarchy function. Could you maybe explain which parts of a transformation are influenced by the roll-back capability, please?

Regards
Tim


Von: great-users [mailto:great-users-bounces at list.isis.vanderbilt.edu] Im Auftrag von Kevin Smyth
Gesendet: Mittwoch, 20. September 2017 22:07
An: A list for GReAT users to share bugs, fixes and ideas
Betreff: Re: [great-users] Udm CopyObjectHierarchy function duration increases during transformation

Hi Tim,

Unfortunately, GME is slow and gets slower under the default configuration, which enables it to roll back illegal operations. Here's code to disable the roll-back capability in the GReAT code generator's ...._main.cpp output file:

#include "Mga.idl" // from $(GME_ROOT)\Interfaces
....

// get objects from DNs
UMLModelTransformer::RootFolder rootUMLModelTransformer_552= UMLModelTransformer::RootFolder::Cast( uMLModelTransformer_ref_54b.GetRootObject());
StructureTestDSL::RootFolder rootStructureTestDSL_553= StructureTestDSL::RootFolder::Cast( structureTestDSL_ref_54e.GetRootObject());

// new code starts here:
// disable nested transactions for output model
IUnknown* gmeFco = UdmGme::Udm2Gme(sdnUMLModelTransformer_549.GetRootObject());
IMgaObject* gmeFcoPtr = NULL;
gmeFco->QueryInterface(__uuidof(IMgaObject), (void**)&gmeFcoPtr);
IMgaProject* project = NULL;
gmeFcoPtr->get_Project(&project);
long prefs;
project->get_Preferences(&prefs);
project->put_Preferences(MGAPREF_NO_NESTED_TX | prefs);
gmeFcoPtr->Release();
project->Release();
gmeFco->Release();
// new code ends

// Add objects to input packets.
templateModels_1.push_back( rootStructureTestDSL_553);
trafos_3.push_back( rootUMLModelTransformer_552);
// Get access to temporary root object(s).
g_Crosslinks__GlobalRootContainer= Crosslinks::GlobalRootContainer::Cast( crosslinks_ref_551.GetRootObject());
// transformation
Start_0 start_0;
start_0( templateModels_1, trafos_3);



Alternatively, you can commit the GME transaction before running UdmUtil::CopyObjectHierarchy:
#include "UdmGme.h"
....
((UdmGme::GmeDataNetwork*)fromObj.__impl()->__getdn())->CommitEditSequence();

GME will be able to roll back operations, but this will reduce the slowdown.


You should add error checking, e.g. in case the output file is not a GME file.

Kevin



On Thu, Sep 14, 2017 at 6:48 AM, Belschner, Tim <tim.belschner at ils.uni-stuttgart.de<mailto:tim.belschner at ils.uni-stuttgart.de>> wrote:
Hello  everybody,

based on the generated code for the GReAT Group operator, we built up a cpp template for copying an abstract source object including its children. Since we would like to pass the copied object to an out-port within the same rule, the approach is to create a dummy object within the rule’s effector and replace it during the AttributeMapping by calling the aforementioned template:

//++++++++++++++++++++++++++
template <class T1, class T2, class T3 > bool UserLibCloneObjectAbstractSource( T1& fromObj, T2& toObj, T3& toParent)
{
                T1 newObj= T1::Create( toParent );

                UdmUtil::copy_assoc_map copy_map;
                UdmUtil::CopyObjectHierarchy(fromObj.__impl(), newObj.__impl(), newObj.__impl()->__getdn(), copy_map);

                toObj.DeleteObject();
                toObj = newObj;

                return true;
}
// ++++++++++++++++++++++++++

The result in the transformation’s output is as intended. But, the runtime of the function UdmUtil::CopyObjectHierarchy within the template increases with every call. After several calls, the execution of UdmUtil::CopyObjectHierarchy takes several seconds. My search within the Udm source code did not reveal any reason. This is why I would like to ask if someone could give me a hint or provide an alternative solution? For example an incorrect usage of the UdmUtil::copy_assoc_map.

An example transformation with the necessary metamodel and inputs can be found here: https://belschner.org/nextcloud/index.php/s/RiMjSyd2yHKFYdT  PW: GReAT123!
The cpp template is located in the “UserLib_CloneObject.h”. The increasing runtime for a single “CopyObjectHierarchy” execution can be seen in the console output (Steps 2 to 3).

Thanks in advance and best regards

Tim

_______________________________________________
great-users mailing list
great-users at list.isis.vanderbilt.edu<mailto:great-users at list.isis.vanderbilt.edu>
http://list.isis.vanderbilt.edu/cgi-bin/mailman/listinfo/great-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.isis.vanderbilt.edu/pipermail/great-users/attachments/20170926/323fd551/attachment.html>


More information about the great-users mailing list