int main(int argc, char *argv[])
{
  printf("\nsim-virtual - Virtual Memory Simulator\n\n");

  srand(time(NULL));

  if(argc == 5 || (argc == 7 && strcmp(argv[5], "-D") == 0)) {
    if(strcmp(argv[1], "NRU") == 0) {
        simulationInfo.prAlgo = PR_NRU;
    }
    else if(strcmp(argv[1], "LRU") == 0) {
        simulationInfo.prAlgo = PR_LRU;
    }
    else if(strcmp(argv[1], "SEC") == 0) {
        simulationInfo.prAlgo = PR_SEC;
    }
    else {
        printf("\n[ERROR] No valid algorithm specified.\n");
        exit(-1);
    }

    if(argc == 7) simulationInfo.debugLevel = atoi(argv[6]);
    return runSimulator(argv[1], argv[2], atoi(argv[3]), atoi(argv[4]));
  }
  else {
    printf("Usage: sim-virtual PageReplacementAlgorithm InputFile PageSizeKB PhysicalMemoryKB (-D DEBUGLEVEL)\n\tPageReplacementAlgorithm - Algorithm to be used for the page replacement (NRU, LRU, or SEC).\n\tInputFile - Path to the input file (.log extension)\n\tPageSizeKB - Page size, in kilobytes\n\tPhysicalMemorySizeKB - Physical memory size, in kilobytes\n\tDEBUGLEVEL - Optional argument. Simulator debug level\n\n");
  }

  return 0;
}
Пример #2
0
int main(int argc, char **argv) {

	int exitCode;

	//doTestAndDie();

	parseArgs(argc,argv);

	if (sendFile)
		exitCode = sendFileContent(ip,udpPort,fileName);
	else
		exitCode = runSimulator(ip,udpPort);

	return exitCode;

	//return EXIT_SUCCESS;
}
Пример #3
0
int main(int argc, char* argv[]) {
	if((argc > 1) && (strcmp(argv[1], "-b") == 0)) {
		benchmark();
	}
	else {
		FILE* cfg = fopen("simulation.cfg", "r");
		if(cfg) {
			int numTests;
			char simType[30], input[30], version;
			fscanf(cfg, "%d %c", &numTests, &version);
			for(int i=0; i<numTests; i++) {
				fscanf(cfg, "%s %s", simType, input);
				runSimulator(simType, input, version);
			}
		}
		else {
			printf("Couldn't open 'simulation.cfg' file. Please verify the file exits in your current directory.\n");
		}
		fclose(cfg);
	}

	return 0;
}
Пример #4
0
void benchmark() {
	string simTypes[] = {"TotalOrderBasic", "TotalOrderTree", "TotalOrderPipeline"};
	string benchs[] = {"in_4_singleMsg.cfg", "in_4_singleSender.cfg", "in_4_nSenders.cfg",
					   "in_5_singleMsg.cfg", "in_5_singleSender.cfg", "in_5_nSenders.cfg",
					   "in_10_singleMsg.cfg", "in_10_singleSender.cfg", "in_10_nSenders.cfg",
					   "in_20_singleMsg.cfg", "in_20_singleSender.cfg", "in_20_nSenders.cfg",
					   "in_50_singleMsg.cfg", "in_50_singleSender.cfg", "in_50_nSenders.cfg"};
	char version[] = {'o', 'l'};
	for(int v=0; v<2; v++) {
		if(version[v]=='o') printf(">== Original Version ==<\n");
		else printf(">== Latency-Optimized version ==<\n");
		double lat[3][NUM_BENCHS], tp[3][NUM_BENCHS], stdDevLat[3][NUM_BENCHS];

		for(int i=0; i<3; i++) {
			for(int j=0; j<NUM_BENCHS; j++) {
				SimulationLog log = runSimulator(simTypes[i].c_str(), benchs[j].c_str(), version[v], false);
				lat[i][j] = log.getAvgLatency();
				stdDevLat[i][j] = log.getStdDevLatency();
				tp[i][j] = log.getAvgThroughput();
			}
		}
	
		for(int i=0; i<3; i++) {
			printf("%s\n", simTypes[i].c_str());
			double avgLat = 0, avgTp = 0, avgStdDevLat = 0;
			for(int j=0; j<NUM_BENCHS; j++) {
				printf("%s: [lat = %lf +- %lf, tp = %lf]\n", benchs[j].c_str(), lat[i][j], stdDevLat[i][j], tp[i][j]);
				avgLat += lat[i][j];
				avgStdDevLat += stdDevLat[i][j];
				avgTp += tp[i][j];
			}
			printf("Avg Lat: %f [AvgStdDev: %lf]\n", avgLat/NUM_BENCHS, avgStdDevLat/NUM_BENCHS);
			printf("Avg Tp: %f\n", avgTp/NUM_BENCHS);
		}
	}
}
Пример #5
0
MyWindow::MyWindow() : QWidget()
{
    simulatorIsInitialized = 0;
    pattern = 0;
    regularDelay = (NB_DISPLAYED_NODES/200) * 20000;
    isPaused = 1;

    this->setFixedSize(950, 700);

    /* Control widgets */
    runButton = new QPushButton("Run");
    QObject::connect(runButton, SIGNAL(clicked()), this, SLOT(runSimulator()));

    pauseButton = new QPushButton("Pause");
    pauseButton->setEnabled(false);
    QObject::connect(pauseButton, SIGNAL(clicked()), this, SLOT(pause()));

    switchView = new QPushButton("Switch View");
    QObject::connect(switchView, SIGNAL(clicked()), this, SLOT(switchTheView()));

    exit = new QPushButton("Exit");
    exit->setEnabled(false);
    QObject::connect(exit, SIGNAL(clicked()), qApp, SLOT(quit()));

    QLabel *pattern = new QLabel;
    pattern->setPixmap(QPixmap("../../Debug/motif.png"));
    pattern->setFixedSize(120,120);

    QLabel *pattern1 = new QLabel;
    pattern1->setPixmap(QPixmap("../../Debug/motif1.png"));
    pattern1->setFixedSize(120,120);

    switchPatt = new QPushButton("Switch Pattern");
    QObject::connect(switchPatt, SIGNAL(clicked()), this, SLOT(switchPattern()));

    QCheckBox *drawConnections = new QCheckBox("Draw Connections");
    drawConnections->setChecked(true);
    QObject::connect(drawConnections, SIGNAL(stateChanged(int)), this, SLOT(setDrawConnections(int)));


    QFrame *speed_field = new QFrame(this);
    QLabel *min = new QLabel("Fastest");
    QLabel *max = new QLabel("Slowest");
    QSlider* speed = new QSlider;
    speed->setMinimum(NB_DISPLAYED_NODES / 200);
    speed->setMaximum(10);
    speed->setValue(NB_DISPLAYED_NODES / 200);
    speed->setOrientation(Qt::Horizontal);
    QObject::connect(speed, SIGNAL(sliderMoved(int)), this, SLOT(changeDelay(int)));
    QHBoxLayout *speed_layout = new QHBoxLayout;
    speed_layout->addWidget(min);
    speed_layout->addWidget(speed);
    speed_layout->addWidget(max);
    speed_field->setLayout(speed_layout);


    /* Control area */
    control_field = new QFrame(this);
    control_field->setFrameShape(QFrame::StyledPanel);
    control_field->setFrameStyle( QFrame::Sunken | QFrame::Panel );
    control_field->setLineWidth( 2 );

    pattern_field = new QFrame(this);
    pattern_field->setFrameShape(QFrame::StyledPanel);
    pattern_field->setFixedSize(270,140);
    QHBoxLayout *pattern_layout = new QHBoxLayout;
    pattern_layout->addWidget(pattern);
    pattern_layout->addWidget(pattern1);
    pattern_field->setLayout(pattern_layout);

    QVBoxLayout *control_layout = new QVBoxLayout;
    control_layout->addWidget(runButton);
    control_layout->addWidget(pauseButton);
    control_layout->addWidget(switchView);
    control_layout->addWidget(pattern_field);
    control_layout->addWidget(switchPatt);
    control_layout->addWidget(exit);
    control_layout->addWidget(drawConnections);
    control_layout->addWidget(speed_field);
    control_field->setLayout(control_layout);

    /* Drawing area */
    openGL_field = new QFrame(this);
    openGL_field->setFrameStyle( QFrame::Sunken | QFrame::Panel );
    openGL_field->setLineWidth( 2 );
    openGl = new OpenGLWidget();
    openGl->setFixedSize(600,440);
    QVBoxLayout *l1 = new QVBoxLayout;
    l1->addWidget(openGl);
    openGL_field->setLayout(l1);

    /* Console area */
    console_field = new QFrame(this);
    output = new QTextEdit();
    output->setReadOnly(true);
    QVBoxLayout *l2 = new QVBoxLayout;
    l2->addWidget(output);
    console_field->setLayout(l2);

    QGridLayout *layout = new QGridLayout;
    layout->addWidget(openGL_field, 0, 0, 1, 3);
    layout->addWidget(control_field, 0, 3, 3, 1);
    layout->addWidget(console_field, 3, 0, 3, 4);

    this->setLayout(layout);
}