Пример #1
0
def theMain():

    OA.GBL.insert_debug_code = 0

    G = OA.GraphTool.DiGraph()

    OA.setupGraph(G, "utest_labelEdt")

    OA.addHeader(G, ' ')  # Just a blank line
    OA.addHeader(G, '#define ENABLE_EXTENSION_LABELING  // For labeled EDTs')
    OA.addHeader(G,
                 '#include "extensions/ocr-labeling.h"  // For labeled EDTs')
    OA.addHeader(G, ' ')  # Just a blank line

    OA.addHeader(G, '#define N 5')
    N = 5

    OA.addHeader(G, 'typedef struct Work { int x[N]; ocrGuid_t emap;} Work_t;')

    # ----- Data Blocks
    dbk = OA.ocrDataBlock()
    dbk.name = 'NULL_GUID'
    dbk_nullGuid = dbk

    dbk = OA.ocrDataBlock()
    dbk.name = 'WorkLeft'
    dbk.count = 1
    dbk.type = 'Work_t'
    dbk_workLeft = dbk

    dbk = OA.ocrDataBlock()
    dbk.name = 'WorkRight'
    dbk.count = 1
    dbk.type = 'Work_t'
    dbk_workRight = dbk

    dbk = OA.ocrDataBlock()
    dbk.name = 'edtMap'
    dbk.count = 1
    dbk.type = 'ocrGuid_t'
    dbk_edtMap = dbk

    dbk = OA.ocrDataBlock()
    dbk.name = 'wDoneLeft'
    dbk.count = 1
    dbk.type = 'ocrGuid_t'
    dbk_wdoneLeft = dbk
    dbk = OA.ocrDataBlock()
    dbk.name = 'wDoneRight'
    dbk.count = 1
    dbk.type = 'ocrGuid_t'
    dbk_wdoneRight = dbk

    # ----- NODES
    nc = OA.GBL.MAINNODE
    taskName = "mainEdt"
    OA.graphAddNode(G, nc, taskName)
    dbk = copy.deepcopy(dbk_edtMap)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_emap'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_workLeft)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_wleft'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_workRight)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_wright'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_wdoneLeft)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_doneLeft'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_wdoneRight)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_doneRight'
    OA.addDataBlocks(G, nc, dbk)
    toFinalLeft = 'GUID_ASSIGN_VALUE(*o_doneLeft, ' + OA.makeGuidEdtname(
        "finalEDT") + ');'
    OA.addCustomText(G, nc, toFinalLeft)
    toFinalRight = 'GUID_ASSIGN_VALUE(*o_doneRight, ' + OA.makeGuidEdtname(
        "finalEDT") + ');'
    OA.addCustomText(G, nc, toFinalRight)
    emapText = 'ocrGuid_t emap = NULL_GUID;'
    OA.addCustomText(G, nc, emapText)
    emapText = 'err = ocrGuidRangeCreate(&emap, 3, GUID_USER_EDT); IFEB; // 3 for fun'
    OA.addCustomText(G, nc, emapText)
    emapText = 'GUID_ASSIGN_VALUE(*o_emap, emap);'
    OA.addCustomText(G, nc, emapText)

    wleft_text = 'int i;'
    OA.addCustomText(G, nc, wleft_text)
    wleft_text = 'for(i=0;i<N;++i) o_wleft->x[i]=i+1;'
    OA.addCustomText(G, nc, wleft_text)
    wleft_text = 'GUID_ASSIGN_VALUE(o_wleft->emap, emap);'
    OA.addCustomText(G, nc, wleft_text)
    wright_text = 'for(i=0;i<N;++i) o_wright->x[i]=N+1+i;'
    OA.addCustomText(G, nc, wright_text)
    wright_text = 'GUID_ASSIGN_VALUE(o_wright->emap, emap);'
    OA.addCustomText(G, nc, wright_text)

    nc = OA.GBL.FINALNODE
    taskName = "finalEDT"
    OA.graphAddNode(G, nc, taskName)
    dbk = copy.deepcopy(dbk_edtMap)
    dbk.flight = 'flLANDING'
    dbk.localname = 'in_edtMap'
    OA.addDataBlocks(G, nc, dbk)
    destroy_emap = 'err = ocrGuidMapDestroy(*in_edtMap); IFEB;'
    OA.addCustomText(G, nc, destroy_emap)

    nc += 1
    taskName = "LeftEDT"
    OA.graphAddNode(G, nc, taskName)
    dbk = copy.deepcopy(dbk_workLeft)
    dbk.flight = 'flTAGO'
    dbk.localname = 'io_workL'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_wdoneLeft)
    dbk.flight = 'flTAGO'
    dbk.localname = 'io_doneL'
    OA.addDataBlocks(G, nc, dbk)
    nextedt = 'ocrGuid_t nextEDT = NULL_GUID;'
    OA.addCustomText(G, nc, nextedt)
    nextedt = 'unsigned long index = 1;'
    OA.addCustomText(G, nc, nextedt)
    nextedt = 'err = ocrXIndexedEdtCreate(SumEDT, 0, NULL, 4, EDT_PROP_NONE, NULL_HINT, index, & io_workL->emap, &nextEDT, NULL); IFEB;'
    OA.addCustomText(G, nc, nextedt)
    guid_sumEDT = OA.makeGuidEdtname("SumEDT")
    guid_sumEDT_text = 'GUID_ASSIGN_VALUE(' + guid_sumEDT + ', nextEDT);'
    OA.addCustomText(G, nc, guid_sumEDT_text)

    nc += 1
    taskName = "RightEDT"
    OA.graphAddNode(G, nc, taskName)
    dbk = copy.deepcopy(dbk_workRight)
    dbk.flight = 'flTAGO'
    dbk.localname = 'io_workR'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_wdoneRight)
    dbk.flight = 'flTAGO'
    dbk.localname = 'io_doneR'
    OA.addDataBlocks(G, nc, dbk)
    nextedt = 'ocrGuid_t nextEDT = NULL_GUID;'
    OA.addCustomText(G, nc, nextedt)
    nextedt = 'unsigned long index = 1;'
    OA.addCustomText(G, nc, nextedt)
    nextedt = 'err = ocrXIndexedEdtCreate(SumEDT, 0, NULL, 4, EDT_PROP_NONE, NULL_HINT, index, & io_workR->emap, &nextEDT, NULL); IFEB;'
    OA.addCustomText(G, nc, nextedt)
    guid_sumEDT = OA.makeGuidEdtname("SumEDT")
    guid_sumEDT_text = 'GUID_ASSIGN_VALUE(' + guid_sumEDT + ', nextEDT);'
    OA.addCustomText(G, nc, guid_sumEDT_text)

    nc += 1
    taskName = "SumEDT"
    OA.graphAddNode(G, nc, taskName)
    dbk = copy.deepcopy(dbk_wdoneLeft)
    dbk.flight = 'flLANDING'
    dbk.localname = 'in_doneL'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_wdoneRight)
    dbk.flight = 'flLANDING'
    dbk.localname = 'in_doneR'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_workLeft)
    dbk.flight = 'flLANDING'
    dbk.localname = 'in_wleft'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_workRight)
    dbk.flight = 'flLANDING'
    dbk.localname = 'in_wright'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_nullGuid)
    dbk.flight = 'flTAKEOFF'
    OA.addDataBlocks(G, nc, dbk)

    sumText = 'int i, sum=0;'
    OA.addCustomText(G, nc, sumText)
    sumText = 'for(i=0; i<N; ++i) sum += in_wleft->x[i];'
    OA.addCustomText(G, nc, sumText)
    sumText = 'for(i=0; i<N; ++i) sum += in_wright->x[i];'
    OA.addCustomText(G, nc, sumText)
    sumText = 'PRINTF("TESTIO> sum = %d\\n", sum);'
    OA.addCustomText(G, nc, sumText)

    guid_finalEDT = OA.makeGuidEdtname('finalEDT')
    doneText = 'ocrGuid_t ' + guid_finalEDT + '; GUID_ASSIGN_VALUE(' + guid_finalEDT + ', *in_doneL);'
    OA.addCustomText(G, nc, doneText)

    # ----- EDGES
    ledg = OA.graphAddEdge(G, "mainEdt", "finalEDT", "edtMap")
    OA.getEvent(G, ledg).accessmode = 'DB_MODE_EW'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('edtMap')

    ledg = OA.graphAddEdge(G, "mainEdt", "LeftEDT", "WorkLeft")
    OA.getEvent(G, ledg).accessmode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('WorkLeft')
    ledg = OA.graphAddEdge(G, "mainEdt", "LeftEDT", "wDoneLeft")
    OA.getEvent(G, ledg).accessmode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('wDoneLeft')

    ledg = OA.graphAddEdge(G, "mainEdt", "RightEDT", "WorkRight")
    OA.getEvent(G, ledg).accessmode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('WorkRight')
    ledg = OA.graphAddEdge(G, "mainEdt", "RightEDT", "wDoneRight")
    OA.getEvent(G, ledg).accessmode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('wDoneRight')

    ledg = OA.graphAddEdge(G, "RightEDT", "SumEDT", "WorkRight")
    OA.getEvent(G, ledg).accessmode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('WorkRight')
    ledg = OA.graphAddEdge(G, "RightEDT", "SumEDT", "wDoneRight")
    OA.getEvent(G, ledg).accessmode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('wDoneRight')

    ledg = OA.graphAddEdge(G, "LeftEDT", "SumEDT", "WorkLeft")
    OA.getEvent(G, ledg).accessmode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('WorkLeft')
    ledg = OA.graphAddEdge(G, "LeftEDT", "SumEDT", "wDoneLeft")
    OA.getEvent(G, ledg).accessmode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('wDoneLeft')

    ledg = OA.graphAddEdge(G, "SumEDT", "finalEDT", "NULL_GUID")
    OA.getEvent(G, ledg).eflag = 'EVT_PROP_NONE'
    OA.getEvent(G, ledg).satisfy = 'NULL_GUID'
    OA.getEvent(G, ledg).fertile = False

    # ----- WORK
    erri = 0
    while not erri:
        if 1 == 2: OA.printGraph(G)  # Just to check if the inputs are ok.

        erri = OA.OCRanalysis(G)
        if erri: break

        if 1 == 2: OA.printGraph(G)
        if 1 == 1:
            erri = OA.outputDot(G, "z_utest_labeledt.dot")
            if erri: break
        if 1 == 1:
            erri = OA.outputOCR(G, "z_utest_labeledt.c")
            if erri: break

        if 1 == 2: OA.printGraph(G)

        break  # while not erri
    OA.errmsg(erri)
    return erri
Пример #2
0
def theMain():
    OA.GBL.insert_debug_code = 0
    G = OA.GraphTool.DiGraph()

    OA.setupGraph(G, "ptest_reductionEvent")
    OA.GBL.app_ocr_util_filename = 'app_ocr_util.h'

    OA.addHeader(G, '#define ENABLE_EXTENSION_LABELING')
    OA.addHeader(G, '#include "extensions/ocr-labeling.h"')
    OA.addHeader(G, ' ')  # Just a blank line

    OA.addHeader(G, '#include "ptest_FORforkjoin.h"')
    OA.addHeader(G, '#include "ptest_reductionEvent.h"')
    OA.addHeader(G, ' ')  # Just a blank line

    OA.addHeader(G, '#include "tailrecursion.h"')

    # ----- Data Blocks
    dbk = OA.ocrDataBlock()
    dbk.name = 'NULL_GUID'
    dbk_nullGuid = dbk
    dbk = OA.ocrDataBlock()
    dbk.name = 'gDone'
    dbk.count = 1
    dbk.type = 'ocrGuid_t'
    dbk_gDone = dbk
    dbk = OA.ocrDataBlock()
    dbk.name = 'gDoneROF'
    dbk.count = 1
    dbk.type = 'ocrGuid_t'
    dbk_gDoneROF = dbk
    dbk = OA.ocrDataBlock()
    dbk.name = 'gDoneTR'
    dbk.count = 1
    dbk.type = 'ocrGuid_t'
    dbk_gDoneTR = dbk
    dbk = OA.ocrDataBlock()
    dbk.name = 'ffjLedger'
    dbk.count = 1
    dbk.type = 'FFJ_Ledger_t'
    dbk_ffjLedger = dbk

    dbk = OA.ocrDataBlock()
    dbk.name = 'DRprivate'
    dbk.count = 1
    dbk.type = 'reductionPrivate_t'
    dbk_DRprivate = dbk
    dbk = OA.ocrDataBlock()
    dbk.name = 'SharedRef'
    dbk.count = 1
    dbk.type = 'DRshared_t'
    dbk_sharedRef = dbk
    dbk = OA.ocrDataBlock()
    dbk.name = 'Shared'
    dbk.count = 1
    dbk.type = 'DRshared_t'
    dbk_shared = dbk

    dbk = OA.ocrDataBlock()
    dbk.name = 'TailRecurIterate'
    dbk.count = 1
    dbk.type = 'TailRecurIterate_t'
    dbk_tailRecurIterate = dbk

    # ----- NODES
    nc = OA.GBL.MAINNODE
    taskName = "mainEdt"
    OA.graphAddNode(G, nc, taskName)
    dbk = copy.deepcopy(dbk_gDone)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_ffjGDone'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_sharedRef)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_sharedRef'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_shared)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_shared'
    OA.addDataBlocks(G, nc, dbk)
    guid_finalEDT = OA.makeGuidEdtname('finalEDT')
    DR_mainedt_txt = 'err = DRmainEdt_fcn(o_sharedRef, o_shared, COUNT_FOR_FORKJOIN); IFEB;'
    OA.addCustomText(G, nc, DR_mainedt_txt)
    mainedtTxt = 'err = ffjMainEdt_fcn(&' + guid_finalEDT + ', o_ffjGDone); IFEB;'
    OA.addCustomText(G, nc, mainedtTxt)

    nc = OA.GBL.FINALNODE
    taskName = "finalEDT"
    OA.graphAddNode(G, nc, taskName)
    dbk = copy.deepcopy(dbk_sharedRef)
    dbk.flight = 'flLANDING'
    dbk.localname = 'in_sharedRef'
    OA.addDataBlocks(G, nc, dbk)
    DR_finalEDT_txt = 'err = DRFinalEdt_fcn(in_sharedRef); IFEB;'
    OA.addCustomText(G, nc, DR_finalEDT_txt)
    finalEDT_txt = 'err = ffjFinalEdt_fcn(); IFEB;'
    OA.addCustomText(G, nc, finalEDT_txt)

    nc += 1
    taskName = "ffjSetup"
    OA.graphAddNode(G, nc, taskName)
    dbk = copy.deepcopy(dbk_ffjLedger)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_ffjLedger'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_gDoneROF)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_gDoneROF'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_shared)
    dbk.flight = 'flTAGO'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_gDone)
    dbk.flight = 'flTAGO'
    OA.addDataBlocks(G, nc, dbk)
    guid_ffjROF = OA.makeGuidEdtname('ffjROF')
    ffjSetup_txt = 'err = ffjSetup_fcn(COUNT_FOR_FORKJOIN, o_ffjLedger, &' + guid_ffjROF + ', o_gDoneROF); IFEB;'
    OA.addCustomText(G, nc, ffjSetup_txt)

    nc += 1
    taskName = "ffjFOR"
    OA.graphAddNode(G, nc, taskName)
    dbk = copy.deepcopy(dbk_ffjLedger)
    dbk.flight = 'flLANDING'
    dbk.localname = 'in_ffjLedger'
    dbk.delayReleaseDestroy = True
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_gDoneROF)
    dbk.flight = 'flLANDING'
    dbk.localname = 'in_gDoneROF'
    dbk.delayReleaseDestroy = True
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_shared)
    dbk.flight = 'flLANDING'
    dbk.localname = 'in_DRshared'
    dbk.delayReleaseDestroy = True
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_ffjLedger)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_ffjshared'
    dbk.hint = 'pHintDBK'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_gDoneROF)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_gDoneROF'
    dbk.hint = 'pHintDBK'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_shared)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_DRshared'
    dbk.hint = 'pHintDBK'
    OA.addDataBlocks(G, nc, dbk)
    fortext = 'int rank; for(rank=0; rank<in_ffjLedger->nrank; ++rank)'
    OA.addFORconditionText(G, nc, fortext)
    OA.addFORconditionText_startingclause(
        G, nc,
        'unsigned long pdID = calculate_pid(rank,in_ffjLedger->OCR_affinityCount,in_ffjLedger->nrank);'
    )
    OA.addFORconditionText_startingclause(
        G, nc, 'ocrHint_t hintEDT, *pHintEDT=0, hintDBK, *pHintDBK=0;')
    OA.addFORconditionText_startingclause(
        G, nc, 'err = ocrXgetEdtHint(pdID, &hintEDT, &pHintEDT); IFEB;')
    OA.addFORconditionText_startingclause(
        G, nc, 'err = ocrXgetDbkHint(pdID, &hintDBK, &pHintDBK); IFEB;')
    ffjFOR_txt = 'err = ffjFOR_fcn(rank, pdID, in_ffjLedger, o_ffjshared, in_gDoneROF, o_gDoneROF); IFEB;'
    OA.addCustomText(G, nc, ffjFOR_txt)
    DR_FOR_txt = 'err = copy_DRshared(in_DRshared, o_DRshared); IFEB;'
    OA.addCustomText(G, nc, DR_FOR_txt)

    nc += 1
    taskName = "ffjFOR_Transist_start"
    OA.graphAddNode(G, nc, taskName)
    OA.getMyTask(G, nc).hint = 'pHintEDT'
    dbk = copy.deepcopy(dbk_ffjLedger)
    dbk.flight = 'flTAGO'
    dbk.localname = 'io_ffjLedger'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_gDoneROF)
    dbk.flight = 'flTAGO'
    dbk.addLocalText('    ocrHint_t hintEDT, *pHintEDT=0;')
    dbk.addLocalText(
        '    err = ocrXgetEdtHint(FFJ_USE_CURRENT_PD, &hintEDT, &pHintEDT); IFEB;'
    )
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_shared)
    dbk.flight = 'flTAGO'
    dbk.localname = 'in_DRshared'
    OA.addDataBlocks(G, nc, dbk)
    ffjFOR_Transist_start = 'err = ffjFOR_Transist_start_fcn(io_ffjLedger); IFEB;'
    OA.addCustomText(G, nc, ffjFOR_Transist_start)

    nc += 1
    taskName = "DR_init"
    OA.graphAddNode(G, nc, taskName)
    OA.getMyTask(G, nc).hint = 'pHintEDT'
    dbk = copy.deepcopy(dbk_ffjLedger)
    dbk.flight = 'flTAGO'
    dbk.localname = 'io_ffjLedger'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_gDoneROF)
    dbk.flight = 'flTAGO'
    dbk.addLocalText('    ocrHint_t hintEDT, *pHintEDT=0;')
    dbk.addLocalText(
        '    err = ocrXgetEdtHint(FFJ_USE_CURRENT_PD, &hintEDT, &pHintEDT); IFEB;'
    )
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_shared)
    dbk.flight = 'flLANDING'
    dbk.localname = 'in_DRshared'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_DRprivate)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_DRprivate'
    OA.addDataBlocks(G, nc, dbk)
    DR_init = 'err = DRinit_fcn(io_ffjLedger, in_DRshared, o_DRprivate); IFEB;'
    OA.addCustomText(G, nc, DR_init)

    nc += 1
    taskName = "DR_reduxA_start"
    OA.graphAddNode(G, nc, taskName)
    OA.getMyTask(G, nc).hint = 'pHintEDT'
    dbk = copy.deepcopy(dbk_ffjLedger)
    dbk.flight = 'flTAGO'
    dbk.localname = 'io_ffjLedger'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_gDoneROF)
    dbk.flight = 'flTAGO'
    dbk.addLocalText('    ocrHint_t hintEDT, *pHintEDT=0;')
    dbk.addLocalText(
        '    err = ocrXgetEdtHint(FFJ_USE_CURRENT_PD, &hintEDT, &pHintEDT); IFEB;'
    )
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_DRprivate)
    dbk.flight = 'flTAGO'
    dbk.localname = 'io_DRprivate'
    dbk.localnameGuid = 'guid_DRprivate'
    dbk.user2destroyORrelease = True
    dbk.addLocalText(
        '//It is expected that the user will release the ReducPrivate data block.'
    )
    OA.addDataBlocks(G, nc, dbk)
    guid_DR_reduxA_stop = OA.makeGuidEdtname('DR_reduxA_stop')
    multi_txtA = 'const unsigned int multiplier = DR_MULTIPLIER_A;'
    OA.addCustomText(G, nc, multi_txtA)
    DR_reduxA_start = 'err = DR_reduxA_start_fcn(io_ffjLedger, multiplier, guid_DRprivate, io_DRprivate, SLOT4REDUCTION_A-1,' + guid_DR_reduxA_stop + '); IFEB;'
    OA.addCustomText(G, nc, DR_reduxA_start)

    nc += 1
    taskName = "DR_reduxA_stop"
    OA.graphAddNode(G, nc, taskName)
    OA.getMyTask(G, nc).hint = 'pHintEDT'
    OA.getMyTask(G, nc).depc = 'SLOT4REDUCTION_A'
    dbk = copy.deepcopy(dbk_ffjLedger)
    dbk.flight = 'flTAGO'
    dbk.localname = 'io_ffjLedger'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_gDoneROF)
    dbk.flight = 'flTAGO'
    dbk.addLocalText('    ocrHint_t hintEDT, *pHintEDT=0;')
    dbk.addLocalText(
        '    err = ocrXgetEdtHint(FFJ_USE_CURRENT_PD, &hintEDT, &pHintEDT); IFEB;'
    )
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_DRprivate)
    dbk.flight = 'flTAGO'
    dbk.localname = 'io_DRprivate'
    dbk.addLocalText(
        '    ocrEdtDep_t IN_BY_USER_depv_sum = depv[SLOT4REDUCTION_A-1];  //This will be LANDING here.'
    )
    dbk.addLocalText('    ocrGuid_t in_sum_guid = IN_BY_USER_depv_sum.guid;')
    dbk.addLocalText('    ReducSum_t * in_sum = IN_BY_USER_depv_sum.ptr;')
    OA.addDataBlocks(G, nc, dbk)
    DR_reduxA_stop = 'err = DR_reduxA_stop_fcn(DR_MULTIPLIER_A, io_ffjLedger, in_sum, in_sum_guid); IFEB;'
    OA.addCustomText(G, nc, DR_reduxA_stop)

    nc += 1
    taskName = "setupTailRecursion"
    OA.graphAddNode(G, nc, taskName)
    OA.getMyTask(G, nc).hint = 'pHintEDT'
    dbk = copy.deepcopy(dbk_ffjLedger)
    dbk.flight = 'flTAGO'
    dbk.localname = 'io_ffjLedger'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_gDoneROF)
    dbk.flight = 'flTAGO'
    dbk.addLocalText('    ocrHint_t hintEDT, *pHintEDT=0;')
    dbk.addLocalText(
        '    err = ocrXgetEdtHint(FFJ_USE_CURRENT_PD, &hintEDT, &pHintEDT); IFEB;'
    )
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_DRprivate)
    dbk.flight = 'flTAGO'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_gDoneTR)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_gDoneTR'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_tailRecurIterate)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_tailRecurIterate'
    OA.addDataBlocks(G, nc, dbk)
    guid_gDoneTR = OA.makeGuidEdtname('concludeTailRecursion')
    setupTR_gdone_txt = '*o_gDoneTR = ' + guid_gDoneTR + ';'
    OA.addCustomText(G, nc, setupTR_gdone_txt)
    tailRecurSetupt = 'err = tailRecurInitialize(io_ffjLedger->nb_iteration_for_recurB, o_tailRecurIterate, '
    tailRecurSetupt += OA.makeGuidEdtname("concludeTailRecursion") + '); IFEB;'
    OA.addCustomText(G, nc, tailRecurSetupt)

    nc += 1
    taskName = "tailRecursionIFThen"
    OA.graphAddNode(G, nc, taskName)
    OA.getMyTask(G, nc).hint = 'pHintEDT'
    dbk = copy.deepcopy(dbk_ffjLedger)
    dbk.flight = 'flTAGO'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_gDoneTR)
    dbk.flight = 'flTAGO'
    dbk.addLocalText('    ocrHint_t hintEDT, *pHintEDT=0;')
    dbk.addLocalText(
        '    err = ocrXgetEdtHint(FFJ_USE_CURRENT_PD, &hintEDT, &pHintEDT); IFEB;'
    )
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_DRprivate)
    dbk.flight = 'flTAGO'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_tailRecurIterate)
    dbk.flight = 'flTAGO'
    dbk.localname = 'io_tailRecurIterate'
    dbk.addLocalText('    ocrGuid_t ' +
                     OA.makeGuidEdtname("concludeTailRecursion") +
                     ' = io_tailRecurIterate->whereToGoWhenDone;')
    OA.addDataBlocks(
        G, nc, dbk
    )  # This DBK guid will be needed by the tailRecursionELSE part of this EDT.
    tailRecurCondition_text = 'tailRecurCondition(io_tailRecurIterate)'
    OA.addIFconditionText(G, nc, tailRecurCondition_text)
    tailRecurTHEN_text = 'err = tailRecurIfThenClause(io_tailRecurIterate); IFEB;'
    OA.addCustomText(G, nc, tailRecurTHEN_text)

    nc += 1
    taskName = "tailRecursionELSE"
    OA.graphAddNode(G, nc, taskName)
    # DBK local names are taken care off by the IF-THEN edt called "tailRecursionIFThen".
    # Hint taken care by its If-THEN counterpart.
    dbk = copy.deepcopy(dbk_ffjLedger)
    dbk.flight = 'flTAGO'
    dbk.localname = 'io_ffjLedger'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_gDoneTR)
    dbk.flight = 'flLANDING'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_DRprivate)
    dbk.flight = 'flLANDING'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_tailRecurIterate)
    dbk.flight = 'flLANDING'
    dbk.localname = 'io_tailRecurIterate'
    OA.addDataBlocks(G, nc, dbk)
    tailRecurELSE_text = 'err = tailRecurElseClause(io_tailRecurIterate); IFEB;'
    OA.addCustomText(G, nc, tailRecurELSE_text)

    nc += 1
    taskName = "DR_reduxB_start"
    OA.graphAddNode(G, nc, taskName)
    OA.getMyTask(G, nc).hint = 'pHintEDT'
    dbk = copy.deepcopy(dbk_tailRecurIterate)
    dbk.flight = 'flTAGO'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_ffjLedger)
    dbk.flight = 'flTAGO'
    dbk.localname = 'io_ffjLedger'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_gDoneTR)
    dbk.flight = 'flTAGO'
    dbk.addLocalText('    ocrHint_t hintEDT, *pHintEDT=0;')
    dbk.addLocalText(
        '    err = ocrXgetEdtHint(FFJ_USE_CURRENT_PD, &hintEDT, &pHintEDT); IFEB;'
    )
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_DRprivate)
    dbk.flight = 'flTAGO'
    dbk.localname = 'io_DRprivate'
    dbk.localnameGuid = 'guid_DRprivate'
    dbk.user2destroyORrelease = True
    dbk.addLocalText(
        '//It is expected that the user will release the ReducPrivate data block.'
    )
    OA.addDataBlocks(G, nc, dbk)
    guid_DR_reduxB_stop = OA.makeGuidEdtname('DR_reduxB_stop')
    multi_txtB = 'const unsigned int multiplier = DR_MULTIPLIER_B;'
    OA.addCustomText(G, nc, multi_txtB)
    DR_reduxB_start = 'err = DR_reduxB_start_fcn(io_ffjLedger, multiplier, guid_DRprivate, io_DRprivate, SLOT4REDUCTION_B-1,' + guid_DR_reduxB_stop + '); IFEB;'
    OA.addCustomText(G, nc, DR_reduxB_start)

    nc += 1
    taskName = "DR_reduxB_stop"
    OA.graphAddNode(G, nc, taskName)
    OA.getMyTask(G, nc).hint = 'pHintEDT'
    OA.getMyTask(G, nc).depc = 'SLOT4REDUCTION_B'
    dbk = copy.deepcopy(dbk_tailRecurIterate)
    dbk.flight = 'flTAGO'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_ffjLedger)
    dbk.flight = 'flTAGO'
    dbk.localname = 'io_ffjLedger'
    dbk.addLocalText('    ocrHint_t hintEDT, *pHintEDT=0;')
    dbk.addLocalText(
        '    err = ocrXgetEdtHint(FFJ_USE_CURRENT_PD, &hintEDT, &pHintEDT); IFEB;'
    )
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_gDoneTR)
    dbk.flight = 'flTAGO'
    dbk.localname = 'io_gDoneTR'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_DRprivate)
    dbk.flight = 'flTAGO'
    dbk.addLocalText(
        '    ocrEdtDep_t IN_BY_USER_depv_sum = depv[SLOT4REDUCTION_B-1];  //This will be LANDING here.'
    )
    dbk.addLocalText('    ocrGuid_t in_sum_guid = IN_BY_USER_depv_sum.guid;')
    dbk.addLocalText('    ReducSum_t * in_sum = IN_BY_USER_depv_sum.ptr;')
    OA.addDataBlocks(G, nc, dbk)
    DR_reduxB_stop = 'err = DR_reduxB_stop_fcn(DR_MULTIPLIER_B, io_ffjLedger, in_sum, in_sum_guid); IFEB;'
    OA.addCustomText(G, nc, DR_reduxB_stop)

    nc += 1
    taskName = "concludeTailRecursion"
    OA.graphAddNode(G, nc, taskName)
    OA.getMyTask(G, nc).hint = 'pHintEDT'
    dbk = copy.deepcopy(dbk_ffjLedger)
    dbk.flight = 'flTAGO'
    dbk.localname = 'io_ffjLedger'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_gDoneROF)
    dbk.flight = 'flTAGO'
    dbk.addLocalText('    ocrHint_t hintEDT, *pHintEDT=0;')
    dbk.addLocalText(
        '    err = ocrXgetEdtHint(FFJ_USE_CURRENT_PD, &hintEDT, &pHintEDT); IFEB;'
    )
    OA.addDataBlocks(G, nc, dbk)

    nc += 1
    taskName = "ffjFOR_Transist_stop"
    OA.graphAddNode(G, nc, taskName)
    OA.getMyTask(G, nc).hint = 'pHintEDT'
    dbk = copy.deepcopy(dbk_ffjLedger)
    dbk.flight = 'flLANDING'
    dbk.localname = 'in_ffjLedger'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_gDoneROF)
    dbk.flight = 'flLANDING'
    dbk.localname = 'in_gDoneROF'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_nullGuid)
    dbk.flight = 'flTAKEOFF'
    OA.addDataBlocks(G, nc, dbk)
    gdoneROF_txt = 'ocrGuid_t ' + OA.makeGuidEdtname(
        'ffjROF') + ' = *in_gDoneROF;'
    OA.addCustomText(G, nc, gdoneROF_txt)
    ROF_which_slot = 'unsigned int slot_for_ROF = in_ffjLedger->rankid +1; //+1 to accommodate the in_gDone sent from ffjSetup'
    OA.addCustomText(G, nc, ROF_which_slot)
    ffjFOR_Transist_stop = 'err = ffjFOR_Transist_stop_fcn(in_ffjLedger); IFEB;'
    OA.addCustomText(G, nc, ffjFOR_Transist_stop)
    DR_Transist_timings = 'print_DR_Ledger_timings(in_ffjLedger);'
    OA.addCustomText(G, nc, DR_Transist_timings)

    nc += 1
    taskName = "ffjROF"
    OA.graphAddNode(G, nc, taskName)
    OA.getMyTask(G, nc).depc = '(1+COUNT_FOR_FORKJOIN)'
    dbk = copy.deepcopy(dbk_gDone)
    dbk.flight = 'flLANDING'
    dbk.localname = 'in_gDone'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_nullGuid)
    dbk.flight = 'flTAKEOFF'
    OA.addDataBlocks(G, nc, dbk)
    gdone_txt = 'ocrGuid_t ' + OA.makeGuidEdtname('finalEDT') + ' = *in_gDone;'
    OA.addCustomText(G, nc, gdone_txt)
    ffjROF = 'err = ffjROF_fcn(); IFEB;'
    OA.addCustomText(G, nc, ffjROF)

    # ----- EDGES
    ledg = OA.graphAddEdge(G, "mainEdt", "finalEDT", "SharedRef")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RW'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('SharedRef')
    ledg = OA.graphAddEdge(G, "mainEdt", "ffjSetup", "gDone")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('gDone')
    ledg = OA.graphAddEdge(G, "mainEdt", "ffjSetup", "Shared")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('Shared')

    ledg = OA.graphAddEdge(G, "ffjSetup", "ffjROF", "gDone")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('gDone')
    ledg = OA.graphAddEdge(G, "ffjSetup", "ffjFOR", "gDoneROF")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('gDoneROF')
    ledg = OA.graphAddEdge(G, "ffjSetup", "ffjFOR", "ffjLedger")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('ffjLedger')
    ledg = OA.graphAddEdge(G, "ffjSetup", "ffjFOR", "Shared")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('ffjLedger')

    ledg = OA.graphAddEdge(G, "ffjFOR", "ffjFOR_Transist_start", "gDoneROF")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('gDoneROF')
    ledg = OA.graphAddEdge(G, "ffjFOR", "ffjFOR_Transist_start", "ffjLedger")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RW'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('ffjLedger')
    ledg = OA.graphAddEdge(G, "ffjFOR", "ffjFOR_Transist_start", "Shared")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RW'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('Shared')

    ledg = OA.graphAddEdge(G, "ffjFOR_Transist_start", "DR_init", "gDoneROF")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('gDoneROF')
    ledg = OA.graphAddEdge(G, "ffjFOR_Transist_start", "DR_init", "ffjLedger")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RW'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('ffjLedger')
    ledg = OA.graphAddEdge(G, "ffjFOR_Transist_start", "DR_init", "Shared")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RW'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('Shared')

    ledg = OA.graphAddEdge(G, "DR_init", "DR_reduxA_start", "gDoneROF")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('gDoneROF')
    ledg = OA.graphAddEdge(G, "DR_init", "DR_reduxA_start", "ffjLedger")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RW'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('ffjLedger')
    ledg = OA.graphAddEdge(G, "DR_init", "DR_reduxA_start", "DRprivate")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RW'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('DRprivate')

    ledg = OA.graphAddEdge(G, "DR_reduxA_start", "DR_reduxA_stop", "gDoneROF")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('gDoneROF')
    ledg = OA.graphAddEdge(G, "DR_reduxA_start", "DR_reduxA_stop", "ffjLedger")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RW'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('ffjLedger')
    ledg = OA.graphAddEdge(G, "DR_reduxA_start", "DR_reduxA_stop", "DRprivate")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RW'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('DRprivate')

    ledg = OA.graphAddEdge(G, "DR_reduxA_stop", "setupTailRecursion",
                           "gDoneROF")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('gDoneROF')
    ledg = OA.graphAddEdge(G, "DR_reduxA_stop", "setupTailRecursion",
                           "ffjLedger")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('ffjLedger')
    ledg = OA.graphAddEdge(G, "DR_reduxA_stop", "setupTailRecursion",
                           "DRprivate")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('DRprivate')

    ledg = OA.graphAddEdge(G, "setupTailRecursion", "concludeTailRecursion",
                           "gDoneROF")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('gDoneROF')
    ledg = OA.graphAddEdge(G, "setupTailRecursion", "tailRecursionIFThen",
                           "gDoneTR")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('gDoneTR')
    tailRecur_gDoneTR_edge = ledg[0]
    ledg = OA.graphAddEdge(G, "setupTailRecursion", "tailRecursionIFThen",
                           "ffjLedger")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RW'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('ffjLedger')
    tailRecur_ffjLedger_edge = ledg[0]
    ledg = OA.graphAddEdge(G, "setupTailRecursion", "tailRecursionIFThen",
                           "DRprivate")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RW'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('DRprivate')
    tailRecur_DRprivate_edge = ledg[0]
    ledg = OA.graphAddEdge(G, "setupTailRecursion", "tailRecursionIFThen",
                           "TailRecurIterate")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RW'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('TailRecurIterate')
    tailRecur_TRiterate_edge = ledg[0]

    ledg = OA.graphAddEdge(G, "tailRecursionIFThen", "DR_reduxB_start",
                           "gDoneTR")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('gDoneROF')
    ledg = OA.graphAddEdge(G, "tailRecursionIFThen", "DR_reduxB_start",
                           "ffjLedger")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RW'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('ffjLedger')
    ledg = OA.graphAddEdge(G, "tailRecursionIFThen", "DR_reduxB_start",
                           "DRprivate")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RW'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('DRprivate')
    ledg = OA.graphAddEdge(G, "tailRecursionIFThen", "DR_reduxB_start",
                           "TailRecurIterate")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('TailRecurIterate')

    ledg = OA.graphAddEdge(G, "DR_reduxB_start", "DR_reduxB_stop", "gDoneTR")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('gDoneROF')
    ledg = OA.graphAddEdge(G, "DR_reduxB_start", "DR_reduxB_stop", "ffjLedger")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RW'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('ffjLedger')
    ledg = OA.graphAddEdge(G, "DR_reduxB_start", "DR_reduxB_stop", "DRprivate")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RW'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('DRprivate')
    ledg = OA.graphAddEdge(G, "DR_reduxB_start", "DR_reduxB_stop",
                           "TailRecurIterate")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('TailRecurIterate')

    ledg = OA.graphAddEdge(G, "DR_reduxB_stop", "tailRecursionIFThen",
                           "gDoneTR")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('gDoneTR')
    OA.sharedConx(G, ledg[0]).append(tailRecur_gDoneTR_edge)
    ledg = OA.graphAddEdge(G, "DR_reduxB_stop", "tailRecursionIFThen",
                           "ffjLedger")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RW'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('ffjLedger')
    OA.sharedConx(G, ledg[0]).append(tailRecur_ffjLedger_edge)
    ledg = OA.graphAddEdge(G, "DR_reduxB_stop", "tailRecursionIFThen",
                           "DRprivate")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RW'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('DRprivate')
    OA.sharedConx(G, ledg[0]).append(tailRecur_DRprivate_edge)
    ledg = OA.graphAddEdge(G, "DR_reduxB_stop", "tailRecursionIFThen",
                           "TailRecurIterate")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RW'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('TailRecurIterate')
    OA.sharedConx(G, ledg[0]).append(tailRecur_TRiterate_edge)

    ledg = OA.graphAddEdge(G, "tailRecursionIFThen", "tailRecursionELSE",
                           "NULL_GUID")
    OA.getEdge(G, ledg[0])["leads_to_ElseClause"] = True

    ledg = OA.graphAddEdge(G, "tailRecursionELSE", "concludeTailRecursion",
                           "ffjLedger")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RW'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('ffjLedger')
    OA.getEvent(G, ledg).fertile = False

    ledg = OA.graphAddEdge(G, "concludeTailRecursion", "ffjFOR_Transist_stop",
                           "gDoneROF")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('gDoneROF')
    ledg = OA.graphAddEdge(G, "concludeTailRecursion", "ffjFOR_Transist_stop",
                           "ffjLedger")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RW'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('ffjLedger')

    ledg = OA.graphAddEdge(G, "ffjFOR_Transist_stop", "ffjROF", "NULL_GUID")
    OA.getEvent(G, ledg).eflag = 'EVT_PROP_NONE'
    OA.getEvent(G, ledg).satisfy = 'NULL_GUID'
    OA.getEvent(G, ledg).fertile = False
    OA.getEvent(G, ledg).user_slotnb_text = 'slot_for_ROF'

    ledg = OA.graphAddEdge(G, "ffjROF", "finalEDT", "NULL_GUID")
    OA.getEvent(G, ledg).eflag = 'EVT_PROP_NONE'
    OA.getEvent(G, ledg).satisfy = 'NULL_GUID'
    OA.getEvent(G, ledg).fertile = False

    # ----- WORK
    erri = 0
    while not erri:
        if True: OA.printGraph(G)  # Just to check if the inputs are ok.

        erri = OA.OCRanalysis(G)
        if erri: break

        if False: OA.printGraph(G)
        if True:
            erri = OA.outputDot(G, "z_ptest_reductionEvent.dot")
            if erri: break
        if True:
            erri = OA.outputOCR(G, "z_ptest_reductionEvent.c")
            if erri: break

        if False: OA.printGraph(G)

        break  # while not erri
    OA.errmsg(erri)
    return erri
