arXiv:2504.09118cs.CL2025-04

用编译器自动优化电磁仿真代码,跨平台提速十倍

Optimizing FDTD Solvers for Electromagnetics: A Compiler-Guided Approach with High-Level Tensor Abstractions

  • 用高阶张量抽象描述三维电磁算法,编译器自动优化
  • 在多平台实现最高10倍于原生Python的加速
  • 适合需要高效电磁仿真的科研与工程人员

有限差分时域(FDTD)方法是计算电磁学和光子学中求解麦克斯韦方程组的常用数值技术,能精确模拟复杂介质中的波传播,但面临显著计算挑战。传统FDTD实现依赖手写、平台特定代码,部分内核优化良好,其余则性能低下,缺乏可移植性导致开发成本高且难以扩展到现代硬件。为此,我们基于MLIR/LLVM基础设施,构建了面向FDTD仿真的端到端领域专用编译器,生成针对多种硬件平台优化的高效可移植代码。将三维FDTD内核表示为具有明确计算语义的3D张量操作,由编译器自动应用循环分块、融合和向量化等高级优化。在Intel、AMD和ARM平台上评估表明,相较于使用NumPy的基准Python实现,本方法最高提升10倍性能。

原文摘要 · Abstract (English)

The Finite Difference Time Domain (FDTD) method is a widely used numerical technique for solving Maxwell's equations, particularly in computational electromagnetics and photonics. It enables accurate modeling of wave propagation in complex media and structures but comes with significant computational challenges. Traditional FDTD implementations rely on handwritten, platform-specific code that optimizes certain kernels while underperforming in others. The lack of portability increases development overhead and creates performance bottlenecks, limiting scalability across modern hardware architectures. To address these challenges, we introduce an end-to-end domain-specific compiler based on the MLIR/LLVM infrastructure for FDTD simulations. Our approach generates efficient and portable code optimized for diverse hardware platforms.We implement the three-dimensional FDTD kernel as operations on a 3D tensor abstraction with explicit computational semantics. High-level optimizations such as loop tiling, fusion, and vectorization are automatically applied by the compiler. We evaluate our customized code generation pipeline on Intel, AMD, and ARM platforms, achieving up to $10\times$ speedup over baseline Python implementation using NumPy.

电磁仿真编译优化张量抽象高性能计算

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。