Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
569e077
Misc refactors, insert internal stmt debuginfo
serenity4 Jun 4, 2025
7b25b96
Add slotnames info
serenity4 Jun 4, 2025
676875a
Refactor naming of locals for ODE codegen
serenity4 Jun 4, 2025
eadfca7
Add comment
serenity4 Jun 4, 2025
3cd1d4f
Merge branch 'main' of github.com:JuliaComputing/DAECompiler.jl into …
serenity4 Jun 6, 2025
16c19ed
Apply DebugInfo at top-level
serenity4 Jun 6, 2025
21ea3d4
Remove `insert_ssa_debuginfo` setting
serenity4 Jun 6, 2025
866480d
Marshall settings everywhere
serenity4 Jun 6, 2025
427c108
Add maybe_insert_debuginfo
serenity4 Jun 6, 2025
7ad9e5c
Disable crashing tests
serenity4 Jun 6, 2025
b0b188f
Propagate source information for `insert_node_here!(...)`
serenity4 Jun 6, 2025
f0bd023
Add source provenance to DAE/Init codegen
serenity4 Jun 6, 2025
c7328b4
Use `__SOURCE__` macro for `replace_call!`
serenity4 Jun 6, 2025
4781765
Update `replace_call!` with source information in index_lowering.jl
serenity4 Jun 6, 2025
e8cb8ce
Default `insert_stmt_debuginfo` to `false` for reflection tools
serenity4 Jun 6, 2025
1465a81
Remove accidental code inclusion
serenity4 Jun 6, 2025
4196e65
Don't seek previous codeloc
serenity4 Jun 9, 2025
b9cc48a
Merge branch 'main' of github.com:JuliaComputing/DAECompiler.jl into …
serenity4 Jun 9, 2025
72b46bd
Remove unused code
serenity4 Jun 9, 2025
446d80c
Reenable IPO tests
serenity4 Jun 9, 2025
2d423bf
[DO NOT MERGE] Temporarily dev ConstructionBase for CI
serenity4 Jun 9, 2025
1f2fcb4
Work around `invokelatest` issue
serenity4 Jun 9, 2025
8eac9a9
Only wrap `string` call in `try`/`catch`
serenity4 Jun 9, 2025
e45136e
Add `insert_ssa_debuginfo` setting
serenity4 Jun 10, 2025
da1df0b
Minor fix
serenity4 Jun 10, 2025
7d0e0a0
Refactor `insert_node_here` macro
serenity4 Jun 19, 2025
194ceab
Use insert_instruction! in more places
serenity4 Jun 19, 2025
888be4c
Rename `insert_node_here` macro to `insert_instruction`
serenity4 Jun 19, 2025
2d2125d
`insert_instruction` -> `insert_instruction_here`
serenity4 Jun 19, 2025
03f2ccf
Fixes
serenity4 Jun 19, 2025
3829ef9
Undev ConstructionBase (and update)
serenity4 Jun 19, 2025
8e2cd1f
[WIP] Add unoptimized compilation path
serenity4 Jun 20, 2025
4dbacc6
Use UnoptimizedKey singleton for caching unoptimized RHS
serenity4 Jun 23, 2025
561c94f
Refactor settings construction for DAE/ODE problems
serenity4 Jun 23, 2025
7f88c60
Write `expand_residuals`
serenity4 Jun 24, 2025
afddff7
Use :call form for macrocall
serenity4 Jun 24, 2025
9a2c519
Use :call for added macrocalls
serenity4 Jun 24, 2025
a3351ac
Fix introduced codegen bug
serenity4 Jun 24, 2025
eba5a4e
[WIP] Add basic infrastructure for testing
serenity4 Jun 24, 2025
03e3942
Reconstruct variables from states
serenity4 Jun 24, 2025
21b8c35
Separate optimized and unoptimized structural caches
serenity4 Jun 26, 2025
4a6d52f
Add incidence-copying constructor for TransformationState
serenity4 Jun 26, 2025
24ef40d
Minor refactor `rhs_ir_finish!`
serenity4 Jun 26, 2025
a81204f
Skip flattening in unoptimized context, WIP on IPO support
serenity4 Jun 26, 2025
4402b42
Correctly compute state/equation indices for IPO
serenity4 Jun 26, 2025
57f65d7
Adjust residual sign based on solved variable coefficient
serenity4 Jun 30, 2025
a9d17dd
Rewrite and support flattening, improve external equation support
serenity4 Jul 2, 2025
120e140
Fix flattening bug
serenity4 Jul 2, 2025
1be8fc6
Fix another flattening bug
serenity4 Jul 2, 2025
5f796d2
Rename testing function
serenity4 Jul 2, 2025
e6f621f
Support type constructors for IPO
serenity4 Jul 2, 2025
b510c79
Split benchmark definition and test
serenity4 Jul 2, 2025
a45c5c4
Remove process_template!
serenity4 Jul 2, 2025
bae2a86
Fix handling of functors, replace flatten_parameter!
serenity4 Jul 2, 2025
eb32850
Fix bug in residual expansion
serenity4 Jul 3, 2025
073dc77
Mark `apply_linear_incidence` as mutating
serenity4 Jul 4, 2025
59bb6ea
Correctly handle nonlinear replacements
serenity4 Jul 7, 2025
1b991fd
Add (broken) validation test for thermalfluid benchmark
serenity4 Jul 8, 2025
ab4899b
Wrap test files in modules
serenity4 Jul 8, 2025
dc11e85
Remove unnecessary import
serenity4 Jul 8, 2025
b33c46f
Remove temp package from project
serenity4 Jul 9, 2025
49d08df
Merge branch 'main' of github.com:JuliaComputing/DAECompiler.jl into …
serenity4 Jul 10, 2025
49cab3f
Remove `refresh()` in tests
serenity4 Jul 10, 2025
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
2 changes: 1 addition & 1 deletion Manifest.toml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions benchmark/main.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using Test
using SciMLBase, Sundials