Пример #3
0
def theMain():

    OA.GBL.insert_debug_code = 0

    G=OA.GraphTool.DiGraph()

    OA.setupGraph(G,"BinTree_ForkJoin")

    OA.addHeader(G, '#include "bintreeForkjoin.h" ')  # This will be put at the beginning of the file
    OA.addHeader(G, '#include "global_data.h"')
    OA.addHeader(G, '#include "reduction2ary.h"')
    OA.addHeader(G, ' ')  # Just a blank line
    OA.addHeader(G, '#define ENABLE_EXTENSION_LABELING  // For labeled EDTs')
    OA.addHeader(G, '#include "extensions/ocr-labeling.h"  // For labeled EDTs')
    OA.addHeader(G, ' ')  # Just a blank line
    OA.addHeader(G, '#define Nfoliation 2 // This is used by the bintreeForkJoin')
    OA.addHeader(G, '#define reductNaryFoliation 2 // This is used by the reductionBy2ary')

    # ----- Data Blocks
    dbk = OA.ocrDataBlock();  dbk.name = 'NULL_GUID'
    dbk_nullGuid = dbk

    dbk = OA.ocrDataBlock();  dbk.name = 'gDone';   dbk.count=1;     dbk.type='ocrGuid_t'
    dbk_gDone = dbk

    dbk = OA.ocrDataBlock();  dbk.name = 'TFJiterate';   dbk.count=1;     dbk.type='TFJiterate_t'
    dbk_iterate = dbk
    dbk = OA.ocrDataBlock();  dbk.name = 'TFJiterate2';   dbk.count=1;     dbk.type='TFJiterate_t'
    dbk_iterate2 = dbk

    dbk = OA.ocrDataBlock();  dbk.name = 'Work';   dbk.count=1;     dbk.type='Work_t'
    dbk_work = dbk
    dbk = OA.ocrDataBlock();  dbk.name = 'Work2';   dbk.count=1;     dbk.type='Work_t'
    dbk_work2 = dbk

    dbk = OA.ocrDataBlock();  dbk.name = 'RefWork';   dbk.count=1;     dbk.type='Work_t'
    dbk_refwork = dbk

    # 'GlobalsRef' is the one we will properly destroy and release its ressources
    # 'Globals' is the one we will move around and clear when done.
    dbk = OA.ocrDataBlock();  dbk.name = 'Globals';   dbk.count=1;     dbk.type='GlobalData_t'
    dbk_globals = dbk
    dbk = OA.ocrDataBlock();  dbk.name = 'GlobalsRef';   dbk.count=1;     dbk.type='GlobalData_t'
    dbk_globalsRef = dbk

    dbk = OA.ocrDataBlock();  dbk.name = 'LedgerR2ary';   dbk.count=1;     dbk.type='LedgerReduc2ary_t'
    dbk_ledgerR2ary = dbk
    dbk = OA.ocrDataBlock();  dbk.name = 'LedgerR2ary2';  dbk.count=1;     dbk.type='LedgerReduc2ary_t'
    dbk_ledgerR2ary2 = dbk

    dbk = OA.ocrDataBlock();  dbk.name = 'R2aryValue';   dbk.count=1;     dbk.type='R2aryValue_t'
    dbk_valueR2ary = dbk

    dbk = OA.ocrDataBlock();  dbk.name = 'R2aryWhenDone';   dbk.count=1;     dbk.type='R2aryWhenDone_t'
    dbk_whenDoneR2ary = dbk

    # =========================================================================
    # =========================================================================
    # =========================================================================
    # =========================================================================
    # =========================================================================
    # ----- NODES -- Fork-Join Tree
    # NOTE: In as much as doable, the EDT are presented in a bracketing fashion.
    #       That is, assuming we have a sequence of EDTs as follows A->B->C->D->E
    #       Then the EDTs are presented as follows:  A,E,B,D,C
    #       For a linear sequence, that is of little importance; but for a more complex graph, bracketing
    #       makes it clear what are the EDTs acting as inputs and outputs.
    #
    # Always root the starting/root/main EDT at ID=0 = OA.GBL.MAINNODE
    # Always cap all ending EDT by the FinalEDT at ID=1 = OA.GBL.FINALNODE

    nc = OA.GBL.MAINNODE;    taskName = "mainEdt"; OA.graphAddNode(G,nc,taskName)
    dbk = copy.deepcopy(dbk_nullGuid); dbk.flight = 'flTAKEOFF'; OA.addDataBlocks(G, nc, dbk)   # To FinalEDT
    dbk = copy.deepcopy(dbk_gDone);    dbk.flight = 'flTAKEOFF'; dbk.localname='o_gDone'; OA.addDataBlocks(G, nc, dbk)   # To SetupBtForkJoin
    dbk = copy.deepcopy(dbk_globals);  dbk.flight = 'flTAKEOFF'; dbk.localname='o_globals'; OA.addDataBlocks(G, nc, dbk)
    toFinalt = 'GUID_ASSIGN_VALUE(*o_gDone, ' + OA.makeGuidEdtname("finalEDT") + ');'
    OA.addCustomText(G, nc, toFinalt)
    initGlobals_text = 'create_globalData(OA_DEBUG_OUTVARS, o_globals);'; OA.addCustomText(G, nc, initGlobals_text)

    nc = OA.GBL.FINALNODE;   taskName="finalEDT"; OA.graphAddNode(G,nc,taskName)
    dbk = copy.deepcopy(dbk_nullGuid); dbk.flight = 'flLANDING'; OA.addDataBlocks(G, nc, dbk)  # From ConcludeBtForkJoin
    dbk = copy.deepcopy(dbk_nullGuid); dbk.flight = 'flLANDING'; OA.addDataBlocks(G, nc, dbk)  # From mainEdt

    nc += 1;  taskName="SetupBtForkJoin"; OA.graphAddNode(G,nc,taskName)
    dbk = copy.deepcopy(dbk_gDone);   dbk.flight = 'flTAGO'; OA.addDataBlocks(G, nc, dbk)  # Toward ConcludeBtForkJoin
    dbk = copy.deepcopy(dbk_globals); dbk.flight = 'flTAGO'; dbk.localname='io_globals'; OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_globalsRef); dbk.flight = 'flTAKEOFF'; dbk.localname='o_refGlobals'; OA.addDataBlocks(G, nc, dbk) # To ConcludeBtForkJoin
    dbk = copy.deepcopy(dbk_refwork); dbk.flight = 'flTAKEOFF'; dbk.localname='o_refWork'; OA.addDataBlocks(G, nc, dbk) # To ConcludeBtForkJoin
    dbk = copy.deepcopy(dbk_iterate); dbk.flight = 'flTAKEOFF'; dbk.localname='o_iterate'; OA.addDataBlocks(G, nc, dbk) # To BtForkIF
    setupt = 'err = setupBtForkJoin(OA_DEBUG_OUTVARS, o_iterate, '
    setupt += OA.makeGuidEdtname("ConcludeBtForkJoin") + ', add, add_zero, io_globals, &o_refWork->result);'
    OA.addCustomText(G, nc, setupt)
    transferGlobal_text = 'copy_globalData(OA_DEBUG_OUTVARS, io_globals, o_refGlobals);'
    OA.addCustomText(G, nc, transferGlobal_text)

    nc += 1;  taskName="ConcludeBtForkJoin"; OA.graphAddNode(G,nc,taskName)
    dbk = copy.deepcopy(dbk_nullGuid); dbk.flight = 'flTAKEOFF'; OA.addDataBlocks(G, nc, dbk)  # To finalEDT
    dbk = copy.deepcopy(dbk_gDone);   dbk.flight = 'flLANDING'; dbk.localname = 'in_gDone'; OA.addDataBlocks(G, nc, dbk)  # From SetupBtForkJoin
    dbk = copy.deepcopy(dbk_refwork); dbk.flight = 'flLANDING'; dbk.localname = 'in_refwork'; OA.addDataBlocks(G, nc, dbk) # From SetupBtForkJoin
    dbk = copy.deepcopy(dbk_globalsRef); dbk.flight = 'flLANDING'; dbk.localname = 'in_refGlobals'; OA.addDataBlocks(G, nc, dbk) # From SetupBtForkJoin
    dbk = copy.deepcopy(dbk_work);    dbk.flight = 'flLANDING'; dbk.localname = 'in_calculated'; OA.addDataBlocks(G, nc, dbk) # From BtJoinELSE
    guid_finalEDT = OA.makeGuidEdtname('finalEDT')
    doneText = 'ocrGuid_t ' + guid_finalEDT + '; GUID_ASSIGN_VALUE(' + guid_finalEDT + ', *in_gDone);'
    OA.addCustomText(G, nc, doneText)
    OA.addCustomText(G, nc, 'err = concludeBtForkJoin(OA_DEBUG_OUTVARS, in_refwork->result, in_calculated->result); IFEB;')
    GlobalDone_text = 'err = destroy_globalData(OA_DEBUG_OUTVARS, in_refGlobals); IFEB;'
    OA.addCustomText(G, nc, GlobalDone_text)

    nc += 1;  taskName="BtForkIF"; OA.graphAddNode(G,nc,taskName)
    dbk = copy.deepcopy(dbk_globals); dbk.flight = 'flLANDING'; dbk.localname = 'in_globals'; OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_globals); dbk.flight = 'flTAKEOFF'; dbk.localname = 'o_globals'; OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_iterate); dbk.flight = 'flLANDING'; dbk.localname = 'in_iterate'; OA.addDataBlocks(G, nc, dbk) # From SetupBtForkJoin or BtForkFOR
    dbk = copy.deepcopy(dbk_iterate); dbk.flight = 'flTAKEOFF'; dbk.localname = 'o_iterate'; OA.addDataBlocks(G, nc, dbk) # To BtForkFOR or BtForkELSE
    dbk = copy.deepcopy(dbk_gDone);   dbk.flight = 'flTAKEOFF'; dbk.localname = 'o_gDone'; OA.addDataBlocks(G, nc, dbk)    # To BtJoinIFTHEN
    #dbk = copy.deepcopy(dbk_nullGuid); dbk.flight = 'flTAKEOFF';  <-- This is the NULL_GUID used to link to the ELSE clause
    OA.addIFconditionText(G, nc, 'conditionBtFork(OA_DEBUG_OUTVARS, in_iterate)')
    iterText = 'err = btForkThen(OA_DEBUG_OUTVARS, in_iterate, ' + OA.makeGuidEdtname("BtJoinIFTHEN") +', o_iterate, o_gDone);'
    OA.addCustomText(G, nc, iterText)
    copy_globals_text = 'copy_globalData(OA_DEBUG_OUTVARS, in_globals, o_globals);'
    OA.addCustomText(G, nc, copy_globals_text)

    nc += 1;  taskName="BtForkFOR"; OA.graphAddNode(G,nc,taskName)
    dbk = copy.deepcopy(dbk_iterate); dbk.flight = 'flLANDING'; dbk.localname = 'in_iterate'; dbk.delayReleaseDestroy = True
    OA.addDataBlocks(G, nc, dbk)  # From SetupBtForkJoin or self
    dbk = copy.deepcopy(dbk_iterate); dbk.flight = 'flTAKEOFF'; dbk.localname = 'o_iterate'; OA.addDataBlocks(G, nc, dbk)  # To self
    dbk = copy.deepcopy(dbk_globals); dbk.flight = 'flLANDING'; dbk.localname = 'in_globals'; dbk.delayReleaseDestroy = True
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_globals); dbk.flight = 'flTAKEOFF'; dbk.localname = 'o_globals'; OA.addDataBlocks(G, nc, dbk)
    fortext = 'int btFoliationIndex; for(btFoliationIndex=0; btFoliationIndex<Nfoliation; ++btFoliationIndex)'
    OA.addFORconditionText(G, nc, fortext)
    forkFORt = 'err = btForkFOR(OA_DEBUG_OUTVARS, btFoliationIndex, in_iterate, o_iterate);'
    OA.addCustomText(G, nc, forkFORt)
    copy_globals_text = 'copy_globalData(OA_DEBUG_OUTVARS, in_globals, o_globals);'
    OA.addCustomText(G, nc, copy_globals_text)

    nc += 1;  taskName="BtForkELSE"; OA.graphAddNode(G,nc,taskName)
    # DBK local names are taken care off by the IF-THEN edt called "btFork".
    dbk = copy.deepcopy(dbk_iterate); dbk.flight = 'flLANDING'; dbk.localname = 'in_iterate'; OA.addDataBlocks(G,nc,dbk)
    dbk = copy.deepcopy(dbk_iterate); dbk.flight = 'flTAKEOFF'; dbk.localname = 'o_iterate';  OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_globals); dbk.flight = 'flLANDING'; dbk.localname = 'in_globals'; OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_globals); dbk.flight = 'flTAKEOFF'; dbk.localname = 'o_globals'; OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_gDone);   dbk.flight = 'flTAKEOFF'; dbk.localname = 'o_gDone'; OA.addDataBlocks(G, nc, dbk)
    btForkElseText = 'err = btForkElse(OA_DEBUG_OUTVARS, in_iterate, '
    btForkElseText += OA.makeGuidEdtname("BtJoinIFTHEN") +', o_iterate, o_gDone);'
    OA.addCustomText(G, nc, btForkElseText)
    copy_globals_text = 'copy_globalData(OA_DEBUG_OUTVARS, in_globals, o_globals);'
    OA.addCustomText(G, nc, copy_globals_text)

    nc += 1;  taskName="BtForkTransition_Start"; OA.graphAddNode(G,nc,taskName)
    dbk = copy.deepcopy(dbk_iterate); dbk.flight = 'flTAGO'; dbk.localname = 'io_FJiterate'; OA.addDataBlocks(G,nc,dbk)
    dbk = copy.deepcopy(dbk_globals); dbk.flight = 'flTAGO'; dbk.localname = 'io_globals'; OA.addDataBlocks(G, nc, dbk)

    dbk = copy.deepcopy(dbk_ledgerR2ary);  dbk.flight = 'flTAKEOFF'; dbk.localname = 'o_ledgerR2ary'; OA.addDataBlocks(G, nc, dbk)
    btForkTransitStart_text = 'err = btForkTransitStart(OA_DEBUG_OUTVARS, io_FJiterate, io_globals,'
    btForkTransitStart_text += '&' + OA.makeGuidEdtname("BtForkTransition_Stop")
    btForkTransitStart_text += ', o_ledgerR2ary); IFEB;'
    OA.addCustomText(G, nc, btForkTransitStart_text)

    nc += 1;  taskName="BtForkTransition_Stop"; OA.graphAddNode(G,nc,taskName)
    dbk = copy.deepcopy(dbk_iterate);  dbk.flight = 'flLANDING'; dbk.localname = 'in_iterate'; OA.addDataBlocks(G,nc,dbk)  # From BtForkELSE
    dbk = copy.deepcopy(dbk_globals); dbk.flight = 'flLANDING'; dbk.localname = 'in_globals'; OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_work2); dbk.flight = 'flTAKEOFF'; dbk.localname = 'o_work2'; OA.addDataBlocks(G, nc, dbk)  # To BtJoinIFTHEN
    dbk = copy.deepcopy(dbk_work);  dbk.flight = 'flTAKEOFF'; dbk.localname = 'o_work'; OA.addDataBlocks(G, nc, dbk)  # To BtJoinIFTHEN

    dbk = copy.deepcopy(dbk_valueR2ary);  dbk.flight = 'flLANDING'; dbk.localname = 'in_valueR2ary'; OA.addDataBlocks(G,nc,dbk)

    guid_BtJoinIFTHEN = OA.makeGuidEdtname('BtJoinIFTHEN')
    transit_whereToText = 'ocrGuid_t ' + guid_BtJoinIFTHEN + '; GUID_ASSIGN_VALUE(' + guid_BtJoinIFTHEN + ', in_iterate->whereToGoWhenFalse);'
    OA.addCustomText(G, nc, transit_whereToText)

    transitText = 'err = transitionBTFork(OA_DEBUG_OUTVARS, in_iterate, o_work, o_work2); IFEB;'
    OA.addCustomText(G, nc, transitText)

    check_valueR2ary_text = 'err = R2ary_ValidateValue_in_btForkTransit_stop(OA_DEBUG_OUTVARS, in_globals, in_valueR2ary, in_iterate);'
    OA.addCustomText(G, nc, check_valueR2ary_text)

    clearGlobals_text = 'err = clear_globalData(OA_DEBUG_OUTVARS, in_globals); IFEB; //The destroy_globalData() has to be done globally.'
    OA.addCustomText(G, nc, clearGlobals_text)

    nc += 1;  taskName="BtJoinIFTHEN"; OA.graphAddNode(G,nc,taskName)
    dbk = copy.deepcopy(dbk_gDone); dbk.flight = 'flLANDING'; dbk.localname = 'in_gDone'; OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_work);  dbk.flight = 'flLANDING'; dbk.localname = 'in_workLeft'; OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_work2); dbk.flight = 'flLANDING'; dbk.localname = 'in_workRight'; OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_work);  dbk.flight = 'flTAKEOFF'; dbk.localname = 'o_work'; OA.addDataBlocks(G, nc, dbk)
    # dbk = copy.deepcopy(dbk_nullGuid); dbk.flight = 'flTAKEOFF';  <-- This is the NULL_GUID used to link to the ELSE clause
    OA.addIFconditionText(G, nc, 'NOTA_BTindex != get_parent_index(in_workLeft->btindex)')
    joinIFTHEN_Text = 'err = joinOperationIFTHEN(OA_edtTypeNb, OA_DBG_thisEDT, *in_workLeft, *in_workRight, o_work);'
    OA.addCustomText(G, nc, joinIFTHEN_Text)
    guid_BtJoinIFTHEN = OA.makeGuidEdtname("BtJoinIFTHEN")
    btJoinIF_whereToGo = 'ocrGuid_t ' + guid_BtJoinIFTHEN + '; GUID_ASSIGN_VALUE(' + guid_BtJoinIFTHEN + ', *in_gDone);'
    OA.addCustomText(G, nc, btJoinIF_whereToGo)
    btJoin_which_slot = 'unsigned int slot_for_work = btCalculateJoinIndex(in_workLeft->btindex);'
    OA.addCustomText(G, nc, btJoin_which_slot)

    nc += 1;  taskName="BtJoinELSE"; OA.graphAddNode(G,nc,taskName)
    dbk = copy.deepcopy(dbk_gDone); dbk.flight = 'flLANDING'; dbk.localname = 'in_gDone'; OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_work);  dbk.flight = 'flLANDING'; dbk.localname = 'in_workLeft'; OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_work2); dbk.flight = 'flLANDING'; dbk.localname = 'in_workRight'; OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_work);  dbk.flight = 'flTAKEOFF'; dbk.localname = 'o_work'; OA.addDataBlocks(G, nc, dbk)
    joinText = 'err = joinOperationELSE(OA_edtTypeNb, OA_DBG_thisEDT, *in_workLeft, *in_workRight, o_work);'
    OA.addCustomText(G, nc, joinText)
    g_ConcludeBtForkJoin = OA.makeGuidEdtname("ConcludeBtForkJoin")
    btJoinELSE_whereToGo = 'ocrGuid_t ' + g_ConcludeBtForkJoin + '; GUID_ASSIGN_VALUE(' + g_ConcludeBtForkJoin + ', *in_gDone);'
    OA.addCustomText(G, nc, btJoinELSE_whereToGo)

    # ----- NODES -- Reduction2ary
    nc += 1;  taskName="R2arySetup"; OA.graphAddNode(G,nc,taskName)
    dbk = copy.deepcopy(dbk_ledgerR2ary);  dbk.flight = 'flLANDING'; dbk.localname = 'in_ledgerR2ary'; OA.addDataBlocks(G, nc, dbk) # From BtForkTransition_Start
    dbk = copy.deepcopy(dbk_ledgerR2ary2); dbk.flight = 'flTAKEOFF'; dbk.localname = 'o_ledgerR2ary'; OA.addDataBlocks(G, nc, dbk) # To R2aryJoinIF
    dbk = copy.deepcopy(dbk_whenDoneR2ary);dbk.flight = 'flTAKEOFF'; dbk.localname = 'o_r2aWdone'; OA.addDataBlocks(G, nc, dbk) # To R2aryConclusion
    guid0_R2aryJoinIF_text = OA.makeGuidEdtname('R2aryJoinIF')
    text_R2ary_nextEDT = 'ocrGuid_t ' + guid0_R2aryJoinIF_text + ';';  OA.addCustomText(G, nc, text_R2ary_nextEDT)

    guid_R2aryConclusion_text = OA.makeGuidEdtname("R2aryConclusion")
    text_R2ary_dslot_to_use = 'unsigned int ra2ary_ledgerSlot2use;'; OA.addCustomText(G, nc, text_R2ary_dslot_to_use)
    text_for_R2arySetup = 'err = setup_reduction2ary(OA_DEBUG_OUTVARS, o_ledgerR2ary, o_r2aWdone, in_ledgerR2ary, &'
    text_for_R2arySetup += guid_R2aryConclusion_text + ', R2aryJoinIF, &'
    text_for_R2arySetup += guid0_R2aryJoinIF_text + ', &ra2ary_ledgerSlot2use); IFEB;'
    OA.addCustomText(G, nc, text_for_R2arySetup)

    nc += 1;  taskName="R2aryConclusion"; OA.graphAddNode(G,nc,taskName)
    dbk = copy.deepcopy(dbk_valueR2ary); dbk.flight = 'flLANDING'; dbk.localname = 'in_value'; OA.addDataBlocks(G, nc, dbk)  # From R2aryForkELSE_FOR
    dbk = copy.deepcopy(dbk_whenDoneR2ary); dbk.flight = 'flLANDING'; dbk.localname = 'in_r2aWdone'; OA.addDataBlocks(G, nc, dbk) # From R2arySetup
    dbk = copy.deepcopy(dbk_valueR2ary); dbk.flight = 'flTAKEOFF'; dbk.localname = "o_value"; OA.addDataBlocks(G, nc, dbk)  # To BtForkTransition_Stop
    initValue_reductBy2ary_text = 'init_R2aryValue(o_value);'; OA.addCustomText(G, nc, initValue_reductBy2ary_text)
    copyValue_r2aryConclude_text = 'copy_R2aryValue(in_value, o_value);'; OA.addCustomText(G, nc, copyValue_r2aryConclude_text)
    guid_BtForkTransition_Stop = OA.makeGuidEdtname("BtForkTransition_Stop")
    R2aryConclusion_whereToGo = 'ocrGuid_t ' + guid_BtForkTransition_Stop
    R2aryConclusion_whereToGo += '; GUID_ASSIGN_VALUE(' + guid_BtForkTransition_Stop + ', in_r2aWdone->wdone[0]);'
    OA.addCustomText(G, nc, R2aryConclusion_whereToGo)

    nc += 1;  taskName="R2aryJoinIF"; OA.graphAddNode(G,nc,taskName)
    dbk = copy.deepcopy(dbk_ledgerR2ary2); dbk.flight = 'flLANDING'; dbk.localname = 'in_ledgerR2ary2'; OA.addDataBlocks(G, nc, dbk)  # From R2arySetup
    dbk = copy.deepcopy(dbk_ledgerR2ary);  dbk.flight = 'flLANDING'; dbk.localname = 'in_ledgerR2ary'; OA.addDataBlocks(G, nc, dbk)  # From another R2arySetup
    dbk = copy.deepcopy(dbk_ledgerR2ary); dbk.flight = 'flTAKEOFF'; dbk.localname = 'o_ledgerR2ary'; OA.addDataBlocks(G, nc, dbk)  # To self
    dbk = copy.deepcopy(dbk_whenDoneR2ary);dbk.flight = 'flTAKEOFF'; dbk.localname = 'o_r2aWdone'; OA.addDataBlocks(G, nc, dbk) # To R2aryForkIF
    dbk = copy.deepcopy(dbk_nullGuid);     dbk.flight = 'flTAKEOFF'; OA.addDataBlocks(G, nc, dbk)  # To R2aryJoinELSE
    OA.addIFconditionText(G, nc, 'conditionR2aryJoinIF(OA_edtTypeNb, OA_DBG_thisEDT, in_ledgerR2ary, in_ledgerR2ary2)')
    guid_R2aryFORKif_text = OA.makeGuidEdtname('R2aryForkIF')  # This is where one goes next in the EDT bracketing.
    guid1_R2aryJoinIF_text = OA.makeGuidEdtname('R2aryJoinIF')
    text1_R2ary_nextEDT = 'ocrGuid_t ' + guid1_R2aryJoinIF_text + ';'; OA.addCustomText(G, nc, text1_R2ary_nextEDT)
    R2aryJoinIF_slot_text = 'unsigned int R2aryJoinIF_slot;';          OA.addCustomText(G, nc, R2aryJoinIF_slot_text)
    R2aryJoinIF_text = 'err = R2aryJoinIF_fcn(OA_DEBUG_OUTVARS, &'
    R2aryJoinIF_text += guid_R2aryFORKif_text + ', in_ledgerR2ary, in_ledgerR2ary2, '
    R2aryJoinIF_text += 'o_ledgerR2ary, o_r2aWdone, R2aryJoinIF, '
    R2aryJoinIF_text += '&' + guid1_R2aryJoinIF_text + ', &R2aryJoinIF_slot); IFEB;'
    OA.addCustomText(G, nc, R2aryJoinIF_text)

    nc += 1;  taskName="R2aryJoinELSE"; OA.graphAddNode(G,nc,taskName)
    dbk = copy.deepcopy(dbk_nullGuid); dbk.flight = 'flLANDING'; OA.addDataBlocks(G, nc, dbk)  # From R2aryJoinIF
    dbk = copy.deepcopy(dbk_ledgerR2ary2); dbk.flight = 'flLANDING'; dbk.localname = 'in_ledgerR2ary2'; OA.addDataBlocks(G, nc, dbk)# From R2arySetup
    dbk = copy.deepcopy(dbk_ledgerR2ary);  dbk.flight = 'flLANDING'; dbk.localname = 'in_ledgerR2ary'; OA.addDataBlocks(G, nc, dbk)# From another R2arySetup
    dbk = copy.deepcopy(dbk_whenDoneR2ary);dbk.flight = 'flTAKEOFF'; dbk.localname = 'o_r2aWdone'; OA.addDataBlocks(G, nc, dbk) # To R2aryForkIF
    dbk = copy.deepcopy(dbk_valueR2ary); dbk.flight = 'flTAKEOFF'; dbk.localname = 'o_valueR2ary'; OA.addDataBlocks(G, nc, dbk)  # To R2aryForkIF
    R2aryJoinELSE_text = 'err = R2aryJoinELSE_fcn(OA_edtTypeNb, OA_DBG_thisEDT, '
    R2aryJoinELSE_text += 'in_ledgerR2ary, in_ledgerR2ary2, o_valueR2ary, o_r2aWdone); IFEB;'
    OA.addCustomText(G, nc, R2aryJoinELSE_text)

    nc += 1;  taskName="R2aryForkIF"; OA.graphAddNode(G,nc,taskName)
    dbk = copy.deepcopy(dbk_whenDoneR2ary); dbk.flight = 'flTAGO'; dbk.localname = 'io_r2aWdone'; OA.addDataBlocks(G, nc, dbk)# To R2aryForkIF_FOR
    dbk = copy.deepcopy(dbk_valueR2ary);    dbk.flight = 'flTAGO'; dbk.localname = 'io_valueR2ary'; OA.addDataBlocks(G, nc, dbk)  # To R2aryForkIF_FOR
    dbk = copy.deepcopy(dbk_nullGuid);      dbk.flight = 'flTAKEOFF'; OA.addDataBlocks(G, nc, dbk)  # To R2aryForkELSE
    OA.addIFconditionText(G, nc, 'conditionR2aryForkIF(OA_edtTypeNb, OA_DBG_thisEDT, io_r2aWdone)')

    nc += 1;  taskName="R2aryForkIF_FOR"; OA.graphAddNode(G,nc,taskName)
    dbk = copy.deepcopy(dbk_whenDoneR2ary); dbk.flight = 'flLANDING'; dbk.localname = 'in_r2aWdone'; dbk.delayReleaseDestroy = True
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_valueR2ary);    dbk.flight = 'flLANDING'; dbk.localname = 'in_valueR2ary'; dbk.delayReleaseDestroy = True
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_valueR2ary); dbk.flight = 'flTAKEOFF'; dbk.localname = 'o_valueR2ary'; OA.addDataBlocks(G, nc, dbk)  # To R2aryForkIF
    R2aryForkIF_FOR_fortext = 'int r2aryX; for(r2aryX=0; r2aryX < reductNaryFoliation; ++r2aryX)'
    OA.addFORconditionText(G, nc, R2aryForkIF_FOR_fortext)
    guid_R2aryForkIF_FOR_2go = OA.makeGuidEdtname('R2aryForkIF')
    OA.addCustomText(G, nc, 'ocrGuid_t ' + guid_R2aryForkIF_FOR_2go + ';')
    R2aryForkIF_FOR_bodytext = 'err = R2aryForkIF_FOR_body(OA_edtTypeNb, OA_DBG_thisEDT, r2aryX, in_r2aWdone, '
    R2aryForkIF_FOR_bodytext += 'in_valueR2ary, o_valueR2ary, &' + guid_R2aryForkIF_FOR_2go + '); IFEB;'
    OA.addCustomText(G, nc, R2aryForkIF_FOR_bodytext)

    nc += 1;  taskName="R2aryForkELSE"; OA.graphAddNode(G,nc,taskName)
    dbk = copy.deepcopy(dbk_nullGuid); dbk.flight = 'flLANDING'; OA.addDataBlocks(G, nc, dbk)  # From R2aryForkIF
    dbk = copy.deepcopy(dbk_whenDoneR2ary); dbk.flight = 'flTAGO'; dbk.localname = 'io_r2aWdone'; OA.addDataBlocks(G, nc, dbk)# To R2aryForkELSE_FOR
    dbk = copy.deepcopy(dbk_valueR2ary);    dbk.flight = 'flTAGO'; dbk.localname = 'io_valueR2ary'; OA.addDataBlocks(G, nc, dbk)  # To R2aryForkELSE_FOR

    nc += 1;  taskName="R2aryForkELSE_FOR"; OA.graphAddNode(G,nc,taskName)
    dbk = copy.deepcopy(dbk_whenDoneR2ary); dbk.flight = 'flLANDING'; dbk.localname = 'in_r2aWdone'; dbk.delayReleaseDestroy = True
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_valueR2ary);    dbk.flight = 'flLANDING'; dbk.localname = 'in_valueR2ary'; dbk.delayReleaseDestroy = True
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_valueR2ary); dbk.flight = 'flTAKEOFF'; dbk.localname = 'o_valueR2ary'; OA.addDataBlocks(G, nc, dbk)  # To R2aryConclusion
    R2aryForkELSE_FOR_fortext = 'int r2aryX; for(r2aryX=0; r2aryX < reductNaryFoliation; ++r2aryX)'
    OA.addFORconditionText(G, nc, R2aryForkELSE_FOR_fortext)
    guid_R2aryForkELSE_FOR_2go = OA.makeGuidEdtname('R2aryConclusion')
    OA.addCustomText(G, nc, 'ocrGuid_t ' + guid_R2aryForkELSE_FOR_2go + ';')
    R2aryForkELSE_FOR_bodytext = 'err = R2aryForkELSE_FOR_body(OA_edtTypeNb, OA_DBG_thisEDT, r2aryX, in_r2aWdone, '
    R2aryForkELSE_FOR_bodytext += 'in_valueR2ary, o_valueR2ary, &' + guid_R2aryForkELSE_FOR_2go + '); IFEB;'
    OA.addCustomText(G, nc, R2aryForkELSE_FOR_bodytext)

    # =========================================================================
    # =========================================================================
    # =========================================================================
    # =========================================================================
    # =========================================================================
    # ----- EDGES - Fork-Join Tree
    ledg = OA.graphAddEdge(G, "mainEdt", "SetupBtForkJoin", "gDone")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'; OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('gDone')
    ledg = OA.graphAddEdge(G, "mainEdt", "SetupBtForkJoin", "Globals")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'; OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('Globals')
    ledg = OA.graphAddEdge(G, "mainEdt", "finalEDT", "NULL_GUID")
    OA.getEvent(G, ledg).eflag = 'EVT_PROP_NONE'; OA.getEvent(G, ledg).satisfy = 'NULL_GUID'

    ledg = OA.graphAddEdge(G, "SetupBtForkJoin", "ConcludeBtForkJoin", "gDone")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'; OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('gDone')
    ledg = OA.graphAddEdge(G, "SetupBtForkJoin", "ConcludeBtForkJoin", "RefWork")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'; OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('RefWork')
    ledg = OA.graphAddEdge(G, "SetupBtForkJoin", "ConcludeBtForkJoin", "GlobalsRef")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RW'; OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('GlobalsRef')

    ledg = OA.graphAddEdge(G, "SetupBtForkJoin", "BtForkIF", "Globals")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'; OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('Globals')
    btForkIF_globals_input_edge=ledg[0]  # This takes only the edge out of the labelled edge.
    ledg = OA.graphAddEdge(G, "SetupBtForkJoin", "BtForkIF", "TFJiterate")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'; OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('TFJiterate')
    btForkIF_main_input_edge=ledg[0]  # This takes only the edge out of the labelled edge.

    ledg = OA.graphAddEdge(G, "ConcludeBtForkJoin", "finalEDT", "NULL_GUID")
    OA.getEvent(G, ledg).eflag = 'EVT_PROP_NONE'; OA.getEvent(G, ledg).satisfy = 'NULL_GUID'
    OA.getEvent(G, ledg).fertile = False

    ledg = OA.graphAddEdge(G, "BtForkIF", "BtForkELSE", "NULL_GUID")
    OA.getEdge(G, ledg[0])["leads_to_ElseClause"] = True

    ledg = OA.graphAddEdge(G, "BtForkIF", "BtForkFOR", "TFJiterate")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'; OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('TFJiterate')
    ledg = OA.graphAddEdge(G, "BtForkIF", "BtForkFOR", "Globals")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'; OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('Globals')
    ledg = OA.graphAddEdge(G, "BtForkIF", "BtJoinIFTHEN", "gDone")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'; OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('gDone')
    btJoin_gDone_main_input_edge = ledg[0]

    ledg = OA.graphAddEdge(G, "BtForkFOR", "BtForkIF", "TFJiterate")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('TFJiterate')
    OA.sharedConx(G, ledg[0]).append(btForkIF_main_input_edge)
    ledg = OA.graphAddEdge(G, "BtForkFOR", "BtForkIF", "Globals")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO';  OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('GlobalD')
    OA.sharedConx(G, ledg[0]).append(btForkIF_globals_input_edge)

    ledg = OA.graphAddEdge(G, "BtForkELSE", "BtJoinIFTHEN", "gDone")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'; OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('gDone')
    OA.sharedConx(G, ledg[0]).append(btJoin_gDone_main_input_edge)

    ledg = OA.graphAddEdge(G, "BtForkELSE", "BtForkTransition_Start", "TFJiterate")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'; OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('TFJiterate')
    ledg = OA.graphAddEdge(G, "BtForkELSE", "BtForkTransition_Start", "Globals")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'; OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('Globals')

    ledg = OA.graphAddEdge(G, "BtForkTransition_Start", "BtForkTransition_Stop", "TFJiterate")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'; OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('TFJiterate')
    ledg = OA.graphAddEdge(G, "BtForkTransition_Start", "BtForkTransition_Stop", "Globals")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'; OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('Globals')

    ledg = OA.graphAddEdge(G, "BtForkTransition_Stop", "BtJoinIFTHEN", "Work2")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'; OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('Work2')
    OA.getEvent(G, ledg).fertile = False
    ledg = OA.graphAddEdge(G, "BtForkTransition_Stop", "BtJoinIFTHEN", "Work")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'; OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('Work')
    OA.getEvent(G, ledg).fertile = False
    btFork_transition_to_btJoinIF_main_edge1 = ledg[0]

    ledg = OA.graphAddEdge(G, "BtJoinIFTHEN", "BtJoinELSE", "NULL_GUID")
    OA.getEdge(G, ledg[0])["leads_to_ElseClause"] = True
    ledg = OA.graphAddEdge(G, "BtJoinIFTHEN", "BtJoinIFTHEN", "Work")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('Work')
    OA.getEvent(G, ledg).fertile = False
    OA.getEvent(G, ledg).user_slotnb_text = 'slot_for_work'
    OA.sharedConx(G, ledg[0]).append(btFork_transition_to_btJoinIF_main_edge1)

    ledg = OA.graphAddEdge(G, "BtJoinELSE", "ConcludeBtForkJoin", "Work")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'; OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('Work')
    OA.getEvent(G, ledg).fertile = False

    # ----- EDGES - Reduction2ary
    ledg = OA.graphAddEdge(G, "BtForkTransition_Start", "R2arySetup", "LedgerR2ary")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'; OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('LedgerR2ary')

    ledg = OA.graphAddEdge(G, "R2arySetup", "R2aryConclusion", "R2aryWhenDone")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'; OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('R2aryWhenDone')
    ledg = OA.graphAddEdge(G, "R2arySetup", "R2aryJoinIF", "LedgerR2ary2")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'; OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('LedgerR2ary2')
    OA.getEvent(G, ledg).user_slotnb_text = 'ra2ary_ledgerSlot2use'
    OA.getEvent(G, ledg).fertile = False  # Sterile because it will be created through the labeled EDT map.

    ledg = OA.graphAddEdge(G, "R2aryConclusion", "BtForkTransition_Stop", "R2aryValue")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'; OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('R2aryValue')
    OA.getEvent(G, ledg).fertile = False

    #2016Sept14:
    #Notice the setting of edges outgoing from R2aryJoinELSE first, instead of the usual traitment of R2aryJoinIF first.
    #It is because of the way shared edges currently work:  If a node has 1 shared edge, all its edges are considered
    #shared, which is not really a good idea.
    #To temporily fix this, this edt inversion causes all the shared edges to NOT be on R2aryJoinELSE, allowing the
    #slot attribution algorithm to work correctly.
    ledg = OA.graphAddEdge(G, "R2aryJoinELSE", "R2aryForkIF", "R2aryWhenDone")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'; OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('R2aryWhenDone')
    R2aryJoinELSE_main_wDone_edge = ledg[0];
    ledg = OA.graphAddEdge(G, "R2aryJoinELSE", "R2aryForkIF", "R2aryValue")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'; OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('R2aryValue')
    R2aryForkIF_main_value_edge = ledg[0]

    ledg = OA.graphAddEdge(G, "R2aryJoinIF", "R2aryJoinELSE", "NULL_GUID")
    OA.getEdge(G, ledg[0])["leads_to_ElseClause"] = True  # Automatically sterile
    ledg = OA.graphAddEdge(G, "R2aryJoinIF", "R2aryJoinIF", "LedgerR2ary")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'; OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('LedgerR2ary')
    OA.getEvent(G, ledg).user_slotnb_text = 'R2aryJoinIF_slot'
    OA.getEvent(G, ledg).fertile = False  # Sterile because it will be created through the labeled EDT map.
    ledg = OA.graphAddEdge(G, "R2aryJoinIF", "R2aryForkIF", "R2aryWhenDone")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'; OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('R2aryWhenDone')
    OA.sharedConx(G, ledg[0]).append(R2aryJoinELSE_main_wDone_edge)

    ledg = OA.graphAddEdge(G, "R2aryForkIF", "R2aryForkIF_FOR", "R2aryWhenDone")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'; OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('R2aryWhenDone')
    ledg = OA.graphAddEdge(G, "R2aryForkIF", "R2aryForkIF_FOR", "R2aryValue")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'; OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('R2aryValue')
    ledg = OA.graphAddEdge(G, "R2aryForkIF", "R2aryForkELSE", "NULL_GUID")
    OA.getEdge(G, ledg[0])["leads_to_ElseClause"] = True # Automatically sterile

    ledg = OA.graphAddEdge(G, "R2aryForkIF_FOR", "R2aryForkIF", "R2aryValue")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'; OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('R2aryValue')
    OA.sharedConx(G, ledg[0]).append(R2aryForkIF_main_value_edge)
    OA.getEvent(G, ledg).fertile = False  # Already created by the Join operations

    ledg = OA.graphAddEdge(G, "R2aryForkELSE", "R2aryForkELSE_FOR", "R2aryWhenDone")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'; OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('R2aryWhenDone')
    ledg = OA.graphAddEdge(G, "R2aryForkELSE", "R2aryForkELSE_FOR", "R2aryValue")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'; OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('R2aryValue')

    ledg = OA.graphAddEdge(G, "R2aryForkELSE_FOR", "R2aryConclusion", "R2aryValue")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'; OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('R2aryValue')
    OA.getEvent(G, ledg).fertile = False # Already created by the Setup operations

    # =========================================================================
    # =========================================================================
    # =========================================================================
    # =========================================================================
    # =========================================================================
    erri = 0
    while not erri:
        if False: OA.printGraph(G)   # Just to check if the inputs are ok.

        erri = OA.OCRanalysis(G)
        if erri: break

        if False: OA.printGraph(G)
        if True :
            erri = OA.outputDot(G, "z_reductionBy2ary.dot")
            if erri: break
        if True:
            erri = OA.outputOCR(G, "z_reductionBy2ary.c")
            if erri: break

        if True: OA.printGraph(G)

        break  # while not erri
    OA.errmsg(erri)
    return erri
