Browse files

Started memory

  • Loading branch information...
1 parent dfc4fc3 commit b5e64b816c38440f7a179d43cb01b28b03ccc063 @pksunkara committed Aug 9, 2011
Showing with 73 additions and 39 deletions.
  1. +1 −0 INPUT
  2. 0 README
  3. +8 −0 README.md
  4. +4 −4 access.h
  5. +13 −13 cache.cpp
  6. +12 −12 cache.h
  7. +25 −0 main.cpp
  8. +4 −4 memory.cpp
  9. +6 −6 memory.h
View
1 INPUT
@@ -0,0 +1 @@
+10
View
0 README
No changes.
View
8 README.md
@@ -0,0 +1,8 @@
+# Implementation of cache-unaware, cache-aware, and cache-oblivious matrix multiplication algorithms
+
+The project consists of two parts:
+
+* Building a cache simulator
+ * Design a cache simulator where user can specify the cache parameters such as cache size, associativity, block size. The cache simulator uses the LRU replacement policy. The simulator need not store the actual data, but it keeps track of data references. It has to give the statistics such as overall accesses, compulsory misses, capacity misses, conflict misses, and hit rate.
+* Implementing various matrix multiplication algorithms
+ * By assuming the elements of a matrix are stored in row-major order, design and implement cache-unaware, cache-aware, and cache-oblivious matrix multiplication algorithms and report the cache statistics using the above simulator.
View
8 access.h
@@ -1,8 +1,8 @@
class Access {
- public:
- Access(void);
+ public:
+ Access(void);
- ~Access(void);
+ ~Access(void);
- private:
+ private:
};
View
26 cache.cpp
@@ -5,28 +5,28 @@
using namespace std;
Cache::Cache(int cache_size, int block_size, int assoc) {
- this->hits = 0;
- this->misses = 0;
+ this->hits = 0;
+ this->misses = 0;
- // Cache size is given in KB
- this->cache_size = cache_size*1024;
- // Block size is given in B
- this->block_size = block_size;
- this->assoc = assoc;
+ // Cache size is given in KB
+ this->cache_size = cache_size*1024;
+ // Block size is given in B
+ this->block_size = block_size;
+ this->assoc = assoc;
- //TODO: Introduce blocks later
- this->memory = new int(this->cache_size/4);
- return;
+ //TODO: Introduce blocks later
+ this->memory = new int(this->cache_size/4);
+ return;
}
int Cache::get_hits(void) {
- return this->hits;
+ return this->hits;
}
int Cache::get_misses(void) {
- return this->misses;
+ return this->misses;
}
Cache::~Cache(void) {
- delete(this->memory);
+ delete this->memory;
}
View
24 cache.h
@@ -1,19 +1,19 @@
class Cache {
- public:
- Cache(int cache_size, int block_size, int assoc);
+ public:
+ Cache(int cache_size, int block_size, int assoc);
- int get_hits(void);
- int get_misses(void);
+ int get_hits(void);
+ int get_misses(void);
- ~Cache(void);
+ ~Cache(void);
- private:
- int* memory;
+ private:
+ int* memory;
- int cache_size;
- int block_size;
- int assoc;
+ int cache_size;
+ int block_size;
+ int assoc;
- int hits;
- int misses;
+ int hits;
+ int misses;
};
View
25 main.cpp
@@ -1,6 +1,7 @@
#include <iostream>
#include <cstdio>
#include <cstdlib>
+#include <fstream>
#include "access.h"
#include "cache.h"
#include "memory.h"
@@ -12,5 +13,29 @@ int main(int argc, char** argv) {
printf("Usage: %s <cache_size_inKB> <block_size_inB> <associativity> <input_file>\n", argv[0]);
return 1;
}
+
+ // Declaring variables
+ int n;
+ Memory* mem;
+ ifstream inFile;
+
+ // Opening files
+ inFile.open(argv[4]);
+
+ // Checking for situation of files
+ if(!inFile.is_open()) {
+ cout << "Error while opening the input file" << endl;
+ return 1;
+ }
+
+ // Reading Matrix
+ inFile >> n;
+
+ // Initalize memory
+ mem = new Memory(n);
+
+ // Closing files
+ inFile.close();
+
return 0;
}
View
8 memory.cpp
@@ -5,11 +5,11 @@
using namespace std;
Memory::Memory(int size) {
- this->size = size;
- this->memory = new int(this->size);
- return;
+ this->size = size;
+ this->memory = new int(this->size);
+ return;
}
Memory::~Memory(void) {
- delete(this->memory);
+ delete this->memory;
}
View
12 memory.h
@@ -1,10 +1,10 @@
class Memory {
- public:
- Memory(int size);
+ public:
+ Memory(int size);
- ~Memory(void);
+ ~Memory(void);
- private:
- int* memory;
- int size;
+ private:
+ int* memory;
+ int size;
};

0 comments on commit b5e64b8

Please sign in to comment.