include("thermalfluid.jl")

Benchmark{3}()()
@test isa(code_lowered(DAECompiler.factory, Tuple{Val{DAECompiler.Settings(mode=DAECompiler.DAENoInit)}, Benchmark{3}})[1], Core.CodeInfo)
let sol = solve(DAECProblem(Benchmark{3}(), [1:9;] .=> 0.), IDA())
@test_broken sol.retcode == ReturnCode.Success
end
8 changes: 0 additions & 8 deletions benchmark/thermalfluid.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ using DAECompiler
using DAECompiler.Intrinsics
using Polynomials: fit
using XSteam: my_pT, rho_pT, Cp_pT, tc_pT
using SciMLBase, Sundials
using Test

struct Sink; end
function (::Sink)(inlet)
Expand Down Expand Up @@ -282,9 +280,3 @@ function (::Benchmark{N})() where {N}
PreinsulatedPipe{N}()(in[2], out[1])
Sink()(out[2])
end

Benchmark{3}()()
@test isa(code_lowered(DAECompiler.factory, Tuple{Val{DAECompiler.Settings(mode=DAECompiler.DAENoInit)}, Benchmark{3}})[1], Core.CodeInfo)
let sol = solve(DAECProblem(Benchmark{3}(), [1:9;] .=> 0.), IDA())
@test_broken sol.retcode == ReturnCode.Success
end
8 changes: 5 additions & 3 deletions src/DAECompiler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module DAECompiler
using Diffractor
using OrderedCollections
using Compiler
using Compiler: IRCode, IncrementalCompact, DebugInfoStream, NewInstruction, argextype, singleton_type, isexpr, widenconst
using Compiler: AbstractLattice, IRCode, IncrementalCompact, DebugInfoStream, NewInstruction, argextype, singleton_type, isexpr, widenconst
using Core.IR
using SciMLBase
using AutoHashEquals
Expand All @@ -16,18 +16,21 @@ module DAECompiler
include("settings.jl")
include("utils.jl")
include("intrinsics.jl")
include("reflection.jl")
include("analysis/utils.jl")
include("analysis/lattice.jl")
include("analysis/ADAnalyzer.jl")
include("analysis/scopes.jl")
include("analysis/flattening.jl")
include("analysis/cache.jl")
include("analysis/refiner.jl")
include("analysis/ipoincidence.jl")
include("analysis/structural.jl")
include("analysis/flattening.jl")
include("transform/state_selection.jl")
include("transform/common.jl")
include("transform/runtime.jl")
include("transform/unoptimized.jl")
include("transform/reconstruct.jl")
include("transform/tearing/schedule.jl")
include("transform/codegen/dae_factory.jl")
include("transform/codegen/ode_factory.jl")
Expand All @@ -40,5 +43,4 @@ module DAECompiler
include("analysis/consistency.jl")
include("interface.jl")
include("problem_interface.jl")
include("reflection.jl")
end
12 changes: 10 additions & 2 deletions src/analysis/ADAnalyzer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ end

