Modeling languages are becoming increasingly important in scientific and engineering domains, and they are driving the need for advanced compilers that automatically translate their descriptive semantics into efficient simulations. As models grow in complexity and scale, state-of-the-art compilers often encounter significant performance challenges, particularly when handling array-oriented models. These limitations hinder the adoption of modeling languages in high-performance applications and therefore restrict the expressiveness and flexibility available to domain experts. This thesis addresses these challenges by presenting novel algorithms, data structures, and compiler infrastructure specifically designed for the compilation and simulation of large-scale array-oriented models written in the Modelica language. The work makes three principal contributions that collectively overcome the scalability limitations of existing compilation approaches. The first contribution introduces compact data structures for representing arbitrarily high-dimensional index spaces, together with efficient algorithms for their manipulation during compilation. These structures maintain constant-time or logarithmic-time complexity for common operations when the number of scalar array elements – and thus equations – grows. Building upon these foundations, the thesis presents array-aware algorithms for incidence matrix construction, matching, strongly connected component detection, and equation scheduling that avoid the prohibitive costs of traditional scalar expansion approaches. These algorithms form the backbone of an array-aware causalization pipeline that processes models at the array level rather than decomposing them into individual scalar elements, whenever possible. The second contribution addresses the need for modern compiler infrastructure capable of preserving high-level semantic information throughout the compilation process. The thesis presents a multi-level intermediate representation based on the MLIR framework, introducing custom dialects that capture differential and algebraic equation semantics, numerical solver interfaces, and runtime system operations. This modular architecture enables clear separation of concerns, with each dialect addressing distinct aspects of the compilation pipeline while maintaining seamless integration with LLVM’s mature optimization and code generation infrastructure. The third contribution implements a multithreaded runtime environment engineered to exploit parallelism on modern multi-core processors. The compiler identifies independent equations and generates code that the runtime system distributes across available processor cores, translating compiler-identified parallelism into concrete performance improvements during simulation execution. Experimental evaluation against the industry-grade OpenModelica compiler demonstrates the effectiveness of these contributions. The experimental results show that MARCO achieves near-constant compilation times as model size increases, contrasting sharply with traditional approaches that exhibit linear or worse scaling behavior. For instance, in the most complex examined case of object-oriented modeling of a silicon chip with cooling channels, MARCO compiled models with over 30 million scalar equations in approximately 2 seconds – the same time required for much smaller versions of the same model. In contrast, OpenModelica exhibited linear scaling, requiring up to ~30 minutes of compilation time for models with ~300 000 equations and being unable to handle models of larger size with the same hardware resources. Beyond compilation efficiency, simulation experiments demonstrated that the runtime environment efficiently exploits modern multi-core processors. As model size increases, MARCO’s superior scalability becomes evident: for the same aforementioned thermal model, MARCO achieves simulation speedups ranging from 4.5x to 9x compared to OpenModelica, depending on the employed numerical integration method, but also up to two orders of magnitude for the simpler thermal version without cooling channels. These results demonstrate that the combination of array-aware data structures and algorithms, modern multi-level compiler infrastructure, and parallel runtime support fundamentally transforms the scalability characteristics of differential and algebraic equation compilation. The presented solutions enable the practical simulation of large-scale cyber-physical systems that were previously computationally infeasible, paving the way for broader adoption of declarative modeling languages in high-performance computational science and engineering applications.
I linguaggi di modellazione stanno diventando sempre più importanti nei domini scientifici e ingegneristici, e stanno alimentando la necessità di compilatori che traducano automaticamente la loro semantica descrittiva in simulazioni efficienti. Tuttavia, con l’aumentare della complessità e della scala dei modelli, le attuali soluzioni spesso incontrano significative sfide prestazionali, in particolare nella gestione di modelli basati su semantiche vettoriali. Queste limitazioni ostacolano l’adozione dei linguaggi di modellazione e quindi restringono l’espressività e la flessibilità a disposizione degli esperti. Questa tesi affronta queste sfide presentando algoritmi, strutture dati e infrastrutture di compilazione innovative, specificamente progettati per la compilazione e simulazione di modelli orientati ai vettori su larga scala scritti nel linguaggio Modelica. Il lavoro fornisce tre contributi principali che collettivamente superano le limitazioni di scalabilità degli approcci di compilazione esistenti. Il primo contributo introduce strutture dati compatte per rappresentare spazi di indici di dimensionalità arbitrariamente elevata, insieme ad algoritmi efficienti per la loro manipolazione durante la compilazione. Queste strutture mantengono complessità temporale costante o logaritmica per le operazioni comuni quando il numero di elementi scalari dei vettori – e quindi le equazioni – aumenta. Basandosi su queste fondamenta, la tesi presenta algoritmi per la costruzione della matrice di incidenza, l'associazione variabile-equazione, il rilevamento delle componenti fortemente connesse e l'ordinamento delle equazioni che evitano i costi proibitivi degli approcci tradizionali basati sull’espansione scalare. Questi algoritmi formano la spina dorsale di una pipeline di causalizzazione che processa i modelli a livello di vettori piuttosto che decomporli in singoli elementi scalari, quando possibile. Il secondo contributo affronta la necessità di un’infrastruttura di compilazione moderna capace di preservare informazioni semantiche di alto livello durante tutto il processo di compilazione. La tesi presenta una rappresentazione intermedia multi-livello basata sul framework MLIR, introducendo dialetti personalizzati che catturano la semantica di equazioni differenziali e algebriche, le interfacce dei solutori numerici e le interfacce dell’ambiente di simulazione. Questa architettura modulare consente una chiara separazione delle responsabilità, con ciascun dialetto che affronta aspetti distinti del processo di compilazione mantenendo al contempo un’ottima integrazione con l’infrastruttura di ottimizzazione e generazione di codice di LLVM. Il terzo contributo implementa un ambiente di simulazione progettato per sfruttare il parallelismo sui moderni processori multi-core. Il compilatore identifica le equazioni indipendenti e genera codice che il sistema di runtime distribuisce sulle risorse hardware disponibili, traducendo il parallelismo identificato dal compilatore in miglioramenti concreti delle prestazioni durante l’esecuzione della simulazione. La valutazione sperimentale confrontata con il compilatore OpenModelica dimostra l’efficacia di questi contributi. I risultati sperimentali mostrano che MARCO raggiunge tempi di compilazione costanti all’aumentare delle dimensioni del modello, in netto contrasto con gli approcci tradizionali che mostrano comportamenti lineari o peggiori. Per esempio, nel caso più complesso esaminato di modellazione orientata agli oggetti di un chip di silicio con canali di raffreddamento, MARCO ha compilato modelli con oltre 30 milioni di equazioni scalari in circa 2 secondi — lo stesso tempo richiesto per versioni molto più piccole dello stesso modello. Al contrario, OpenModelica ha mostrato un incremento lineare, richiedendo fino a ~30 minuti di tempo di compilazione per modelli con ~300 000 equazioni e risultando incapace di gestire modelli di dimensioni maggiori con le stesse risorse hardware. Oltre all’efficienza di compilazione, gli esperimenti di simulazione hanno dimostrato che l’ambiente di runtime sfrutta efficientemente i moderni processori multi-core. All’aumentare delle dimensioni del modello, la superiore scalabilità di MARCO diventa evidente: per lo stesso modello termico sopra menzionato, MARCO raggiunge incrementi prestazionali che vanno da 4.5x a 9x rispetto a OpenModelica, a seconda del metodo di integrazione numerica impiegato, ma anche fino a due ordini di grandezza per il modello termico più semplice senza canali di raffreddamento. Questi risultati dimostrano che la combinazione di strutture dati e algoritmi vettoriali, infrastruttura di compilazione moderna multi-livello e ambiente di runtime parallelo trasforma fondamentalmente le caratteristiche di scalabilità della compilazione di equazioni differenziali e algebriche. Le soluzioni presentate abilitano la simulazione pratica di sistemi ciber-fisici su larga scala che erano precedentemente computazionalmente infattibili, aprendo la strada a una più ampia adozione dei linguaggi di modellazione dichiarativi nelle applicazioni di scienza computazionale e ingegneria ad alte prestazioni.
Advancing Modelica with MLIR: array-aware compilation and simulation
SCUTTARI, MICHELE
2026
Abstract
Modeling languages are becoming increasingly important in scientific and engineering domains, and they are driving the need for advanced compilers that automatically translate their descriptive semantics into efficient simulations. As models grow in complexity and scale, state-of-the-art compilers often encounter significant performance challenges, particularly when handling array-oriented models. These limitations hinder the adoption of modeling languages in high-performance applications and therefore restrict the expressiveness and flexibility available to domain experts. This thesis addresses these challenges by presenting novel algorithms, data structures, and compiler infrastructure specifically designed for the compilation and simulation of large-scale array-oriented models written in the Modelica language. The work makes three principal contributions that collectively overcome the scalability limitations of existing compilation approaches. The first contribution introduces compact data structures for representing arbitrarily high-dimensional index spaces, together with efficient algorithms for their manipulation during compilation. These structures maintain constant-time or logarithmic-time complexity for common operations when the number of scalar array elements – and thus equations – grows. Building upon these foundations, the thesis presents array-aware algorithms for incidence matrix construction, matching, strongly connected component detection, and equation scheduling that avoid the prohibitive costs of traditional scalar expansion approaches. These algorithms form the backbone of an array-aware causalization pipeline that processes models at the array level rather than decomposing them into individual scalar elements, whenever possible. The second contribution addresses the need for modern compiler infrastructure capable of preserving high-level semantic information throughout the compilation process. The thesis presents a multi-level intermediate representation based on the MLIR framework, introducing custom dialects that capture differential and algebraic equation semantics, numerical solver interfaces, and runtime system operations. This modular architecture enables clear separation of concerns, with each dialect addressing distinct aspects of the compilation pipeline while maintaining seamless integration with LLVM’s mature optimization and code generation infrastructure. The third contribution implements a multithreaded runtime environment engineered to exploit parallelism on modern multi-core processors. The compiler identifies independent equations and generates code that the runtime system distributes across available processor cores, translating compiler-identified parallelism into concrete performance improvements during simulation execution. Experimental evaluation against the industry-grade OpenModelica compiler demonstrates the effectiveness of these contributions. The experimental results show that MARCO achieves near-constant compilation times as model size increases, contrasting sharply with traditional approaches that exhibit linear or worse scaling behavior. For instance, in the most complex examined case of object-oriented modeling of a silicon chip with cooling channels, MARCO compiled models with over 30 million scalar equations in approximately 2 seconds – the same time required for much smaller versions of the same model. In contrast, OpenModelica exhibited linear scaling, requiring up to ~30 minutes of compilation time for models with ~300 000 equations and being unable to handle models of larger size with the same hardware resources. Beyond compilation efficiency, simulation experiments demonstrated that the runtime environment efficiently exploits modern multi-core processors. As model size increases, MARCO’s superior scalability becomes evident: for the same aforementioned thermal model, MARCO achieves simulation speedups ranging from 4.5x to 9x compared to OpenModelica, depending on the employed numerical integration method, but also up to two orders of magnitude for the simpler thermal version without cooling channels. These results demonstrate that the combination of array-aware data structures and algorithms, modern multi-level compiler infrastructure, and parallel runtime support fundamentally transforms the scalability characteristics of differential and algebraic equation compilation. The presented solutions enable the practical simulation of large-scale cyber-physical systems that were previously computationally infeasible, paving the way for broader adoption of declarative modeling languages in high-performance computational science and engineering applications.| File | Dimensione | Formato | |
|---|---|---|---|
|
Advancing Modelica with MLIR - Array-Aware Compilation and Simulation.pdf
accesso aperto
Licenza:
Tutti i diritti riservati
Dimensione
911.59 kB
Formato
Adobe PDF
|
911.59 kB | Adobe PDF | Visualizza/Apri |
I documenti in UNITESI sono protetti da copyright e tutti i diritti sono riservati, salvo diversa indicazione.
https://hdl.handle.net/20.500.14242/384573
URN:NBN:IT:POLIMI-384573