Skip to content

Commit c30bade

Browse files
committed
-updated VxWorks makefile
-some experimental changes to improve sparseMatrices
1 parent 6ac5418 commit c30bade

File tree

12 files changed

+349
-96
lines changed

12 files changed

+349
-96
lines changed

Compiler/Template/CodegenCpp.tpl

Lines changed: 226 additions & 57 deletions
Large diffs are not rendered by default.

SimulationRuntime/cpp/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ SET(IDAName ${LIBPREFIX}IDA)
6262
SET(PeerName ${LIBPREFIX}Peer)
6363
SET(RTRKName ${LIBPREFIX}RTRK)
6464
SET(EulerName ${LIBPREFIX}Euler)
65+
SET(kluName ${LIBPREFIX}klu)
6566
SET(RTEulerName ${LIBPREFIX}RTEuler)
6667
SET(IdaName ${LIBPREFIX}Ida)
6768
SET(IdasName ${LIBPREFIX}Idas)
@@ -433,6 +434,10 @@ message(STATUS "Boost dirs '${Boost_LIBRARY_DIRS}', '${Boost_INCLUDE_DIR}'")
433434
#build of simulation.core
434435
include_directories ("Include")
435436
include_directories ("Solver")
437+
include_directories ("Include/Solver/KLU")
438+
439+
add_subdirectory (Solver/KLU)
440+
436441
add_subdirectory (Core/Modelica)
437442
add_subdirectory (Core/Math)
438443
add_subdirectory (SimCoreFactory/OMCFactory)
@@ -453,6 +458,7 @@ add_subdirectory (Core/SimController)
453458

454459
#add Euler solver project
455460
add_subdirectory (Solver/Euler)
461+
456462
add_subdirectory (Solver/RTEuler)
457463
add_subdirectory (Solver/Newton)
458464
add_subdirectory (Solver/Hybrj)
@@ -515,6 +521,9 @@ GET_FILENAME_COMPONENT(libUmfPackName ${libUmfPack} NAME)
515521
GET_TARGET_PROPERTY(libEuler ${EulerName} LOCATION)
516522
GET_FILENAME_COMPONENT(libEulerName ${libEuler} NAME)
517523

524+
GET_TARGET_PROPERTY(libKlu ${kluName} LOCATION)
525+
GET_FILENAME_COMPONENT(libKluName ${libKlu} NAME)
526+
518527
GET_TARGET_PROPERTY(libRTEuler ${RTEulerName} LOCATION)
519528
GET_FILENAME_COMPONENT(libRTEulerName ${libRTEuler} NAME)
520529

@@ -552,6 +561,7 @@ GET_FILENAME_COMPONENT(libSimObjFactoryName ${libSimObjFactory} NAME)
552561
GET_TARGET_PROPERTY(libFMU ${FMUName} LOCATION)
553562
GET_FILENAME_COMPONENT(libFMUName ${libFMU} NAME)
554563

564+
set (KLU_LIB ${libKluName})
555565
set (EULER_LIB ${libEulerName})
556566
set (RTEULER_LIB ${libRTEulerName})
557567
set (SETTINGSFACTORY_LIB ${libSetFactoryName})

SimulationRuntime/cpp/Core/System/AlgLoopDefaultImplementation.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,17 @@
77
#include <Core/System/FactoryExport.h>
88
#include <Core/System/AlgLoopDefaultImplementation.h>
99

10-
10+
bool BOOST_EXTENSION_EXPORT_DECL mycompare ( mytuple lhs, mytuple rhs)
11+
{
12+
return lhs.ele1 < rhs.ele1;
13+
}
1114

1215
AlgLoopDefaultImplementation::AlgLoopDefaultImplementation()
1316
: _dimAEq (0)
1417
, _constraintType(IAlgLoop::UNDEF)
1518
,__xd(NULL)
1619
,_xd_init(NULL)
20+
,_AData(NULL)
1721
{
1822
}
1923

@@ -49,6 +53,8 @@ void AlgLoopDefaultImplementation::initialize()
4953
delete [] _xd_init;
5054
__xd = new double[_dimAEq];
5155
_xd_init = new double[_dimAEq];
56+
memset(__xd,0,_dimAEq*sizeof(double));
57+
memset(_xd_init,0,_dimAEq*sizeof(double));
5258
};
5359

