Inline linear SCC solves share one `LinearCache` per matrix size, so every call refactorizes

Abierto
#178 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
45/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Activo
Área
performance

Línea de trabajo

Start by tracing numeric_ldiv! and solve_into! to see how task-local LinearCache instances are selected and refactorized. The issue suggests adding a solve-site key to emitted safe_ldiv(A, b) calls; compare that approach with keying by A's buffer and consider cache lifetime. Done when unchanged matrices at distinct inline linear SCC solve sites reuse their own factorization without retaining a cache for every problem built.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

numeric_ldiv! keeps one task-local LinearCache per array type and size, shared by every inline linear SCC solve of that shape. So solve_into! copies A in and refactorizes on every call, even when A hasn't changed, since another site of the same size may have used the cache in between.

With one cache per solve site (still task-local), a site whose A depends only on parameters could keep its factorization. On the model below, skipping the refactorization while A is unchanged makes f about 2.5x faster at N = 12 and 1.5x at N = 6 (Julia 1.12).

The emitted safe_ldiv(A, b) would need a site key to key the cache by, e.g. a third argument. Keying by A's buffer instead would leave the emitted code alone, but keep a cache alive for every problem ever built.

@DhairyaLGandhi does this direction sound right? Related: #173.

Model
using ModelingToolkit, LinearAlgebra
using ModelingToolkit: t_nounits as t, D_nounits as D
import ModelingToolkitTearing as MTKTearing

N = 12
@variables x(t)[1:N] y(t)[1:N]
@parameters K[1:N, 1:N]
eqs = [[D(x[i]) ~ -x[i] + y[i] for i in 1:N]; [sum(K[i, j] * y[j] for j in 1:N) ~ x[i] for i in 1:N]]
sys = mtkcompile(System(eqs, t; name = :m);
    reassemble_alg = MTKTearing.DefaultReassembleAlgorithm(; inline_linear_sccs = true))
prob = ODEProblem(sys, [x => (1:N) ./ N, K => fill(0.5, N, N) + N * I], (0.0, 1.0))
Lenguaje dominante
Julia
Estrellas
8
Forks
14
Merge medio
8 d 8 h
PR fusionados (30 d)
1

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de JuliaComputing/StateSelection.jl

Todos los issues de JuliaComputing/StateSelection.jl

Issues similares

Más issues de Julia

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.