taichi-dev / taichi

Productive, portable, and performant GPU programming in Python.
https://taichi-lang.org
Apache License 2.0
25.37k stars 2.27k forks source link

UFL as frontend for taichi #2088

Open salazardetroya opened 3 years ago

salazardetroya commented 3 years ago

Concisely describe the proposed feature I wanted to ask if there is interest on using the Unified Form Language (UFL) as frontend for taichi.

Describe the solution you'd like (if any) The idea is to use UFL as a DSL that is very close to the mathematics with a form compiler such as TSFC to generate the local stiffness matrix and then use taichi to assemble them into the bigger matrix. The goal is to take advantage of the fast data structures in taichi and the versatility of the UFL language. This approach might be mixing apples and oranges since the UFL+TSFC toolchain is designed for the finite element method, whereas taichi is designed for cartesian meshes (if I am not wrong), but I can see some benefit.

k-ye commented 3 years ago

Thanks, this looks interesting! There has long been a plan to standardize the CHI IR infrastructure (#689), which had to be postponed due to the ongoing research projects. If you are super interested in Taichi, you can probably take a look at these files:

  1. https://github.com/taichi-dev/taichi/blob/master/python/taichi/lang/transformer.py: this walks the Python AST and translates it into CHI IR.
  2. https://github.com/taichi-dev/taichi/blob/master/taichi/ir/frontend_ir.h and https://github.com/taichi-dev/taichi/blob/master/taichi/ir/ir.h: these define the actual CHI IR structs
  3. https://github.com/taichi-dev/taichi/blob/master/taichi/python/export_lang.cpp: how the CHI IR in C++ is exposed to Python