Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 77 additions & 8 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,9 @@ jobs:
- os: macos-latest
arch: arm64
version: '1.12'
# Windows is disabled while the silent test-suite stall is being
# debugged locally. The 90-minute job cap is hit consistently even
# after warm depot cache, D:-drive depot, coverage off and
# check_bounds=auto reduce setup + pre-test precompile to ~3
# minutes. The test runner then goes silent for 70+ minutes with
# no output before the cap, so the stall is inside the test suite
# itself. Re-enable once the hung @testset is identified and
# either fixed or skipped.
- os: windows-latest
arch: x64
version: '1.12'

steps:
- name: Cap precompile concurrency (macOS)
Expand Down Expand Up @@ -145,3 +140,77 @@ jobs:
Commit: ${{ github.sha }}
Branch: ${{ github.ref_name }}
Matrix: ${{ matrix.os }} / Julia ${{ matrix.version }} / ${{ matrix.arch }}

# Downstream integration gate: after the OMBackend tests pass, run the parent
# OM.jl test suite (runtests.jl) on Ubuntu with THIS OMBackend checkout dev'd
# in, so an OMBackend change that breaks the parent is caught here.
om-rt:
name: OM.jl RT - Ubuntu (downstream)
needs: test
runs-on: ubuntu-latest
timeout-minutes: 120
env:
# This job builds the parent OM.jl project, not OMBackend; repoint the
# project so the cache action and bare `julia --project` calls key off it.
JULIA_PROJECT: OM.jl
steps:
# OMBackend under test: the current repo at the triggering ref, placed as a
# sibling so OM.jl's [sources] path ../OMBackend.jl resolves to it.
- name: Checkout OMBackend.jl (under test)
uses: actions/checkout@v4
with:
path: OMBackend.jl

# Parent OM.jl and the remaining siblings mirror OM.jl's own CI so RT runs
# in the same environment, with OMBackend swapped for the checkout above.
- { name: Checkout OM.jl, uses: actions/checkout@v4, with: { repository: JKRT/OM.jl, ref: master, path: OM.jl } }
- { name: Checkout Absyn.jl, uses: actions/checkout@v4, with: { repository: OpenModelica/Absyn.jl, ref: master, path: Absyn.jl } }
- { name: Checkout ArrayUtil.jl, uses: actions/checkout@v4, with: { repository: JKRT/ArrayUtil.jl, ref: master, path: ArrayUtil.jl } }
- { name: Checkout DAE.jl, uses: actions/checkout@v4, with: { repository: JKRT/DAE.jl, ref: master, path: DAE.jl } }
- { name: Checkout DoubleEnded.jl, uses: actions/checkout@v4, with: { repository: OpenModelica/DoubleEnded.jl, ref: master, path: DoubleEnded.jl } }
- { name: Checkout ImmutableList.jl, uses: actions/checkout@v4, with: { repository: OpenModelica/ImmutableList.jl, ref: master, path: ImmutableList.jl } }
- { name: Checkout ListUtil.jl, uses: actions/checkout@v4, with: { repository: JKRT/ListUtil.jl, ref: master, path: ListUtil.jl } }
- { name: Checkout MetaModelica.jl, uses: actions/checkout@v4, with: { repository: OpenModelica/MetaModelica.jl, ref: master, path: MetaModelica.jl } }
- { name: Checkout OMFrontend.jl, uses: actions/checkout@v4, with: { repository: OpenModelica/OMFrontend.jl, ref: master, path: OMFrontend.jl } }
- { name: Checkout OMParser.jl, uses: actions/checkout@v4, with: { repository: OpenModelica/OMParser.jl, ref: master, path: OMParser.jl } }
- { name: Checkout OMRuntimeExternalC.jl, uses: actions/checkout@v4, with: { repository: OpenModelica/OMRuntimeExternalC.jl, ref: master, path: OMRuntimeExternalC.jl } }
- { name: Checkout SCode.jl, uses: actions/checkout@v4, with: { repository: OpenModelica/SCode.jl, ref: master, path: SCode.jl } }

- uses: julia-actions/setup-julia@v2
with:
version: '1.12'
arch: x64

- uses: julia-actions/cache@v2
with:
cache-name: om-rt

