Polymorphic Register Files Simulator
This program aims at simulating the Polymorphic Register Files behaviour, as described in "On Implementability of Polymorphic Register Files"
prf.h
Go to the documentation of this file.
1 //
3 // PRF_Sim
4 //
5 // Created by Giulio Stramondo on 10/05/16.
6 // Copyright © 2016 UVA. All rights reserved.
7 //
8 
9 #ifndef PRF_H
10 #define PRF_H
11 
12 #include <stdio.h>
13 #include <stdlib.h>
14 #include <math.h>
15 #include "collection.h"
16 
17 #define ERR -1
18 //#define N 10
19 //#define M 10
20 extern int N;
21 extern int M;
24 
28 typedef struct list {
29  int data;
30  struct list* next;
32 
34 typedef struct address2d {
35  int i;
36  int j;
37 }Address2d;
38 
39 
41 
43 typedef enum {
53  UNDEFINED
54 } scheme;
55 
57 typedef enum {
60  ROW,
64  DEFAULT
65 } acc_type;
66 
67 typedef struct block_access{
68  Address2d start_index;
69  acc_type type;
71 
73 typedef struct polReg {
75  int p;
76  int q;
81 
83 
91 int m_v(int index_i, int index_j, scheme s, int p, int q);
92 
94 
102 int m_h(int index_i, int index_j, scheme s, int p, int q);
103 
105 
112 int A_standard(int index_i, int index_j, int p, int q);
113 
114 int A_custom(PolymorphicRegister *pR,int index_i, int index_j, int alpha, int beta, acc_type type);
116 
122 PolymorphicRegister *createPolymorphicRegister(int p, int q, int linRegSize);
123 
125 
132 void writeToPR(PolymorphicRegister *pR, int data, int index_i, int index_j);
133 
135 
142 int readFromPR(PolymorphicRegister *pR, int index_i, int index_j);
143 
145 
150 int** parallelReadFromPR(PolymorphicRegister *pR, int z);
151 
152 //Trying to implement the Inverse mapping function
153 //int** parallelReadRectangleOnly(PolymorphicRegister *pR, int index_i, int index_j);
154 
155 //int** parallelReadRow(PolymorphicRegister *pR, int index_i, int index_j);
156 
158 
166 int** readBlock(PolymorphicRegister *pR, int index_i, int index_j, acc_type type);
167 
168 int** readBlockCustom(PolymorphicRegister *pR, int index_i, int index_j, acc_type type);
170 
178 int** computeConflicts(PolymorphicRegister *pR, int index_i, int index_j, acc_type type);
179 
181 
189 Address2d* AGU(int index_i, int index_j,int p, int q, acc_type type);
190 
191 int compareAddress(void *a, void *b);
192 
193 t_list* parallelAccessCoverage(PolymorphicRegister *pR, t_list *parallel_accesses);
194 #endif
int m_v(int index_i, int index_j, scheme s, int p, int q)
Given two input indices and a PRF mapping scheme, outputs the row of the corrispondent linear registe...
Data structure used for representing a 2D address.
Definition: prf.h:34
Access p x q rectangle.
Definition: prf.h:58
int A_standard(int index_i, int index_j, int p, int q)
Given two input indices and a PRF mapping scheme, outputs the linear register index where the data is...
This access scheme allows only conflict free rectangular, row, main diagonal and secondary diagonal b...
Definition: prf.h:45
Definition: collection.h:33
linearRegister ** data
2D array of linearRegister (lists).
Definition: prf.h:74
int data
The integer stored by this node.
Definition: prf.h:29
struct list * next
Pointer to the next node.
Definition: prf.h:30
This access scheme allows only conflict free rectangular block accesses.
Definition: prf.h:44
Access qxp rectangle.
Definition: prf.h:59
Access elements in the main diagonal.
Definition: prf.h:62
PolymorphicRegister * createPolymorphicRegister(int p, int q, int linRegSize)
Allocates memory required for a Polymorphic Register and returns a pointer to it. ...
scheme
Enum containing all the available mapping scheme.
Definition: prf.h:43
int ** readBlock(PolymorphicRegister *pR, int index_i, int index_j, acc_type type)
Performs a block read on the PolymorphicRegister.
int ** computeConflicts(PolymorphicRegister *pR, int index_i, int index_j, acc_type type)
Computes the conflict matrix relative to a block read on the PolymorphicRegister. ...
Access p*q x 1 columns.
Definition: prf.h:61
Data structure used for representing a Polymorphic Register.
Definition: prf.h:73
int ** parallelReadFromPR(PolymorphicRegister *pR, int z)
Reads an array of integer at the given depth in the Polymorphic Register given as argument...
acc_type
Enum containing all the available access types.
Definition: prf.h:57
Definition: prf.h:67
Address2d * AGU(int index_i, int index_j, int p, int q, acc_type type)
Generates all the 2D logical addresses of the elements read in a block read.
int p
Size of the first dimension of the linearRegister array.
Definition: prf.h:75
int m_h(int index_i, int index_j, scheme s, int p, int q)
Given two input indices and a PRF mapping scheme, outputs the column of the corrispondent linear regi...
void writeToPR(PolymorphicRegister *pR, int data, int index_i, int index_j)
Stores an integer at the given "logical" index in the Polymorphic Register given as argument...
Access elements in the secondary diagonal.
Definition: prf.h:63
Data structure used for representing a linearly accessible register.
Definition: prf.h:28
This access scheme allows only conflict free rectangular, column, main diagonal and secondary diagona...
Definition: prf.h:47
This access scheme allows only conflict free rectangular, column, and row block accesses.
Definition: prf.h:49
This access scheme allows only conflict free rectangular, and transposed rectangular block accesses...
Definition: prf.h:51
scheme s
Eunum which identifies the mapping scheme used by this register.
Definition: prf.h:77
Access 1 x p*q rows.
Definition: prf.h:60
int q
Size of the second dimension of the linearRegister array.
Definition: prf.h:76
int readFromPR(PolymorphicRegister *pR, int index_i, int index_j)
Reads an integer at the given "logical" index in the Polymorphic Register given as argument...