Exemple #1
0
int main()
{
   int              noNodes;
   int              noStreams;

   char *noPri = "CPU Scheduler - No Pri";
   char *priOn = "CPU Scheduler - Pri On";

   float Ucpu_prod;
   float GetProdU();

   if (PRIORITY) { 
   	Ucpu_prod = GetProdU();
   }

   PDQ_Init(PRIORITY ? priOn : noPri);

   // workloads ...

   noStreams = PDQ_CreateClosed("Production", TERM, 20.0, 20.0);
   noStreams = PDQ_CreateClosed("Developmnt", TERM, 15.0, 15.0);

   // queueing noNodes ...

   noNodes = PDQ_CreateNode("CPU", CEN, FCFS);

   if (PRIORITY) { 
   	noNodes = PDQ_CreateNode("shadCPU", CEN, FCFS);
   }

   noNodes = PDQ_CreateNode("DK1", CEN, FCFS);
   noNodes = PDQ_CreateNode("DK2", CEN, FCFS);

   // service demands at each node ...

   PDQ_SetDemand("CPU", "Production", 0.30);

   if (PRIORITY) { 
   	PDQ_SetDemand("shadCPU", "Developmnt", 1.00/(1 - Ucpu_prod));
   } else { 
   	PDQ_SetDemand("CPU", "Developmnt", 1.00);
   }

   PDQ_SetDemand("DK1", "Production", 0.08);
   PDQ_SetDemand("DK1", "Developmnt", 0.05);

   PDQ_SetDemand("DK2", "Production", 0.10);
   PDQ_SetDemand("DK2", "Developmnt", 0.06);

   // We use APPROX rather than EXACT to match the numbers in the book

   PDQ_Solve(APPROX); 

   PDQ_Report();

   return(0);
}  // main
Exemple #2
0
int main()
{

   /************************
    * PDQ global variables *
    ************************/
   int              noNodes;
   int              noStreams;

   /************************
    * Initialize the model *
    ************************/
   /* Give model a name */

   PDQ_Init("Multiclass Test");

   /* Define the workload and circuit type */
   noStreams = PDQ_CreateClosed("term1", TERM, 5.0, 20.0);
   noStreams = PDQ_CreateClosed("term2", TERM, 15.0, 30.0);
   noStreams = PDQ_CreateClosed("batch", BATCH, 5.0, 0.0);

   /* Define the queueing center */
   noNodes = PDQ_CreateNode("node1", CEN, FCFS);
   noNodes = PDQ_CreateNode("node2", CEN, FCFS);
   noNodes = PDQ_CreateNode("node3", CEN, FCFS);

   /* Define service demand */
   PDQ_SetDemand("node1", "term1", 0.50);
   PDQ_SetDemand("node1", "term2", 0.04);
   PDQ_SetDemand("node1", "batch", 0.06);

   PDQ_SetDemand("node2", "term1", 0.40);
   PDQ_SetDemand("node2", "term2", 0.20);
   PDQ_SetDemand("node2", "batch", 0.30);

   PDQ_SetDemand("node3", "term1", 1.20);
   PDQ_SetDemand("node3", "term2", 0.05);
   PDQ_SetDemand("node3", "batch", 0.06);

   /*******************
    * Solve the model *
    *******************/
   PDQ_Solve(EXACT);
   PDQ_Report();

   return(0);
   
}
Exemple #3
0
void mem_model(int n, int m)
{
	extern double   GetThruput();

	float           x = 0.0;
	int             i;
	int             noNodes;
	int             noStreams;

	for (i = 1; i <= n; i++) {
		if (i <= m) {

			PDQ_Init("");

			noNodes = PDQ_CreateNode("CPU", CEN, FCFS);
			noNodes = PDQ_CreateNode("DK1", CEN, FCFS);
			noNodes = PDQ_CreateNode("DK2", CEN, FCFS);

			noStreams = PDQ_CreateClosed("work", TERM, (float) i, 0.0);

			PDQ_SetDemand("CPU", "work", 3.0);
			PDQ_SetDemand("DK1", "work", 4.0);
			PDQ_SetDemand("DK2", "work", 2.0);

			PDQ_Solve(EXACT);

			x = PDQ_GetThruput(TERM, "work");
			sm_x[i] = x;

		} else
			sm_x[i] = x;        /* last computed value */

	}
}  /* mem_model */
Exemple #4
0
void multiserver(int m, double stime)
{
	int              i;
	int              nodes;
	int              streams;
	double           x;
	char            *work = "reqs";
	char            *node = "bus";

	for (i = 1; i <= CPUS; i++) {
		//fprintf(stderr, "[multiserver] i -> %d, m -> %d, stime -> %f\n", i, m, stime);

		if (i <= m) {
	 		PDQ_Init("multibus");
	 		streams = PDQ_CreateClosed(work, TERM, (double) i, 0.0);
	 		nodes = PDQ_CreateNode(node, CEN, ISRV);
	 		PDQ_SetDemand(node, work, stime);
	 		PDQ_Solve(EXACT);
	 		x = PDQ_GetThruput(TERM, work);
	 		sm_x[i] = x;
		} else {
	 		sm_x[i] = x;
		}
	}
}  /* multiserver */
Exemple #5
0
float GetProdU(void) {
   int              noNodes;
   int              noStreams;

   PDQ_Init("");

   noStreams = PDQ_CreateClosed("Production", TERM, 20.0, 20.0);
   noNodes = PDQ_CreateNode("CPU", CEN, FCFS);
   noNodes = PDQ_CreateNode("DK1", CEN, FCFS);
   noNodes = PDQ_CreateNode("DK2", CEN, FCFS);

   PDQ_SetDemand("CPU", "Production", 0.30);
   PDQ_SetDemand("DK1", "Production", 0.08);
   PDQ_SetDemand("DK2", "Production", 0.10);

   PDQ_Solve(APPROX); 

   return(PDQ_GetUtilization("CPU", "Production", TERM));
}  // GetProdU
Exemple #6
0
int main()
{
   /************************
    * PDQ global variables *
    ************************/

   extern JOB_TYPE *job;
   extern double    getjob_pop();
   extern int       getjob_index();
   extern double    PDQ_GetResponse();
   extern double    PDQ_GetThruput();
   extern double    PDQ_GetUtilization();

   /****************************
    * Model specific variables *
    ****************************/

   int              noNodes;
   int              noStreams;
   int              tech;
   int              pop;
   double           think = 0.0;

   /************************
    * Initialize the model *
    ************************/

   /* Give model a name */
   /*PDQ_Init("Test_Exact_Calc");*/

   tech = APPROX;
   printf("**** %s Solution ****:\n\n", tech == EXACT ? "EXACT" : "APPROX");
   printf("  N      R (w1)    R (w2)\n");

   for (pop = 1; pop < 10; pop++) {
      PDQ_Init("Test_Exact_calc");

      /* Define the workload and circuit type */
      noStreams = PDQ_CreateClosed("w1", TERM, 1.0 * pop, think);
      noStreams = PDQ_CreateClosed("w2", TERM, 1.0 * pop, think);

      /* Define the queueing center */
      noNodes = PDQ_CreateNode("node", CEN, FCFS);

      /* Define service demand */
      PDQ_SetDemand("node", "w1", 1.0);
      PDQ_SetDemand("node", "w2", 0.5);

      /*******************
       * Solve the model *
       *******************/
      PDQ_Solve(tech);

/*
      printf("N\tR\n%8.4f  %8.4f\n",
	     getjob_pop(getjob_index("w1")),
	     PDQ_GetResponse(TERM, "w1"));

      printf("N\tR\n%8.4f  %8.4f\n",
	     getjob_pop(getjob_index("w2")),
	     PDQ_GetResponse(TERM, "w2"));
*/
      printf("%3d    %8.4f  %8.4f\n",
	     pop, PDQ_GetResponse(TERM, "w1"),
	     PDQ_GetResponse(TERM, "w2"));
   }

   return(0);
}  // main
Exemple #7
0
int main(int argc, char *argv[])
{
   extern JOB_TYPE *job;

   int              k;
   int              sol_mode = APPROX;
   char            *sol_name = "APPROX";
   char             name[16];
   char             nstr[5];
   void             nullit();
   void             itoa();

   // input parameters
   double           think = 10.0;
   /*int             users = 800;*/
   int              users = 300;

   double           Sifp = 0.10;
   double           Samp = 0.60;
   double           Sdsu = 1.20;

   int              Nifp = 15;
   int              Namp = 50;
   int              Ndsu = 100;

   if (argc == 2) {
       if (!strcmp(argv[1], "APPROX")) {
          sol_name = argv[1];
          sol_mode = APPROX;
       } else if (!strcmp(argv[1], "EXACT")) {
          sol_name = argv[1];
          sol_mode = EXACT;
       }
   }

   PDQ_Init("Teradata DBC-10/12");

   //Create parallel centers
   for (k = 0; k < Nifp; k++) {
      // itoa(k, nstr);
      // strcpy(name, "IFP");
      // strcat(name, nstr);
      sprintf(name, "IFP%d", k);
      PDQ_CreateNode(name, CEN, FCFS);
      // nullit(name);
      // nullit(nstr);
   }

   for (k = 0; k < Namp; k++) {
      // itoa(k, nstr);
      // strcpy(name, "AMP");
      // strcat(name, nstr);
      sprintf(name, "AMP%d", k);
      PDQ_CreateNode(name, CEN, FCFS);
      // nullit(name);
      // nullit(nstr);
   }

   for (k = 0; k < Ndsu; k++) {
      // itoa(k, nstr);
      // strcpy(name, "DSU");
      // strcat(name, nstr);
      sprintf(name, "DSU%d", k);
      PDQ_CreateNode(name, CEN, FCFS);
      // nullit(name);
      // nullit(nstr);
   }

   PDQ_CreateClosed("query", TERM, (double) users, think);

   for (k = 0; k < Nifp; k++) {
      // itoa(k, nstr);
      // strcpy(name, "IFP");
      // strcat(name, nstr);
      sprintf(name, "IFP%d", k);
      PDQ_SetDemand(name, "query", Sifp / Nifp);
      nullit(name);
      nullit(nstr);
   }

   for (k = 0; k < Namp; k++) {
      sprintf(name, "AMP%d", k);
      PDQ_SetDemand(name, "query", Samp / Namp);
   }

   for (k = 0; k < Ndsu; k++) {
      sprintf(name, "DSU%d", k);
      PDQ_SetDemand(name, "query", Sdsu / Ndsu);
   }

   // 300 nodes takes about a minute to solve on a PowerMac

   fprintf(stdout, "Solving %s... ", sol_name);
   fflush(stdout);

   PDQ_Solve(sol_mode);
   printf("Done.\n");
   PDQ_Report();   
}  
Exemple #8
0
int main()
{
   extern JOB_TYPE *job;
   extern double    getjob_pop();
   extern int       getjob_index();
   extern double    PDQ_GetResponse();
   extern double    PDQ_GetThruput();
   extern double    PDQ_GetUtilization();

   /****************************
	* Model specific variables *
	****************************/

   int              noNodes;
	int              noStreams;
   int              pop, servers = 2;
   int              s, w;

#define STRESS	0
#define HOMEPG 1

   static char    *work[] = {
	  "stress",
	  "homepg"
   };

   static double   time[] = {
	  0.0044,			/* stress */
	  0.0300			/* homepg */
   };

   static char    *slave[] = {
	  "slave0",
	  "slave1",
	  "slave2",
	  "slave3",
	  "slave4",
	  "slave5",
	  "slave6",
	  "slave7",
	  "slave8",
	  "slave9",
	  "slave10",
	  "slave11",
	  "slave12",
	  "slave13",
	  "slave14",
	  "slave15"
   };

#define	PREFORK 
	w = HOMEPG;

#ifdef PREFORK
	printf("Pre-Fork Model under \"%s\" Load (m = %d)\n",
		w == STRESS ? work[STRESS] : work[HOMEPG], servers);
#else
	printf("Forking  Model under \"%s\" Load \n",
		w == STRESS ? work[STRESS] : work[HOMEPG]);
#endif

	printf("\n  N        X         R\n");

	for (pop = 1; pop <= 10; pop++) {

		PDQ_Init("HTTPd_Server");

		noStreams = PDQ_CreateClosed(work[w], TERM, 1.0 * pop, 0.0);
		noNodes = PDQ_CreateNode("master", CEN, FCFS);

#ifdef PREFORK
		for (s = 0; s < servers; s++) {
			noNodes = PDQ_CreateNode(slave[s], CEN, FCFS);
		}

		PDQ_SetDemand("master", work[w], 0.0109);

		for (s = 0; s < servers; s++) {
			PDQ_SetDemand(slave[s], work[w], time[w] / servers);
		}
#else				/* FORKING */
	noNodes = PDQ_CreateNode("forks", CEN, ISRV);

	PDQ_SetDemand("master", work[w], 0.0165);
	PDQ_SetDemand("forks", work[w], time[w]);
#endif

	PDQ_Solve(EXACT);

	printf("%5.2f   %8.4f  %8.4f\n",
		 getjob_pop(getjob_index(work[w])),
		 PDQ_GetThruput(TERM, work[w]),
		 PDQ_GetResponse(TERM, work[w]));
   }

   return(0);
}  // main
Exemple #9
0
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);

}