- name: Develop siblings, build native libs, precompile
shell: bash
working-directory: OM.jl
# Disable auto-precompile so the native-lib build runs before precompile
# (OMParser/OMRuntimeExternalC download shared libs in their build step).
env:
JULIA_PKG_PRECOMPILE_AUTO: '0'
run: |
julia --color=yes --project -e '
import Pkg
Pkg.Registry.add("General")
Pkg.Registry.add(Pkg.RegistrySpec(url="https://github.com/OpenModelica/OpenModelicaRegistry.git"))
siblings = [
"../Absyn.jl", "../ArrayUtil.jl", "../DAE.jl", "../DoubleEnded.jl",
"../ImmutableList.jl", "../ListUtil.jl", "../MetaModelica.jl",
"../OMBackend.jl", "../OMFrontend.jl", "../OMParser.jl",
"../OMRuntimeExternalC.jl", "../SCode.jl",
]
Pkg.develop([Pkg.PackageSpec(path = p) for p in siblings])
# Test-only deps used by test/testUtils.jl but absent from OM [deps].
Pkg.add(["ADTypes", "Sundials", "Logging", "Test"])
Pkg.build(["OMParser", "OMRuntimeExternalC"]; verbose=true)
Pkg.resolve()
Pkg.precompile()'

- name: Test (OM.jl runtests)
shell: bash
working-directory: OM.jl/test # runtests.jl guards pwd() == @__DIR__
run: julia --color=yes --project=.. -e 'include("runtests.jl")'
2 changes: 2 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ ModelingToolkit = "961ee093-0014-501f-94e3-6117800e7a78"
OMFrontend = "b10394b5-f439-4073-a0c5-e09cb00cf46c"
OMParser = "11f87224-cae7-4e99-a924-e50d12f62c59"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
REPL = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
SCode = "350d45b0-c210-11e9-3b9e-fdad65bb3d46"
Setfield = "efcf1570-3423-57d1-acb7-fd33fddbac46"
Expand Down Expand Up @@ -55,6 +56,7 @@ SCode = { path = "../SCode.jl" }

[compat]
ModelingToolkit = "= 11.21.0"
PrecompileTools = "1"
julia = "1.12"

