Ejemplo n.º 1
0
void GenBench(sParams* PBBench) {

	boolean 	finished = FALSE;
	int32		prevExp = 0;
	int32		currExp;
	int32 		numExp;
	FILE*		fp = NULL;	// file pointer
	FILE*		fp2 = NULL;	// file pointer
	char 		str[MAX_STR];
	int32		tabVal[MAX_VARYING_VAL];
	sParams		PBExp;
	int32		nbVal;
	item* 		memList;
	bool		tabSel[MAXBENCH*MAXMODE];
	int32		nbExp = 0;
	int32		key = 0;
	
	parseSel(PBBench, tabSel);
	// Allocate data structure for computing target offset
	memList = InitMemList((int32)(PBBench->deviceSize));
	fp2 = fopen(PBBench->outName, "w");
	if (fp2 == NULL) HandleError("GenBench", "Could not open output file", GetLastError(), ERR_ABORT);
	
	while (finished == FALSE) {
	// find the next experiment - it is the smallest numExp, greater than prevExp 
		if ((fp  = fopen(PBBench->expPlan, "r")) == NULL ) 
			HandleError("GenBench", "Cannot open experimentation plan file", GetLastError(), ERR_ABORT);
		currExp = INT32_MAX;
		while (fgets(str, MAX_STR,fp) != NULL) {
			numExp = atoi(str);
			if ((numExp > prevExp) && (numExp < currExp)) {
				currExp = numExp;
			}
		}
		if ((currExp > prevExp) && (currExp != INT32_MAX)) {
			printf("===================  Order Number %d\n", currExp);
			
			//New param structure
			InitParams(&PBExp);
			PBExp.deviceNum = PBBench->deviceNum;
			PBExp.IOSize = PBBench->IOSize;
			PBExp.IOCount = PBBench->IOCount;
			PBExp.IOCountSR = PBBench->IOCountSR;
			PBExp.IOCountRR = PBBench->IOCountRR;
			PBExp.IOCountSW = PBBench->IOCountSW;
			PBExp.IOCountRW = PBBench->IOCountRW;
			PBExp.ignoreIO = PBBench->ignoreIO;
			PBExp.ignoreIOSR = PBBench->ignoreIOSR;
			PBExp.ignoreIORR = PBBench->ignoreIORR;
			PBExp.ignoreIOSW = PBBench->ignoreIOSW;
			PBExp.ignoreIORW = PBBench->ignoreIORW;
			PBExp.collectErase = PBBench->collectErase;
			PBExp.pauseExp = PBBench->pauseExp;
			PBExp.fake = PBBench->fake;
			PBExp.bufferType = PBBench->bufferType;
			PBExp.deviceSize = PBBench->deviceSize;	
			PBExp.burstIO = PBBench->burstIO;
			PBExp.nbRun = PBBench->nbRun;  
			
			// parse the experiment
			nbVal = parseExp(fp, currExp, &PBExp, tabVal);
			if (tabSel[(PBExp.microBenchID - 1) * MAXMODE + PBExp.expID - 1] == TRUE) {
				for (int32 exp = 0; exp < nbVal; ++exp) {
					// Compute the different parameters
					if (PBExp.microBenchID == PAR)  {
						for (PBExp.runID = 0; PBExp.runID < PBExp.nbRun; (PBExp.runID)++) {
							PBExp.parDeg = tabVal[exp];
							for (int32 pID = 0; pID < PBExp.parDeg; ++pID) {
								PBExp.processID = PBExp.parDeg - pID - 1;
								PBExp.key = key++;
								ComputeParams(&PBExp, memList,PBExp.parDeg, nbVal );
								GenExp(fp2, &PBExp);
								nbExp++;
								PBExp.IOSize = PBBench->IOSize;
								PBExp.IOCount = PBBench->IOCount;
								PBExp.ignoreIO = PBBench->ignoreIO;
								
							}
						}
					}
					else {
						for (PBExp.runID = 0; PBExp.runID < PBExp.nbRun; (PBExp.runID)++) {
							PBExp.key = key++;
							ComputeParams(&PBExp, memList, tabVal[exp], nbVal);
							GenExp(fp2, &PBExp);
							nbExp ++;
							PBExp.IOSize = PBBench->IOSize;
							PBExp.IOCount = PBBench->IOCount;
							PBExp.ignoreIO = PBBench->ignoreIO;
						}
					}
				}
			}
			else
				printf("===================  Not Selected\n");
			fprintf(fp2, "\n");		
		}
		else finished = TRUE;
		prevExp = currExp;
		if (fp) fclose(fp);
	}
	fclose(fp2);							// close the output file if we opened it
	while (memList) {
		item *tmp = memList->next;
		free(memList);
		memList = tmp;
	}
	sprintf(str, "%d Experiments have been generated\n", nbExp);
	OutputString(OUT_LOG, str);

}
Ejemplo n.º 2
0
void
GenBench (UflipParams *PBBench)
{
  bool         finished = false;
  int32_t      prevExp  = 0;
  int32_t      currExp;
  int32_t      numExp;
  FILE        *fp       = NULL;  /* file pointer */
  FILE        *fp2      = NULL;  /* file pointer */
  char         str [MAX_STR];
  int32_t      tabVal [MAX_VARYING_VAL];
  UflipParams *PBExp;
  int32_t      nbVal;
  item        *memList;
  bool         tabSel [MAXBENCH*MAXMODE];
  int32_t      nbExp    = 0;
  int          key      = 0;

  if (parseSel (PBBench, tabSel) == -1)
    HandleError (__func__, "Problem with the experimentation plan!", 0, ERR_ABORT);

  /* Allocate data structure for computing target offset */
  memList = InitMemList ((int32_t) (PBBench->deviceSize));
  if (memList == NULL)
    HandleError (__func__, "Could not allocate memList", errno, ERR_ABORT);

  fp2 = fopen (PBBench->outName, "w");
  if (fp2 == NULL)
    HandleError (__func__, "Could not open output file", errno, ERR_ABORT);

  if (fwrite (SCRIPT_SHEBANGS, sizeof (char), strlen (SCRIPT_SHEBANGS), fp2) < strlen (SCRIPT_SHEBANGS))
    {
      int err = errno;
      fclose (fp2);
      HandleError (__func__, "Could not write to output file", err, ERR_ABORT);
    }

  while (finished == false)
    {
      /* find the next experiment - it is the smallest numExp, greater than prevExp */
      if ((fp = fopen (PBBench->expPlan, "r")) == NULL )
        HandleError (__func__, "Cannot open experimentation plan file", errno, ERR_ABORT);

      currExp = INT32_MAX;
      while (fgets(str, MAX_STR,fp) != NULL)
        {
          numExp = atoi (str);
          if ((numExp > prevExp) && (numExp < currExp))
            currExp = numExp;
        }

      if ((currExp > prevExp) && (currExp != INT32_MAX))
        {
          printf ("===================  Order Number %d\n", currExp);

          /* New param structure */
          PBExp = uflip_params_new ();
          PBExp->device = uflip_device_copy (PBBench->device);
          if (PBExp->device == NULL)
                    HandleError (__func__, "couldn't allocate Param->device subblock", 0, ERR_ABORT);

          InitParams (PBExp);
          PBExp->IOSize       = PBBench->IOSize;
          PBExp->IOCount      = PBBench->IOCount;
          PBExp->IOCountSR    = PBBench->IOCountSR;
          PBExp->IOCountRR    = PBBench->IOCountRR;
          PBExp->IOCountSW    = PBBench->IOCountSW;
          PBExp->IOCountRW    = PBBench->IOCountRW;
          PBExp->ignoreIO     = PBBench->ignoreIO;
          PBExp->ignoreIOSR   = PBBench->ignoreIOSR;
          PBExp->ignoreIORR   = PBBench->ignoreIORR;
          PBExp->ignoreIOSW   = PBBench->ignoreIOSW;
          PBExp->ignoreIORW   = PBBench->ignoreIORW;
          PBExp->collectErase = PBBench->collectErase;
          PBExp->pauseExp     = PBBench->pauseExp;
          PBExp->fake         = PBBench->fake;
          PBExp->bufferType   = PBBench->bufferType;
          PBExp->deviceSize   = PBBench->deviceSize;
          PBExp->burstIO      = PBBench->burstIO;
          PBExp->nbRun        = PBBench->nbRun;

          /* parse the experiment */
          nbVal = parseExp (fp, currExp, PBExp, tabVal);
          if (nbVal == -1)
            HandleError (__func__, "Problem with the experimentation selection!", 0, ERR_ABORT);

          if (tabSel [(PBExp->microBenchID - 1) * MAXMODE + PBExp->expID - 1] == true)
            {
              for (int32_t exp = 0; exp < nbVal; ++exp)
                {
                  /* Compute the different parameters */
                  if (PBExp->microBenchID == PAR)
                    {
                      for (PBExp->runID = 0; PBExp->runID < PBExp->nbRun; ++PBExp->runID)
                        {
                          PBExp->parDeg = tabVal [exp];
                          for (int32_t pID = 0; pID < PBExp->parDeg; ++pID)
                            {
                              PBExp->processID = PBExp->parDeg - pID - 1;
                              PBExp->key       = key++;
                              ComputeParams (PBExp, memList, PBExp->parDeg, nbVal);
                              GenExp (fp2, PBExp);
                              ++nbExp;
                              PBExp->IOSize    = PBBench->IOSize;
                              PBExp->IOCount   = PBBench->IOCount;
                              PBExp->ignoreIO  = PBBench->ignoreIO;
                            }
                        }
                    }
                  else
                    {
                      for (PBExp->runID = 0; PBExp->runID < PBExp->nbRun; ++PBExp->runID)
                        {
                          PBExp->key      = key++;
                          ComputeParams (PBExp, memList, tabVal [exp], nbVal);
                          GenExp (fp2, PBExp);
                          ++nbExp;
                          PBExp->IOSize   = PBBench->IOSize;
                          PBExp->IOCount  = PBBench->IOCount;
                          PBExp->ignoreIO = PBBench->ignoreIO;
                        }
                    }
                }
            }
          else
            {
              printf ("===================  Not Selected\n");
            }
          fprintf (fp2, "\n");
        }
      else
        {
          finished = true;
        }
      prevExp = currExp;
      uflip_params_destroy (PBExp);
      PBExp = NULL;
      if (fp)
        fclose (fp);

    }
  fclose (fp2);

  while (memList)
    {
      item *tmp = memList->next;
      free (memList);
      memList = tmp;
    }

  sprintf (str, "%d Experiments have been generated\n", nbExp);
  OutputString (OUT_LOG, str);
}