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 File Reference
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "collection.h"
Include dependency graph for prf.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  linearRegister
 Data structure used for representing a linearly accessible register. More...
 
struct  Address2d
 Data structure used for representing a 2D address. More...
 
struct  BlockAccess
 
struct  PolymorphicRegister
 Data structure used for representing a Polymorphic Register. More...
 

Macros

#define ERR   -1
 The default error value. More...
 

Enumerations

enum  scheme {
  RECTANGLE_ONLY, RECT_ROW, RECT_COL, ROW_COL,
  RECT_TRECT, UNDEFINED
}
 Enum containing all the available mapping scheme. More...
 
enum  acc_type {
  RECTANGLE, TRANSP_RECTANGLE, ROW, COLUMN,
  MAIN_DIAG, SECONDARY_DIAG, DEFAULT
}
 Enum containing all the available access types. More...
 

Functions

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 register where the data is stored. More...
 
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 register where the data is stored. More...
 
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 stored. More...
 
int A_custom (PolymorphicRegister *pR, int index_i, int index_j, int alpha, int beta, acc_type type)
 
PolymorphicRegistercreatePolymorphicRegister (int p, int q, int linRegSize)
 Allocates memory required for a Polymorphic Register and returns a pointer to it. More...
 
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. More...
 
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. More...
 
int ** parallelReadFromPR (PolymorphicRegister *pR, int z)
 Reads an array of integer at the given depth in the Polymorphic Register given as argument. More...
 
int ** readBlock (PolymorphicRegister *pR, int index_i, int index_j, acc_type type)
 Performs a block read on the PolymorphicRegister. More...
 
int ** readBlockCustom (PolymorphicRegister *pR, int index_i, int index_j, acc_type type)
 
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. More...
 
Address2dAGU (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. More...
 
int compareAddress (void *a, void *b)
 
t_listparallelAccessCoverage (PolymorphicRegister *pR, t_list *parallel_accesses)
 

Variables

int N
 Size of the horizontal dimension of the original matrix. More...
 
int M
 Size of the vertical dimension of the original matrix. More...
 

Macro Definition Documentation

#define ERR   -1

The default error value.

Enumeration Type Documentation

enum acc_type

Enum containing all the available access types.

Enumerator
RECTANGLE 

Access p x q rectangle.

TRANSP_RECTANGLE 

Access qxp rectangle.

ROW 

Access 1 x p*q rows.

COLUMN 

Access p*q x 1 columns.

MAIN_DIAG 

Access elements in the main diagonal.

SECONDARY_DIAG 

Access elements in the secondary diagonal.

enum scheme

Enum containing all the available mapping scheme.

suitable for mapping input matrix logical addresses into physical Polymorphic Register addresses;

Enumerator
RECTANGLE_ONLY 

This access scheme allows only conflict free rectangular block accesses.

RECT_ROW 

This access scheme allows only conflict free rectangular, row, main diagonal and secondary diagonal block accesses.

RECT_COL 

This access scheme allows only conflict free rectangular, column, main diagonal and secondary diagonal block accesses.

ROW_COL 

This access scheme allows only conflict free rectangular, column, and row block accesses.

RECT_TRECT 

This access scheme allows only conflict free rectangular, and transposed rectangular block accesses.

Function Documentation

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 stored.

Parameters
index_iindex of the access.
index_jindex of the access.
psize of the PRF on its first dimension.
qsize of the PRF on its second dimension.
Returns
Correspondent index in the linear register.
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.

Parameters
index_iindex of the top-left element in the block read.
index_jindex of the top-left element in the block read.
psize of the PRF on its first dimension.
qsize of the PRF on its second dimension.
typeaccess type specifying the shape of the block access.
Returns
list of the 2D addresses of the block read.
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.

Parameters
pRPointer to the Polymorphic Register.
index_iLogical index on the horizontal dimension of the top-left element in the accessed block.
index_jLogical index on the vertical dimension of the top-left element in the accessed block.
typeAccess Type defining the shape of the block access.
Returns
2D array containing the conflict matrix.
PolymorphicRegister* createPolymorphicRegister ( int  p,
int  q,
int  linRegSize 
)

Allocates memory required for a Polymorphic Register and returns a pointer to it.

Parameters
psize of the PRF on its first dimension.
qsize of the PRF on its second dimension.
linRegSizesize of each linear register in the PRF.
Returns
Pointer to the Polymorphic Register
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 register where the data is stored.

Parameters
index_iindex of the access.
index_jindex of the access.
sselected mapping scheme for the access.
psize of the PRF on its first dimension.
qsize of the PRF on its second dimension.
Returns
Correspondent linear register column.
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 register where the data is stored.

Parameters
index_iindex of the access.
index_jindex of the access.
sselected mapping scheme for the access.
psize of the PRF on its first dimension.
qsize of the PRF on its second dimension.
Returns
Correspondent linear register row.
int** parallelReadFromPR ( PolymorphicRegister pR,
int  z 
)

Reads an array of integer at the given depth in the Polymorphic Register given as argument.

Parameters
pRPointer to the Polymorphic Register.
zDepth of the 2D array in the Polymorphic Register.
Returns
2D array resulting from the parallel read.
int** readBlock ( PolymorphicRegister pR,
int  index_i,
int  index_j,
acc_type  type 
)

Performs a block read on the PolymorphicRegister.

Parameters
pRPointer to the Polymorphic Register.
index_iLogical index on the horizontal dimension of the top-left element in the accessed block.
index_jLogical index on the vertical dimension of the top-left element in the accessed block.
typeAccess Type defining the shape of the block access.
Returns
2D array resulting from the block read.
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.

Parameters
pRPointer to the Polymorphic Register.
index_iLogical index on the first dimension.
index_jLogical index on the second dimension.
Returns
integer at the given logical position.
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.

Parameters
pRPointer to the Polymorphic Register.
index_iLogical index on the first dimension.
index_jLogical index on the second dimension.
datainteger to store
Returns
Pointer to the Polymorphic Register

Variable Documentation

int M

Size of the vertical dimension of the original matrix.

int N

Size of the horizontal dimension of the original matrix.