0%

体验 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).

1
2
3
4
5
# install python
brew install python

# install taichi
python3 -m pip install taichi

Taichi Examples

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
➜  ~ 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

1
ti example ad_gravity

Comet

1
ti example comet

Cornell Box

1
ti example cornell_box

Euler equations

1
ti example euler

Encounter error:

  • ModuleNotFoundError: No module named ‘matplotlib’
    • solution: python3 -m pip install matplotlib

Explicit activation

1
ti example explicit_activation

export_mesh

1
ti example export_mesh

Encounter error:

  • Unknown type foo_data_type detected, skipping this channel

Export ply

1
ti example export_ply

export_videos

1
ti example export_videos

Encounter error:

  • FileNotFoundError: [Errno 2] No such file or directory: ‘palette.png’

FEM128

1
ti example fem128

fem128_ggui

1
ti example fem128_ggui

Encounter error:

FEM99

1
ti example fem99

Fractal - Julia Set

1
ti example fractal

fractal3d_ggui

1
ti example fractal3d_ggui

Encounter error:

Full screen

1
ti example fullscreen

Game of life

1
ti example game_of_life

GUI image IO - Random Generated

1
ti example gui_image_io

GUI widgets

1
ti example gui_widgets

Implicit mass spring system

1
ti example implicit_mass_spring

inital_value_problem

1
ti example inital_value_problem

Encounter error:

  • RuntimeError: [kernel_utils.cpp:KernelContextAttributes@88] Metal kernel only supports <= 32-bit data, got double

Keyboard

1
ti example keyboard

Laplace

1
ti example laplace

Marching squares

1
ti example marching_squares

mass_spring_3d_ggui

1
ti example mass_spring_3d_ggui

Encounter error:

Explicit mass spring system

1
ti example mass_spring_game

mass_spring_game_ggui

1
ti example mass_spring_game_ggui

Encounter error:

mciso_advanced

1
ti example mciso_advanced

Encounter error:

mgpcg

1
ti example mgpcg

mgpcg advanced

1
ti example mgpcg_advanced

minimal

1
ti example minimal

minimization

1
ti example minimization

MPM128

1
ti example mpm128

mpm128_ggui

1
ti example mpm128_ggui

Encounter error:

MPM3d

1
ti example mpm3d

mpm3d_ggui

1
ti example mpm3d_ggui

Encounter error:

MPM88

1
ti example mpm88

mpm99

1
ti example mpm99

MPM lagrangian forces

1
ti example mpm_lagrangian_forces

N-body problem

1
ti example nbody

Odop Solar

1
ti example odop_solar

PBF2D

1
ti example pbf2d

Physarum

1
ti example physarum
1
ti example print_offset

Rasterizer

1
ti example rasterizer

Regression

1
ti example regression

SDF renderer - SDF Path Tracer

1
ti example sdf_renderer

Simple derivative

1
ti example simple_derivative

Simple UV

1
ti example simple_uv

Stable fluid

1
ti example stable_fluid

stable_fluid_ggui

1
ti example stable_fluid_ggui

Encounter error:

Taichi bitmasked

1
ti example taichi_bitmasked

Taichi dynamic

1
ti example taichi_dynamic
1
ti example taichi_logo

Taichi sparse

1
ti example taichi_sparse

tutorial

1
ti example tutorial

Vortex rings

1
ti example vortex_rings

Water waves

1
ti example waterwave