Exemplo n.º 1
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
Exemplo n.º 2
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
Exemplo n.º 3
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
Exemplo n.º 4
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