Hybrid Query Processing Engine for Coprocessing in Database Systems
HyPE
virtual_processing_device.cpp
Go to the documentation of this file.
00001 
00002 
00003 
00004 #include <list>
00005 
00006 #include <config/global_definitions.hpp>
00007 #include <core/scheduling_decision.hpp>
00008 #include <query_processing/virtual_processing_device.hpp>
00009 #include <util/get_name.hpp>
00010 
00011 namespace hype
00012 {
00013    namespace queryprocessing
00014    {
00015    using namespace std;
00016    using namespace core;
00017    using namespace util;   
00018       
00019 VirtualProcessingDevice::VirtualProcessingDevice(const core::DeviceSpecification& dev_spec) : dev_spec_(dev_spec), scheduled_tasks_()
00020 {
00021 }
00022 
00023 bool VirtualProcessingDevice::addRunningOperation(const SchedulingDecision& sched_dec)
00024 {
00025    //cout << "VirtualProcessingDevice: add operator" << endl;
00026    scheduled_tasks_.push_back(sched_dec);
00027    return true;
00028 }
00029 
00030 double VirtualProcessingDevice::getEstimatedFinishingTime() const
00031 {     
00032       TaskQueue::const_iterator it;
00033       double result=0;
00034       for(it=scheduled_tasks_.begin();it!=scheduled_tasks_.end();++it){
00035             result+=it->getEstimatedExecutionTimeforAlgorithm().getTimeinNanoseconds();
00036       }
00037       return result;
00038 }
00039 
00040 unsigned int VirtualProcessingDevice::getNumberOfRunningOperations() const
00041 {
00042    return scheduled_tasks_.size();
00043 }
00044 
00045 bool VirtualProcessingDevice::isIdle() const
00046 {
00047    return scheduled_tasks_.empty();
00048 }
00049 
00050 bool VirtualProcessingDevice::removeFinishedOperation(const SchedulingDecision& sched_dec)
00051 {
00052    //cout << "VirtualProcessingDevice: delete operator" << endl;
00053    scheduled_tasks_.remove(sched_dec);
00054    return true;
00055    
00056 }
00057 
00058 const core::DeviceSpecification& VirtualProcessingDevice::getDeviceSpecification() const throw(){
00059       return this->dev_spec_;
00060 }
00061 
00062 void VirtualProcessingDevice::print() const throw(){
00063       cout << "Processing Device " <<  dev_spec_.getProcessingDeviceID() << ":" << endl;
00064       cout << "\t" << "Device Type: " << getName(dev_spec_.getDeviceType()) << endl;
00065       cout << "\t" << "MemoryID: " << dev_spec_.getMemoryID() << endl;     
00066       cout << "\t" << "Number of Running Operations: "<< this->getNumberOfRunningOperations() << endl;
00067       cout << "\t" << "Estimated Finishing Time: " << this->getEstimatedFinishingTime() << endl;
00068       cout << "\t" << "Is Idle: " << this->isIdle() << endl;
00069 }
00070 
00071    }; //end namespace queryprocessing
00072 }; //end namespace hype
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines