Skip to content
Browse files

Changed the method of taking INPUT

  • Loading branch information...
1 parent 8a94054 commit aebb7962e0f61e7f784b911c0304b4f09d4d1ede @pksunkara committed
Showing with 49 additions and 32 deletions.
  1. +8 −8 Access.cpp
  2. +14 −1 INPUT
  3. +8 −0 cases.py
  4. +19 −23 main.cpp
View
16 Access.cpp
@@ -13,14 +13,14 @@ Access::Access(int cache_size, int block_size, int assoc, int data_numbers) {
}
void Access::print(char* str) {
- cout << "Cache " << str << " Statistics:" << endl;
- cout << "\tAccesses: " << this->accesses << endl;
- cout << "\tHits: " << this->cache->get_hits() << endl;
- cout << "\tMisses: " << this->cache->get_misses() << endl;
- cout << "\tCold Misses: " << this->cache->get_cold_misses() << endl;
- cout << "\tCapacity Misses: " << this->cache->get_capacity_misses() << endl;
- cout << "\tConflict Misses: " << this->cache->get_conflict_misses() << endl;
- cout << endl << endl;
+ cout << endl;
+ cout << "\tCache " << str << " Statistics:" << endl;
+ cout << "\t\tAccesses: " << this->accesses << endl;
+ cout << "\t\tHits: " << this->cache->get_hits() << endl;
+ cout << "\t\tMisses: " << this->cache->get_misses() << endl;
+ cout << "\t\tCold Misses: " << this->cache->get_cold_misses() << endl;
+ cout << "\t\tCapacity Misses: " << this->cache->get_capacity_misses() << endl;
+ cout << "\t\tConflict Misses: " << this->cache->get_conflict_misses() << endl;
}
void Access::restart_cache(void) {
View
15 INPUT
@@ -1 +1,14 @@
-10 10 16
+2
+1
+64/32/16
+1/4
+3
+10x10x16
+30x30x30
+20x100x30
+1024
+64/16
+4/0
+2
+100x500x40
+400x100x600
View
8 cases.py
@@ -0,0 +1,8 @@
+#!/usr/bin/python
+
+'''
+This python script is used to iterate over
+the all the cases in the input file and
+run the cache-simulator program and print
+it's output
+'''
View
42 main.cpp
@@ -1,7 +1,6 @@
#include <iostream>
#include <cstdlib>
#include <cmath>
-#include <fstream>
#include "Access.h"
using namespace std;
@@ -20,40 +19,38 @@ int A(int x, int y);
int B(int x, int y);
int main(int argc, char** argv) {
- if(argc!=4) {
- cout << "Usage: " << argv[0] << " <cache_size_inKB> <block_size_inB> <associativity>\n";
- return 1;
- }
-
- // Declaring variables
- int i, j;
- ifstream inFile;
-
- // Opening files
- inFile.open("INPUT");
-
- // Checking for situation of files
- if(!inFile.is_open()) {
- cout << "Error while opening the input file" << endl;
+ if(argc!=7) {
+ cout << "Usage: " << argv[0] << " <cache_size_inKB> <block_size_inB> <associativity> <matrix_n> <matrix_m> <matrix_p>\n";
return 1;
}
// Reading matrix lengths
- inFile >> matrix_n >> matrix_m >> matrix_p;
+ matrix_n = atoi(argv[4]);
+ matrix_m = atoi(argv[5]);
+ matrix_p = atoi(argv[6]);
// Initialise accessor
accessor = new Access(atoi(argv[1])*1024, atoi(argv[2]), atoi(argv[3]), (matrix_n+matrix_p)*matrix_m);
// Reading matrices A & B
- for(i=0; i<matrix_n; i++)
- for(j=0; j<matrix_m; j++) {
+ for(int i=0; i<matrix_n; i++)
+ for(int j=0; j<matrix_m; j++) {
accessor->write(rand());
}
- for(i=0; i<matrix_m; i++)
- for(j=0; j<matrix_p; j++) {
+ for(int i=0; i<matrix_m; i++)
+ for(int j=0; j<matrix_p; j++) {
accessor->write(rand());
}
+ // Starting Ouput
+ cout << "\tCache size: " << argv[1] << " KB" << endl;
+ cout << "\tBlock size: " << argv[2] << " B" << endl;
+ cout << "\tAssociativity: " << argv[3] << endl;
+ cout << endl;
+ cout << "\tMatrix n: " << argv[4] << endl;
+ cout << "\tMatrix m: " << argv[5] << endl;
+ cout << "\tMatrix p: " << argv[6] << endl;
+
// Cache Unaware matrix multiplication
cache_unaware();
accessor->print("unaware");
@@ -72,8 +69,7 @@ int main(int argc, char** argv) {
cache_oblivious();
accessor->print("oblivious");
- // Closing files
- inFile.close();
+ cout << endl;
return 0;
}

0 comments on commit aebb796

Please sign in to comment.
Something went wrong with that request. Please try again.