5460
/// Output routine (to be called by the solver after every successful integration step)
@@ -73,4 +79,8 @@ void AlgLoopDefaultImplementation::getRHS(double* res)
7379
{
7480
memcpy(res, __xd, sizeof(double) * _dimAEq);
7581
}
82+
//void AlgLoopDefaultImplementation::getSparseAdata(double* data, int nonzeros)
83+
//{
84+
// memcpy(data, _AData, sizeof(double) * nonzeros);
85+
//}
7686
/** @} */ // end of coreSystem

SimulationRuntime/cpp/Core/Utils/extension/CMakeLists.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,27 @@ install (FILES ${CMAKE_SOURCE_DIR}/Include/Core/Utils/extension/measure_time.hp
3232
${CMAKE_SOURCE_DIR}/Include/Core/Utils/extension/logger.hpp
3333
DESTINATION include/omc/cpp/Core/Utils/extension)
3434

35+
#install (FILES ${CMAKE_SOURCE_DIR}/Include/Core/Utils/numeric/utils.h
36+
# DESTINATION include/omc/cpp/Core/Utils/numeric)
37+
#install (FILES ${CMAKE_SOURCE_DIR}/Include/Core/Utils/numeric/bindings/ublas.hpp
38+
# DESTINATION include/omc/cpp/Core/Utils/numeric/bindings)
39+
#install (FILES ${CMAKE_SOURCE_DIR}/Include/Core/Utils/numeric/bindings/ublas.hpp
40+
# ${CMAKE_SOURCE_DIR}/Include/Core/Utils/numeric/bindings/ublas/banded.hpp>
41+
# ${CMAKE_SOURCE_DIR}/Include/Core/Utils/numeric/bindings/ublas/hermitian.hpp>
42+
# ${CMAKE_SOURCE_DIR}/Include/Core/Utils/numeric/bindings/ublas/matrix.hpp>
43+
# ${CMAKE_SOURCE_DIR}/Include/Core/Utils/numeric/bindings/ublas/matrix_expression.hpp>
44+
# ${CMAKE_SOURCE_DIR}/Include/Core/Utils/numeric/bindings/ublas/matrix_proxy.hpp>
45+
# ${CMAKE_SOURCE_DIR}/Include/Core/Utils/numeric/bindings/ublas/matrix_sparse.hpp>
46+
# ${CMAKE_SOURCE_DIR}/Include/Core/Utils/numeric/bindings/ublas/scalar_vector.hpp>
47+
# ${CMAKE_SOURCE_DIR}/Include/Core/Utils/numeric/bindings/ublas/storage.hpp>
48+
# ${CMAKE_SOURCE_DIR}/Include/Core/Utils/numeric/bindings/ublas/symmetric.hpp>
49+
# ${CMAKE_SOURCE_DIR}/Include/Core/Utils/numeric/bindings/ublas/triangular.hpp>
50+
# ${CMAKE_SOURCE_DIR}/Include/Core/Utils/numeric/bindings/ublas/vector.hpp>
51+
# ${CMAKE_SOURCE_DIR}/Include/Core/Utils/numeric/bindings/ublas/vector_expression.hpp>
52+
# ${CMAKE_SOURCE_DIR}/Include/Core/Utils/numeric/bindings/ublas/vector_proxy.hpp>
53+
# ${CMAKE_SOURCE_DIR}/Include/Core/Utils/numeric/bindings/ublas/vector_sparse.hpp>
54+
# DESTINATION include/omc/cpp/Core/Utils/numeric/bindings/ublas)
55+
3556
IF(PAPI_FOUND)
3657
add_library("${ExtensionUtilitiesName}_papi" SHARED measure_time_papi.cpp)
3758

SimulationRuntime/cpp/Include/Core/Math/SparseMatrix.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
#pragma once
22

33

4-
using std::map;
5-
using std::pair;
6-
using std::make_pair;
74