Пример #4
0
def theMain():

    G = OA.GraphTool.DiGraph()

    OA.setupGraph(G, "RecursiveBinaryTree")

    # ----- Data Blocks
    # NOTE: The counts
    #           123456     for the original Set
    #           10123456   for Set1
    #           20123456   for Set2
    #       are purely arbitrary and serves as placeholders that the customer
    #       can track easily in the generated code.

    dbk = OA.ocrDataBlock();  dbk.name = 'dSet';   dbk.count=123456;     dbk.type='int'
    dbk_dSet = dbk
    # These 2 "dSet" are sub-arrays split from "dSet"
    dbk = OA.ocrDataBlock();  dbk.name = 'dSet1';  dbk.count=10123456;     dbk.type='int'
    dbk_dSet1 = dbk
    dbk = OA.ocrDataBlock();  dbk.name = 'dSet2';  dbk.count=20123456;     dbk.type='int'
    dbk_dSet2 = dbk

    # These 2 "boundary" sets contain the offsets in the original dSet
    dbk = OA.ocrDataBlock();  dbk.name = 'boundary1';   dbk.count=2;     dbk.type='int'
    dbk_boundary1 = dbk
    dbk = OA.ocrDataBlock();  dbk.name = 'boundary2';   dbk.count=2;     dbk.type='int'
    dbk_boundary2 = dbk

    # These contains the scattering of the gathering EDT
    dbk = OA.ocrDataBlock();  dbk.name = 'scatter1';  dbk.count=1;    dbk.type='ocrGuid_t'
    dbk_scatter1 = dbk
    dbk = OA.ocrDataBlock();  dbk.name = 'scatter2';  dbk.count=1;    dbk.type='ocrGuid_t'
    dbk_scatter2 = dbk

    # This contains the propagation of the gather element
    dbk = OA.ocrDataBlock();  dbk.name = 'gather';    dbk.count=1;    dbk.type='ocrGuid_t'
    dbk_gather = dbk

    # These contains the results from the gathering operations
    dbk = OA.ocrDataBlock();  dbk.name = 'result1';   dbk.count=1;    dbk.type='int'
    dbk_result1 = dbk
    dbk = OA.ocrDataBlock();  dbk.name = 'result2';   dbk.count=1;    dbk.type='int'
    dbk_result2 = dbk

    # ----- NODES
    # A
    nc = OA.GBL.MAINNODE;   taskName = "mainEDT";     OA.graphAddNode(G,nc,taskName)
    OA.getEdts(G, nc).append('a')
    dbk = copy.deepcopy(dbk_dSet);      dbk.flight = 'HOP';      OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_dSet1);     dbk.flight = 'TAKEOFF';  OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_boundary1); dbk.flight = 'TAKEOFF';  OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_scatter1);  dbk.flight = 'TAKEOFF';  OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_dSet2);     dbk.flight = 'TAKEOFF';  OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_boundary2); dbk.flight = 'TAKEOFF';  OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_scatter2);  dbk.flight = 'TAKEOFF';  OA.addDataBlocks(G, nc, dbk)

    # a
    nc = OA.GBL.FINALNODE;   taskName = "a";    OA.graphAddNode(G,nc,taskName)
    dbk = copy.deepcopy(dbk_result1);   dbk.flight = 'LANDING';  OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_result2);   dbk.flight = 'LANDING';  OA.addDataBlocks(G, nc, dbk)

    # B
    nc += 1;  taskName = "B";    OA.graphAddNode(G,nc,taskName)
    dbk = copy.deepcopy(dbk_dSet1);     dbk.flight = 'LANDING';  OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_boundary1); dbk.flight = 'LANDING';  OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_scatter1);  dbk.flight = 'LANDING';  OA.addDataBlocks(G, nc, dbk)

    dbk = copy.deepcopy(dbk_dSet1);     dbk.flight = 'TAKEOFF';  OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_scatter1);  dbk.flight = 'TAKEOFF';  OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_boundary1); dbk.flight = 'TAKEOFF';  OA.addDataBlocks(G, nc, dbk)

    dbk = copy.deepcopy(dbk_dSet2);     dbk.flight = 'TAKEOFF';  OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_scatter2);  dbk.flight = 'TAKEOFF';  OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_boundary2); dbk.flight = 'TAKEOFF';  OA.addDataBlocks(G, nc, dbk)

    dbk = copy.deepcopy(dbk_gather);    dbk.flight = 'TAKEOFF';  OA.addDataBlocks(G, nc, dbk)

    # D
    nc += 1;  taskName = "D";        OA.graphAddNode(G,nc,taskName)
    dbk = copy.deepcopy(dbk_dSet1);     dbk.flight = 'LANDING';  OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_scatter1);  dbk.flight = 'LANDING';  OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_boundary1); dbk.flight = 'LANDING';  OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_result1);   dbk.flight = 'TAKEOFF';  OA.addDataBlocks(G, nc, dbk)

    # E
    nc += 1;  taskName = "E";        OA.graphAddNode(G,nc,taskName)
    dbk = copy.deepcopy(dbk_dSet2);     dbk.flight = 'LANDING';  OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_scatter2);  dbk.flight = 'LANDING';  OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_boundary2); dbk.flight = 'LANDING';  OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_result2);   dbk.flight = 'TAKEOFF';  OA.addDataBlocks(G, nc, dbk)

    # b
    nc += 1;  taskName = "b";        OA.graphAddNode(G,nc,taskName)
    dbk = copy.deepcopy(dbk_gather);    dbk.flight = 'LANDING';  OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_result1);   dbk.flight = 'LANDING';  OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_result2);   dbk.flight = 'LANDING';  OA.addDataBlocks(G, nc, dbk)

    dbk = copy.deepcopy(dbk_result1);   dbk.flight = 'TAKEOFF';  OA.addDataBlocks(G, nc, dbk)

    # C
    nc += 1;  taskName = "C";    OA.graphAddNode(G,nc,taskName)
    dbk = copy.deepcopy(dbk_dSet2);     dbk.flight = 'LANDING';  OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_boundary2); dbk.flight = 'LANDING';  OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_scatter2);  dbk.flight = 'LANDING';  OA.addDataBlocks(G, nc, dbk)

    dbk = copy.deepcopy(dbk_dSet1);     dbk.flight = 'TAKEOFF';  OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_scatter1);  dbk.flight = 'TAKEOFF';  OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_boundary1); dbk.flight = 'TAKEOFF';  OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_dSet2);     dbk.flight = 'TAKEOFF';  OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_scatter2);  dbk.flight = 'TAKEOFF';  OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_boundary2); dbk.flight = 'TAKEOFF';  OA.addDataBlocks(G, nc, dbk)

    dbk = copy.deepcopy(dbk_gather);    dbk.flight = 'TAKEOFF';  OA.addDataBlocks(G, nc, dbk)

    #F
    nc += 1;  taskName = "F";        OA.graphAddNode(G,nc,taskName)
    dbk = copy.deepcopy(dbk_dSet1);     dbk.flight = 'LANDING';  OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_scatter1);  dbk.flight = 'LANDING';  OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_boundary1); dbk.flight = 'LANDING';  OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_result1);   dbk.flight = 'TAKEOFF';  OA.addDataBlocks(G, nc, dbk)

    # G
    nc += 1;  taskName = "G";        OA.graphAddNode(G,nc,taskName)
    dbk = copy.deepcopy(dbk_dSet2);     dbk.flight = 'LANDING';  OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_scatter2);  dbk.flight = 'LANDING';  OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_boundary2); dbk.flight = 'LANDING';  OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_result2);   dbk.flight = 'TAKEOFF';  OA.addDataBlocks(G, nc, dbk)

    # c
    nc += 1;  taskName = "c";        OA.graphAddNode(G,nc,taskName)
    dbk = copy.deepcopy(dbk_gather);    dbk.flight = 'LANDING';  OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_result1);   dbk.flight = 'LANDING';  OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_result2);   dbk.flight = 'LANDING';  OA.addDataBlocks(G, nc, dbk)

    dbk = copy.deepcopy(dbk_result2);   dbk.flight = 'TAKEOFF';  OA.addDataBlocks(G, nc, dbk)

    # ----- EDGES
    # TODO: Put in the correct " getEvent(G, edg).accessMode" as everything is now DB_MODE_RW

    # From A
    edg = OA.graphAddEdge(G,     "mainEDT", "B", "dSet1")
    OA.getEvent(G, edg).satisfy = OA.makeGuidDataBlockname('dSet1')
    edg = OA.graphAddEdge(G,     "mainEDT", "B", "boundary1")
    OA.getEvent(G, edg).satisfy = OA.makeGuidDataBlockname('boundary1')
    edg = OA.graphAddEdge(G,     "mainEDT", "B", "scatter1")
    OA.getEvent(G, edg).satisfy = OA.makeGuidDataBlockname('scatter1')

    edg = OA.graphAddEdge(G,     "mainEDT", "C", "dSet2")
    OA.getEvent(G, edg).satisfy = OA.makeGuidDataBlockname('dSet2')
    edg = OA.graphAddEdge(G,     "mainEDT", "C", "boundary2")
    OA.getEvent(G, edg).satisfy = OA.makeGuidDataBlockname('boundary2')
    edg = OA.graphAddEdge(G,     "mainEDT", "C", "scatter2")
    OA.getEvent(G, edg).satisfy = OA.makeGuidDataBlockname('scatter2')

    # From B
    edg = OA.graphAddEdge(G,     "B", "D", "dSet1")
    OA.getEvent(G, edg).satisfy = OA.makeGuidDataBlockname('dSet1')
    edg = OA.graphAddEdge(G,     "B", "D", "boundary1")
    OA.getEvent(G, edg).satisfy = OA.makeGuidDataBlockname('boundary1')
    edg = OA.graphAddEdge(G,     "B", "D", "scatter1")
    OA.getEvent(G, edg).satisfy = OA.makeGuidDataBlockname('scatter1')
    edg = OA.graphAddEdge(G,     "B", "E", "dSet2")
    OA.getEvent(G, edg).satisfy = OA.makeGuidDataBlockname('dSet2')
    edg = OA.graphAddEdge(G,     "B", "E", "boundary2")
    OA.getEvent(G, edg).satisfy = OA.makeGuidDataBlockname('boundary2')
    edg = OA.graphAddEdge(G,     "B", "E", "scatter2")
    OA.getEvent(G, edg).satisfy = OA.makeGuidDataBlockname('scatter2')

    edg = OA.graphAddEdge(G,     "B", "b", "gather")
    OA.getEvent(G, edg).satisfy = OA.makeGuidDataBlockname('gather')

    # From C
    edg = OA.graphAddEdge(G,     "C", "F", "dSet1")
    OA.getEvent(G, edg).satisfy = OA.makeGuidDataBlockname('dSet1')
    edg = OA.graphAddEdge(G,     "C", "F", "boundary1")
    OA.getEvent(G, edg).satisfy = OA.makeGuidDataBlockname('boundary1')
    edg = OA.graphAddEdge(G,     "C", "F", "scatter1")
    OA.getEvent(G, edg).satisfy = OA.makeGuidDataBlockname('scatter1')
    edg = OA.graphAddEdge(G,     "C", "G", "dSet2")
    OA.getEvent(G, edg).satisfy = OA.makeGuidDataBlockname('dSet2')
    edg = OA.graphAddEdge(G,     "C", "G", "boundary2")
    OA.getEvent(G, edg).satisfy = OA.makeGuidDataBlockname('boundary2')
    edg = OA.graphAddEdge(G,     "C", "G", "scatter2")
    OA.getEvent(G, edg).satisfy = OA.makeGuidDataBlockname('scatter2')

    edg = OA.graphAddEdge(G,     "C", "c", "gather")
    OA.getEvent(G, edg).satisfy = OA.makeGuidDataBlockname('gather')

    # From D
    edg = OA.graphAddEdge(G,     "D", "b", "result1")
    OA.getEvent(G, edg).satisfy = OA.makeGuidDataBlockname('result1')
    OA.getEvent(G, edg).fertile = False

    # From E
    edg = OA.graphAddEdge(G,     "E", "b", "result2")
    OA.getEvent(G, edg).satisfy = OA.makeGuidDataBlockname('result2')
    OA.getEvent(G, edg).fertile = False

    # From F
    edg = OA.graphAddEdge(G,     "F", "c", "result1")
    OA.getEvent(G, edg).satisfy = OA.makeGuidDataBlockname('result1')
    OA.getEvent(G, edg).fertile = False

    # From G
    edg = OA.graphAddEdge(G,     "G", "c", "result2")
    OA.getEvent(G, edg).satisfy = OA.makeGuidDataBlockname('result2')
    OA.getEvent(G, edg).fertile = False

    # From b
    edg = OA.graphAddEdge(G,     "b", "a", "result1")
    OA.getEvent(G, edg).satisfy = OA.makeGuidDataBlockname('result1')
    OA.getEvent(G, edg).fertile = False

    # From c
    edg = OA.graphAddEdge(G,     "c", "a", "result2")
    OA.getEvent(G, edg).satisfy = OA.makeGuidDataBlockname('result2')
    OA.getEvent(G, edg).fertile = False

    # ----- WORK
    erri = 0
    while not erri:
        if 1 == 2: OA.printGraph(G)

        erri = OA.OCRanalysis(G)
        if erri: break

        if 1 == 2: OA.printGraph(G)
        if 1 == 1:
            erri = OA.outputDot(G, "z_recursiveBinaryTree_full.dot")
            if erri: break
        if 1 == 1:
            erri = OA.outputOCR(G, "z_recursiveBinaryTree_full.c")
            if erri: break

        if 1 == 1: OA.printGraph(G)

        break  # while not erri
    OA.errmsg(erri)
    return erri
