Skip to content

Commit

Permalink
Add Runge-Kutta family of solvers
Browse files Browse the repository at this point in the history
  • Loading branch information
mscuttari committed Jul 31, 2024
1 parent ee8964d commit bdf4239
Show file tree
Hide file tree
Showing 14 changed files with 2,291 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .jenkins/install_llvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

git clone https://github.com/marco-compiler/llvm-project.git
cd llvm-project
git checkout 4b2b0c70a2f28e87c0c559e9a17ec0f5573420fa
git checkout 969ff8ef9aba8c17ddb53fd44bd8d3b82d47b3fa

rm -rf build
mkdir build
Expand Down
2 changes: 1 addition & 1 deletion .jenkins/install_runtime.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

git clone https://github.com/marco-compiler/marco-runtime.git
cd marco-runtime
git checkout 58fd4d19c815527bd09a45061f55d208173ab170
git checkout f7aa2422e563cf10cd5d865be72a442ffde6e871

rm -rf build
mkdir build
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "marco/Dialect/BaseModelica/Transforms/RangeBoundariesInference.h"
#include "marco/Dialect/BaseModelica/Transforms/ReadOnlyVariablesPropagation.h"
#include "marco/Dialect/BaseModelica/Transforms/RecordInlining.h"
#include "marco/Dialect/BaseModelica/Transforms/RungeKutta.h"
#include "marco/Dialect/BaseModelica/Transforms/SCCAbsenceVerification.h"
#include "marco/Dialect/BaseModelica/Transforms/SCCDetection.h"
#include "marco/Dialect/BaseModelica/Transforms/SCCSolvingBySubstitution.h"
Expand Down
20 changes: 20 additions & 0 deletions include/public/marco/Dialect/BaseModelica/Transforms/Passes.td
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,26 @@ def EulerForwardPass : Pass<"euler-forward", "mlir::ModuleOp">
let constructor = "mlir::bmodelica::createEulerForwardPass()";
}

def RungeKuttaPass : Pass<"runge-kutta", "mlir::ModuleOp">
{
let summary = "Apply the implicit Euler integration method";

let description = [{
Apply the implicit Euler integration method.
}];

let dependentDialects = [
"mlir::bmodelica::BaseModelicaDialect",
"mlir::runtime::RuntimeDialect"
];

let options = [
Option<"variant", "variant", "std::string", "", "Runge-Kutta variant">
];

let constructor = "mlir::bmodelica::createRungeKuttaPass()";
}

def IDAPass : Pass<"ida", "mlir::ModuleOp">
{
let summary = "Solve the model with IDA";
Expand Down
17 changes: 17 additions & 0 deletions include/public/marco/Dialect/BaseModelica/Transforms/RungeKutta.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#ifndef MARCO_DIALECT_BASEMODELICA_TRANSFORMS_RUNGEKUTTA_H
#define MARCO_DIALECT_BASEMODELICA_TRANSFORMS_RUNGEKUTTA_H

#include "mlir/Pass/Pass.h"

namespace mlir::bmodelica
{
#define GEN_PASS_DECL_RUNGEKUTTAPASS
#include "marco/Dialect/BaseModelica/Transforms/Passes.h.inc"

std::unique_ptr<mlir::Pass> createRungeKuttaPass();

std::unique_ptr<mlir::Pass> createRungeKuttaPass(
const RungeKuttaPassOptions& options);
}

#endif // MARCO_DIALECT_BASEMODELICA_TRANSFORMS_RUNGEKUTTA_H
1 change: 1 addition & 0 deletions include/public/marco/Frontend/FrontendActions.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ namespace marco::frontend
std::unique_ptr<mlir::Pass> createMLIRFunctionScalarizationPass();
std::unique_ptr<mlir::Pass> createMLIRReadOnlyVariablesPropagationPass();

std::unique_ptr<mlir::Pass> createMLIRRungeKuttaPass(llvm::StringRef variant);
std::unique_ptr<mlir::Pass> createMLIREulerForwardPass();
std::unique_ptr<mlir::Pass> createMLIRIDAPass();
std::unique_ptr<mlir::Pass> createMLIRSCCSolvingWithKINSOLPass();
Expand Down
1 change: 1 addition & 0 deletions lib/Dialect/BaseModelica/Transforms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ add_mlir_dialect_library(MLIRBaseModelicaTransforms
RangeBoundariesInference.cpp
ReadOnlyVariablesPropagation.cpp
RecordInlining.cpp
RungeKutta.cpp
SCCAbsenceVerification.cpp
SCCDetection.cpp
SCCSolvingBySubstitution.cpp
Expand Down
Loading

0 comments on commit bdf4239

Please sign in to comment.