体验 Taichi(太极)编程语言
Basic
Taichi(太极)是一种用于高性能数值计算的并行编程语言。它嵌入在
Python
中,其即时编译器将计算密集型任务卸载到多核CPU
和大规模并行GPU
。
GitHub: https://github.com/taichi-dev/taichi
Install
Currently, Taichi only supports Python 3.6/3.7/3.8/3.9 (64-bit).
# install python
brew install python
# install taichi
python3 -m pip install taichi
Taichi Examples
➜ ~ ti example -h
[Taichi] version 0.8.10, llvm 10.0.0, commit 016feb38, osx, python 3.9.8
*******************************************
** Taichi Programming Language **
*******************************************
Docs: https://docs.taichi.graphics/
GitHub: https://github.com/taichi-dev/taichi/
Forum: https://forum.taichi.graphics/
usage: ti example [-h] [-p] [-P] [-s]
{ad_gravity,comet,cornell_box,euler,explicit_activation,export_mesh,export_ply,export_videos,fem128,fem128_ggui,fem99,fractal,fractal3d_ggui,fullscreen,game_of_life,gui_image_io,gui_widgets,implicit_mass_spring,inital_value_problem,keyboard,laplace,marching_squares,mass_spring_3d_ggui,mass_spring_game,mass_spring_game_ggui,mciso_advanced,mgpcg,mgpcg_advanced,minimal,minimization,mpm128,mpm128_ggui,mpm3d,mpm3d_ggui,mpm88,mpm99,mpm_lagrangian_forces,nbody,odop_solar,pbf2d,physarum,print_offset,rasterizer,regression,sdf_renderer,simple_derivative,simple_uv,stable_fluid,stable_fluid_ggui,taichi_bitmasked,taichi_dynamic,taichi_logo,taichi_sparse,tutorial,vortex_rings,waterwave}
Run an example by name (or name.py)
Autodiff gravity
ti example ad_gravity
Comet
ti example comet
Cornell Box
ti example cornell_box
Euler equations
ti example euler
Encounter error:
- ModuleNotFoundError: No module named ‘matplotlib’
- solution:
python3 -m pip install matplotlib
- solution:
Explicit activation
ti example explicit_activation
export_mesh
ti example export_mesh
Encounter error:
- Unknown type foo_data_type detected, skipping this channel
Export ply
ti example export_ply
export_videos
ti example export_videos
Encounter error:
- FileNotFoundError: [Errno 2] No such file or directory: ‘palette.png’
FEM128
ti example fem128
fem128_ggui
ti example fem128_ggui
Encounter error:
- Exception: GGUI Not Available
FEM99
ti example fem99
Fractal - Julia Set
ti example fractal
fractal3d_ggui
ti example fractal3d_ggui
Encounter error:
- Exception: GGUI Not Available
Full screen
ti example fullscreen
Game of life
ti example game_of_life
GUI image IO - Random Generated
ti example gui_image_io
GUI widgets
ti example gui_widgets
Implicit mass spring system
ti example implicit_mass_spring
inital_value_problem
ti example inital_value_problem
Encounter error:
- RuntimeError: [kernel_utils.cpp:KernelContextAttributes@88] Metal kernel only supports <= 32-bit data, got double
Keyboard
ti example keyboard
Laplace
ti example laplace
Marching squares
ti example marching_squares
mass_spring_3d_ggui
ti example mass_spring_3d_ggui
Encounter error:
- Exception: GGUI Not Available
Explicit mass spring system
ti example mass_spring_game
mass_spring_game_ggui
ti example mass_spring_game_ggui
Encounter error:
- Exception: GGUI Not Available
mciso_advanced
ti example mciso_advanced
Encounter error:
mgpcg
ti example mgpcg
mgpcg advanced
ti example mgpcg_advanced
minimal
ti example minimal
minimization
ti example minimization
MPM128
ti example mpm128
mpm128_ggui
ti example mpm128_ggui
Encounter error:
- Exception: GGUI Not Available
MPM3d
ti example mpm3d
mpm3d_ggui
ti example mpm3d_ggui
Encounter error:
- Exception: GGUI Not Available
MPM88
ti example mpm88
mpm99
ti example mpm99
MPM lagrangian forces
ti example mpm_lagrangian_forces
N-body problem
ti example nbody
Odop Solar
ti example odop_solar
PBF2D
ti example pbf2d
Physarum
ti example physarum
Print Offset - Layout
ti example print_offset
Rasterizer
ti example rasterizer
Regression
ti example regression
SDF renderer - SDF Path Tracer
ti example sdf_renderer
Simple derivative
ti example simple_derivative
Simple UV
ti example simple_uv
Stable fluid
ti example stable_fluid
stable_fluid_ggui
ti example stable_fluid_ggui
Encounter error:
- Exception: GGUI Not Available
Taichi bitmasked
ti example taichi_bitmasked
Taichi dynamic
ti example taichi_dynamic
Taichi logo
ti example taichi_logo
Taichi sparse
ti example taichi_sparse
tutorial
ti example tutorial
Vortex rings
ti example vortex_rings
Water waves
ti example waterwave