Пример #5
0
def theMain():

    OA.GBL.insert_debug_code = 0

    G = OA.GraphTool.DiGraph()

    # ==============================================================================
    # ----- GLOBALS
    OA.setupGraph(G, "mpiRanks_inOcr")

    OA.addHeader(G, '#include "treeForkJoin.h" ')
    OA.addHeader(G, '#include "global_data.h" ')
    OA.addHeader(G, '#include "tailrecursion.h" ')
    OA.addHeader(
        G,
        '#define Nfoliation 2')  # If set to two that makes it a binary tree.

    # ==============================================================================
    # ==============================================================================
    # Fork-Join tree for the distribution of MPI ranks
    # ----- Data Blocks
    dbk = OA.ocrDataBlock()
    dbk.name = 'NULL_GUID'
    dbk_nullGuid = dbk

    dbk = OA.ocrDataBlock()
    dbk.name = 'gDone'
    dbk.count = 1
    dbk.type = 'ocrGuid_t'
    dbk_gDone = dbk

    dbk = OA.ocrDataBlock()
    dbk.name = 'TFJiterate'
    dbk.count = 1
    dbk.type = 'TFJiterate_t'
    dbk_TFJiterate = dbk

    dbk = OA.ocrDataBlock()
    dbk.name = 'TCsum'
    dbk.count = 1
    dbk.type = 'TChecksum_work_t'
    dbk_work = dbk
    dbk = OA.ocrDataBlock()
    dbk.name = 'TCsum2'
    dbk.count = 1
    dbk.type = 'TChecksum_work_t'
    dbk_work2 = dbk

    dbk = OA.ocrDataBlock()
    dbk.name = 'RefTCsum'
    dbk.count = 1
    dbk.type = 'TChecksum_work_t'
    dbk_refwork = dbk

    dbk = OA.ocrDataBlock()
    dbk.name = 'GlobalD'
    dbk.count = 1
    dbk.type = 'GlobalData_t'
    dbk_globald = dbk

    # ----- NODES
    # NOTE: In as much as doable, the EDT are presented in a bracketing fashion.
    #       That is, assuming we have a sequence of EDTs as follows A->B->C->D->E
    #       Then the EDTs are presented as follows:  A,E,B,D,C
    #       For a linear sequence, that is of little importance; but for a more complex graph, bracketing
    #       makes it clear what are the EDTs acting as inputs and outputs.
    #
    # Always root the starting/root/main EDT at ID=0 = OA.GBL.MAINNODE
    # Always cap all ending EDT by the FinalEDT at ID=1 = OA.GBL.FINALNODE

    nc = OA.GBL.MAINNODE
    taskName = "mainEdt"
    OA.graphAddNode(G, nc, taskName)
    dbk = copy.deepcopy(dbk_nullGuid)
    dbk.flight = 'flTAKEOFF'
    OA.addDataBlocks(G, nc, dbk)  # To FinalEDT
    dbk = copy.deepcopy(dbk_gDone)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_gDone'
    OA.addDataBlocks(G, nc, dbk)  # To SetupBtForkJoin
    dbk = copy.deepcopy(dbk_globald)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_globald'
    OA.addDataBlocks(G, nc, dbk)  # To SetupBtForkJoin
    toFinalt = 'GUID_ASSIGN_VALUE(*o_gDone, ' + OA.makeGuidEdtname(
        "finalEDT") + ');'
    OA.addCustomText(G, nc, toFinalt)
    init_globald = 'init_globalData(o_globald);'
    OA.addCustomText(G, nc, init_globald)

    nc = OA.GBL.FINALNODE
    taskName = "finalEDT"
    OA.graphAddNode(G, nc, taskName)
    dbk = copy.deepcopy(dbk_nullGuid)
    dbk.flight = 'flLANDING'
    OA.addDataBlocks(G, nc, dbk)  # From ConcludeBtForkJoin
    dbk = copy.deepcopy(dbk_nullGuid)
    dbk.flight = 'flLANDING'
    OA.addDataBlocks(G, nc, dbk)  # From mainEdt

    nc += 1
    taskName = "SetupBtForkJoin"
    OA.graphAddNode(G, nc, taskName)
    dbk = copy.deepcopy(dbk_gDone)
    dbk.flight = 'flTAGO'
    OA.addDataBlocks(G, nc, dbk)  # Toward ConcludeBtForkJoin
    dbk = copy.deepcopy(dbk_globald)
    dbk.flight = 'flTAGO'
    dbk.localname = 'io_globald'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_refwork)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_refTCsum'
    OA.addDataBlocks(G, nc, dbk)  # To ConcludeBtForkJoin
    dbk = copy.deepcopy(dbk_TFJiterate)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_TFJiterate'
    OA.addDataBlocks(G, nc, dbk)  # To BtForkIF
    setupt = 'err = setupBtForkJoin(OA_edtTypeNb, OA_DBG_thisEDT, o_TFJiterate, '
    setupt += OA.makeGuidEdtname(
        "ConcludeBtForkJoin") + ', io_globald, &o_refTCsum->result);'
    OA.addCustomText(G, nc, setupt)

    nc += 1
    taskName = "ConcludeBtForkJoin"
    OA.graphAddNode(G, nc, taskName)
    dbk = copy.deepcopy(dbk_nullGuid)
    dbk.flight = 'flTAKEOFF'
    OA.addDataBlocks(G, nc, dbk)  # To finalEDT
    dbk = copy.deepcopy(dbk_gDone)
    dbk.flight = 'flLANDING'
    dbk.localname = 'in_gDone'
    OA.addDataBlocks(G, nc, dbk)  # From SetupBtForkJoin
    dbk = copy.deepcopy(dbk_refwork)
    dbk.flight = 'flLANDING'
    dbk.localname = 'in_refwork'
    OA.addDataBlocks(G, nc, dbk)  # From SetupBtForkJoin
    dbk = copy.deepcopy(dbk_work)
    dbk.flight = 'flLANDING'
    dbk.localname = 'in_calculated'
    OA.addDataBlocks(G, nc, dbk)  # From BtJoinELSE
    guid_finalEDT = OA.makeGuidEdtname('finalEDT')
    doneText = 'ocrGuid_t ' + guid_finalEDT + '; GUID_ASSIGN_VALUE(' + guid_finalEDT + ', *in_gDone);'
    OA.addCustomText(G, nc, doneText)
    OA.addCustomText(
        G, nc,
        'err = concludeBtForkJoin(OA_edtTypeNb, OA_DBG_thisEDT, in_refwork->result, in_calculated->result); IFEB;'
    )

    nc += 1
    taskName = "BtForkIF"
    OA.graphAddNode(G, nc, taskName)
    dbk = copy.deepcopy(dbk_TFJiterate)
    dbk.flight = 'flLANDING'
    dbk.localname = 'in_TFJiterate'
    OA.addDataBlocks(G, nc, dbk)  # From SetupBtForkJoin or BtForkFOR
    dbk = copy.deepcopy(dbk_TFJiterate)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_TFJiterate'
    OA.addDataBlocks(G, nc, dbk)  # To BtForkFOR or BtForkELSE
    dbk = copy.deepcopy(dbk_globald)
    dbk.flight = 'flLANDING'
    dbk.localname = 'in_globald'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_globald)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_globald'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_gDone)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_gDone'
    OA.addDataBlocks(G, nc, dbk)  # To BtJoinIFTHEN
    #dbk = copy.deepcopy(dbk_nullGuid); dbk.flight = 'flTAKEOFF';  <-- This is the NULL_GUID used to link to the ELSE clause
    OA.addIFconditionText(
        G, nc, 'conditionBtFork(OA_edtTypeNb, OA_DBG_thisEDT, in_TFJiterate)')
    iterText = 'err = btForkThen(OA_edtTypeNb, OA_DBG_thisEDT, in_TFJiterate, ' + OA.makeGuidEdtname(
        "BtJoinIFTHEN") + ', o_TFJiterate, o_gDone);'
    OA.addCustomText(G, nc, iterText)
    copy_globals = 'copy_globalData(in_globald, o_globald);'
    OA.addCustomText(G, nc, copy_globals)

    nc += 1
    taskName = "BtForkFOR"
    OA.graphAddNode(G, nc, taskName)
    dbk = copy.deepcopy(dbk_TFJiterate)
    dbk.flight = 'flLANDING'
    dbk.localname = 'in_TFJiterate'
    dbk.delayReleaseDestroy = True
    OA.addDataBlocks(G, nc, dbk)  # From SetupBtForkJoin or self
    dbk = copy.deepcopy(dbk_globald)
    dbk.flight = 'flLANDING'
    dbk.localname = 'in_globald'
    dbk.delayReleaseDestroy = True

    OA.addDataBlocks(G, nc, dbk)
    fortext = 'int btFoliationIndex; for(btFoliationIndex=0; btFoliationIndex < Nfoliation; ++btFoliationIndex)'
    OA.addFORconditionText(G, nc, fortext)

    dbk = copy.deepcopy(dbk_TFJiterate)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_TFJiterate'
    OA.addDataBlocks(G, nc, dbk)  # To self
    dbk = copy.deepcopy(dbk_globald)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_globald'
    OA.addDataBlocks(G, nc, dbk)
    forkFORt = 'err = btForkFOR(OA_edtTypeNb, OA_DBG_thisEDT, btFoliationIndex, in_TFJiterate, o_TFJiterate);'
    OA.addCustomText(G, nc, forkFORt)
    copy_globals = 'copy_globalData(in_globald, o_globald);'
    OA.addCustomText(G, nc, copy_globals)

    nc += 1
    taskName = "BtForkELSE"
    OA.graphAddNode(G, nc, taskName)
    # DBK local names are taken care off by the IF-THEN edt called "btFork".
    dbk = copy.deepcopy(dbk_TFJiterate)
    dbk.flight = 'flLANDING'
    dbk.localname = 'in_TFJiterate'
    OA.addDataBlocks(G, nc, dbk)  # From self BtForkIF
    dbk = copy.deepcopy(dbk_TFJiterate)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_TFJiterate'
    OA.addDataBlocks(G, nc, dbk)  # To BtForkTransition
    dbk = copy.deepcopy(dbk_globald)
    dbk.flight = 'flLANDING'
    dbk.localname = 'in_globald'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_globald)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_globald'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_gDone)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_gDone'
    OA.addDataBlocks(G, nc, dbk)  # To BtJoinIFTHEN
    btForkElseText = 'err = btForkElse(OA_edtTypeNb, OA_DBG_thisEDT, in_TFJiterate, ' + OA.makeGuidEdtname(
        "BtJoinIFTHEN") + ', o_TFJiterate, o_gDone);'
    OA.addCustomText(G, nc, btForkElseText)
    copy_globals = 'copy_globalData(in_globald, o_globald);'
    OA.addCustomText(G, nc, copy_globals)

    nc += 1
    taskName = "BtForkTransition_Start"
    OA.graphAddNode(G, nc, taskName)
    dbk = copy.deepcopy(dbk_TFJiterate)
    dbk.flight = 'flTAGO'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_globald)
    dbk.flight = 'flTAGO'
    dbk.localname = 'io_globald'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_gDone)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_gDone'
    OA.addDataBlocks(G, nc, dbk)
    transitStart_text = '*o_gDone = ' + OA.makeGuidEdtname(
        "BtForkTransition_Stop") + ';'
    OA.addCustomText(G, nc, transitStart_text)

    nc += 1
    taskName = "BtForkTransition_Stop"
    OA.graphAddNode(G, nc, taskName)
    dbk = copy.deepcopy(dbk_TFJiterate)
    dbk.flight = 'flLANDING'
    dbk.localname = 'in_TFJiterate'
    OA.addDataBlocks(G, nc, dbk)  # From BtForkELSE
    dbk = copy.deepcopy(dbk_globald)
    dbk.flight = 'flLANDING'
    dbk.localname = 'in_globald'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_work2)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_work2'
    OA.addDataBlocks(G, nc, dbk)  # To BtJoinIFTHEN
    dbk = copy.deepcopy(dbk_work)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_work'
    OA.addDataBlocks(G, nc, dbk)  # To BtJoinIFTHEN
    guid_BtJoinIFTHEN = OA.makeGuidEdtname('BtJoinIFTHEN')
    transit_whereToText = 'ocrGuid_t ' + guid_BtJoinIFTHEN + '; GUID_ASSIGN_VALUE(' + guid_BtJoinIFTHEN + ', in_TFJiterate->whereToGoWhenFalse);'
    OA.addCustomText(G, nc, transit_whereToText)
    transitText = 'err = transitionBTFork(OA_edtTypeNb, OA_DBG_thisEDT, in_TFJiterate, o_work, o_work2);'
    OA.addCustomText(G, nc, transitText)

    nc += 1
    taskName = "BtJoinIFTHEN"
    OA.graphAddNode(G, nc, taskName)
    dbk = copy.deepcopy(dbk_gDone)
    dbk.flight = 'flLANDING'
    dbk.localname = 'in_gDone'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_work)
    dbk.flight = 'flLANDING'
    dbk.localname = 'in_workLeft'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_work2)
    dbk.flight = 'flLANDING'
    dbk.localname = 'in_workRight'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_work)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_work'
    OA.addDataBlocks(G, nc, dbk)
    # dbk = copy.deepcopy(dbk_nullGuid); dbk.flight = 'flTAKEOFF';  <-- This is the NULL_GUID used to link to the ELSE clause
    OA.addIFconditionText(
        G, nc, 'NOTA_BTindex != get_parent_index(in_workLeft->btindex)')
    joinIFTHEN_Text = 'err = joinOperationIFTHEN(OA_edtTypeNb, OA_DBG_thisEDT, *in_workLeft, *in_workRight, o_work);'
    OA.addCustomText(G, nc, joinIFTHEN_Text)
    guid_BtJoinIFTHEN = OA.makeGuidEdtname("BtJoinIFTHEN")
    btJoinIF_whereToGo = 'ocrGuid_t ' + guid_BtJoinIFTHEN + '; GUID_ASSIGN_VALUE(' + guid_BtJoinIFTHEN + ', *in_gDone);'
    OA.addCustomText(G, nc, btJoinIF_whereToGo)
    btJoin_which_slot = 'unsigned int slot_for_work = btCalculateJoinIndex(in_workLeft->btindex);'
    OA.addCustomText(G, nc, btJoin_which_slot)

    nc += 1
    taskName = "BtJoinELSE"
    OA.graphAddNode(G, nc, taskName)
    dbk = copy.deepcopy(dbk_gDone)
    dbk.flight = 'flLANDING'
    dbk.localname = 'in_gDone'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_work)
    dbk.flight = 'flLANDING'
    dbk.localname = 'in_workLeft'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_work2)
    dbk.flight = 'flLANDING'
    dbk.localname = 'in_workRight'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_work)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_work'
    OA.addDataBlocks(G, nc, dbk)
    joinText = 'err = joinOperationELSE(OA_edtTypeNb, OA_DBG_thisEDT, *in_workLeft, *in_workRight, o_work);'
    OA.addCustomText(G, nc, joinText)
    g_ConcludeBtForkJoin = OA.makeGuidEdtname("ConcludeBtForkJoin")
    btJoinELSE_whereToGo = 'ocrGuid_t ' + g_ConcludeBtForkJoin + '; GUID_ASSIGN_VALUE(' + g_ConcludeBtForkJoin + ', *in_gDone);'
    OA.addCustomText(G, nc, btJoinELSE_whereToGo)

    # ==============================================================================
    # ==============================================================================
    # Tail recursion used to provide an execution path for each rank
    # It is inserted between BtForkTransition_Start and BtForkTransition_Stop
    # ----- Data Blocks
    dbk = OA.ocrDataBlock()
    dbk.name = 'NULL_GUID'
    dbk_nullGuid = dbk

    dbk = OA.ocrDataBlock()
    dbk.name = 'TailRecurIterate'
    dbk.count = 1
    dbk.type = 'TailRecurIterate_t'
    dbk_tailRecurIterate = dbk

    # ----- NODES
    nc += 1
    taskName = "setupTailRecursion"
    OA.graphAddNode(G, nc, taskName)
    dbk = copy.deepcopy(dbk_gDone)
    dbk.flight = 'flTAGO'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_globald)
    dbk.flight = 'flTAGO'
    dbk.localname = 'io_globald'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_tailRecurIterate)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_tailRecurIterate'
    OA.addDataBlocks(G, nc, dbk)
    tailRecurSetupt = 'err = tailRecurInitialize(o_tailRecurIterate, '
    tailRecurSetupt += OA.makeGuidEdtname(
        "concludeTailRecursion") + ', io_globald); IFEB;'
    OA.addCustomText(G, nc, tailRecurSetupt)

    nc += 1
    taskName = "tailRecursionIFThen"
    OA.graphAddNode(G, nc, taskName)
    dbk = copy.deepcopy(dbk_globald)
    dbk.flight = 'flTAGO'
    dbk.localname = 'io_globald'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_tailRecurIterate)
    dbk.flight = 'flTAGO'
    dbk.localname = 'io_tailRecurIterate'
    dbk.addLocalText('ocrGuid_t ' +
                     OA.makeGuidEdtname("concludeTailRecursion") +
                     ' = io_tailRecurIterate->whereToGoWhenDone;')
    OA.addDataBlocks(
        G, nc, dbk
    )  # This DBK guid will be needed by the tailRecursionELSE part of this EDT.
    tailRecurCondition_text = 'tailRecurCondition(io_tailRecurIterate)'
    OA.addIFconditionText(G, nc, tailRecurCondition_text)
    tailRecurTHEN_text = 'err = tailRecurIfThenClause(io_tailRecurIterate); IFEB;'
    OA.addCustomText(G, nc, tailRecurTHEN_text)

    nc += 1
    taskName = "tailRecursionELSE"
    OA.graphAddNode(G, nc, taskName)
    # DBK local names are taken care off by the IF-THEN edt called "tailRecursionIFThen".
    dbk = copy.deepcopy(dbk_tailRecurIterate)
    dbk.flight = 'flLANDING'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_globald)
    dbk.flight = 'flTAGO'
    dbk.localname = 'io_globald'
    OA.addDataBlocks(G, nc, dbk)
    tailRecurELSE_text = 'err = tailRecurElseClause(io_tailRecurIterate); IFEB;'
    OA.addCustomText(G, nc, tailRecurELSE_text)

    nc += 1
    taskName = "tailRecurTransitBEGIN"
    OA.graphAddNode(G, nc, taskName)
    dbk = copy.deepcopy(dbk_tailRecurIterate)
    dbk.flight = 'flTAGO'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_globald)
    dbk.flight = 'flTAGO'
    dbk.localname = 'io_globald'
    OA.addDataBlocks(G, nc, dbk)

    nc += 1
    taskName = "tailRecurTransitEND"
    OA.graphAddNode(G, nc, taskName)
    dbk = copy.deepcopy(dbk_tailRecurIterate)
    dbk.flight = 'flTAGO'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_globald)
    dbk.flight = 'flTAGO'
    dbk.localname = 'io_globald'
    OA.addDataBlocks(G, nc, dbk)

    nc += 1
    taskName = "concludeTailRecursion"
    OA.graphAddNode(G, nc, taskName)
    dbk = copy.deepcopy(dbk_globald)
    dbk.flight = 'flTAGO'
    dbk.localname = 'io_globald'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_gDone)
    dbk.flight = 'flLANDING'
    dbk.localname = 'in_gDone'
    OA.addDataBlocks(G, nc, dbk)
    OA.addCustomText(G, nc, 'err = tailRecurConclude(); IFEB;')
    dbk.addLocalText('ocrGuid_t ' +
                     OA.makeGuidEdtname("BtForkTransition_Stop") +
                     ' = *in_gDone;')

    # ==============================================================================
    # ==============================================================================
    # Fork-Join tree for the distribution of MPI ranks
    # ----- EDGES
    ledg = OA.graphAddEdge(G, "mainEdt", "SetupBtForkJoin", "gDone")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('gDone')
    ledg = OA.graphAddEdge(G, "mainEdt", "SetupBtForkJoin", "GlobalD")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('GlobalD')
    ledg = OA.graphAddEdge(G, "mainEdt", "finalEDT", "NULL_GUID")
    OA.getEvent(G, ledg).eflag = 'EVT_PROP_NONE'
    OA.getEvent(G, ledg).satisfy = 'NULL_GUID'

    ledg = OA.graphAddEdge(G, "SetupBtForkJoin", "ConcludeBtForkJoin", "gDone")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('gDone')
    ledg = OA.graphAddEdge(G, "SetupBtForkJoin", "ConcludeBtForkJoin",
                           "RefTCsum")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('RefTCsum')

    ledg = OA.graphAddEdge(G, "SetupBtForkJoin", "BtForkIF", "GlobalD")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('GlobalD')
    btForkIF_global_input_edge = ledg[
        0]  # This takes only the edge out of the labelled edge.
    ledg = OA.graphAddEdge(G, "SetupBtForkJoin", "BtForkIF", "TFJiterate")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('TFJiterate')
    btForkIF_main_input_edge = ledg[
        0]  # This takes only the edge out of the labelled edge.

    ledg = OA.graphAddEdge(G, "ConcludeBtForkJoin", "finalEDT", "NULL_GUID")
    OA.getEvent(G, ledg).eflag = 'EVT_PROP_NONE'
    OA.getEvent(G, ledg).satisfy = 'NULL_GUID'
    OA.getEvent(G, ledg).fertile = False

    ledg = OA.graphAddEdge(G, "BtForkIF", "BtForkELSE", "NULL_GUID")
    OA.getEdge(G, ledg[0])["leads_to_ElseClause"] = True

    ledg = OA.graphAddEdge(G, "BtForkIF", "BtForkFOR", "TFJiterate")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('TFJiterate')
    ledg = OA.graphAddEdge(G, "BtForkIF", "BtForkFOR", "GlobalD")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('GlobalD')
    ledg = OA.graphAddEdge(G, "BtForkIF", "BtJoinIFTHEN", "gDone")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('gDone')
    btJoin_gDone_main_input_edge = ledg[0]

    ledg = OA.graphAddEdge(G, "BtForkFOR", "BtForkIF", "TFJiterate")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('TFJiterate')
    OA.sharedConx(G, ledg[0]).append(btForkIF_main_input_edge)
    ledg = OA.graphAddEdge(G, "BtForkFOR", "BtForkIF", "GlobalD")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('GlobalD')
    OA.sharedConx(G, ledg[0]).append(btForkIF_global_input_edge)

    ledg = OA.graphAddEdge(G, "BtForkELSE", "BtJoinIFTHEN", "gDone")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('gDone')
    OA.sharedConx(G, ledg[0]).append(btJoin_gDone_main_input_edge)

    ledg = OA.graphAddEdge(G, "BtForkELSE", "BtForkTransition_Start",
                           "TFJiterate")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('TFJiterate')
    ledg = OA.graphAddEdge(G, "BtForkELSE", "BtForkTransition_Start",
                           "GlobalD")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('GlobalD')

    ledg = OA.graphAddEdge(G, "BtForkTransition_Start",
                           "BtForkTransition_Stop", "TFJiterate")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('TFJiterate')

    #    Old code
    #    ledg = OA.graphAddEdge(G, "BtForkTransition_Start", "BtForkTransition_Stop", "GlobalD")
    #    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'; OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('GlobalD')
    #This is where we stitch in the tail recursion.
    ledg = OA.graphAddEdge(G, "BtForkTransition_Start", "setupTailRecursion",
                           "GlobalD")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('GlobalD')
    ledg = OA.graphAddEdge(G, "BtForkTransition_Start", "setupTailRecursion",
                           "gDone")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('gDone')

    ledg = OA.graphAddEdge(G, "BtForkTransition_Stop", "BtJoinIFTHEN",
                           "TCsum2")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('TCsum2')
    OA.getEvent(G, ledg).fertile = False
    btFork_transition_to_btJoinIF_main_edge2 = ledg[0]
    ledg = OA.graphAddEdge(G, "BtForkTransition_Stop", "BtJoinIFTHEN", "TCsum")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('TCsum')
    OA.getEvent(G, ledg).fertile = False
    btFork_transition_to_btJoinIF_main_edge1 = ledg[0]

    ledg = OA.graphAddEdge(G, "BtJoinIFTHEN", "BtJoinELSE", "NULL_GUID")
    OA.getEdge(G, ledg[0])["leads_to_ElseClause"] = True
    ledg = OA.graphAddEdge(G, "BtJoinIFTHEN", "BtJoinIFTHEN", "TCsum")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('TCsum')
    OA.getEvent(G, ledg).fertile = False
    OA.getEvent(G, ledg).user_slotnb_text = 'slot_for_work'
    OA.sharedConx(G, ledg[0]).append(btFork_transition_to_btJoinIF_main_edge1)

    ledg = OA.graphAddEdge(G, "BtJoinELSE", "ConcludeBtForkJoin", "TCsum")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('TCsum')
    OA.getEvent(G, ledg).fertile = False

    # ==============================================================================
    # ==============================================================================
    # Tail recursion used to provide an execution path for each rank
    # It is inserted between BtForkTransition_Start and BtForkTransition_Stop
    # ----- EDGES
    ledg = OA.graphAddEdge(G, "BtForkTransition_Start", "setupTailRecursion",
                           "GlobalD")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('GlobalD')

    ledg = OA.graphAddEdge(G, "setupTailRecursion", "concludeTailRecursion",
                           "gDone")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.contextedGuid(
        OA.GBL.DBK_structName + '->', OA.makeGuidDataBlockname('gDone'), 'DBK')

    ledg = OA.graphAddEdge(G, "setupTailRecursion", "tailRecursionIFThen",
                           "TailRecurIterate")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RW'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('TailRecurIterate')
    tailRecur_main_iteration_edge = ledg[
        0]  # This takes only the edge out of the labelled edge.

    ledg = OA.graphAddEdge(G, "setupTailRecursion", "tailRecursionIFThen",
                           "GlobalD")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('GlobalD')
    tailRecur_main_globald_edge = ledg[
        0]  # This takes only the edge out of the labelled edge.

    ledg = OA.graphAddEdge(G, "tailRecursionIFThen", "tailRecurTransitBEGIN",
                           "TailRecurIterate")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.contextedGuid(
        OA.GBL.DBK_structName + '->',
        OA.makeGuidDataBlockname('TailRecurIterate'), 'DBK')

    ledg = OA.graphAddEdge(G, "tailRecurTransitBEGIN", "tailRecurTransitEND",
                           "TailRecurIterate")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.contextedGuid(
        OA.GBL.DBK_structName + '->',
        OA.makeGuidDataBlockname('TailRecurIterate'), 'DBK')

    ledg = OA.graphAddEdge(G, "tailRecurTransitEND", "tailRecursionIFThen",
                           "TailRecurIterate")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RW'
    OA.getEvent(G, ledg).satisfy = OA.contextedGuid(
        OA.GBL.DBK_structName + '->',
        OA.makeGuidDataBlockname('TailRecurIterate'), 'DBK')
    OA.sharedConx(G, ledg[0]).append(tailRecur_main_iteration_edge)

    ledg = OA.graphAddEdge(G, "tailRecursionIFThen", "tailRecurTransitBEGIN",
                           "GlobalD")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.contextedGuid(
        OA.GBL.DBK_structName + '->', OA.makeGuidDataBlockname('GlobalD'),
        'DBK')

    ledg = OA.graphAddEdge(G, "tailRecurTransitBEGIN", "tailRecurTransitEND",
                           "GlobalD")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.contextedGuid(
        OA.GBL.DBK_structName + '->', OA.makeGuidDataBlockname('GlobalD'),
        'DBK')

    ledg = OA.graphAddEdge(G, "tailRecurTransitEND", "tailRecursionIFThen",
                           "GlobalD")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.contextedGuid(
        OA.GBL.DBK_structName + '->', OA.makeGuidDataBlockname('GlobalD'),
        'DBK')
    OA.sharedConx(G, ledg[0]).append(tailRecur_main_globald_edge)

    ledg = OA.graphAddEdge(G, "tailRecursionIFThen", "tailRecursionELSE",
                           "NULL_GUID")
    OA.getEdge(G, ledg[0])["leads_to_ElseClause"] = True

    ledg = OA.graphAddEdge(G, "tailRecursionELSE", "concludeTailRecursion",
                           "GlobalD")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.contextedGuid(
        OA.GBL.DBK_structName + '->', OA.makeGuidDataBlockname('GlobalD'),
        'DBK')
    OA.getEvent(G, ledg).fertile = False

    ledg = OA.graphAddEdge(G, "concludeTailRecursion", "BtForkTransition_Stop",
                           "GlobalD")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.contextedGuid(
        OA.GBL.DBK_structName + '->', OA.makeGuidDataBlockname('GlobalD'),
        'DBK')
    OA.getEvent(G, ledg).fertile = False

    # ==============================================================================
    # ==============================================================================
    # ==============================================================================
    # ==============================================================================
    # ==============================================================================
    # ----- WORK
    erri = 0
    while not erri:
        if False: OA.printGraph(G)  # Just to check if the inputs are ok.

        erri = OA.OCRanalysis(G)
        if erri: break

        if False: OA.printGraph(G)
        if True:
            erri = OA.outputDot(G, "z_mpiranks_inOcr.dot")
            if erri: break
        if True:
            erri = OA.outputOCR(G, "z_mpiranks_inOcr.c")
            if erri: break

        if False: OA.printGraph(G)

        break  # while not erri
    OA.errmsg(erri)
    return erri
