int main() { //----- Deprecated since PDQ 6 ----- int nodes; int streams; //----- Model specific variables ----- double arrivRate = 0.75; double service_time = 1.0; //----- Initialize the model & Give it a name ------ PDQ_Init("OpenCenter"); PDQ_SetComment("This is just a simple M/M/1 queue."); //----- Define the queueing center ----- nodes = PDQ_CreateNode("server", CEN, FCFS); //----- Define the workload and circuit type ----- streams = PDQ_CreateOpen("work", arrivRate); //----- Define service demand due to workload on the queueing center ------ PDQ_SetDemand("server", "work", service_time); //----- Change unit labels ----- PDQ_SetWUnit("Customers"); PDQ_SetTUnit("Seconds"); //----- Solve the model ----- // Must use the CANONical method for an open circuit PDQ_Solve(CANON); //----- Generate a report ----- PDQ_Report(); }
int main() { void namex(); int intwt(); void itoa(); char cname[10]; /* cache id */ char wname[10]; /* workload */ int i; /* per CPU intruction stream intensity */ double Prhit = (RD * HT); double Pwhit = (WR * HT * (1 - WUMD)) + (WR * (1 - HT) * (1 - MD)); double Prdop = RD * (1 - HT); double Pwbop = WR * (1 - HT) * MD; double Pwthr = WR; double Pinvl = WR * HT * WUMD; double Nrwht = 0.8075 * MAXCPU; double Nrdop = 0.0850 * MAXCPU; double Nwthr = 0.15 * MAXCPU; double Nwbop = 0.0003 * MAXCPU * 100; double Ninvl = 0.015 * MAXCPU; double Srdop = (20.0); double Swthr = (25.0); double Swbop = (20.0); double Wrwht; double Wrdop; double Wwthr; double Wwbop; double Winvl; double Zrwht = ZX; double Zrdop = ZX; double Zwbop = ZX; double Zinvl = ZX; double Zwthr = ZX; double Xcpu = 0.0; double Pcpu = 0.0; double Ubrd = 0.0; double Ubwr = 0.0; double Ubin = 0.0; double Ucht = 0.0; double Ucrd = 0.0; double Ucwr = 0.0; double Ucin = 0.0; char *model = "ABC Model"; PDQ_Init(model); /* create single bus queueing center */ PDQ_CreateNode(BUS, CEN, FCFS); /* create per CPU cache queueing centers */ for (i = 0; i < MAXCPU; i++) { namex(i, L2C, cname); PDQ_CreateNode(cname, CEN, FCFS); } /* create CPU nodes, workloads, and demands */ for (i = 0; i < intwt(Nrwht, &Wrwht); i++) { namex(i, RWHT, wname); PDQ_CreateClosed(wname, TERM, Nrwht, Zrwht); namex(i, L2C, cname); PDQ_SetDemand(cname, wname, 1.0); PDQ_SetDemand(BUS, wname, 0.0); /* no bus activity */ } for (i = 0; i < intwt(Nrdop, &Wrdop); i++) { namex(i, RDOP, wname); PDQ_CreateClosed(wname, TERM, Nrdop, Zrdop); namex(i, L2C, cname); PDQ_SetDemand(cname, wname, gen); /* generate bus request */ PDQ_SetDemand(BUS, wname, Srdop); /* req + async data return */ } if (WBACK) { for (i = 0; i < intwt(Nwbop, &Wwbop); i++) { namex(i, WROP, wname); PDQ_CreateClosed(wname, TERM, Nwbop, Zwbop); namex(i, L2C, cname); PDQ_SetDemand(cname, wname, gen); PDQ_SetDemand(BUS, wname, Swbop); /* asych write to memory ? */ } } else { /* write-thru */ for (i = 0; i < intwt(Nwthr, &Wwthr); i++) { namex(i, WROP, wname); PDQ_CreateClosed(wname, TERM, Nwthr, Zwthr); namex(i, L2C, cname); PDQ_SetDemand(cname, wname, gen); PDQ_SetDemand(BUS, wname, Swthr); } } if (WBACK) { for (i = 0; i < intwt(Ninvl, &Winvl); i++) { namex(i, INVL, wname); PDQ_CreateClosed(wname, TERM, Ninvl, Zinvl); namex(i, L2C, cname); PDQ_SetDemand(cname, wname, gen); /* gen + intervene */ PDQ_SetDemand(BUS, wname, 1.0); } } PDQ_SetWUnit("Reqs"); PDQ_SetTUnit("Cycs"); PDQ_Solve(APPROX); /* bus utilizations */ for (i = 0; i < intwt(Nrdop, &Wrdop); i++) { namex(i, RDOP, wname); Ubrd += PDQ_GetUtilization(BUS, wname, TERM); } Ubrd *= Wrdop; if (WBACK) { for (i = 0; i < intwt(Nwbop, &Wwbop); i++) { namex(i, WROP, wname); Ubwr += PDQ_GetUtilization(BUS, wname, TERM); } Ubwr *= Wwbop; for (i = 0; i < intwt(Ninvl, &Winvl); i++) { namex(i, INVL, wname); Ubin += PDQ_GetUtilization(BUS, wname, TERM); } Ubin *= Winvl; } else { /* write-thru */ for (i = 0; i < intwt(Nwthr, &Wwthr); i++) { namex(i, WROP, wname); Ubwr += PDQ_GetUtilization(BUS, wname, TERM); } Ubwr *= Wwthr; } /* cache measures at CPU[0] only */ i = 0; namex(i, L2C, cname); namex(i, RWHT, wname); Xcpu = PDQ_GetThruput(TERM, wname) * Wrwht; Pcpu += Xcpu * Zrwht; Ucht = PDQ_GetUtilization(cname, wname, TERM) * Wrwht; namex(i, RDOP, wname); Xcpu = PDQ_GetThruput(TERM, wname) * Wrdop; Pcpu += Xcpu * Zrdop; Ucrd = PDQ_GetUtilization(cname, wname, TERM) * Wrdop; Pcpu *= 1.88; if (WBACK) { namex(i, WROP, wname); Ucwr = PDQ_GetUtilization(cname, wname, TERM) * Wwbop; namex(i, INVL, wname); Ucin = PDQ_GetUtilization(cname, wname, TERM) * Winvl; } else { /* write-thru */ namex(i, WROP, wname); Ucwr = PDQ_GetUtilization(cname, wname, TERM) * Wwthr; } printf("\n**** %s Results ****\n", model); printf("PDQ nodes: %d PDQ streams: %d\n", PDQ_GetNodesCount(), PDQ_GetStreamsCount()); printf("Memory Mode: %s\n", WBACK ? "WriteBack" : "WriteThru"); printf("Ncpu: %2d\n", MAXCPU); printf("Nrwht: %5.2f (N:%2d W:%5.2f)\n", Nrwht, intwt(Nrwht, &Wrwht), Wrwht); printf("Nrdop: %5.2f (N:%2d W:%5.2f)\n", Nrdop, intwt(Nrdop, &Wrdop), Wrdop); if (WBACK) { printf("Nwbop: %5.2f (N:%2d W:%5.2f)\n", Nwbop, intwt(Nwbop, &Wwbop), Wwbop); printf("Ninvl: %5.2f (N:%2d W:%5.2f)\n", Ninvl, intwt(Ninvl, &Winvl), Winvl); } else { printf("Nwthr: %5.2f (N:%2d W:%5.2f)\n", Nwthr, intwt(Nwthr, &Wwthr), Wwthr); } printf("\n"); printf("Hit Ratio: %5.2f %%\n", HT * 100.0); printf("Read Miss: %5.2f %%\n", RD * (1 - HT) * 100.0); printf("WriteMiss: %5.2f %%\n", WR * (1 - HT) * 100.0); printf("Ucpu: %5.2f %%\n", Pcpu * 100.0 / MAXCPU); printf("Pcpu: %5.2f\n", Pcpu); printf("\n"); printf("Ubus[reads]: %5.2f %%\n", Ubrd * 100.0); printf("Ubus[write]: %5.2f %%\n", Ubwr * 100.0); printf("Ubus[inval]: %5.2f %%\n", Ubin * 100.0); printf("Ubus[total]: %5.2f %%\n", (Ubrd + Ubwr + Ubin) * 100.0); printf("\n"); printf("Uca%d[hits]: %5.2f %%\n", i, Ucht * 100.0); printf("Uca%d[reads]: %5.2f %%\n", i, Ucrd * 100.0); printf("Uca%d[write]: %5.2f %%\n", i, Ucwr * 100.0); printf("Uca%d[inval]: %5.2f %%\n", i, Ucin * 100.0); printf("Uca%d[total]: %5.2f %%\n", i, (Ucht + Ucrd + Ucwr + Ucin) * 100.0); }
int main(void) { int nodes; int streams; // Mean service times from G&H double stimeSelect = 0.5; // mins double stimeClaims = 6.0; // mins double stimePolicy = 20.0; // mins double callRateIncoming = 35.0/60; // per min double callRateClaim; // compute from traffic eqns below double callRatePolicy; // compute from traffic eqns below // Routing probabilities from G&H double routeSelectClaim = 0.55; double routeSelectPolicy = 0.45; double routePolicyClaim = 0.01; double routeClaimPolicy = 0.02; // Visit ratios: lambda_k / lambda double vSelect; // no branching double vClaims; // compute from traffic eqns below double vPolicy; // compute from traffic eqns below /*** Solve the traffic equations first ***/ callRateClaim = (routeSelectClaim + routePolicyClaim * routeSelectPolicy) * callRateIncoming / (1 - routePolicyClaim * routeSelectPolicy); callRatePolicy = routeSelectPolicy * callRateIncoming + routeClaimPolicy * callRateClaim; vSelect = 1.0; // no branching vClaims = callRateClaim / callRateIncoming; vPolicy = callRatePolicy / callRateIncoming; /*** Now setup and solve the PDQ model using these visit ratios ***/ PDQ_Init("G&H Example 4.2"); streams = PDQ_CreateOpen("Customers", callRateIncoming); PDQ_SetWUnit("Calls"); PDQ_SetTUnit("Mins"); // timebase for PDQ report // Use a standard PDQ node as a test case nodes = PDQ_CreateNode("Select", CEN, FCFS); // Multiserver nodes nodes = PDQ_CreateMultiNode(3, "Claims", CEN, FCFS); nodes = PDQ_CreateMultiNode(7, "Policy", CEN, FCFS); // In PDQ the computed visit ratios multiply the service times PDQ_SetDemand("Select", "Customers", vSelect * stimeSelect); PDQ_SetDemand("Claims", "Customers", vClaims * stimeClaims); PDQ_SetDemand("Policy", "Customers", vPolicy * stimePolicy); PDQ_Solve(CANON); PDQ_Report(); } // main