Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
+ Added automatic parallelization implementation.
- A generic task system. - A generic level scheduler. - Model representation for OM models. - An interface for OM model runtime. - support for loading model info from XML. Compile time loading to come. - dumping system graphs to graphviz and graphml formats. git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@19274 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
- Loading branch information
Showing
19 changed files
with
2,089 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
TOP_BUILDDIR = ../../../build/ | ||
|
||
OPENMODELICA_INC=$(TOP_BUILDDIR)/include/omc/c/ | ||
PARMODELICAAUTO_INC=$(OPENMODELICA_INC)/ParModelica/auto/ | ||
OPENMODELICA_LIB=$(TOP_BUILDDIR)/lib/omc/ | ||
OPENMODELICA_BIN=$(TOP_BUILDDIR)/bin/ | ||
|
||
# cp -u is a GNU extension. Do not rely on it. | ||
COPY=cp -rp | ||
AR_=ar -rcs | ||
|
||
SRCS = \ | ||
om_pm_equation.cpp \ | ||
pm_utility.cpp \ | ||
om_pm_interface.cpp \ | ||
om_pm_model.cpp \ | ||
pm_win_timer.cpp | ||
# ParModelicaTaskGrapExt_rml.cpp | ||
# ParModelicaTaskGrapExt_omc.cpp \ | ||
|
||
OBJS = $(SRCS:.cpp=.o) | ||
|
||
.PHONY : libom_pm_autort clean | ||
|
||
libom_pm_autort.a: $(OBJS) | ||
@rm -f $@ | ||
$(AR_) $@ $(OBJS) | ||
|
||
test: test_task_graph.cpp transfer | ||
$(CXX) $(CPPFLAGS) -I. test_task_graph.cpp -o gen_graph$(EXEEXT) libom_pm_autort.a | ||
|
||
clean : | ||
rm -f *.o *.a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
/* | ||
* This file is part of OpenModelica. | ||
* | ||
* Copyright (c) 1998-CurrentYear, Linköping University, | ||
* Department of Computer and Information Science, | ||
* SE-58183 Linköping, Sweden. | ||
* | ||
* All rights reserved. | ||
* | ||
* THIS PROGRAM IS PROVIDED UNDER THE TERMS OF GPL VERSION 3 | ||
* AND THIS OSMC PUBLIC LICENSE (OSMC-PL). | ||
* ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES RECIPIENT'S | ||
* ACCEPTANCE OF THE OSMC PUBLIC LICENSE. | ||
* | ||
* The OpenModelica software and the Open Source Modelica | ||
* Consortium (OSMC) Public License (OSMC-PL) are obtained | ||
* from Linköping University, either from the above address, | ||
* from the URLs: http://www.ida.liu.se/projects/OpenModelica or | ||
* http://www.openmodelica.org, and in the OpenModelica distribution. | ||
* GNU version 3 is obtained from: http://www.gnu.org/copyleft/gpl.html. | ||
* | ||
* This program is distributed WITHOUT ANY WARRANTY; without | ||
* even the implied warranty of MERCHANTABILITY or FITNESS | ||
* FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH | ||
* IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS | ||
* OF OSMC-PL. | ||
* | ||
* See the full OSMC Public License conditions for more details. | ||
* | ||
*/ | ||
|
||
|
||
/* | ||
Mahder.Gebremedhin@liu.se 2014-02-10 | ||
*/ | ||
|
||
|
||
|
||
|
||
#include <iterator> | ||
#include <sstream> | ||
|
||
#include "om_pm_equation.hpp" | ||
#include "pm_utility.hpp" | ||
|
||
|
||
namespace openmodelica { | ||
namespace parmodelica { | ||
|
||
|
||
Equation::Equation() : | ||
TaskNode(), | ||
index(-1) | ||
{ | ||
} | ||
|
||
bool Equation::depends_on(const Equation& other) const { | ||
|
||
bool found_dep = false; | ||
|
||
// True dependency | ||
found_dep = utility::has_intersection(this->rhs.begin(),this->rhs.end(), | ||
other.lhs.begin(), other.lhs.end()); | ||
// Anti-dependency | ||
if(!found_dep) | ||
found_dep = utility::has_intersection(this->lhs.begin(),this->lhs.end(), | ||
other.rhs.begin(), other.rhs.end()); | ||
// output-dependency | ||
if(!found_dep) | ||
found_dep = utility::has_intersection(this->lhs.begin(),this->lhs.end(), | ||
other.lhs.begin(), other.lhs.end()); | ||
|
||
return found_dep; | ||
} | ||
|
||
|
||
} // openmodelica | ||
} // parmodelica | ||
|
||
|
||
|
||
|
||
// Leave the stream operators in global namespace. | ||
using namespace openmodelica::parmodelica; | ||
|
||
std::ostream& operator<<(std::ostream& os, const Equation& eq) { | ||
os << eq.index << " : "; | ||
std::copy(eq.lhs.begin(),eq.lhs.end(), std::ostream_iterator<Ident>(os,", ")); | ||
os << " : "; | ||
std::copy(eq.rhs.begin(),eq.rhs.end(), std::ostream_iterator<Ident>(os,", ")); | ||
return os; | ||
} | ||
|
||
|
||
std::istream& operator>>(std::istream& is, Equation& eq) { | ||
// Unfortunatly back_inserter initalizes by copy. | ||
// So we have to clear the conainers here. This should be rewritten. | ||
// Remove istream_iterator altogether. | ||
eq.lhs.clear(); eq.rhs.clear(); | ||
std::string line, var; | ||
|
||
if(!std::getline(is, line)) | ||
return is; | ||
|
||
std::istringstream iss(line); | ||
iss >> eq.index; | ||
|
||
iss >> var; | ||
while(var != ":") { | ||
eq.lhs.insert(var); | ||
iss >> var; | ||
} | ||
while(iss >> var) { | ||
eq.rhs.insert(var); | ||
} | ||
|
||
return is; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
#pragma once | ||
#ifndef idA890A2D6_30B0_44AD_B07DF074DD9AC126 | ||
#define idA890A2D6_30B0_44AD_B07DF074DD9AC126 | ||
|
||
|
||
/* | ||
* This file is part of OpenModelica. | ||
* | ||
* Copyright (c) 1998-CurrentYear, Linköping University, | ||
* Department of Computer and Information Science, | ||
* SE-58183 Linköping, Sweden. | ||
* | ||
* All rights reserved. | ||
* | ||
* THIS PROGRAM IS PROVIDED UNDER THE TERMS OF GPL VERSION 3 | ||
* AND THIS OSMC PUBLIC LICENSE (OSMC-PL). | ||
* ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES RECIPIENT'S | ||
* ACCEPTANCE OF THE OSMC PUBLIC LICENSE. | ||
* | ||
* The OpenModelica software and the Open Source Modelica | ||
* Consortium (OSMC) Public License (OSMC-PL) are obtained | ||
* from Linköping University, either from the above address, | ||
* from the URLs: http://www.ida.liu.se/projects/OpenModelica or | ||
* http://www.openmodelica.org, and in the OpenModelica distribution. | ||
* GNU version 3 is obtained from: http://www.gnu.org/copyleft/gpl.html. | ||
* | ||
* This program is distributed WITHOUT ANY WARRANTY; without | ||
* even the implied warranty of MERCHANTABILITY or FITNESS | ||
* FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH | ||
* IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS | ||
* OF OSMC-PL. | ||
* | ||
* See the full OSMC Public License conditions for more details. | ||
* | ||
*/ | ||
|
||
|
||
/* | ||
Mahder.Gebremedhin@liu.se 2014-02-10 | ||
*/ | ||
|
||
|
||
|
||
|
||
#include <iostream> | ||
#include <set> | ||
#include <vector> | ||
#include <string> | ||
|
||
|
||
|
||
namespace openmodelica { | ||
namespace parmodelica { | ||
|
||
struct TaskNode { | ||
TaskNode() : level(0) ,cost(0), comm_cost(0) {}; | ||
|
||
long node_id; | ||
int level; | ||
double cost; | ||
double comm_cost; | ||
|
||
// bool depends_on(const TaskNode& other); | ||
}; | ||
|
||
typedef std::string Ident; | ||
|
||
struct Equation : public TaskNode { | ||
Equation(); | ||
|
||
long index; | ||
std::set<Ident> lhs; | ||
std::set<Ident> rhs; | ||
std::string type; | ||
|
||
bool depends_on(const Equation& other) const; | ||
|
||
}; | ||
|
||
|
||
|
||
|
||
|
||
|
||
} // openmodelica | ||
} // parmodelica | ||
|
||
|
||
|
||
#endif // header |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
/* | ||
* This file is part of OpenModelica. | ||
* | ||
* Copyright (c) 1998-CurrentYear, Linköping University, | ||
* Department of Computer and Information Science, | ||
* SE-58183 Linköping, Sweden. | ||
* | ||
* All rights reserved. | ||
* | ||
* THIS PROGRAM IS PROVIDED UNDER THE TERMS OF GPL VERSION 3 | ||
* AND THIS OSMC PUBLIC LICENSE (OSMC-PL). | ||
* ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES RECIPIENT'S | ||
* ACCEPTANCE OF THE OSMC PUBLIC LICENSE. | ||
* | ||
* The OpenModelica software and the Open Source Modelica | ||
* Consortium (OSMC) Public License (OSMC-PL) are obtained | ||
* from Linköping University, either from the above address, | ||
* from the URLs: http://www.ida.liu.se/projects/OpenModelica or | ||
* http://www.openmodelica.org, and in the OpenModelica distribution. | ||
* GNU version 3 is obtained from: http://www.gnu.org/copyleft/gpl.html. | ||
* | ||
* This program is distributed WITHOUT ANY WARRANTY; without | ||
* even the implied warranty of MERCHANTABILITY or FITNESS | ||
* FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH | ||
* IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS | ||
* OF OSMC-PL. | ||
* | ||
* See the full OSMC Public License conditions for more details. | ||
* | ||
*/ | ||
|
||
|
||
/* | ||
Mahder.Gebremedhin@liu.se 2014-02-10 | ||
*/ | ||
|
||
|
||
#include <iostream> | ||
|
||
#include "om_pm_interface.hpp" | ||
#include "om_pm_model.hpp" | ||
|
||
|
||
extern "C" { | ||
|
||
using namespace openmodelica::parmodelica; | ||
|
||
OMModel pm_om_model; | ||
|
||
void PM_Model_init(const char* model_name, DATA* data) { | ||
pm_om_model.model_name = model_name; | ||
pm_om_model.data = data; | ||
|
||
pm_om_model.initialize(); | ||
} | ||
|
||
void PM_functionInitialEquations(int size, DATA* data, functionXXX_system* functionInitialEquations_systems) { | ||
|
||
pm_om_model.ini_system_funcs = functionInitialEquations_systems; | ||
|
||
pm_om_model.total_ini_time.start_timer(); | ||
pm_om_model.system_execute_ini(); | ||
pm_om_model.total_ini_time.stop_timer(); | ||
|
||
// for(int i = 0; i < size; ++i) | ||
// functionInitialEquations_systems[i](data); | ||
} | ||
|
||
|
||
void PM_functionDAE(int size, DATA* data, functionXXX_system* functionDAE_systems) { | ||
|
||
pm_om_model.dae_system_funcs = functionDAE_systems; | ||
|
||
pm_om_model.total_dae_time.start_timer(); | ||
pm_om_model.system_execute_dae(); | ||
pm_om_model.total_dae_time.stop_timer(); | ||
|
||
// for(int i = 0; i < size; ++i) | ||
// functionDAE_systems[i](data); | ||
|
||
} | ||
|
||
|
||
void PM_functionODE(int size, DATA* data, functionXXX_system* functionODE_systems) { | ||
|
||
pm_om_model.ode_system_funcs = functionODE_systems; | ||
|
||
pm_om_model.total_ode_time.start_timer(); | ||
pm_om_model.system_execute_ode(); | ||
pm_om_model.total_ode_time.stop_timer(); | ||
|
||
// for(int i = 0; i < size; ++i) | ||
// functionODE_systems[i](data); | ||
|
||
} | ||
|
||
void PM_functionAlg(int size, DATA* data, functionXXX_system* functionAlg_systems) { | ||
|
||
pm_om_model.total_alg_time.start_timer(); | ||
|
||
for(int i = 0; i < size; ++i) | ||
functionAlg_systems[i](data); | ||
|
||
pm_om_model.total_alg_time.stop_timer(); | ||
|
||
} | ||
|
||
void dump_times() { | ||
std::cout << "Total INI: " << pm_om_model.total_ini_time.get_elapsed_time() << std::endl; | ||
std::cout << "Total DAE: " << pm_om_model.total_dae_time.get_elapsed_time() << std::endl; | ||
std::cout << "Total ODE: " << pm_om_model.total_ode_time.get_elapsed_time() << std::endl; | ||
std::cout << "Total ALG: " << pm_om_model.total_alg_time.get_elapsed_time() << std::endl; | ||
} | ||
|
||
|
||
|
||
|
||
} // extern "C" |
Oops, something went wrong.