Пример #6
0
def theMain():

    SLOT4REDUCTION = 4

    OA.GBL.insert_debug_code = 0

    G = OA.GraphTool.DiGraph()

    OA.setupGraph(G, "utest_DaveReduction")
    OA.GBL.app_ocr_util_filename = 'app_ocr_util.h'

    OA.addHeader(G, ' ')  # Just a blank line
    OA.addHeader(G, '#define ENABLE_EXTENSION_LABELING')
    OA.addHeader(G, '#include "extensions/ocr-labeling.h"')
    OA.addHeader(G, ' ')  # Just a blank line
    OA.addHeader(G, '#include "utest_reduction.h"')
    OA.addHeader(G, '#include "reduction.h"')
    OA.addHeader(G, ' ')  # Just a blank line
    OA.addHeader(G, '#define NRANK 2')
    OA.addHeader(G, '#define SzVEC 3')
    OA.addHeader(G, ' ')  # Just a blank line

    # ----- Data Blocks
    dbk = OA.ocrDataBlock()
    dbk.name = 'NULL_GUID'
    dbk_nullGuid = dbk

    dbk = OA.ocrDataBlock()
    dbk.name = 'workLeft'
    dbk.count = 'SzVEC*sizeof(ReducValue_t)'
    dbk.type = 'ReducValue_t'
    dbk_workLeft = dbk
    dbk = OA.ocrDataBlock()
    dbk.name = 'workRight'
    dbk.count = 'SzVEC*sizeof(ReducValue_t)'
    dbk.type = 'ReducValue_t'
    dbk_workRight = dbk

    dbk = OA.ocrDataBlock()
    dbk.name = 'doneLeft'
    dbk.count = 1
    dbk.type = 'ocrGuid_t'
    dbk_doneLeft = dbk
    dbk = OA.ocrDataBlock()
    dbk.name = 'doneRight'
    dbk.count = 1
    dbk.type = 'ocrGuid_t'
    dbk_doneRight = dbk

    dbk = OA.ocrDataBlock()
    dbk.name = 'sum'
    dbk.count = 1
    dbk.type = 'ReducSum_t'
    dbk_sum = dbk

    dbk = OA.ocrDataBlock()
    dbk.name = 'sharedG'
    dbk.count = 1
    dbk.type = 'DReduct_shared_t'
    dbk_sharedG = dbk
    dbk = OA.ocrDataBlock()
    dbk.name = 'sharedR'
    dbk.count = 1
    dbk.type = 'DReduct_shared_t'
    dbk_sharedR = dbk
    dbk = OA.ocrDataBlock()
    dbk.name = 'sharedL'
    dbk.count = 1
    dbk.type = 'DReduct_shared_t'
    dbk_sharedL = dbk

    dbk = OA.ocrDataBlock()
    dbk.name = 'ReducPrivate'
    dbk.count = 1
    dbk.type = 'reductionPrivate_t'
    dbk_ReducPrivate = dbk

    # ----- NODES
    nc = OA.GBL.MAINNODE
    taskName = "mainEdt"
    OA.graphAddNode(G, nc, taskName)
    dbk = copy.deepcopy(dbk_workLeft)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_workLeft'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_workRight)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_workRight'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_doneLeft)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_doneLeft'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_doneRight)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_doneRight'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_sharedG)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_sharedG'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_sharedL)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_sharedL'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_sharedR)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_sharedR'
    OA.addDataBlocks(G, nc, dbk)
    toFinalLeft = 'GUID_ASSIGN_VALUE(*o_doneLeft, ' + OA.makeGuidEdtname(
        "finalEDT") + ');'
    OA.addCustomText(G, nc, toFinalLeft)
    toFinalRight = 'GUID_ASSIGN_VALUE(*o_doneRight, ' + OA.makeGuidEdtname(
        "finalEDT") + ');'
    OA.addCustomText(G, nc, toFinalRight)
    mainedtTxt = 'err = utest_mainedt(NRANK, 1, SzVEC, o_workLeft,o_workRight, o_sharedG,o_sharedL,o_sharedR); IFEB;'
    OA.addCustomText(G, nc, mainedtTxt)

    nc = OA.GBL.FINALNODE
    taskName = "finalEDT"
    OA.graphAddNode(G, nc, taskName)
    dbk = copy.deepcopy(dbk_sharedG)
    dbk.flight = 'flLANDING'
    dbk.localname = 'in_shared'
    OA.addDataBlocks(G, nc, dbk)
    finalEDTtxt = 'err = destroy_DReduct_shared(in_shared); IFEB;'
    OA.addCustomText(G, nc, finalEDTtxt)

    nc += 1
    taskName = "LeftEDT_init"
    OA.graphAddNode(G, nc, taskName)
    dbk = copy.deepcopy(dbk_sharedL)
    dbk.flight = 'flLANDING'
    dbk.localname = 'io_sharedL'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_workLeft)
    dbk.flight = 'flTAGO'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_doneLeft)
    dbk.flight = 'flTAGO'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_ReducPrivate)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_ReducPrivate'
    OA.addDataBlocks(G, nc, dbk)
    rankTxt = 'unsigned long rank = 0;'
    OA.addCustomText(G, nc, rankTxt)
    leftEDT_init = 'err = reduction_init(rank, io_sharedL, o_ReducPrivate); IFEB;'
    OA.addCustomText(G, nc, leftEDT_init)

    nc += 1
    taskName = "RightEDT_init"
    OA.graphAddNode(G, nc, taskName)
    dbk = copy.deepcopy(dbk_sharedR)
    dbk.flight = 'flLANDING'
    dbk.localname = 'io_sharedR'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_workRight)
    dbk.flight = 'flTAGO'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_doneRight)
    dbk.flight = 'flTAGO'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_ReducPrivate)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_ReducPrivate'
    OA.addDataBlocks(G, nc, dbk)
    rankTxt = 'unsigned long rank = 1;'
    OA.addCustomText(G, nc, rankTxt)
    rightEDT_init = 'err = reduction_init(rank, io_sharedR, o_ReducPrivate); IFEB;'
    OA.addCustomText(G, nc, rightEDT_init)

    nc += 1
    taskName = "LeftEDT_start"
    OA.graphAddNode(G, nc, taskName)
    dbk = copy.deepcopy(dbk_workLeft)
    dbk.flight = 'flTAGO'
    dbk.localname = 'io_workLeft'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_doneLeft)
    dbk.flight = 'flTAGO'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_ReducPrivate)
    dbk.flight = 'flTAGO'
    dbk.user2destroyORrelease = True
    dbk.localname = 'io_ReducPrivate'
    dbk.localnameGuid = 'guid_ReducPrivate_left'
    dbk.addLocalText(
        '//It is expected that the reduction library will release the ReducPrivate data block.'
    )
    dbk.addLocalText(
        '//-->????Should the ReducPrivate data block be sent to the ...stop EDT? What if we want to use it again?'
    )
    OA.addDataBlocks(G, nc, dbk)
    guid_LeftEDT_stop = OA.makeGuidEdtname('LeftEDT_stop')
    doLStart = 'err = compute_start(1, guid_ReducPrivate_left, io_ReducPrivate, SzVEC, io_workLeft, SLOT4REDUCTION-1,' + guid_LeftEDT_stop + '); IFEB;'
    OA.addCustomText(G, nc, doLStart)

    nc += 1
    taskName = "RightEDT_start"
    OA.graphAddNode(G, nc, taskName)
    dbk = copy.deepcopy(dbk_workRight)
    dbk.flight = 'flTAGO'
    dbk.localname = 'io_workRight'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_doneRight)
    dbk.flight = 'flTAGO'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_ReducPrivate)
    dbk.flight = 'flTAGO'
    dbk.user2destroyORrelease = True
    dbk.localname = 'io_ReducPrivate'
    dbk.localnameGuid = 'guid_ReducPrivate_right'
    dbk.addLocalText(
        '//It is expected that the reduction library will release the ReducPrivate data block.'
    )
    dbk.addLocalText(
        '//-->????Should the ReducPrivate data block be sent to the ...stop EDT? What if we want to use it again?'
    )
    OA.addDataBlocks(G, nc, dbk)
    guid_RightEDT_stop = OA.makeGuidEdtname('RightEDT_stop')
    doRStart = 'err = compute_start(1, guid_ReducPrivate_right, io_ReducPrivate, SzVEC, io_workRight, SLOT4REDUCTION-1, ' + guid_RightEDT_stop + '); IFEB;'
    OA.addCustomText(G, nc, doRStart)

    nc += 1
    taskName = "LeftEDT_stop"
    OA.graphAddNode(G, nc, taskName)
    OA.getMyTask(G, nc).depc = SLOT4REDUCTION
    dbk = copy.deepcopy(dbk_workLeft)
    dbk.flight = 'flTAGO'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_doneLeft)
    dbk.flight = 'flTAGO'
    dbk.localname = 'in_doneLeft'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_ReducPrivate)
    dbk.flight = 'flTAGO'
    dbk.localname = 'in_ReducPrivate'
    dbk.addLocalText(
        'ocrEdtDep_t IN_BY_USER_depv_sum = depv[SLOT4REDUCTION-1];  //This will be LANDING here.'
    )
    dbk.addLocalText('ocrGuid_t in_sum_guid = IN_BY_USER_depv_sum.guid;')
    dbk.addLocalText('ReducSum_t * in_sum = IN_BY_USER_depv_sum.ptr;')
    OA.addDataBlocks(G, nc, dbk)
    resultTxt = 'err = leftEDT_stop(in_ReducPrivate, in_sum, in_sum_guid); IFEB;'
    OA.addCustomText(G, nc, resultTxt)

    nc += 1
    taskName = "RightEDT_stop"
    OA.graphAddNode(G, nc, taskName)
    OA.getMyTask(G, nc).depc = SLOT4REDUCTION
    dbk = copy.deepcopy(dbk_workRight)
    dbk.flight = 'flTAGO'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_doneRight)
    dbk.flight = 'flTAGO'
    dbk.localname = 'in_doneRight'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_ReducPrivate)
    dbk.flight = 'flTAGO'
    dbk.localname = 'in_ReducPrivate'
    dbk.addLocalText(
        'ocrEdtDep_t IN_BY_USER_depv_sum = depv[SLOT4REDUCTION-1];  //This will be LANDING here.'
    )
    dbk.addLocalText('ocrGuid_t in_sum_guid = IN_BY_USER_depv_sum.guid;')
    dbk.addLocalText('ReducSum_t * in_sum = IN_BY_USER_depv_sum.ptr;')
    OA.addDataBlocks(G, nc, dbk)
    resultTxt = 'err = rightEDT_stop(in_ReducPrivate, in_sum, in_sum_guid); IFEB;'
    OA.addCustomText(G, nc, resultTxt)

    nc += 1
    taskName = "LeftEDT_start2"
    OA.graphAddNode(G, nc, taskName)
    dbk = copy.deepcopy(dbk_workLeft)
    dbk.flight = 'flTAGO'
    dbk.localname = 'io_workLeft'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_doneLeft)
    dbk.flight = 'flTAGO'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_ReducPrivate)
    dbk.flight = 'flTAGO'
    dbk.user2destroyORrelease = True
    dbk.localname = 'io_ReducPrivate'
    dbk.localnameGuid = 'guid_ReducPrivate_left'
    OA.addDataBlocks(G, nc, dbk)
    guid_LeftEDT_stop = OA.makeGuidEdtname('LeftEDT_stop2')
    doLStart2 = 'err = compute_start(2, guid_ReducPrivate_left, io_ReducPrivate, SzVEC, io_workLeft, SLOT4REDUCTION-1,' + guid_LeftEDT_stop + '); IFEB;'
    OA.addCustomText(G, nc, doLStart2)

    nc += 1
    taskName = "RightEDT_start2"
    OA.graphAddNode(G, nc, taskName)
    dbk = copy.deepcopy(dbk_workRight)
    dbk.flight = 'flTAGO'
    dbk.localname = 'io_workRight'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_doneRight)
    dbk.flight = 'flTAGO'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_ReducPrivate)
    dbk.flight = 'flTAGO'
    dbk.user2destroyORrelease = True
    dbk.localname = 'io_ReducPrivate'
    dbk.localnameGuid = 'guid_ReducPrivate_right'
    OA.addDataBlocks(G, nc, dbk)
    guid_RightEDT_stop = OA.makeGuidEdtname('RightEDT_stop2')
    doRStart = 'err = compute_start(2, guid_ReducPrivate_right, io_ReducPrivate, SzVEC, io_workRight, SLOT4REDUCTION-1, ' + guid_RightEDT_stop + '); IFEB;'
    OA.addCustomText(G, nc, doRStart)

    nc += 1
    taskName = "LeftEDT_stop2"
    OA.graphAddNode(G, nc, taskName)
    OA.getMyTask(G, nc).depc = SLOT4REDUCTION
    dbk = copy.deepcopy(dbk_workLeft)
    dbk.flight = 'flLANDING'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_doneLeft)
    dbk.flight = 'flLANDING'
    dbk.localname = 'in_doneLeft'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_ReducPrivate)
    dbk.flight = 'flLANDING'
    dbk.localname = 'in_ReducPrivate'
    dbk.addLocalText(
        'ocrEdtDep_t IN_BY_USER_depv_sum = depv[SLOT4REDUCTION-1];  //This will be LANDING here.'
    )
    dbk.addLocalText('ocrGuid_t in_sum_guid = IN_BY_USER_depv_sum.guid;')
    dbk.addLocalText('ReducSum_t * in_sum = IN_BY_USER_depv_sum.ptr;')
    OA.addDataBlocks(G, nc, dbk)
    guid_finalEDT = OA.makeGuidEdtname('finalEDT')
    doneText = 'ocrGuid_t ' + guid_finalEDT + '; GUID_ASSIGN_VALUE(' + guid_finalEDT + ', *in_doneLeft);'
    OA.addCustomText(G, nc, doneText)
    resultTxt = 'err = leftEDT_stop(in_ReducPrivate, in_sum, in_sum_guid); IFEB;'
    OA.addCustomText(G, nc, resultTxt)
    releaseText = '//Somehow release channel event in_reducPrivate->returnEVT'
    OA.addCustomText(G, nc, releaseText)

    nc += 1
    taskName = "RightEDT_stop2"
    OA.graphAddNode(G, nc, taskName)
    OA.getMyTask(G, nc).depc = SLOT4REDUCTION
    dbk = copy.deepcopy(dbk_workRight)
    dbk.flight = 'flLANDING'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_doneRight)
    dbk.flight = 'flLANDING'
    dbk.localname = 'in_doneRight'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_ReducPrivate)
    dbk.flight = 'flLANDING'
    dbk.localname = 'in_ReducPrivate'
    dbk.addLocalText(
        'ocrEdtDep_t IN_BY_USER_depv_sum = depv[SLOT4REDUCTION-1];  //This will be LANDING here.'
    )
    dbk.addLocalText('ocrGuid_t in_sum_guid = IN_BY_USER_depv_sum.guid;')
    dbk.addLocalText('ReducSum_t * in_sum = IN_BY_USER_depv_sum.ptr;')
    OA.addDataBlocks(G, nc, dbk)
    guid_finalEDT = OA.makeGuidEdtname('finalEDT')
    doneText = 'ocrGuid_t ' + guid_finalEDT + '; GUID_ASSIGN_VALUE(' + guid_finalEDT + ', *in_doneRight);'
    OA.addCustomText(G, nc, doneText)
    resultTxt = 'err = rightEDT_stop(in_ReducPrivate, in_sum, in_sum_guid); IFEB;'
    OA.addCustomText(G, nc, resultTxt)
    releaseText = '//Somehow release channel event in_reducPrivate->returnEVT'
    OA.addCustomText(G, nc, releaseText)

    # ----- EDGES
    ledg = OA.graphAddEdge(G, "mainEdt", "finalEDT", "sharedG")
    OA.getEvent(G, ledg).accessmode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('sharedG')

    ledg = OA.graphAddEdge(G, "mainEdt", "LeftEDT_init", "workLeft")
    OA.getEvent(G, ledg).accessmode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('workLeft')
    ledg = OA.graphAddEdge(G, "mainEdt", "LeftEDT_init", "doneLeft")
    OA.getEvent(G, ledg).accessmode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('doneLeft')
    ledg = OA.graphAddEdge(G, "mainEdt", "LeftEDT_init", "sharedL")
    OA.getEvent(G, ledg).accessmode = 'DB_MODE_RW'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('sharedL')

    ledg = OA.graphAddEdge(G, "mainEdt", "RightEDT_init", "workRight")
    OA.getEvent(G, ledg).accessmode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('workRight')
    ledg = OA.graphAddEdge(G, "mainEdt", "RightEDT_init", "doneRight")
    OA.getEvent(G, ledg).accessmode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('doneRight')
    ledg = OA.graphAddEdge(G, "mainEdt", "RightEDT_init", "sharedR")
    OA.getEvent(G, ledg).accessmode = 'DB_MODE_RW'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('sharedR')

    ledg = OA.graphAddEdge(G, "LeftEDT_init", "LeftEDT_start", "workLeft")
    OA.getEvent(G, ledg).accessmode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('workLeft')
    ledg = OA.graphAddEdge(G, "LeftEDT_init", "LeftEDT_start", "doneLeft")
    OA.getEvent(G, ledg).accessmode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('doneLeft')
    ledg = OA.graphAddEdge(G, "LeftEDT_init", "LeftEDT_start", "ReducPrivate")
    OA.getEvent(G, ledg).accessmode = 'DB_MODE_RW'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('ReducPrivate')

    ledg = OA.graphAddEdge(G, "RightEDT_init", "RightEDT_start", "workRight")
    OA.getEvent(G, ledg).accessmode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('workRight')
    ledg = OA.graphAddEdge(G, "RightEDT_init", "RightEDT_start", "doneRight")
    OA.getEvent(G, ledg).accessmode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('doneRight')
    ledg = OA.graphAddEdge(G, "RightEDT_init", "RightEDT_start",
                           "ReducPrivate")
    OA.getEvent(G, ledg).accessmode = 'DB_MODE_RW'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('ReducPrivate')

    ledg = OA.graphAddEdge(G, "LeftEDT_start", "LeftEDT_stop", "workLeft")
    OA.getEvent(G, ledg).accessmode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('workLeft')
    ledg = OA.graphAddEdge(G, "LeftEDT_start", "LeftEDT_stop", "doneLeft")
    OA.getEvent(G, ledg).accessmode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('doneLeft')
    ledg = OA.graphAddEdge(G, "LeftEDT_start", "LeftEDT_stop", "ReducPrivate")
    OA.getEvent(G, ledg).accessmode = 'DB_MODE_RW'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('ReducPrivate')

    ledg = OA.graphAddEdge(G, "RightEDT_start", "RightEDT_stop", "workRight")
    OA.getEvent(G, ledg).accessmode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('workRight')
    ledg = OA.graphAddEdge(G, "RightEDT_start", "RightEDT_stop", "doneRight")
    OA.getEvent(G, ledg).accessmode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('doneRight')
    ledg = OA.graphAddEdge(G, "RightEDT_start", "RightEDT_stop",
                           "ReducPrivate")
    OA.getEvent(G, ledg).accessmode = 'DB_MODE_RW'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('ReducPrivate')

    ledg = OA.graphAddEdge(G, "LeftEDT_stop", "LeftEDT_start2", "workLeft")
    OA.getEvent(G, ledg).accessmode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('workLeft')
    ledg = OA.graphAddEdge(G, "LeftEDT_stop", "LeftEDT_start2", "doneLeft")
    OA.getEvent(G, ledg).accessmode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('doneLeft')
    ledg = OA.graphAddEdge(G, "LeftEDT_stop", "LeftEDT_start2", "ReducPrivate")
    OA.getEvent(G, ledg).accessmode = 'DB_MODE_RW'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('ReducPrivate')

    ledg = OA.graphAddEdge(G, "RightEDT_stop", "RightEDT_start2", "workRight")
    OA.getEvent(G, ledg).accessmode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('workRight')
    ledg = OA.graphAddEdge(G, "RightEDT_stop", "RightEDT_start2", "doneRight")
    OA.getEvent(G, ledg).accessmode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('doneRight')
    ledg = OA.graphAddEdge(G, "RightEDT_stop", "RightEDT_start2",
                           "ReducPrivate")
    OA.getEvent(G, ledg).accessmode = 'DB_MODE_RW'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('ReducPrivate')

    ledg = OA.graphAddEdge(G, "LeftEDT_start2", "LeftEDT_stop2", "workLeft")
    OA.getEvent(G, ledg).accessmode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('workLeft')
    ledg = OA.graphAddEdge(G, "LeftEDT_start2", "LeftEDT_stop2", "doneLeft")
    OA.getEvent(G, ledg).accessmode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('doneLeft')
    ledg = OA.graphAddEdge(G, "LeftEDT_start2", "LeftEDT_stop2",
                           "ReducPrivate")
    OA.getEvent(G, ledg).accessmode = 'DB_MODE_RW'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('ReducPrivate')

    ledg = OA.graphAddEdge(G, "RightEDT_start2", "RightEDT_stop2", "workRight")
    OA.getEvent(G, ledg).accessmode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('workRight')
    ledg = OA.graphAddEdge(G, "RightEDT_start2", "RightEDT_stop2", "doneRight")
    OA.getEvent(G, ledg).accessmode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('doneRight')
    ledg = OA.graphAddEdge(G, "RightEDT_start2", "RightEDT_stop2",
                           "ReducPrivate")
    OA.getEvent(G, ledg).accessmode = 'DB_MODE_RW'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('ReducPrivate')

    ledg = OA.graphAddEdge(G, "LeftEDT_stop2", "finalEDT", "NULL_GUID")
    OA.getEvent(G, ledg).eflag = 'EVT_PROP_NONE'
    OA.getEvent(G, ledg).satisfy = 'NULL_GUID'
    OA.getEvent(G, ledg).fertile = False
    ledg = OA.graphAddEdge(G, "RightEDT_stop2", "finalEDT", "NULL_GUID")
    OA.getEvent(G, ledg).eflag = 'EVT_PROP_NONE'
    OA.getEvent(G, ledg).satisfy = 'NULL_GUID'
    OA.getEvent(G, ledg).fertile = False

    # ----- WORK
    erri = 0
    while not erri:
        if True: OA.printGraph(G)  # Just to check if the inputs are ok.

        erri = OA.OCRanalysis(G)
        if erri: break

        if False: OA.printGraph(G)
        if True:
            erri = OA.outputDot(G, "z_utest_DaveReduction.dot")
            if erri: break
        if True:
            erri = OA.outputOCR(G, "z_utest_DaveReduction.c")
            if erri: break

        if False: OA.printGraph(G)

        break  # while not erri
    OA.errmsg(erri)
    return erri
Пример #7
0
def theMain():

    OA.GBL.insert_debug_code = 0

    G = OA.GraphTool.DiGraph()

    OA.setupGraph(G, "BinTree_ForkJoin")

    OA.addHeader(G, '#include "bintreeForkjoin.h" '
                 )  # This will be put at the beginning of the file
    OA.addHeader(
        G,
        '#define Nfoliation 2')  # If set to two that makes it a binary tree.

    # ----- Data Blocks
    dbk = OA.ocrDataBlock()
    dbk.name = 'NULL_GUID'
    dbk_nullGuid = dbk

    dbk = OA.ocrDataBlock()
    dbk.name = 'gDone'
    dbk.count = 1
    dbk.type = 'ocrGuid_t'
    dbk_gDone = dbk

    dbk = OA.ocrDataBlock()
    dbk.name = 'TFJiterate'
    dbk.count = 1
    dbk.type = 'TFJiterate_t'
    dbk_iterate = dbk
    dbk = OA.ocrDataBlock()
    dbk.name = 'TFJiterate2'
    dbk.count = 1
    dbk.type = 'TFJiterate_t'
    dbk_iterate2 = dbk

    dbk = OA.ocrDataBlock()
    dbk.name = 'Work'
    dbk.count = 1
    dbk.type = 'Work_t'
    dbk_work = dbk
    dbk = OA.ocrDataBlock()
    dbk.name = 'Work2'
    dbk.count = 1
    dbk.type = 'Work_t'
    dbk_work2 = dbk

    dbk = OA.ocrDataBlock()
    dbk.name = 'RefWork'
    dbk.count = 1
    dbk.type = 'Work_t'
    dbk_refwork = dbk

    # ----- NODES
    # NOTE: In as much as doable, the EDT are presented in a bracketing fashion.
    #       That is, assuming we have a sequence of EDTs as follows A->B->C->D->E
    #       Then the EDTs are presented as follows:  A,E,B,D,C
    #       For a linear sequence, that is of little importance; but for a more complex graph, bracketing
    #       makes it clear what are the EDTs acting as inputs and outputs.
    #
    # Always root the starting/root/main EDT at ID=0 = OA.GBL.MAINNODE
    # Always cap all ending EDT by the FinalEDT at ID=1 = OA.GBL.FINALNODE

    nc = OA.GBL.MAINNODE
    taskName = "mainEdt"
    OA.graphAddNode(G, nc, taskName)
    dbk = copy.deepcopy(dbk_nullGuid)
    dbk.flight = 'flTAKEOFF'
    OA.addDataBlocks(G, nc, dbk)  # To FinalEDT
    dbk = copy.deepcopy(dbk_gDone)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_gDone'
    OA.addDataBlocks(G, nc, dbk)  # To SetupBtForkJoin
    toFinalt = 'GUID_ASSIGN_VALUE(*o_gDone, ' + OA.makeGuidEdtname(
        "finalEDT") + ');'
    OA.addCustomText(G, nc, toFinalt)

    nc = OA.GBL.FINALNODE
    taskName = "finalEDT"
    OA.graphAddNode(G, nc, taskName)
    dbk = copy.deepcopy(dbk_nullGuid)
    dbk.flight = 'flLANDING'
    OA.addDataBlocks(G, nc, dbk)  # From ConcludeBtForkJoin
    dbk = copy.deepcopy(dbk_nullGuid)
    dbk.flight = 'flLANDING'
    OA.addDataBlocks(G, nc, dbk)  # From mainEdt

    nc += 1
    taskName = "SetupBtForkJoin"
    OA.graphAddNode(G, nc, taskName)
    dbk = copy.deepcopy(dbk_gDone)
    dbk.flight = 'flTAGO'
    OA.addDataBlocks(G, nc, dbk)  # Toward ConcludeBtForkJoin
    dbk = copy.deepcopy(dbk_refwork)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_refWork'
    OA.addDataBlocks(G, nc, dbk)  # To ConcludeBtForkJoin
    dbk = copy.deepcopy(dbk_iterate)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_iterate'
    OA.addDataBlocks(G, nc, dbk)  # To BtForkIF
    setupt = 'err = setupBtForkJoin(OA_edtTypeNb, OA_DBG_thisEDT, o_iterate, ' + OA.makeGuidEdtname(
        "ConcludeBtForkJoin") + ', add, add_zero, &o_refWork->result);'
    OA.addCustomText(G, nc, setupt)

    nc += 1
    taskName = "ConcludeBtForkJoin"
    OA.graphAddNode(G, nc, taskName)
    dbk = copy.deepcopy(dbk_nullGuid)
    dbk.flight = 'flTAKEOFF'
    OA.addDataBlocks(G, nc, dbk)  # To finalEDT
    dbk = copy.deepcopy(dbk_gDone)
    dbk.flight = 'flLANDING'
    dbk.localname = 'in_gDone'
    OA.addDataBlocks(G, nc, dbk)  # From SetupBtForkJoin
    dbk = copy.deepcopy(dbk_refwork)
    dbk.flight = 'flLANDING'
    dbk.localname = 'in_refwork'
    OA.addDataBlocks(G, nc, dbk)  # From SetupBtForkJoin
    dbk = copy.deepcopy(dbk_work)
    dbk.flight = 'flLANDING'
    dbk.localname = 'in_calculated'
    OA.addDataBlocks(G, nc, dbk)  # From BtJoinELSE
    guid_finalEDT = OA.makeGuidEdtname('finalEDT')
    doneText = 'ocrGuid_t ' + guid_finalEDT + '; GUID_ASSIGN_VALUE(' + guid_finalEDT + ', *in_gDone);'
    OA.addCustomText(G, nc, doneText)
    OA.addCustomText(
        G, nc,
        'err = concludeBtForkJoin(OA_edtTypeNb, OA_DBG_thisEDT, in_refwork->result, in_calculated->result); IFEB;'
    )

    nc += 1
    taskName = "BtForkIF"
    OA.graphAddNode(G, nc, taskName)
    dbk = copy.deepcopy(dbk_iterate)
    dbk.flight = 'flLANDING'
    dbk.localname = 'in_iterate'
    OA.addDataBlocks(G, nc, dbk)  # From SetupBtForkJoin or BtForkFOR
    dbk = copy.deepcopy(dbk_iterate)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_iterate'
    OA.addDataBlocks(G, nc, dbk)  # To BtForkFOR or BtForkELSE
    dbk = copy.deepcopy(dbk_gDone)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_gDone'
    OA.addDataBlocks(G, nc, dbk)  # To BtJoinIFTHEN
    #dbk = copy.deepcopy(dbk_nullGuid); dbk.flight = 'flTAKEOFF';  <-- This is the NULL_GUID used to link to the ELSE clause
    OA.addIFconditionText(
        G, nc, 'conditionBtFork(OA_edtTypeNb, OA_DBG_thisEDT, in_iterate)')
    iterText = 'err = btForkThen(OA_edtTypeNb, OA_DBG_thisEDT, in_iterate, ' + OA.makeGuidEdtname(
        "BtJoinIFTHEN") + ', o_iterate, o_gDone);'
    OA.addCustomText(G, nc, iterText)

    nc += 1
    taskName = "BtForkFOR"
    OA.graphAddNode(G, nc, taskName)
    dbk = copy.deepcopy(dbk_iterate)
    dbk.flight = 'flLANDING'
    dbk.localname = 'in_iterate'
    dbk.delayReleaseDestroy = True
    OA.addDataBlocks(G, nc, dbk)  # From SetupBtForkJoin or self
    fortext = 'int btFoliationIndex; for(btFoliationIndex=0; btFoliationIndex<Nfoliation; ++btFoliationIndex)'
    OA.addFORconditionText(G, nc, fortext)
    dbk = copy.deepcopy(dbk_iterate)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_iterate'
    OA.addDataBlocks(G, nc, dbk)  # To self
    forkFORt = 'err = btForkFOR(OA_edtTypeNb, OA_DBG_thisEDT, btFoliationIndex, in_iterate, o_iterate);'
    OA.addCustomText(G, nc, forkFORt)

    nc += 1
    taskName = "BtForkELSE"
    OA.graphAddNode(G, nc, taskName)
    # DBK local names are taken care off by the IF-THEN edt called "btFork".
    dbk = copy.deepcopy(dbk_iterate)
    dbk.flight = 'flLANDING'
    dbk.localname = 'in_iterate'
    OA.addDataBlocks(G, nc, dbk)  # From self BtForkIF
    dbk = copy.deepcopy(dbk_iterate)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_iterate'
    OA.addDataBlocks(G, nc, dbk)  # To BtForkTransition
    dbk = copy.deepcopy(dbk_gDone)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_gDone'
    OA.addDataBlocks(G, nc, dbk)  # To BtJoinIFTHEN
    btForkElseText = 'err = btForkElse(OA_edtTypeNb, OA_DBG_thisEDT, in_iterate, ' + OA.makeGuidEdtname(
        "BtJoinIFTHEN") + ', o_iterate, o_gDone);'
    OA.addCustomText(G, nc, btForkElseText)

    nc += 1
    taskName = "BtForkTransition"
    OA.graphAddNode(G, nc, taskName)
    dbk = copy.deepcopy(dbk_iterate)
    dbk.flight = 'flLANDING'
    dbk.localname = 'in_iterate'
    OA.addDataBlocks(G, nc, dbk)  # From BtForkELSE
    dbk = copy.deepcopy(dbk_work2)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_work2'
    OA.addDataBlocks(G, nc, dbk)  # To BtJoinIFTHEN
    dbk = copy.deepcopy(dbk_work)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_work'
    OA.addDataBlocks(G, nc, dbk)  # To BtJoinIFTHEN
    guid_BtJoinIFTHEN = OA.makeGuidEdtname('BtJoinIFTHEN')
    transit_whereToText = 'ocrGuid_t ' + guid_BtJoinIFTHEN + '; GUID_ASSIGN_VALUE(' + guid_BtJoinIFTHEN + ', in_iterate->whereToGoWhenFalse);'
    OA.addCustomText(G, nc, transit_whereToText)
    transitText = 'err = transitionBTFork(OA_edtTypeNb, OA_DBG_thisEDT, in_iterate, o_work, o_work2);'
    OA.addCustomText(G, nc, transitText)

    nc += 1
    taskName = "BtJoinIFTHEN"
    OA.graphAddNode(G, nc, taskName)
    dbk = copy.deepcopy(dbk_gDone)
    dbk.flight = 'flLANDING'
    dbk.localname = 'in_gDone'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_work)
    dbk.flight = 'flLANDING'
    dbk.localname = 'in_workLeft'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_work2)
    dbk.flight = 'flLANDING'
    dbk.localname = 'in_workRight'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_work)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_work'
    OA.addDataBlocks(G, nc, dbk)
    # dbk = copy.deepcopy(dbk_nullGuid); dbk.flight = 'flTAKEOFF';  <-- This is the NULL_GUID used to link to the ELSE clause
    OA.addIFconditionText(
        G, nc, 'NOTA_BTindex != get_parent_index(in_workLeft->btindex)')
    joinIFTHEN_Text = 'err = joinOperationIFTHEN(OA_edtTypeNb, OA_DBG_thisEDT, *in_workLeft, *in_workRight, o_work);'
    OA.addCustomText(G, nc, joinIFTHEN_Text)
    guid_BtJoinIFTHEN = OA.makeGuidEdtname("BtJoinIFTHEN")
    btJoinIF_whereToGo = 'ocrGuid_t ' + guid_BtJoinIFTHEN + '; GUID_ASSIGN_VALUE(' + guid_BtJoinIFTHEN + ', *in_gDone);'
    OA.addCustomText(G, nc, btJoinIF_whereToGo)
    btJoin_which_slot = 'unsigned int slot_for_work = btCalculateJoinIndex(in_workLeft->btindex);'
    OA.addCustomText(G, nc, btJoin_which_slot)

    nc += 1
    taskName = "BtJoinELSE"
    OA.graphAddNode(G, nc, taskName)
    dbk = copy.deepcopy(dbk_gDone)
    dbk.flight = 'flLANDING'
    dbk.localname = 'in_gDone'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_work)
    dbk.flight = 'flLANDING'
    dbk.localname = 'in_workLeft'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_work2)
    dbk.flight = 'flLANDING'
    dbk.localname = 'in_workRight'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_work)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_work'
    OA.addDataBlocks(G, nc, dbk)
    joinText = 'err = joinOperationELSE(OA_edtTypeNb, OA_DBG_thisEDT, *in_workLeft, *in_workRight, o_work);'
    OA.addCustomText(G, nc, joinText)
    g_ConcludeBtForkJoin = OA.makeGuidEdtname("ConcludeBtForkJoin")
    btJoinELSE_whereToGo = 'ocrGuid_t ' + g_ConcludeBtForkJoin + '; GUID_ASSIGN_VALUE(' + g_ConcludeBtForkJoin + ', *in_gDone);'
    OA.addCustomText(G, nc, btJoinELSE_whereToGo)

    # ----- EDGES
    ledg = OA.graphAddEdge(G, "mainEdt", "SetupBtForkJoin", "gDone")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('gDone')
    ledg = OA.graphAddEdge(G, "mainEdt", "finalEDT", "NULL_GUID")
    OA.getEvent(G, ledg).eflag = 'EVT_PROP_NONE'
    OA.getEvent(G, ledg).satisfy = 'NULL_GUID'

    ledg = OA.graphAddEdge(G, "SetupBtForkJoin", "ConcludeBtForkJoin", "gDone")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('gDone')
    ledg = OA.graphAddEdge(G, "SetupBtForkJoin", "ConcludeBtForkJoin",
                           "RefWork")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('RefWork')
    ledg = OA.graphAddEdge(G, "SetupBtForkJoin", "BtForkIF", "TFJiterate")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('TFJiterate')
    btForkIF_main_input_edge = ledg[
        0]  # This takes only the edge out of the labelled edge.

    ledg = OA.graphAddEdge(G, "ConcludeBtForkJoin", "finalEDT", "NULL_GUID")
    OA.getEvent(G, ledg).eflag = 'EVT_PROP_NONE'
    OA.getEvent(G, ledg).satisfy = 'NULL_GUID'
    OA.getEvent(G, ledg).fertile = False

    ledg = OA.graphAddEdge(G, "BtForkIF", "BtForkELSE", "NULL_GUID")
    OA.getEdge(G, ledg[0])["leads_to_ElseClause"] = True
    ledg = OA.graphAddEdge(G, "BtForkIF", "BtForkFOR", "TFJiterate")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('TFJiterate')
    ledg = OA.graphAddEdge(G, "BtForkIF", "BtJoinIFTHEN", "gDone")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('gDone')
    btJoin_gDone_main_input_edge = ledg[0]

    ledg = OA.graphAddEdge(G, "BtForkFOR", "BtForkIF", "TFJiterate")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('TFJiterate')
    OA.sharedConx(G, ledg[0]).append(btForkIF_main_input_edge)

    ledg = OA.graphAddEdge(G, "BtForkELSE", "BtJoinIFTHEN", "gDone")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('gDone')
    OA.sharedConx(G, ledg[0]).append(btJoin_gDone_main_input_edge)

    ledg = OA.graphAddEdge(G, "BtForkELSE", "BtForkTransition", "TFJiterate")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('TFJiterate')

    ledg = OA.graphAddEdge(G, "BtForkTransition", "BtJoinIFTHEN", "Work2")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('Work2')
    OA.getEvent(G, ledg).fertile = False
    btFork_transition_to_btJoinIF_main_edge2 = ledg[0]
    ledg = OA.graphAddEdge(G, "BtForkTransition", "BtJoinIFTHEN", "Work")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('Work')
    OA.getEvent(G, ledg).fertile = False
    btFork_transition_to_btJoinIF_main_edge1 = ledg[0]

    ledg = OA.graphAddEdge(G, "BtJoinIFTHEN", "BtJoinELSE", "NULL_GUID")
    OA.getEdge(G, ledg[0])["leads_to_ElseClause"] = True
    ledg = OA.graphAddEdge(G, "BtJoinIFTHEN", "BtJoinIFTHEN", "Work")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('Work')
    OA.getEvent(G, ledg).fertile = False
    OA.getEvent(G, ledg).user_slotnb_text = 'slot_for_work'
    OA.sharedConx(G, ledg[0]).append(btFork_transition_to_btJoinIF_main_edge1)

    ledg = OA.graphAddEdge(G, "BtJoinELSE", "ConcludeBtForkJoin", "Work")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('Work')
    OA.getEvent(G, ledg).fertile = False

    # ----- WORK
    erri = 0
    while not erri:
        if 1 == 2: OA.printGraph(G)  # Just to check if the inputs are ok.

        erri = OA.OCRanalysis(G)
        if erri: break

        if 1 == 2: OA.printGraph(G)
        if 1 == 1:
            erri = OA.outputDot(G, "z_bintree_forkjoin.dot")
            if erri: break
        if 1 == 1:
            erri = OA.outputOCR(G, "z_bintree_forkjoin.c")
            if erri: break

        if 1 == 2: OA.printGraph(G)

        break  # while not erri
    OA.errmsg(erri)
    return erri
Пример #8
0
def theMain():
    OA.GBL.insert_debug_code = 0
    G = OA.GraphTool.DiGraph()

    OA.setupGraph(G, "ptest_FORforkjoin")
    OA.GBL.app_ocr_util_filename = 'app_ocr_util.h'

    OA.addHeader(G, '#include "ptest_FORforkjoin.h"')

    # ----- Data Blocks
    dbk = OA.ocrDataBlock()
    dbk.name = 'NULL_GUID'
    dbk_nullGuid = dbk
    dbk = OA.ocrDataBlock()
    dbk.name = 'gDone'
    dbk.count = 1
    dbk.type = 'ocrGuid_t'
    dbk_gDone = dbk
    dbk = OA.ocrDataBlock()
    dbk.name = 'gDoneROF'
    dbk.count = 1
    dbk.type = 'ocrGuid_t'
    dbk_gDoneROF = dbk
    dbk = OA.ocrDataBlock()
    dbk.name = 'ffjLedger'
    dbk.count = 1
    dbk.type = 'FFJ_Ledger_t'
    dbk_ffjLedger = dbk

    # ----- NODES
    nc = OA.GBL.MAINNODE
    taskName = "mainEdt"
    OA.graphAddNode(G, nc, taskName)
    dbk = copy.deepcopy(dbk_nullGuid)
    dbk.flight = 'flTAKEOFF'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_gDone)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_ffjGDone'
    OA.addDataBlocks(G, nc, dbk)
    guid_finalEDT = OA.makeGuidEdtname('finalEDT')
    mainedtTxt = 'err = ffjMainEdt_fcn(&' + guid_finalEDT + ', o_ffjGDone); IFEB;'
    OA.addCustomText(G, nc, mainedtTxt)

    nc = OA.GBL.FINALNODE
    taskName = "finalEDT"
    OA.graphAddNode(G, nc, taskName)
    dbk = copy.deepcopy(dbk_nullGuid)
    dbk.flight = 'flLANDING'
    OA.addDataBlocks(G, nc, dbk)
    finalEDT_txt = 'err = ffjFinalEdt_fcn(); IFEB;'
    OA.addCustomText(G, nc, finalEDT_txt)

    nc += 1
    taskName = "ffjSetup"
    OA.graphAddNode(G, nc, taskName)
    dbk = copy.deepcopy(dbk_ffjLedger)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_ffjLedger'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_gDoneROF)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_gDoneROF'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_gDone)
    dbk.flight = 'flTAGO'
    OA.addDataBlocks(G, nc, dbk)
    guid_ffjROF = OA.makeGuidEdtname('ffjROF')
    ffjSetup_txt = 'err = ffjSetup_fcn(COUNT_FOR_FORKJOIN, o_ffjLedger, &' + guid_ffjROF + ', o_gDoneROF); IFEB;'
    OA.addCustomText(G, nc, ffjSetup_txt)

    nc += 1
    taskName = "ffjFOR"
    OA.graphAddNode(G, nc, taskName)
    dbk = copy.deepcopy(dbk_ffjLedger)
    dbk.flight = 'flLANDING'
    dbk.localname = 'in_ffjLedger'
    dbk.delayReleaseDestroy = True
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_gDoneROF)
    dbk.flight = 'flLANDING'
    dbk.localname = 'in_gDoneROF'
    dbk.delayReleaseDestroy = True
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_ffjLedger)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_ffjshared'
    dbk.hint = 'pHintDBK'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_gDoneROF)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_gDoneROF'
    dbk.hint = 'pHintDBK'
    OA.addDataBlocks(G, nc, dbk)
    fortext = 'int rank; for(rank=0; rank<in_ffjLedger->nrank; ++rank)'
    OA.addFORconditionText(G, nc, fortext)
    OA.addFORconditionText_startingclause(
        G, nc,
        'unsigned long pdID = calculate_pid(rank, in_ffjLedger->OCR_affinityCount, in_ffjLedger->nrank);'
    )
    OA.addFORconditionText_startingclause(
        G, nc, 'ocrHint_t hintEDT, *pHintEDT=0, hintDBK, *pHintDBK=0;')
    OA.addFORconditionText_startingclause(
        G, nc, 'err = ocrXgetEdtHint(pdID, &hintEDT, &pHintEDT); IFEB;')
    OA.addFORconditionText_startingclause(
        G, nc, 'err = ocrXgetDbkHint(pdID, &hintDBK, &pHintDBK); IFEB;')
    ffjFOR_txt = 'err = ffjFOR_fcn(rank, in_ffjLedger, o_ffjshared, in_gDoneROF, o_gDoneROF); IFEB;'
    OA.addCustomText(G, nc, ffjFOR_txt)

    nc += 1
    taskName = "ffjFOR_Transist_start"
    OA.graphAddNode(G, nc, taskName)
    OA.getMyTask(G, nc).hint = 'pHintEDT'
    dbk = copy.deepcopy(dbk_ffjLedger)
    dbk.flight = 'flTAGO'
    dbk.localname = 'io_ffjLedger'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_gDoneROF)
    dbk.flight = 'flTAGO'
    dbk.addLocalText('    ocrHint_t hintEDT, *pHintEDT=0;')
    dbk.addLocalText(
        '    err = ocrXgetEdtHint(FFJ_USE_CURRENT_PD, &hintEDT, &pHintEDT); IFEB;'
    )
    OA.addDataBlocks(G, nc, dbk)
    ffjFOR_Transist_start = 'err = ffjFOR_Transist_start_fcn(io_ffjLedger); IFEB;'
    OA.addCustomText(G, nc, ffjFOR_Transist_start)

    nc += 1
    taskName = "ffjFOR_Transist_stop"
    OA.graphAddNode(G, nc, taskName)
    OA.getMyTask(G, nc).hint = 'pHintEDT'
    dbk = copy.deepcopy(dbk_ffjLedger)
    dbk.flight = 'flLANDING'
    dbk.localname = 'in_ffjLedger'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_gDoneROF)
    dbk.flight = 'flLANDING'
    dbk.localname = 'in_gDoneROF'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_nullGuid)
    dbk.flight = 'flTAKEOFF'
    OA.addDataBlocks(G, nc, dbk)
    gdoneROF_txt = 'ocrGuid_t ' + OA.makeGuidEdtname(
        'ffjROF') + ' = *in_gDoneROF;'
    OA.addCustomText(G, nc, gdoneROF_txt)
    ROF_which_slot = 'unsigned int slot_for_ROF = in_ffjLedger->rankid +1; //+1 to accommodate the in_gDone sent from ffjSetup'
    OA.addCustomText(G, nc, ROF_which_slot)
    ffjFOR_Transist_stop = 'err = ffjFOR_Transist_stop_fcn(in_ffjLedger); IFEB;'
    OA.addCustomText(G, nc, ffjFOR_Transist_stop)

    nc += 1
    taskName = "ffjROF"
    OA.graphAddNode(G, nc, taskName)
    OA.getMyTask(G, nc).depc = '(1+COUNT_FOR_FORKJOIN)'
    dbk = copy.deepcopy(dbk_gDone)
    dbk.flight = 'flLANDING'
    dbk.localname = 'in_gDone'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_nullGuid)
    dbk.flight = 'flTAKEOFF'
    OA.addDataBlocks(G, nc, dbk)
    gdone_txt = 'ocrGuid_t ' + OA.makeGuidEdtname('finalEDT') + ' = *in_gDone;'
    OA.addCustomText(G, nc, gdone_txt)
    ffjROF = 'err = ffjROF_fcn(); IFEB;'
    OA.addCustomText(G, nc, ffjROF)

    # ----- EDGES
    ledg = OA.graphAddEdge(G, "mainEdt", "finalEDT", "NULL_GUID")
    OA.getEvent(G, ledg).accessmode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('NULL_GUID')
    ledg = OA.graphAddEdge(G, "mainEdt", "ffjSetup", "gDone")
    OA.getEvent(G, ledg).accessmode = 'DB_MODE_RW'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('gDone')

    ledg = OA.graphAddEdge(G, "ffjSetup", "ffjROF", "gDone")
    OA.getEvent(G, ledg).accessmode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('gDone')
    ledg = OA.graphAddEdge(G, "ffjSetup", "ffjFOR", "gDoneROF")
    OA.getEvent(G, ledg).accessmode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('gDoneROF')
    ledg = OA.graphAddEdge(G, "ffjSetup", "ffjFOR", "ffjLedger")
    OA.getEvent(G, ledg).accessmode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('ffjLedger')

    ledg = OA.graphAddEdge(G, "ffjFOR", "ffjFOR_Transist_start", "gDoneROF")
    OA.getEvent(G, ledg).accessmode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('gDoneROF')
    ledg = OA.graphAddEdge(G, "ffjFOR", "ffjFOR_Transist_start", "ffjLedger")
    OA.getEvent(G, ledg).accessmode = 'DB_MODE_RW'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('ffjLedger')

    ledg = OA.graphAddEdge(G, "ffjFOR_Transist_start", "ffjFOR_Transist_stop",
                           "gDoneROF")
    OA.getEvent(G, ledg).accessmode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('gDoneROF')
    ledg = OA.graphAddEdge(G, "ffjFOR_Transist_start", "ffjFOR_Transist_stop",
                           "ffjLedger")
    OA.getEvent(G, ledg).accessmode = 'DB_MODE_RW'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('ffjLedger')

    ledg = OA.graphAddEdge(G, "ffjFOR_Transist_stop", "ffjROF", "NULL_GUID")
    OA.getEvent(G, ledg).eflag = 'EVT_PROP_NONE'
    OA.getEvent(G, ledg).satisfy = 'NULL_GUID'
    OA.getEvent(G, ledg).fertile = False
    OA.getEvent(G, ledg).user_slotnb_text = 'slot_for_ROF'

    ledg = OA.graphAddEdge(G, "ffjROF", "finalEDT", "NULL_GUID")
    OA.getEvent(G, ledg).eflag = 'EVT_PROP_NONE'
    OA.getEvent(G, ledg).satisfy = 'NULL_GUID'
    OA.getEvent(G, ledg).fertile = False

    # ----- WORK
    erri = 0
    while not erri:
        if True: OA.printGraph(G)  # Just to check if the inputs are ok.

        erri = OA.OCRanalysis(G)
        if erri: break

        if False: OA.printGraph(G)
        if True:
            erri = OA.outputDot(G, "z_ptest_FORforkjoin.dot")
            if erri: break
        if True:
            erri = OA.outputOCR(G, "z_ptest_FORforkjoin.c")
            if erri: break

        if False: OA.printGraph(G)

        break  # while not erri
    OA.errmsg(erri)
    return erri
