Skip to content

Commit

Permalink
Revert r16871 (needs lis source code for linux, or ifdef's to not com…
Browse files Browse the repository at this point in the history
…pile against it)

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@16875 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Aug 20, 2013
1 parent 23a9f28 commit 96b7fe8
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 265 deletions.
10 changes: 4 additions & 6 deletions Compiler/Template/CodegenC.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -948,11 +948,9 @@ template functionInitialLinearSystemsTemp(list<SimEqSystem> allEquations)
case eq as SES_MIXED(__) then functionInitialLinearSystemsTemp(fill(eq.cont,1))
case eq as SES_LINEAR(__) then
let size = listLength(vars)
let nnz = listLength(simJac)
<<
linearSystemData[<%indexLinearSystem%>].equationIndex = <%index%>;
linearSystemData[<%indexLinearSystem%>].size = <%size%>;
linearSystemData[<%indexLinearSystem%>].nnz = <%nnz%>;
linearSystemData[<%indexLinearSystem%>].setA = setLinearMatrixA<%index%>;
linearSystemData[<%indexLinearSystem%>].setb = setLinearVectorb<%index%>;
>>
Expand Down Expand Up @@ -989,10 +987,10 @@ template functionSetupLinearSystemsTemp(list<SimEqSystem> allEquations)
case eq as SES_MIXED(__) then functionSetupLinearSystemsTemp(fill(eq.cont,1))
case eq as SES_LINEAR(__) then
let &varDecls = buffer "" /*BUFD*/
let MatrixA = (simJac |> (row, col, eq as SES_RESIDUAL(__)) hasindex i0 =>
let MatrixA = (simJac |> (row, col, eq as SES_RESIDUAL(__)) =>
let &preExp = buffer "" /*BUFD*/
let expPart = daeExp(eq.exp, contextSimulationDiscrete, &preExp /*BUFC*/, &varDecls /*BUFD*/)
'<%preExp%>linearSystemData->setAElement(<%row%>, <%col%>, <%expPart%>, <%i0%>, linearSystemData);'
'<%preExp%>linearSystemData->A[<%row%> + <%col%> * linearSystemData->size] = <%expPart%>;'
;separator="\n")
let &varDecls2 = buffer "" /*BUFD*/
let vectorb = (beqs |> exp hasindex i0 =>
Expand Down Expand Up @@ -3233,7 +3231,7 @@ case SIMCODE(modelInfo=MODELINFO(__), makefileParams=MAKEFILE_PARAMS(__), simula
# /MD - link with MSVCRT.LIB
# /link - [linker options and libraries]
# /LIBPATH: - Directories where libs can be found
LDFLAGS=/MD /link /STACK:0x2000000 /pdb:"<%fileNamePrefix%>.pdb" /LIBPATH:"<%makefileParams.omhome%>/lib/omc/msvc/" /LIBPATH:"<%makefileParams.omhome%>/lib/omc/msvc/release/" <%dirExtra%> <%libsPos1%> <%libsPos2%> f2c.lib initialization.lib libexpat.lib math-support.lib meta.lib results.lib simulation.lib solver.lib sundials_kinsol.lib sundials_nvecserial.lib util.lib lapack_win32_MT.lib lis.lib
LDFLAGS=/MD /link /STACK:0x2000000 /pdb:"<%fileNamePrefix%>.pdb" /LIBPATH:"<%makefileParams.omhome%>/lib/omc/msvc/" /LIBPATH:"<%makefileParams.omhome%>/lib/omc/msvc/release/" <%dirExtra%> <%libsPos1%> <%libsPos2%> f2c.lib initialization.lib libexpat.lib math-support.lib meta.lib results.lib simulation.lib solver.lib sundials_kinsol.lib sundials_nvecserial.lib util.lib lapack_win32_MT.lib

# /MDd link with MSVCRTD.LIB debug lib
# lib names should not be appended with a d just switch to lib/omc/msvc/debug
Expand Down Expand Up @@ -3276,7 +3274,7 @@ case SIMCODE(modelInfo=MODELINFO(__), makefileParams=MAKEFILE_PARAMS(__), simula
CFLAGS=$(CFLAGS_BASED_ON_INIT_FILE) <%makefileParams.cflags%> <%match sopt case SOME(s as SIMULATION_SETTINGS(__)) then s.cflags /* From the simulate() command */%>
CPPFLAGS=-I"<%makefileParams.omhome%>/include/omc" -I. <%dirExtra%> <%makefileParams.includes ; separator=" "%> -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME
LIBSIMULATIONRUNTIMEC=<% if boolAnd(boolNot(stringEq(os(), "OSX")), boolOr(acceptMetaModelicaGrammar(), Flags.isSet(Flags.GEN_DEBUG_SYMBOLS))) then "-Wl,-whole-archive "%>-lSimulationRuntimeC <% if boolAnd(boolNot(stringEq(os(), "OSX")), boolOr(acceptMetaModelicaGrammar(), Flags.isSet(Flags.GEN_DEBUG_SYMBOLS))) then " -Wl,-no-whole-archive"%> <% if stringEq(makefileParams.platform, "win32") then "" else " -ldl"%>
LDFLAGS=-L"<%makefileParams.omhome%>/lib/omc" -Wl,<% if stringEq(makefileParams.platform, "win32") then "--stack,0x2000000,"%>-rpath,'<%makefileParams.omhome%>/lib/omc' $(LIBSIMULATIONRUNTIMEC) -linteractive <%ParModelicaLibs%> <%makefileParams.ldflags%> <%makefileParams.runtimelibs%> <%match System.os() case "OSX" then "-lf2c" else "-Wl,-Bstatic -lf2c -Wl,-Bdynamic -llis"%>
LDFLAGS=-L"<%makefileParams.omhome%>/lib/omc" -Wl,<% if stringEq(makefileParams.platform, "win32") then "--stack,0x2000000,"%>-rpath,'<%makefileParams.omhome%>/lib/omc' $(LIBSIMULATIONRUNTIMEC) -linteractive <%ParModelicaLibs%> <%makefileParams.ldflags%> <%makefileParams.runtimelibs%> <%match System.os() case "OSX" then "-lf2c" else "-Wl,-Bstatic -lf2c -Wl,-Bdynamic"%>
PERL=perl
FILEPREFIX=<%fileNamePrefix%>
MAINFILE=$(FILEPREFIX)<% if boolOr(acceptMetaModelicaGrammar(), Flags.isSet(Flags.GEN_DEBUG_SYMBOLS)) then ".conv"%>.c
Expand Down
4 changes: 0 additions & 4 deletions SimulationRuntime/c/simulation/simulation_runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,14 +295,10 @@ int getlinearSolverMethod(int argc, char**argv)
if(*method == string("lapack"))
return LS_LAPACK;

if(*method == string("lis"))
return LS_LIS;

WARNING1(LOG_STDOUT, "unrecognized option -ls %s", method->c_str());
WARNING(LOG_STDOUT, "current options are:");
INDENT(LOG_STDOUT);
WARNING2(LOG_STDOUT, "%-18s [%s]", "lapack", "default method");
WARNING2(LOG_STDOUT, "%-18s [%s]", "lis", "Lis");
THROW("see last warning");
return LS_NONE;
}
Expand Down
2 changes: 0 additions & 2 deletions SimulationRuntime/c/simulation/solver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ SET(solver_sources dassl.c
kinsolSolver.c
linearSystem.c
linearSolverLapack.c
linearSolverLis.c
nonlinearSystem.c
nonlinearSolverHybrd.c
nonlinearSolverNewton.c
Expand All @@ -29,7 +28,6 @@ SET(solver_headers dassl.h
kinsolSolver.h
linearSystem.h
linearSolverLapack.h
linearSolverLis.h
model_help.h
nonlinearSolverHybrd.h
nonlinearSolverNewton.h
Expand Down
142 changes: 0 additions & 142 deletions SimulationRuntime/c/simulation/solver/linearSolverLis.c

This file was deleted.

70 changes: 0 additions & 70 deletions SimulationRuntime/c/simulation/solver/linearSolverLis.h

This file was deleted.

48 changes: 13 additions & 35 deletions SimulationRuntime/c/simulation/solver/linearSystem.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,10 @@
#include "omc_error.h"
#include "linearSystem.h"
#include "linearSolverLapack.h"
#include "linearSolverLis.h"
#include "simulation_info_xml.h"
#include "blaswrap.h"
#include "f2c.h"

int globalCounterIterations = 0;
/*! \fn int allocatelinearSystem(DATA *data)
*
* This function allocates memory for all linear systems.
Expand All @@ -51,31 +49,25 @@ int globalCounterIterations = 0;
*/
int allocatelinearSystem(DATA *data)
{
int i,nnz;
int i;
int size;
LINEAR_SYSTEM_DATA *linsys = data->simulationInfo.linearSystemData;

for(i=0; i<data->modelData.nLinearSystems; ++i)
{
size = linsys[i].size;
nnz = linsys[i].nnz;

/* allocate system data */
linsys[i].x = (double*) malloc(size*sizeof(double));
linsys[i].b = (double*) malloc(size*sizeof(double));
linsys[i].A = (double*) malloc(size*size*sizeof(double));

/* allocate solver data */
/* the implementation of matrix A is solver-specific */
switch(data->simulationInfo.lsMethod){
switch(data->simulationInfo.lsMethod)
{
case LS_LAPACK:
linsys[i].A = (double*) malloc(size*size*sizeof(double));
linsys[i].setAElement = setAElementLAPACK;
allocateLapackData(size, &linsys[i].solverData);
break;
case LS_LIS:
linsys[i].setAElement = setAElementLis;
allocateLisData(size, size, nnz, &linsys[i].solverData);
break;
default:
THROW("unrecognized linear solver");
}
Expand All @@ -96,17 +88,15 @@ int freelinearSystem(DATA *data)

for(i=0;i<data->modelData.nLinearSystems;++i)
{
/* free system and solver data */
free(linsys[i].x);
free(linsys[i].b);
free(linsys[i].A);

switch(data->simulationInfo.lsMethod){
/* allocate solver data */
switch(data->simulationInfo.lsMethod)
{
case LS_LAPACK:
freeLapackData(&linsys[i].solverData);
free(linsys[i].A);
break;
case LS_LIS:
freeLisData(&linsys[i].solverData);
break;
default:
THROW("unrecognized linear solver");
Expand All @@ -127,16 +117,17 @@ int freelinearSystem(DATA *data)
*/
int solve_linear_system(DATA *data, int sysNumber)
{
/* NONLINEAR_SYSTEM_DATA
* system = &(data->simulationInfo.nonlinearSystemData[sysNumber]); */
int success;
LINEAR_SYSTEM_DATA* linsys = data->simulationInfo.linearSystemData;

switch(data->simulationInfo.lsMethod){
/* for now just use lapack solver as before */
switch(data->simulationInfo.lsMethod)
{
case LS_LAPACK:
success = solveLapack(data, sysNumber);
break;
case LS_LIS:
success = solveLis(data, sysNumber);
break;
default:
THROW("unrecognized linear solver");
}
Expand Down Expand Up @@ -175,16 +166,3 @@ int check_linear_solutions(DATA *data, int printFailingSystems)

return retVal;
}

void setAElementLAPACK(int row, int col, double value, int nth, void *data )
{
LINEAR_SYSTEM_DATA* linsys = (LINEAR_SYSTEM_DATA*) data;
linsys->A[row + col * linsys->size] = value;
}

void setAElementLis(int row, int col, double value, int nth, void *data )
{
LINEAR_SYSTEM_DATA* linSys = (LINEAR_SYSTEM_DATA*) data;
DATA_LIS* sData = (DATA_LIS*) linSys->solverData;
lis_matrix_set_value(LIS_INS_VALUE, row, col, value, sData->A);
}

0 comments on commit 96b7fe8

Please sign in to comment.