[extras]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Github Action CI](https://github.com/JKRT/OMBackend.jl/workflows/CI/badge.svg)](https://github.com/JKRT/OMBackend.jl/actions) [![License: OSMC-PL](https://img.shields.io/badge/license-OSMC--PL-lightgrey.svg)](LICENSE.md)
[![Github Action CI](https://github.com/OpenModelica/OMBackend.jl/workflows/CI/badge.svg)](https://github.com/OpenModelica/OMBackend.jl/actions) [![License: OSMC-PL](https://img.shields.io/badge/license-OSMC--PL-lightgrey.svg)](LICENSE.md)

# About OMBackend.jl

Expand Down
60 changes: 25 additions & 35 deletions src/Backend/BDAE.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,8 @@

#=
TODO:
Change Integer -> Int here. Integer is an old artifact.
Make sure all types here properly typed!
Move Var s.t it is close to the struct that defines it.
Make all datatypes here immutable. I think having VAR as a immutable struct is better.

Remove VarKind types we do not use.

=#

"""
Expand Down Expand Up @@ -173,7 +168,7 @@ using ExportAll
- `BRANCH(ar, br)` — `Connections.branch(ar, br)`.
- `STRUCTURAL_IF_EQUATION(ifEquation)` — DOCC if-equation preserved as a
frontend `EQUATION_IF` so the runtime can replay the branch choice.
- `STRUCTURAL_TRANSISTION(fromState, toState, transistionCondition)` —
- `STRUCTURAL_TRANSITION(fromState, toState, transitionCondition)` —
VSS transition; a structural callback is generated from the condition.
(Name is a historical typo preserved across the codebase.)
"""
Expand All @@ -187,11 +182,7 @@ using ExportAll
- `WHEN_STMTS(condition, whenStmtLst, elsewhenPart)`:
- `condition`: the when-condition expression.
- `whenStmtLst`: list of `WhenOperator` statements to run on trigger.
- `elsewhenPart`: chained `elsewhen`. Intentionally untyped: depending
on the call site it can be `NONE()`, an `Option{WHEN_STMTS}`, a
`SOME(WHEN_EQUATION)` (as produced by `lowerWhenEquation`), or plain
`nothing`. Until those call sites converge, constraining the field
type would be a breaking change.
- `elsewhenPart`: chained `elsewhen`, `NONE()` or `SOME(WHEN_EQUATION)`.
"""
@UniontypeDecl WhenEquation

Expand Down Expand Up @@ -254,10 +245,10 @@ mutable struct VAR <: Var
varKind::VarKind
varDirection::DAE.VarDirection
varType::DAE.Type
bindExp::Option
arryDim::List
bindExp::Option{DAE.Exp}
arryDim::List{DAE.Dimension}
source::DAE.ElementSource
values::Option
values::Option{DAE.VariableAttributes}
tearingSelectOption::Option
connectorType::DAE.ConnectorType
unreplaceable::Bool
Expand Down Expand Up @@ -316,8 +307,8 @@ end
struct SHARED
globalKnownVars::Vector{VAR}
localKnownVars::Vector{VAR}
metaModel::Option
flatModel::Option
metaModel::Option{SCode.CLASS}
flatModel::Option{OMFrontend.Frontend.FlatModel}
DOCC_equations::Vector{Equation}
end

Expand All @@ -337,7 +328,7 @@ end
end

@Record STATE begin
index::Integer
index::Int
derName::Option{DAE.ComponentRef}
natural::Bool
end
Expand Down Expand Up @@ -436,7 +427,6 @@ end

@Uniontype EvaluationStages begin
@Record EVALUATION_STAGES begin

dynamicEval::Bool
algebraicEval::Bool
zerocrossEval::Bool
Expand Down Expand Up @@ -465,9 +455,9 @@ const EQ_ATTR_DEFAULT_UNKNOWN = EQUATION_ATTRIBUTES(false, UNKNOWN_EQUATION_KIND

@Uniontype Equation begin
@Record EQUATION begin
lhs
rhs
source
lhs::DAE.Exp
rhs::DAE.Exp
source::DAE.ElementSource
attributes::EquationAttributes
end

Expand All @@ -477,7 +467,7 @@ const EQ_ATTR_DEFAULT_UNKNOWN = EQUATION_ATTRIBUTES(false, UNKNOWN_EQUATION_KIND
right::DAE.Exp
source::DAE.ElementSource
attr::EquationAttributes
recordSize::Option{Integer}
recordSize::Option{Int}
end

@Record SOLVED_EQUATION begin
Expand All @@ -488,45 +478,45 @@ const EQ_ATTR_DEFAULT_UNKNOWN = EQUATION_ATTRIBUTES(false, UNKNOWN_EQUATION_KIND
end

@Record RESIDUAL_EQUATION begin
exp
source
attr
exp::DAE.Exp
source::DAE.ElementSource
attr::EquationAttributes
end

@Record ALGORITHM begin
size::Integer
size::Int
alg::DAE.Algorithm
source::DAE.ElementSource
expand::DAE.Expand
attr::EquationAttributes
end

@Record WHEN_EQUATION begin
size::Integer
size::Int
whenEquation::WhenEquation
source::DAE.ElementSource
attr
attr::EquationAttributes
end

#= Body of an `algorithm when initial() then ... end when` clause. Distinct
from WHEN_EQUATION so init-time bodies stay separated from runtime
when-equations through the pipeline. =#
@Record INITIAL_WHEN_EQUATION begin
size::Integer
size::Int
whenEquation::WhenEquation
source::DAE.ElementSource
attr
attr::EquationAttributes
end

@Record STRUCTURAL_WHEN_EQUATION begin
size::Integer
size::Int
whenEquation::WhenEquation
source::DAE.ElementSource
attr::EquationAttributes
end

@Record COMPLEX_EQUATION begin
size::Integer
size::Int
left::DAE.Exp
right::DAE.Exp
source::DAE.ElementSource
Expand Down Expand Up @@ -573,18 +563,18 @@ const EQ_ATTR_DEFAULT_UNKNOWN = EQUATION_ATTRIBUTES(false, UNKNOWN_EQUATION_KIND
ifEquation::OMFrontend.Frontend.EQUATION_IF
end

@Record STRUCTURAL_TRANSISTION begin
@Record STRUCTURAL_TRANSITION begin
fromState::String
toState::String
transistionCondition::DAE.Exp
transitionCondition::DAE.Exp
end
end

@Uniontype WhenEquation begin
@Record WHEN_STMTS begin
condition::DAE.Exp
whenStmtLst::List{WhenOperator}
elsewhenPart
elsewhenPart::Option{WHEN_EQUATION}
end
end

Expand Down
Loading
Loading