Пример #9
0
def theMain():

    OA.GBL.insert_debug_code = 0

    G=OA.GraphTool.DiGraph()

    OA.setupGraph(G,"HelloWorld")

    OA.addHeader(G, '#include "helloworld.h" ')  # This will be put at the beginning of the file

    # ----- Data Blocks
    dbk = OA.ocrDataBlock();  dbk.name = 'NULL_GUID'
    dbk_nullGuid = dbk

    dbk = OA.ocrDataBlock();  dbk.name = 'Parabola';   dbk.count=3;     dbk.type='int'
    dbk_parabola = dbk

    dbk=OA.ocrDataBlock();  dbk.name = 'Roots';   dbk.count=2;     dbk.type='double'
    dbk_roots = dbk

    # ----- NODES
    # Always root the starting/root/main EDT at ID=0 = OA.GBL.MAINNODE
    # Always cap all ending EDT by the FinalEDT at ID=1 = OA.GBL.FINALNODE
    nc = OA.GBL.MAINNODE;    taskName = "mainEdt"; OA.graphAddNode(G,nc,taskName)
    dbk = copy.deepcopy(dbk_nullGuid); dbk.flight = 'flTAKEOFF'; OA.addDataBlocks(G,nc,dbk)

    nc = OA.GBL.FINALNODE;   taskName="finalEDT"; OA.graphAddNode(G,nc,taskName)
    dbk = copy.deepcopy(dbk_nullGuid); dbk.flight = 'flLANDING'; OA.addDataBlocks(G,nc,dbk)

    nc += 1;  taskName="beginAlgoEDT"; OA.graphAddNode(G,nc,taskName)
    dbk = copy.deepcopy(dbk_parabola); dbk.flight = 'flTAKEOFF';  dbk.localname='o_parabola'; OA.addDataBlocks(G,nc,dbk)
    OA.addCustomText(G, nc, 'err = setupTheParabola(o_parabola); IFEB;')

    nc += 1;  taskName="SolveEDT"; OA.graphAddNode(G,nc,taskName)
    dbk = copy.deepcopy(dbk_parabola); dbk.flight = 'flLANDING'; dbk.localname='in_parabola'; OA.addDataBlocks(G,nc,dbk)
    dbk = copy.deepcopy(dbk_roots); dbk.flight = 'flTAKEOFF'; dbk.localname='o_roots'; OA.addDataBlocks(G,nc,dbk)
    OA.addCustomText(G, nc, 'err = solveForRoots(in_parabola, o_roots); IFEB;')

    nc += 1;  taskName="CountEDT"; OA.graphAddNode(G,nc,taskName)
    dbk = copy.deepcopy(dbk_roots); dbk.flight = 'flTAGO'; dbk.localname='io_roots'; OA.addDataBlocks(G,nc,dbk)
    OA.addCustomText(G, nc, 'err = deduplicateRoots(io_roots); IFEB;')

    nc += 1;  taskName="PrintEDT"; OA.graphAddNode(G,nc,taskName)
    dbk = copy.deepcopy(dbk_roots); dbk.flight = 'flTAGO'; dbk.localname='io_roots'; OA.addDataBlocks(G,nc,dbk)
    OA.addCustomText(G, nc, 'err = printRoots(io_roots); IFEB;')

    nc += 1;  taskName="endAlgoEDT"; OA.graphAddNode(G,nc,taskName)
    dbk = copy.deepcopy(dbk_roots); dbk.flight = 'flLANDING'; OA.addDataBlocks(G,nc,dbk)

    # ----- EDGES
    edg = OA.graphAddEdge(G,     "mainEdt", "beginAlgoEDT", "NULL_GUID")
    OA.getEvent(G, edg).eflag = 'EVT_PROP_NONE'
    OA.getEvent(G, edg).satisfy = 'NULL_GUID'

    edg=OA.graphAddEdge(G, "beginAlgoEDT", "SolveEDT", "Parabola")
    OA.getEvent(G, edg).accessMode = 'DB_MODE_EW'
    OA.getEvent(G, edg).satisfy = OA.makeGuidDataBlockname('Parabola')

    edg=OA.graphAddEdge(G,    "SolveEDT",     "CountEDT", "Roots")
    OA.getEvent(G, edg).accessmode = 'DB_MODE_EW'
    OA.getEvent(G, edg).satisfy = OA.makeGuidDataBlockname('Roots')

    edg=OA.graphAddEdge(G,    "CountEDT",     "PrintEDT", "Roots")
    OA.getEvent(G, edg).accessMode = 'DB_MODE_CONST'
    OA.getEvent(G, edg).satisfy = OA.contextedGuid(OA.GBL.DBK_structName +'->', OA.makeGuidDataBlockname('Roots'), 'DBK')

    edg=OA.graphAddEdge(G,    "PrintEDT",   "endAlgoEDT", "Roots")
    OA.getEvent(G, edg).accessMode = 'DB_MODE_CONST'
    OA.getEvent(G, edg).satisfy = OA.contextedGuid(OA.GBL.DBK_structName +'->', OA.makeGuidDataBlockname('Roots'), 'DBK')

    edg=OA.graphAddEdge(G,  "endAlgoEDT",     "finalEDT", "NULL_GUID")
    OA.getEvent(G, edg).eflag = 'EVT_PROP_NONE'
    OA.getEvent(G, edg).satisfy = 'NULL_GUID'

    # ----- WORK
    erri = 0
    while not erri:
        if 1 == 2: OA.printGraph(G)   # Just to check if the inputs are ok.

        erri = OA.OCRanalysis(G)
        if erri: break

        if 1 == 2: OA.printGraph(G)
        if 1 == 2:
            erri = OA.outputDot(G, "z_helloWorld.dot")
            if erri: break
        if 1 == 1:
            erri = OA.outputOCR(G, "z_helloWorld.c")
            if erri: break

        if 1 == 2: OA.printGraph(G)

        break  # while not erri
    OA.errmsg(erri)
    return erri
Пример #10
0
def theMain():

    use_a_work_block = True

    G = OA.GraphTool.DiGraph()

    OA.setupGraph(G, "TailRecursion")

    OA.addHeader(G, '#include "tailrecursion.h" '
                 )  # This will be put at the beginning of the file

    # ----- Data Blocks
    dbk = OA.ocrDataBlock()
    dbk.name = 'NULL_GUID'
    dbk_nullGuid = dbk

    dbk = OA.ocrDataBlock()
    dbk.name = 'Iterate'
    dbk.count = 1
    dbk.type = 'Iterate_t'
    dbk_iterate = dbk

    if use_a_work_block:
        dbk = OA.ocrDataBlock()
        dbk.name = 'Work'
        dbk.count = 1000 + 1
        dbk.type = 'int'
        #Offset 0 is used to store the size.
        dbk_work = dbk

    # ----- NODES
    # Always root the starting/root/main EDT at ID=0 = OA.GBL.MAINNODE
    # Always cap all ending EDT by the FinalEDT at ID=1 = OA.GBL.FINALNODE
    nc = OA.GBL.MAINNODE
    taskName = "mainEdt"
    OA.graphAddNode(G, nc, taskName)  # Got to have one 'mainEdt'
    dbk = copy.deepcopy(dbk_nullGuid)
    dbk.flight = 'flTAKEOFF'
    OA.addDataBlocks(G, nc, dbk)

    nc = OA.GBL.FINALNODE
    taskName = "finalEDT"
    OA.graphAddNode(G, nc, taskName)
    dbk = copy.deepcopy(dbk_nullGuid)
    dbk.flight = 'flLANDING'
    OA.addDataBlocks(G, nc, dbk)

    nc += 1
    taskName = "SetupIteration"
    OA.graphAddNode(G, nc, taskName)
    dbk = copy.deepcopy(dbk_nullGuid)
    dbk.flight = 'flTAKEOFF'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_iterate)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_iterate'
    OA.addDataBlocks(G, nc, dbk)
    setupt = 'err = initializeIterate(o_iterate, ' + OA.makeGuidEdtname(
        "ConcludeIteration") + '); IFEB;'
    OA.addCustomText(G, nc, setupt)
    if use_a_work_block:
        dbk = copy.deepcopy(dbk_work)
        dbk.flight = 'flTAKEOFF'
        dbk.localname = 'o_work'
        OA.addDataBlocks(G, nc, dbk)
        setupWork = 'err = initializeWork(' + dbk_work.text_for_sizeName(
        ) + ', o_work); IFEB;'
        OA.addCustomText(G, nc, setupWork)

    nc += 1
    taskName = "Iteration"
    OA.graphAddNode(G, nc, taskName)
    dbk = copy.deepcopy(dbk_iterate)
    dbk.flight = 'flTAGO'
    dbk.localname = 'io_iterate'
    dbk.addLocalText('ocrGuid_t ' + OA.makeGuidEdtname("ConcludeIteration") +
                     ' = io_iterate->whereToGoWhenFalse;')
    OA.addDataBlocks(G, nc, dbk)
    iterConditionText = 'condition(io_iterate)'
    OA.addIFconditionText(G, nc, iterConditionText)
    if use_a_work_block:
        dbk = copy.deepcopy(dbk_work)
        dbk.flight = 'flTAGO'
        dbk.localname = 'io_work'
        OA.addDataBlocks(G, nc, dbk)
        text_for_THEN_clause = 'err = trueClauseWithWork(io_iterate, io_work); IFEB;'
    else:
        text_for_THEN_clause = 'err = trueClause(io_iterate); IFEB;'
    OA.addCustomText(G, nc, text_for_THEN_clause)

    nc += 1
    taskName = "IterationElse"
    OA.graphAddNode(G, nc, taskName)
    # DBK local names are taken care off by the IF-THEN edt called "Iteration".
    dbk = copy.deepcopy(dbk_iterate)
    dbk.flight = 'flLANDING'
    OA.addDataBlocks(G, nc, dbk)
    if use_a_work_block:
        dbk = copy.deepcopy(dbk_work)
        dbk.flight = 'flTAGO'
        OA.addDataBlocks(G, nc, dbk)
        text_for_ELSE_clause = 'err = falseClauseWithWork(io_iterate, io_work); IFEB;'
    else:
        dbk = copy.deepcopy(dbk_nullGuid)
        dbk.flight = 'flTAKEOFF'
        OA.addDataBlocks(G, nc, dbk)
        text_for_ELSE_clause = 'err = falseClause(io_iterate); IFEB;'
    OA.addCustomText(G, nc, text_for_ELSE_clause)

    nc += 1
    taskName = "ConcludeIteration"
    OA.graphAddNode(G, nc, taskName)
    dbk = copy.deepcopy(dbk_nullGuid)
    dbk.flight = 'flTAKEOFF'
    OA.addDataBlocks(G, nc, dbk)
    if use_a_work_block:
        dbk = copy.deepcopy(dbk_work)
        dbk.flight = 'flLANDING'
        dbk.localname = 'io_work'
        OA.addDataBlocks(G, nc, dbk)
        OA.addCustomText(G, nc, 'err = concludeIteration(io_work); IFEB;')
    else:
        OA.addCustomText(G, nc, 'err = concludeIteration(NULL); IFEB;')

    # ----- EDGES
    ledg = OA.graphAddEdge(G, "mainEdt", "SetupIteration", "NULL_GUID")
    OA.getEvent(G, ledg).eflag = 'EVT_PROP_NONE'
    OA.getEvent(G, ledg).satisfy = 'NULL_GUID'

    ledg = OA.graphAddEdge(G, "SetupIteration", "ConcludeIteration",
                           "NULL_GUID")
    OA.getEvent(G, ledg).eflag = 'EVT_PROP_NONE'
    OA.getEvent(G, ledg).satisfy = 'NULL_GUID'

    ledg = OA.graphAddEdge(G, "SetupIteration", "Iteration", "Iterate")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RW'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('Iterate')
    main_iteration_input_edge = ledg[
        0]  # This takes only the edge out of the labelled edge.

    main_iteration_work_edge = ()
    if use_a_work_block:
        ledg = OA.graphAddEdge(G, "SetupIteration", "Iteration", "Work")
        OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
        OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('Work')
        main_iteration_work_edge = ledg[
            0]  # This takes only the edge out of the labelled edge.

    ledg = OA.graphAddEdge(G, "Iteration", "Iteration", "Iterate")
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RW'
    OA.getEvent(G, ledg).satisfy = OA.contextedGuid(
        OA.GBL.DBK_structName + '->', OA.makeGuidDataBlockname('Iterate'),
        'DBK')
    OA.sharedConx(G, ledg[0]).append(main_iteration_input_edge)

    if use_a_work_block:
        ledg = OA.graphAddEdge(G, "Iteration", "Iteration", "Work")
        OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
        OA.getEvent(G, ledg).satisfy = OA.contextedGuid(
            OA.GBL.DBK_structName + '->', OA.makeGuidDataBlockname('Work'),
            'DBK')
        OA.sharedConx(G, ledg[0]).append(main_iteration_work_edge)

    ledg = OA.graphAddEdge(G, "Iteration", "IterationElse", "NULL_GUID")
    OA.getEdge(G, ledg[0])["leads_to_ElseClause"] = True

    if use_a_work_block:
        ledg = OA.graphAddEdge(G, "IterationElse", "ConcludeIteration", "Work")
        OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
        OA.getEvent(G, ledg).satisfy = OA.contextedGuid(
            OA.GBL.DBK_structName + '->', OA.makeGuidDataBlockname('Work'),
            'DBK')
        OA.getEvent(G, ledg).fertile = False
    else:
        ledg = OA.graphAddEdge(G, "IterationElse", "ConcludeIteration",
                               "NULL_GUID")
        OA.getEvent(G, ledg).eflag = 'EVT_PROP_NONE'
        OA.getEvent(G, ledg).satisfy = 'NULL_GUID'
        OA.getEvent(G, ledg).fertile = False

    ledg = OA.graphAddEdge(G, "ConcludeIteration", "finalEDT", "NULL_GUID")
    OA.getEvent(G, ledg).eflag = 'EVT_PROP_NONE'
    OA.getEvent(G, ledg).satisfy = 'NULL_GUID'

    # ----- WORK
    erri = 0
    while not erri:
        if 1 == 2: OA.printGraph(G)  # Just to check if the inputs are ok.

        erri = OA.OCRanalysis(G)
        if erri: break

        if 1 == 2: OA.printGraph(G)
        if 1 == 2:
            erri = OA.outputDot(G, "z_tailRecursion.dot")
            if erri: break
        if 1 == 1:
            erri = OA.outputOCR(G, "z_tailRecursion.c")
            if erri: break

        if 1 == 2: OA.printGraph(G)

        break  # while not erri
    OA.errmsg(erri)
    return erri
Пример #11
0
def theMain():

    OA.GBL.insert_debug_code = 0

    G = OA.GraphTool.DiGraph()

    OA.setupGraph(G, "utest_channel")

    OA.addHeader(G, '#include "utest_channelG.h" ')
    OA.addHeader(G, ' ')

    # ----- Data Blocks
    dbk = OA.ocrDataBlock()
    dbk.name = 'rightLedger'
    dbk.count = 1
    dbk.type = 'utcLedger_t'
    dbk_rightLedger = dbk
    dbk = OA.ocrDataBlock()
    dbk.name = 'leftLedger'
    dbk.count = 1
    dbk.type = 'utcLedger_t'
    dbk_leftLedger = dbk
    dbk = OA.ocrDataBlock()
    dbk.name = 'refLedger'
    dbk.count = 1
    dbk.type = 'utcLedger_t'
    dbk_refLedger = dbk

    dbk = OA.ocrDataBlock()
    dbk.name = 'channelEnvelop'
    dbk.count = 1
    dbk.type = 'ocrGuid_t'
    dbk_channelEnvelop = dbk
    dbk = OA.ocrDataBlock()
    dbk.name = 'labelEventEnvelop'
    dbk.count = 1
    dbk.type = 'ocrGuid_t'
    dbk_labelEventEnvelop = dbk

    #    dbk = OA.ocrDataBlock();  dbk.name = 'neighborChannel';  dbk.count=1; dbk.type='ocrGuid_t'
    #    dbk_neighborChannel = dbk

    # ----- NODES
    # Always root the starting/root/main EDT at ID=0 = OA.GBL.MAINNODE
    # Always cap all ending EDT by the FinalEDT at ID=1 = OA.GBL.FINALNODE
    nc = OA.GBL.MAINNODE
    taskName = "mainEdt"
    OA.graphAddNode(G, nc, taskName)
    dbk = copy.deepcopy(dbk_leftLedger)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_leftLedger'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_rightLedger)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_rightLedger'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_refLedger)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_refLedger'
    OA.addDataBlocks(G, nc, dbk)
    Ma = 'err = Userfcn_MainEdt( OA_DEBUG_OUTVARS, &' + OA.makeGuidEdtname(
        "finalEDT") + ', '
    Ma += 'o_leftLedger,o_rightLedger,o_refLedger); IFEB;'
    OA.addCustomText(G, nc, Ma)

    nc = OA.GBL.FINALNODE
    taskName = "finalEDT"
    OA.graphAddNode(G, nc, taskName)
    dbk = copy.deepcopy(dbk_refLedger)
    dbk.flight = 'flLANDING'
    dbk.localname = 'in_refLedger'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_leftLedger)
    dbk.flight = 'flLANDING'
    dbk.localname = 'in_leftLedger'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_rightLedger)
    dbk.flight = 'flLANDING'
    dbk.localname = 'in_rightLedger'
    OA.addDataBlocks(G, nc, dbk)
    finalEDTa = 'err = Userfcn_FinalEdt(OA_DEBUG_OUTVARS, in_refLedger, in_leftLedger, in_rightLedger); IFEB;'
    OA.addCustomText(G, nc, finalEDTa)

    nc += 1
    taskName = "BeginInit_Left"
    OA.graphAddNode(G, nc, taskName)
    dbk = copy.deepcopy(dbk_leftLedger)
    dbk.flight = 'flLANDING'
    dbk.localname = 'in_ledger'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_leftLedger)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_ledger'
    OA.addDataBlocks(G, nc, dbk)
    EndInit_Left_guid = OA.makeGuidEdtname('EndInit_Left')
    BILc = 'err = Userfcn_BeginInit(OA_DEBUG_OUTVARS, in_ledger, o_ledger, &'
    BILc += EndInit_Left_guid + ', SLOTCNT_EndInit-1 ); IFEB;'
    OA.addCustomText(G, nc, BILc)

    nc += 1
    taskName = "BeginInit_Right"
    OA.graphAddNode(G, nc, taskName)
    dbk = copy.deepcopy(dbk_rightLedger)
    dbk.flight = 'flLANDING'
    dbk.localname = 'in_ledger'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_rightLedger)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_ledger'
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_channelEnvelop)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_chanEnvelop'
    OA.addDataBlocks(G, nc, dbk)
    EndInit_Right_guid = OA.makeGuidEdtname('EndInit_Right')
    BIRc = 'err = Userfcn_BeginInit(OA_DEBUG_OUTVARS, in_ledger, o_ledger, &'
    BIRc += EndInit_Right_guid + ', SLOTCNT_EndInit-1); IFEB;'
    OA.addCustomText(G, nc, BIRc)

    nc += 1
    taskName = "EndInit_Left"
    OA.graphAddNode(G, nc, taskName)
    OA.getMyTask(G, nc).depc = 'SLOTCNT_EndInit'
    dbk = copy.deepcopy(dbk_leftLedger)
    dbk.flight = 'flLANDING'
    dbk.localname = 'in_ledger'
    dbk.addLocalText(
        '    ocrEdtDep_t IN_BY_USER_depv_neighborLabelEvt = depv[SLOTCNT_EndInit-1];  //This will be LANDING here.'
    )
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_leftLedger)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_ledger'
    OA.addDataBlocks(G, nc, dbk)
    EndInit_Lefta = ' err = Userfcn_EndInit(OA_DEBUG_OUTVARS, in_ledger, o_ledger, IN_BY_USER_depv_neighborLabelEvt); IFEB;'
    OA.addCustomText(G, nc, EndInit_Lefta)

    nc += 1
    taskName = "EndInit_Right"
    OA.graphAddNode(G, nc, taskName)
    OA.getMyTask(G, nc).depc = 'SLOTCNT_EndInit'
    dbk = copy.deepcopy(dbk_rightLedger)
    dbk.flight = 'flLANDING'
    dbk.localname = 'in_ledger'
    dbk.addLocalText(
        '    ocrEdtDep_t IN_BY_USER_depv_neighborLabelEvt = depv[SLOTCNT_EndInit-1];  //This will be LANDING here.'
    )
    OA.addDataBlocks(G, nc, dbk)
    dbk = copy.deepcopy(dbk_rightLedger)
    dbk.flight = 'flTAKEOFF'
    dbk.localname = 'o_ledger'
    OA.addDataBlocks(G, nc, dbk)
    EndInit_Righta = ' err = Userfcn_EndInit(OA_DEBUG_OUTVARS, in_ledger, o_ledger, IN_BY_USER_depv_neighborLabelEvt); IFEB;'
    OA.addCustomText(G, nc, EndInit_Righta)

    nc += 1
    taskName = "Work_Left_start"
    OA.graphAddNode(G, nc, taskName)
    dbk = copy.deepcopy(dbk_leftLedger)
    dbk.flight = 'flTAGO'
    dbk.localname = 'io_ledger'
    OA.addDataBlocks(G, nc, dbk)
    Work_Left_stop_guid = OA.makeGuidEdtname('Work_Left_stop')
    Work_Left_startA = 'err = work_start(OA_DEBUG_OUTVARS, io_ledger, &' + Work_Left_stop_guid + ', SLOTCNT_WorkStop-1); IFEB;'
    OA.addCustomText(G, nc, Work_Left_startA)

    nc += 1
    taskName = "Work_Right_start"
    OA.graphAddNode(G, nc, taskName)
    dbk = copy.deepcopy(dbk_rightLedger)
    dbk.flight = 'flTAGO'
    dbk.localname = 'io_ledger'
    OA.addDataBlocks(G, nc, dbk)
    Work_Right_stop_guid = OA.makeGuidEdtname('Work_Right_stop')
    Work_Right_startA = 'err = work_start(OA_DEBUG_OUTVARS, io_ledger, &' + Work_Right_stop_guid + ', SLOTCNT_WorkStop-1); IFEB;'
    OA.addCustomText(G, nc, Work_Right_startA)

    nc += 1
    taskName = "Work_Left_stop"
    OA.graphAddNode(G, nc, taskName)
    OA.getMyTask(G, nc).depc = 'SLOTCNT_WorkStop'
    dbk = copy.deepcopy(dbk_leftLedger)
    dbk.flight = 'flTAGO'
    dbk.localname = 'io_ledger'
    dbk.addLocalText(
        '    ocrEdtDep_t IN_BY_USER_depv_neighborChanEvt = depv[SLOTCNT_WorkStop-1];  //This will be LANDING here.'
    )
    OA.addDataBlocks(G, nc, dbk)
    finalEdt_guid = OA.makeGuidEdtname('finalEDT')
    guid_text = 'ocrGuid_t ' + finalEdt_guid + ';'
    OA.addCustomText(G, nc, guid_text)
    Work_Left_stopA = 'err = work_stop(OA_DEBUG_OUTVARS, io_ledger, &' + finalEdt_guid + ', IN_BY_USER_depv_neighborChanEvt); IFEB;'
    OA.addCustomText(G, nc, Work_Left_stopA)

    nc += 1
    taskName = "Work_Right_stop"
    OA.graphAddNode(G, nc, taskName)
    OA.getMyTask(G, nc).depc = 'SLOTCNT_WorkStop'
    dbk = copy.deepcopy(dbk_rightLedger)
    dbk.flight = 'flTAGO'
    dbk.localname = 'io_ledger'
    dbk.addLocalText(
        '    ocrEdtDep_t IN_BY_USER_depv_neighborChanEvt = depv[SLOTCNT_WorkStop-1];  //This will be LANDING here.'
    )
    OA.addDataBlocks(G, nc, dbk)
    finalEdt_guid = OA.makeGuidEdtname('finalEDT')
    guid_text = 'ocrGuid_t ' + finalEdt_guid + ';'
    OA.addCustomText(G, nc, guid_text)
    Work_Right_stopA = 'err = work_stop(OA_DEBUG_OUTVARS, io_ledger, &' + finalEdt_guid + ', IN_BY_USER_depv_neighborChanEvt); IFEB;'
    OA.addCustomText(G, nc, Work_Right_stopA)

    # ----- EDGES
    ledg = OA.graphAddEdge(G, "mainEdt", "finalEDT", 'refLedger')
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('refLedger')

    ledg = OA.graphAddEdge(G, "mainEdt", "BeginInit_Left", 'leftLedger')
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('leftLedger')

    ledg = OA.graphAddEdge(G, "mainEdt", "BeginInit_Right", 'rightLedger')
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('rightLedger')

    ledg = OA.graphAddEdge(G, "BeginInit_Left", "EndInit_Left", 'leftLedger')
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('leftLedger')
    #    OA.getEvent(G, ledg).user_slotnb_text = '0'

    ledg = OA.graphAddEdge(G, "BeginInit_Right", "EndInit_Right",
                           'rightLedger')
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('rightLedger')
    #    OA.getEvent(G, ledg).user_slotnb_text = '0'

    ledg = OA.graphAddEdge(G, "EndInit_Left", "Work_Left_start", 'leftLedger')
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('leftLedger')

    ledg = OA.graphAddEdge(G, "EndInit_Right", "Work_Right_start",
                           'rightLedger')
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('rightLedger')

    ledg = OA.graphAddEdge(G, "Work_Left_start", "Work_Left_stop",
                           'leftLedger')
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('leftLedger')

    ledg = OA.graphAddEdge(G, "Work_Right_start", "Work_Right_stop",
                           'rightLedger')
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('rightLedger')

    ledg = OA.graphAddEdge(G, "Work_Left_stop", "finalEDT", 'leftLedger')
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('leftLedger')
    OA.getEvent(G, ledg).fertile = False

    ledg = OA.graphAddEdge(G, "Work_Right_stop", "finalEDT", 'rightLedger')
    OA.getEvent(G, ledg).accessMode = 'DB_MODE_RO'
    OA.getEvent(G, ledg).satisfy = OA.makeGuidDataBlockname('rightLedger')
    OA.getEvent(G, ledg).fertile = False

    # ----- WORK
    erri = 0
    while not erri:
        if True: OA.printGraph(G)  # Just to check if the inputs are ok.

        erri = OA.OCRanalysis(G)
        if erri: break

        if False: OA.printGraph(G)
        if True:
            erri = OA.outputDot(G, "z_utest_channelG.dot")
            if erri: break
        if True:
            erri = OA.outputOCR(G, "z_utest_channelG.c")
            if erri: break

        if False: OA.printGraph(G)

        break  # while not erri
    OA.errmsg(erri)
    return erri