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
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
def theMain(): OA.GBL.insert_debug_code = 0 G = OA.GraphTool.DiGraph() OA.setupGraph(G, "ptest_daveReduction") 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, '#ifdef REDUCTION_EAGER') OA.addHeader(G, '#include "reductionEager.h"') OA.addHeader(G, '#else') OA.addHeader(G, '#include "reduction.h"') OA.addHeader(G, '#endif') OA.addHeader(G, ' ') # Just a blank line OA.addHeader(G, '#include "ptest_FORforkjoin.h"') OA.addHeader(G, '#include "ptest_daveReduction.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_daveReduction.dot") if erri: break if True: erri = OA.outputOCR(G, "z_ptest_daveReduction.c") if erri: break if False: OA.printGraph(G) break # while not erri OA.errmsg(erri) return erri
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
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
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
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
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