www.pudn.com > ghs1.2.rar > apppred.cpp


/*
 * Copyright (c) 2000-2003 Illinois Institute of Technology.
 *                         All rights reserved.
 *
 * This file is part of the GHS software package.  For license
 * information, see the LICENSE file in the top level directory of the
 * GHS source distribution.
 *
 * Released Date: August 18 2005
 * This is the GHS I release by the
 *   SCS Group,
 *   http://www.cs.iit.edu/~scs
 *   Department of Computer Science,
 *   Illinois Institute of Technology.
 *
 * This release has been tested under SUN OS 5.9.
 *
 * Supervisor
 * ----------
 * Illiniois Institute of Technology:
 * -Dr. Xian-He Sun
 *
 * Author(s)
 * -----------------
 * Illinois Institute of Technology:
 * -Ming Wu
 * -Xian-He Sun
 *
 */

#include
#include 
#include
#include
#include
#include
#include
#include "ghs.h"

using namespace std;

extern double GetParaCDF(double tasktime);
extern double GetParaMean(int numOfinte);
extern double GetParaVari(double paraMean, int numOfInte);
extern void ReadTaskPara(const vector& ut, const vector& ar, const vector& ss, const vector& wo, int mNum);
extern void CalculateAB();

class AppPredictor
{
  private:
    vector utilPara, servPara, arriPara, servstdPara, workPara, speedPara;
    vector machname;
    vector taskname;
    int wsNum;
    double meantime, variance;
  
  public:
    void EstiRuntime();
    void GetMapTab(char *configFile);
    void OutputPredict(char *outputFile);
};


/* calcuate the mean+variance of the parallel task runtime
 * using model formulas 
 */
void
AppPredictor::EstiRuntime()
{
  ReadTaskPara(utilPara, arriPara, servstdPara, workPara, wsNum);
  //read_taskpara(util, arri, servstd, work, j);
  int interNum = XNUM;
  meantime = GetParaMean(interNum);
  //cout << "the meantime is " << meantime << endl;
  variance = GetParaVari(meantime, interNum);
  //cout << "the variance is " << variance << endl;
  meantime = GetParaMean(interNum);

}

/*  read resource parameters
 *	resource name, utilization, arrival rate, servicestd
 */
void 
AppPredictor::GetMapTab(char *configFile) 
{
  
  fstream mapStream;
  mapStream.open(configFile, fstream::in);
  if ( !mapStream.is_open()) 
  {
    cout << "can't open the maptab file" <> tmpName >> tmpUtil >> tmpArri >> tmpServ >> tmpSpeed >> tmpWorkload;
    machname.push_back(tmpName);
    utilPara.push_back(tmpUtil);
    arriPara.push_back(tmpArri);
    servstdPara.push_back(tmpServ);
    speedPara.push_back(tmpSpeed);
    workPara.push_back(tmpWorkload/tmpSpeed);
    //cout << utilPara[i] <<" "<< arriPara[i] <<" "<< servstdPara[i] <<" "<< speedPara[i] < 0.995) break;

    outStream << taskTime + timeInterval << " " << newCDF << endl;
  }

  outStream.close();

}

int 
main(int argc, char **argv)
{
  if (argc != 3)
  {
    cout << "apppred mapinfo.txt result.txt" << endl;
    exit(1);
  }

  AppPredictor myPred;

  myPred.GetMapTab(argv[1]);
  myPred.EstiRuntime();
  myPred.OutputPredict(argv[2]);
  return(0);

}