- Written what I suppose might be HoltGraph

git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@809 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
elvez 2006-08-02 00:28:31 +00:00
parent b9cbbacd10
commit 6969d5b2c2
3 changed files with 154 additions and 0 deletions

View File

@ -161,6 +161,7 @@ src_backend_libbackend_la_SOURCES = \
src/backend/global_preferences.cc \ src/backend/global_preferences.cc \
src/backend/history.cc \ src/backend/history.cc \
src/backend/history_observer.cc \ src/backend/history_observer.cc \
src/backend/holt_graph.cc \
src/backend/invalid_plugin_exception.cc \ src/backend/invalid_plugin_exception.cc \
src/backend/key_file.cc \ src/backend/key_file.cc \
src/backend/module.cc \ src/backend/module.cc \
@ -198,6 +199,7 @@ pkginclude_HEADERS += \
src/backend/global_preferences.hh \ src/backend/global_preferences.hh \
src/backend/history.hh \ src/backend/history.hh \
src/backend/history_observer.hh \ src/backend/history_observer.hh \
src/backend/holt_graph.hh \
src/backend/invalid_plugin_exception.hh \ src/backend/invalid_plugin_exception.hh \
src/backend/key_file.hh \ src/backend/key_file.hh \
src/backend/module.hh \ src/backend/module.hh \

88
src/backend/holt_graph.cc Normal file
View File

@ -0,0 +1,88 @@
// src/backend/holt_graph.cc - Copyright 2005, 2006, University
// of Padova, dept. of Pure and Applied
// Mathematics
//
// This file is part of SGPEMv2.
//
// This is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// SGPEMv2 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with SGPEMv2; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "holt_graph.hh"
#include "history.hh"
#include "process.hh"
#include "thread.hh"
using namespace sgpem;
using namespace std;
void
HoltGraph::update(const History& changed_history)
{
const Environment& env = changed_history.get_last_environment();
const Environment::Processes& processes = env.get_processes();
_resources.clear();
_active_threads.clear();
_active_requests.clear();
for(unsigned int pi = 0; pi < processes.size(); ++pi)
{
vector<Thread*> threads = processes[pi]->get_threads();
for(unsigned int ti = 0; ti < threads.size(); ++ti)
{
vector<Request*> requests = threads[ti]->get_requests();
for(unsigned int ri = 0; ri < requests.size(); ++ri)
{
Request& r = *requests[ri];
if(r.get_state() == Request::state_allocated)
{
_active_requests.push_back(&r);
_active_threads.insert(&r.get_thread());
vector<SubRequest*> subrequests = r.get_subrequests();
for(unsigned int sri = 0; sri < subrequests.size(); ++sri)
{
Environment::resource_key_t key = subrequests[sri]->get_resource_key();
_resources.insert(env.get_resources().find(key)->second);
}
}
}
}
}
}
HoltGraph::Resources
HoltGraph::get_resources() const
{
return Resources(_resources.begin(), _resources.end());
}
HoltGraph::Threads
HoltGraph::get_active_threads() const
{
return Threads(_active_threads.begin(), _active_threads.end());
}
HoltGraph::Requests
HoltGraph::get_active_requests() const
{
return _active_requests;
}

64
src/backend/holt_graph.hh Normal file
View File

@ -0,0 +1,64 @@
// src/backend/holt_graph.hh - Copyright 2005, 2006, University
// of Padova, dept. of Pure and Applied
// Mathematics
//
// This file is part of SGPEMv2.
//
// This is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// SGPEMv2 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with SGPEMv2; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#ifndef HOLT_GRAPH_HH
#define HOLT_GRAPH_HH 1
namespace sgpem
{
class Resource;
class Thread;
class Request;
}
#include "history_observer.hh"
#include <set>
#include <vector>
namespace sgpem
{
class HoltGraph;
class SG_DLLEXPORT HoltGraph : public HistoryObserver
{
public:
typedef std::vector<const Resource*> Resources;
typedef std::vector<const Thread*> Threads;
typedef std::vector<const Request*> Requests;
HoltGraph();
virtual void update(const History& changed_history);
Resources get_resources() const;
Threads get_active_threads() const;
Requests get_active_requests() const;
private:
std::set<const Resource*> _resources;
std::set<const Thread*> _active_threads;
Requests _active_requests;
}; // class HistoryObserver
}//~ namespace sgpem
#endif //HOLT_GRAPH_HH