85
struct BOOST_EXTENSION_EXPORT_DECL sparse_inserter {
96
struct t2 {

SimulationRuntime/cpp/Include/Core/Modelica.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,4 +133,5 @@ typedef ublas::matrix<double, ublas::column_major> matrix_t;
133133
#include <Core/DataExchange/Policies/BufferReaderWriter.h>
134134
#include <Core/HistoryImpl.h>
135135
#include <Core/DataExchange/SimDouble.h>
136+
136137
/** @} */ // end of group1

SimulationRuntime/cpp/Include/Core/System/AlgLoopDefaultImplementation.h

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,38 @@ Services for the implementation of an algebraic loop in open modelica.
1818
Copyright (c) 2008, OSMC
1919
*****************************************************************************/
2020

21+
//using std::map;
22+
//using std::pair;
23+
//using std::make_pair;
24+
25+
//#include <string>
26+
//#include <vector>
27+
#include <boost/tuple/tuple.hpp>
28+
29+
//#include <Core/Utils/numeric/bindings/ublas.hpp>
30+
//#include <Core/Utils/numeric/utils.h>
31+
32+
//#include <algorithm>
33+
34+
//typedef boost::tuple<int,int> mytuple;
35+
36+
class mytuple
37+
{
38+
public:
39+
mytuple(int a, int b)
40+
{
41+
ele1 = a;
42+
ele2 = b;
43+
};
44+
~mytuple(){};
45+
int ele1;
46+
int ele2;
47+
};
48+
49+
50+
51+
bool BOOST_EXTENSION_EXPORT_DECL mycompare ( mytuple lhs, mytuple rhs);
52+
2153
/// Enumeration to control the output
2254
enum OUTPUT
2355
{
@@ -63,6 +95,8 @@ class BOOST_EXTENSION_ALGLOOPDEFAULTIMPL_DECL AlgLoopDefaultImplementation
6395
/// Provide the right hand side (according to the index)
6496
void getRHS(double* res);
6597

98+
//void getSparseAdata(double* data, int nonzeros);
99+
66100

67101
/// Output routine (to be called by the solver after every successful integration step)
68102
void writeOutput(const OUTPUT command = UNDEF_OUTPUT);
@@ -81,7 +115,8 @@ class BOOST_EXTENSION_ALGLOOPDEFAULTIMPL_DECL AlgLoopDefaultImplementation
81115
double* __xd;
82116

83117
IAlgLoop::CONSTRTYPE
84-
_constraintType; ///< Typ der Bindungsgleichungen (analog, digital, binär)
118+
_constraintType; ///< Typ der Bindungsgleichungen (analog, digital, binär)
119+
double * _AData;
85120

86121
};
87122
/** @} */ // end of coreSystem

SimulationRuntime/cpp/Include/Core/System/IAlgLoop.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Abstract interface class for algebraic loop in equations in open modelica.
1717
Copyright (c) 2008, OSMC
1818
*****************************************************************************/
1919

20+
2021
class IAlgLoop
2122
{
2223
public:
@@ -54,6 +55,8 @@ class IAlgLoop
5455
/// Provide the right hand side (according to the index)
5556
virtual void getRHS(double* res) = 0;
5657

58+
virtual void getSparseAdata(double* data, int nonzeros) = 0;
59+
5760

5861
virtual const matrix_t& getSystemMatrix() = 0;
5962
virtual const sparsematrix_t& getSystemSparseMatrix() = 0;
@@ -73,5 +76,6 @@ class IAlgLoop
7376
/// Definiert die übergebene Größe als Schnittgröße
7477
void addConstraint(double& constr_value);
7578
*/
79+
//public : double * _AData;
7680
};
7781
/** @} */ // end of coreSystem

SimulationRuntime/cpp/Include/Solver/Kinsol/Kinsol.h

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,16 @@
33
*
44
* @{
55
*/
6-
7-
8-
9-
10-
6+
#if defined(__vxworks)
7+
#include <klu.h>
8+
#else
9+
#include <Solver/KLU/klu.h>
10+
#endif
11+
/*
12+
class klu_symbolic;
13+
class klu_numeric ;
14+
class klu_common ;
15+
*/
1116

1217
class Kinsol : public IAlgLoopSolver
1318
{
@@ -52,7 +57,7 @@ class Kinsol : public IAlgLoopSolver
5257

5358
long int
5459
_dimSys; ///< Temp - Number of unknowns (=dimension of system of equations)
55-
60+
int _dim;
5661
bool
5762
_firstCall; ///< Temp - Denotes the first call to the solver, init() is called
5863
long int *_ihelpArray,
@@ -100,5 +105,17 @@ class Kinsol : public IAlgLoopSolver
100105
_currentIterateNorm;
101106

102107
int _counter;
108+
//required for klu linear solver
109+
bool _sparse;
110+
111+
klu_symbolic* _kluSymbolic ;
112+
klu_numeric* _kluNumeric ;
113+
klu_common* _kluCommon ;
114+
int* _Ai;
115+
int* _Ap;
116+
double* _Ax;
117+
int _nonzeros;
118+
119+
103120
};
104121
/** @} */ // end of solverKinsol

SimulationRuntime/cpp/LibrariesConfig.h.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#define KLU_LIB "@KLU_LIB@"
12

23
#define EULER_LIB "@EULER_LIB@"
34
#define RTEULER_LIB "@RTEULER_LIB@"

0 commit comments

Comments
 (0)