//+----------------------------------------------------------------------+
//|								    DAPsim								 |
//| Dean Morrison												11/30/06 |
//| University of Florida												 |
//| Department of Electrical and Computer Engineering					 |
//+----------------------------------------------------------------------+
//| Description: DAPsim is a trace-driven simulator developed in C++ for |
//| the purpose of designing, testing, and evaluating demand prepaging 	 |
//| policies.  It currently implements my proposed concept of Dynamically|
//| Adaptive Prepaging, but may be modified to evaluate many other 		 |
//| policies.															 |
//|																		 |
//| Reuse Policy: Use of this software for personal or instructional	 |
//| purposes is granted without fee provided that the source bears a	 |
//| clear and complete citation.										 |
//+----------------------------------------------------------------------+

#ifndef __MAIN_H
#define __MAIN_H

#include <iostream>
#include <math.h>
#include <string>

using namespace std;

// Test Parameters
#define PROG_INTERVAL 10000
#define NO_DEBUG 0
#define DEBUG_1 1
#define DEBUG_2 2
#define DEBUG_3 3
#define DEBUG_4 4
#define DEBUG_5 5
#define DEBUG_6 6
#define DEBUG_7 7
#define DEBUG_8 8
//--Configuration--
#define DEBUG_MODE NO_DEBUG

// Prediction Schemes
#define PREDICTION_UNINITIALIZED 0
#define PREDICTION_ADDRESS_LOCAL 1
#define PREDICTION_RECENCY_LOCAL 2
#define PREDICTION_STRIDE 3
#define PREDICTION_HYBRID 4
//--Configuration--
#define DEFAULT_PREDICTION_SCHEME PREDICTION_ADDRESS_LOCAL

// System Parameters
#define DEFAULT_MEM_SIZE 1000
#define DEFAULT_MAX_MEM_SIZE DEFAULT_MEM_SIZE
#define DEFAULT_USED_Q_SIZE DEFAULT_MEM_SIZE*(0.9)
#define DEFAULT_MIN_USED_Q_SIZE DEFAULT_MEM_SIZE/4
#define DEFAULT_PREPAGED_Q_SIZE DEFAULT_MEM_SIZE/5
#define DEFAULT_PREPAGED_TARGET_ALLOC DEFAULT_MEM_SIZE/5
#define DEFAULT_MAX_PREPAGED_TARGET_ALLOC (DEFAULT_MEM_SIZE - DEFAULT_MIN_USED_Q_SIZE)
#define DEFAULT_MIN_PREPAGED_TARGET_ALLOC DEFAULT_MEM_SIZE/10
#define DEFAULT_DEGREE 5
#define DEFAULT_MAX_DEGREE DEFAULT_MAX_PREPAGED_TARGET_ALLOC
#define DEFAULT_MIN_DEGREE 5
#define DEFAULT_DECAY_PERIOD 2000000
#define DEFAULT_ALLOC_UPDATE_PERIOD 5
#define DEFAULT_ALLOC_STARTUP_PERIOD DEFAULT_DECAY_PERIOD/10
#define DEFAULT_DECAY_NUMERATOR 1
#define DEFAULT_DECAY_DENOMINATOR 2

#define STATIC_PREPAGE_PARAMETERS 0
#define DYNAMIC_PREPAGE_ALLOCATION 1
#define DYNAMIC_DEGREE 2
#define DYNAMIC_PREDICTION_METHOD 3
#define DYNAMIC_PREPAGE_PARAMETERS 4

#define MAINTAIN_NON_RESIDENTS 0
#define EVICT_NON_RESIDENT 1
#define PAGE_FAULT 0
#define PAGE_HIT 1
//--Configurations--
#define PRAPAGE_PARAMETER_MODE DYNAMIC_PREDICTION_METHOD
#define RESIDENCY_POLICY MAINTAIN_NON_RESIDENTS

// Benchmarks
#define LU 0
#define MM16 1
#define MM32 2
#define QUICK_SORT 3
#define COL_MM 4
#define DIAGONAL_SWEEP 5
#define LINEAR_SEARCH 6
#define ROW_MM 7
#define SAW_TOOTH 8
#define ACROREAD 9
#define CC1 10
#define COMPRESS 11
#define GO 12
#define NETSCAPE 13
#define POWERPOINT 14
#define WINWORD 15
#define CUSTOM_SAWTOOTH 16

// Classless Function Prototypes
int axtoi(string hexStg);
void reduceTrace(int benchmarkNumber, int NumReferences);
void translateTrace(int reducedBenchmarkNumber);
void fixTrace(int reducedBenchmarkNumber);
void reduceAndTranslate(int benchmarkNumber, int NumReferences);
void queueTest(void);
void virtualMMUTest(void);
void simulateTrace(int rtBenchmarkNumber, long int sampleSize, int prepageParameterMode);
void simulateTraceSuite(int rtBenchmarkNumber, long int sampleSize);
void createTrace(int rtBenchmarkNumber, long int sampleSize);


#endif
