Example #1
0
static  void    ExpOp( TYPE typ1, TYPE typ2, OPTR op ) {
//======================================================

    op = op;
    if( !_IsTypeInteger( typ2 ) ) {
        Convert();
        GenExp( ResultType );
    } else {
        CnvTo( CITNode, ResultType, TypeSize( ResultType ) );
        ExpI( typ1, &CITNode->value, ITIntValue( CITNode->link ) );
    }
}
Example #2
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);

}
Example #3
0
/* This function generates a batch named prepare.bat (default).
 * The batch contains 6 experiments
 * Exp1: SPE - (Special) - runs IOCount SR then IOCount RW then IOCount SR
 * 		 The goal is here to determine the Pause value
 * Exp2: SIO.SR - runs IOCount2 SR - goal: determine IOIgnoreSR and IOCountSR
 * Exp3-5 : same for RR, SW, RW
 * Exp6 : Random format of the device 
 */ 
 	void GenPrepare(sParams* PB) {
	FILE*		fp2 = NULL;	// file pointer
	int32 		size;

	fp2 = fopen(PB->outName, "w");
	if (fp2 == NULL) HandleError("GenBench", "Could not open output file", GetLastError(), ERR_ABORT);
	strcpy(PB->comment, "SPE");
	strcpy(PB->base, "SR");
	PB->expID = 1;
	PB->microBenchID = 0;
	PB->pauseExp = 10000;
	size = PB->IOSize * PB->IOCount;
	for (PB->runID = 0; PB->runID < PB->nbRun; (PB->runID)++) {
		PB->targetOffset = rg.IRandom(0,(int32)((PB->deviceSize/2 - size)/BLOCK))*BLOCK; // We choose a random location in the first half of the device
		PB->targetSize = PB->deviceSize - PB->targetOffset;
		GenExp(fp2, PB);
	}
	PB->IOCount = PB->IOCount2;
	size = PB->IOSize * PB->IOCount;
	strcpy(PB->comment, "SIO.SR");
	PB->expID = 2;
	for (PB->runID = 0; PB->runID < PB->nbRun; (PB->runID)++) {
		PB->targetOffset = rg.IRandom(0,(int32)((PB->deviceSize/2 - size)/BLOCK))*BLOCK; // We choose a random location in the first half of the device
		PB->targetSize = PB->deviceSize - PB->targetOffset;
		GenExp(fp2, PB);
	}
	strcpy(PB->base, "RR");
	strcpy(PB->comment, "SIO.RR");
	PB->expID++;
	for (PB->runID = 0; PB->runID < PB->nbRun; (PB->runID)++) {
		PB->targetOffset = rg.IRandom(0,(int32)((PB->deviceSize/2 - size)/BLOCK))*BLOCK; // We choose a random location in the first half of the device
		PB->targetSize = PB->deviceSize - PB->targetOffset;
		GenExp(fp2, PB);
	}
	strcpy(PB->base, "SW");
	strcpy(PB->comment, "SIO.SW");
	PB->expID++;
	for (PB->runID = 0; PB->runID < PB->nbRun; (PB->runID)++) {
		PB->targetOffset = rg.IRandom(0,(int32)((PB->deviceSize/2 - size)/BLOCK))*BLOCK; // We choose a random location in the first half of the device
		PB->targetSize = PB->deviceSize - PB->targetOffset;
		GenExp(fp2, PB);
	}
	strcpy(PB->base, "RW");
	strcpy(PB->comment, "SIO.RW");
	PB->expID++;
	for (PB->runID = 0; PB->runID < PB->nbRun; (PB->runID)++) {
		PB->targetOffset = rg.IRandom(0,(int32)((PB->deviceSize/2 - size)/BLOCK))*BLOCK; // We choose a random location in the first half of the device
		PB->targetSize = PB->deviceSize - PB->targetOffset;
		GenExp(fp2, PB);
	}
	PB->expID++;
	fprintf(fp2, "FlashIO RandomFormat Dev %d Bench %d Exp %d ", PB->deviceNum, PB->microBenchID, PB->expID);

	if (PB->trimBeforeRun == TRUE)
			fprintf(fp2, "TrimBeforeRun True\n");
		else
			fprintf(fp2, "\n");

	if (PB->fake == TRUE) 
		fprintf(fp2, "Fake True\n Pause\n");
	else
		fprintf(fp2, "\n Pause\n");

	fclose(fp2);
}
Example #4
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);
}
Example #5
0
void
GenPrepare (UflipParams *PB)
{
  FILE   *fp2 = NULL; /* file pointer */
  int32_t size;

  fp2 = fopen (PB->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);
    }
  strcpy (PB->comment, "SPE");
  strcpy (PB->base, "SR");
  PB->expID        = 1;
  PB->microBenchID = 0;
  size = PB->IOSize * PB->IOCount;
  for (PB->runID = 0; PB->runID < PB->nbRun; ++PB->runID)
    {
      PB->targetOffset = uflip_random_get_int (rg, 0, (int32_t) ((PB->deviceSize / 2 - size) / BLOCK)) * BLOCK; /* We choose a random location in the first half of the device */
      PB->targetSize = PB->deviceSize - PB->targetOffset;
      GenExp (fp2, PB);
    }

  PB->IOCount = PB->IOCount2;
  size        = PB->IOSize * PB->IOCount;
  strcpy (PB->comment, "SIO.SR");
  PB->expID   = 2;
  for (PB->runID = 0; PB->runID < PB->nbRun; ++PB->runID)
    {
      PB->targetOffset = uflip_random_get_int (rg, 0, (int32_t) ((PB->deviceSize / 2 - size) / BLOCK)) * BLOCK; /* We choose a random location in the first half of the device */
      PB->targetSize = PB->deviceSize - PB->targetOffset;
      GenExp (fp2, PB);
    }

  strcpy (PB->base, "RR");
  strcpy (PB->comment, "SIO.RR");
  ++PB->expID;
  for (PB->runID = 0; PB->runID < PB->nbRun; ++PB->runID)
    {
      PB->targetOffset = uflip_random_get_int (rg, 0, (int32_t) ((PB->deviceSize / 2 - size) / BLOCK)) * BLOCK; /* We choose a random location in the first half of the device */
      PB->targetSize = PB->deviceSize - PB->targetOffset;
      GenExp (fp2, PB);
    }

  strcpy (PB->base, "SW");
  strcpy (PB->comment, "SIO.SW");
  ++PB->expID;
  for (PB->runID = 0; PB->runID < PB->nbRun; ++PB->runID)
    {
      PB->targetOffset = uflip_random_get_int (rg, 0, (int32_t) ((PB->deviceSize / 2 - size) / BLOCK)) * BLOCK; /* We choose a random location in the first half of the device */
      PB->targetSize = PB->deviceSize - PB->targetOffset;
      GenExp (fp2, PB);
    }

  strcpy (PB->base, "RW");
  strcpy (PB->comment, "SIO.RW");
  ++PB->expID;
  for (PB->runID = 0; PB->runID < PB->nbRun; ++PB->runID)
    {
      PB->targetOffset = uflip_random_get_int (rg, 0, (int32_t) ((PB->deviceSize / 2 - size) / BLOCK)) * BLOCK; /* We choose a random location in the first half of the device */
      PB->targetSize = PB->deviceSize - PB->targetOffset;
      GenExp (fp2, PB);
    }

  ++PB->expID;
  if (PB->fmtType != NONE)
    {
      char *fmt_str;
      if (PB->fmtType == SEQ)
        {
          fmt_str = "SequentialFormat";
        }
      else
        {
          fmt_str = "RandomFormat";
        }
      fprintf (fp2, EXEC_PREFIX""PACKAGE_NAME" %s Dev %s Bench %d Exp %d ", fmt_str, uflip_device_to_string (PB->device), PB->microBenchID, PB->expID);
      if (PB->fake == true)
        fprintf (fp2, "Fake True");
    }
  fprintf (fp2, "\n"SCRIPT_PAUSE"\n");
  fclose (fp2);
}