From 69f2911e04ffb1b19eef1fafb8c040af271f656e Mon Sep 17 00:00:00 2001 From: Tor Aamodt Date: Thu, 15 Jul 2010 18:09:46 -0800 Subject: creating branch for adding support for CUDA 3.x and Fermi [git-p4: depot-paths = "//depot/gpgpu_sim_research/fermi/distribution/": change = 6829] --- src/intersim/allocator.hpp | 122 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 src/intersim/allocator.hpp (limited to 'src/intersim/allocator.hpp') diff --git a/src/intersim/allocator.hpp b/src/intersim/allocator.hpp new file mode 100644 index 0000000..ac77a3a --- /dev/null +++ b/src/intersim/allocator.hpp @@ -0,0 +1,122 @@ +#ifndef _ALLOCATOR_HPP_ +#define _ALLOCATOR_HPP_ + +#include +#include + +#include "module.hpp" +#include "config_utils.hpp" + +class Allocator : public Module { +protected: + const int _inputs; + const int _outputs; + + int *_inmatch; + int *_outmatch; + + int *_outmask; + + void _ClearMatching( ); +public: + + struct sRequest { + int port; + int label; + int in_pri; + int out_pri; + }; + + Allocator( const Configuration &config, + Module *parent, const string& name, + int inputs, int outputs ); + virtual ~Allocator( ); + + virtual void Clear( ) = 0; + + virtual int ReadRequest( int in, int out ) const = 0; + virtual bool ReadRequest( sRequest &req, int in, int out ) const = 0; + + virtual void AddRequest( int in, int out, int label = 1, + int in_pri = 0, int out_pri = 0 ) = 0; + virtual void RemoveRequest( int in, int out, int label = 1 ) = 0; + + virtual void Allocate( ) = 0; + + void MaskOutput( int out, int mask = 1 ); + + int OutputAssigned( int in ) const; + int InputAssigned( int out ) const; + + virtual void PrintRequests( ) const = 0; + + static Allocator *NewAllocator( const Configuration &config, + Module *parent, const string& name, + const string &alloc_type, + int inputs, int input_speedup, + int outputs, int output_speedup ); +}; + +//================================================== +// A dense allocator stores the entire request +// matrix. +//================================================== + +class DenseAllocator : public Allocator { +protected: + sRequest **_request; + +public: + DenseAllocator( const Configuration &config, + Module *parent, const string& name, + int inputs, int outputs ); + virtual ~DenseAllocator( ); + + void Clear( ); + + int ReadRequest( int in, int out ) const; + bool ReadRequest( sRequest &req, int in, int out ) const; + + void AddRequest( int in, int out, int label = 1, + int in_pri = 0, int out_pri = 0 ); + void RemoveRequest( int in, int out, int label = 1 ); + + virtual void Allocate( ) = 0; + + void PrintRequests( ) const; +}; + +//================================================== +// A sparse allocator only stores the requests +// (allows for a more efficient implementation). +//================================================== + +class SparseAllocator : public Allocator { +protected: + list _in_occ; + list _out_occ; + + list *_in_req; + list *_out_req; + +public: + SparseAllocator( const Configuration &config, + Module *parent, const string& name, + int inputs, int outputs ); + virtual ~SparseAllocator( ); + + void Clear( ); + + int ReadRequest( int in, int out ) const; + bool ReadRequest( sRequest &req, int in, int out ) const; + + void AddRequest( int in, int out, int label = 1, + int in_pri = 0, int out_pri = 0 ); + void RemoveRequest( int in, int out, int label = 1 ); + + virtual void Allocate( ) = 0; + + void PrintRequests( ) const; +}; + +#endif -- cgit v1.3