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/wavefront.cpp | 61 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 src/intersim/wavefront.cpp (limited to 'src/intersim/wavefront.cpp') diff --git a/src/intersim/wavefront.cpp b/src/intersim/wavefront.cpp new file mode 100644 index 0000000..c9fab7a --- /dev/null +++ b/src/intersim/wavefront.cpp @@ -0,0 +1,61 @@ +#include "booksim.hpp" +#include + +#include "wavefront.hpp" +#include "random_utils.hpp" + +Wavefront::Wavefront( const Configuration &config, + Module *parent, const string& name, + int inputs, int outputs ) : +DenseAllocator( config, parent, name, inputs, outputs ) +{ + // We need a square wavefront allocator, so take the max dimension + _square = ( _inputs > _outputs ) ? _inputs : _outputs; + + // The diagonal with priority + _pri = 0; +} + +Wavefront::~Wavefront( ) +{ +} + +void Wavefront::Allocate( ) +{ + int input; + int output; + + // Clear matching + + for ( int i = 0; i < _inputs; ++i ) { + _inmatch[i] = -1; + } + for ( int j = 0; j < _outputs; ++j ) { + _outmatch[j] = -1; + } + + // Loop through diagonals of request matrix + + for ( int p = 0; p < _square; ++p ) { + output = ( _pri + p ) % _square; + + // Step through the current diagonal + for ( input = 0; input < _inputs; ++input ) { + if ( ( output < _outputs ) && + ( _inmatch[input] == -1 ) && + ( _outmatch[output] == -1 ) && + ( _request[input][output].label != -1 ) ) { + // Grant! + _inmatch[input] = output; + _outmatch[output] = input; + } + + output = ( output + 1 ) % _square; + } + } + + // Round-robin the priority diagonal + _pri = ( _pri + 1 ) % _square; +} + + -- cgit v1.3