struct AnalyzedSource
ir::Compiler.IRCode
slotnames::Vector{Any}
inline_cost::Compiler.InlineCostType
nargs::UInt
isva::Bool
Expand All @@ -72,19 +73,26 @@ end
Core.svec(edges..., interp.edges...)
end

function get_slotnames(def::Method)
names = split(def.slot_syms, '\0')
return map(Symbol, names)
end

@override function Compiler.transform_result_for_cache(interp::ADAnalyzer, result::InferenceResult, edges::SimpleVector)
ir = result.src.optresult.ir
slotnames = get_slotnames(result.linfo.def)
params = Compiler.OptimizationParams(interp)
return AnalyzedSource(ir, Compiler.compute_inlining_cost(interp, result), result.src.src.nargs, result.src.src.isva)
return AnalyzedSource(ir, slotnames, Compiler.compute_inlining_cost(interp, result), result.src.src.nargs, result.src.src.isva)
end

@override function Compiler.transform_result_for_local_cache(interp::ADAnalyzer, result::InferenceResult)
if Compiler.result_is_constabi(interp, result)
return nothing
end
ir = result.src.optresult.ir
slotnames = get_slotnames(result.linfo.def)
params = Compiler.OptimizationParams(interp)
return AnalyzedSource(ir, Compiler.compute_inlining_cost(interp, result), result.src.src.nargs, result.src.src.isva)
return AnalyzedSource(ir, slotnames, Compiler.compute_inlining_cost(interp, result), result.src.src.nargs, result.src.src.isva)
end

function Compiler.retrieve_ir_for_inlining(ci::CodeInstance, result::AnalyzedSource)
Expand Down
15 changes: 15 additions & 0 deletions src/analysis/cache.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,19 @@ end
var_schedule::Vector{Pair{BitSet, BitSet}}
end

struct VariableReplacement
replaced::Incidence
by::Int
equation::Int
end

mutable struct NonlinearReplacementMap
const variables::Vector{VariableReplacement}
variable_counter::Int
equation_counter::Int
end
NonlinearReplacementMap() = NonlinearReplacementMap(VariableReplacement[], 0, 0)

"""
StructuralSSARef

Expand All @@ -35,6 +48,7 @@ struct DAEIPOResult
opaque_eligible::Bool
extended_rt::Any
argtypes
argmap::ArgumentMap
nexternalargvars::Int # total vars is length(var_to_diff)
nsysmscopes::Int
nexternaleqs::Int
Expand All @@ -44,6 +58,7 @@ struct DAEIPOResult
total_incidence::Vector{Any}
eqclassification::Vector{VarEqClassification}
eq_callee_mapping::Vector{Union{Nothing, Vector{Pair{StructuralSSARef, Int}}}}
replacement_map::NonlinearReplacementMap
names::OrderedDict{Any, ScopeDictEntry} # TODO: OrderedIdDict
varkinds::Vector{Union{Intrinsics.VarKind, Nothing}}
eqkinds::Vector{Union{Intrinsics.EqKind, Nothing}}
Expand Down
Loading