X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 05 Apr 2023 01:11 AM by  Jasmine Kurb
IDL_IDLBridge parallel computation
 2 Replies
Sort:
You are not authorized to post a reply.
Author Messages

WWei XXue



New Member


Posts:
New Member


--
10 Mar 2022 07:31 PM
    Dear all,
    I am working on IDL parallel computation by using IDL_IDLBridge. One problem arises when I tried to transfer the structure variable from parent to child.
    Using SetVar does not work! I searched the reason, saying "Only scalar or array variables of numeric or string type can be transferred. Structures, pointers, and object references cannot be transferred between processes using the IDL_IDLBridge object".
    My Structure variable (list variable) contains 56 2000column*1000row matrix. I tried the COMMON to share the Structure between parent and child. But it seems doesn't work.
    My question is there any way to successfully transfer Structures from parent to child.
    Thanks.

    Ben Castellani



    Basic Member


    Posts:129
    Basic Member


    --
    14 Mar 2022 11:59 AM
    SETVAR does not support structure passing between parent and child IDL sessions. However, you can work-around this using other methods. I've listed two below.

    1) Convert the structure to a string in the main program with IDLDehydrate and JSON_SERIALIZE. Then pass the resulting string to the bridge and then use JSON_PARSE and IDLHydrate to bring it back to the identical structure form.

    See the example program at the end of this post for how to do this (test_bridgeStructurePass.pro).

    Note: The Hydrate and Dehydrate functionality was added in IDL 8.5.2. You must use at least that version for this to work. Here is the doc page for this: https://www.harrisgeospatial.com/docs/idlhydrate.html

    2) Use the IDL Asynchronous Task Framework instead. Check out IDLAsynBridgeTaskJob which will take care of executing the IDLTask inside a bridge. Parameters for the task need to be defined before it is kicked off. However, the task framework will handle all of the parameter passing between the main IDL session and the bridge (both ways). Many folks don't even know this functionality exists, but it can be super useful in the right circumstances. This was added in IDL 8.7.0: https://www.harrisgeospatial.com/docs/idlasyncbridgetaskjob.html

    EXAMPLE IDL CODE FOR WORKAROUND #1:

    pro test_bridgeStructurePass

    s = {structName, name:'NameOne', data1:50, data2:['a','b','c'], data3:FLTARR(12)}
    h = hash(s,/extract)
    j = json_serialize(h.dehydrate())

    oBridge = OBJ_NEW('IDL_IDLBridge', OUTPUT='bridge_log.txt')
    oBridge->Setvar,'j',j
    oBridge->Execute, 'd = json_parse(j)'
    oBridge->Execute, "h = IDLHydrate(d,TYPE='ORDEREDHASH')"
    oBridge->Execute, 's = h.ToStruct()'
    oBridge->Execute, 'help,s & print,s'

    OBJ_DESTROY, oBridge

    end

    Jasmine Kurb



    New Member


    Posts:1
    New Member


    --
    05 Apr 2023 01:11 AM
    You are not authorized to post a reply.