#include taichi.graphics/wp-content/uploads/2018/11/include_taichi.pdf · taichi as of 2018 taichi...

31
#include <taichi> Yuanming Hu MIT CSAIL

Upload: others

Post on 05-Feb-2020

25 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: #include taichi.graphics/wp-content/uploads/2018/11/include_taichi.pdf · Taichi as of 2018 Taichi MLS-MPM-CPIC Simulator SIGGRAPH 2018, SCA 2018 Narrowband Topology

#include <taichi>

Yuanming Hu MIT CSAIL

Page 2: #include taichi.graphics/wp-content/uploads/2018/11/include_taichi.pdf · Taichi as of 2018 Taichi MLS-MPM-CPIC Simulator SIGGRAPH 2018, SCA 2018 Narrowband Topology

What is Taichi?

2015 Random codebase of a computer graphics newbie

2016 Physically based Computer Graphics Library

2017 Computer Graphics Library

2018 Computer Graphics R&D Infrastructure

Page 3: #include taichi.graphics/wp-content/uploads/2018/11/include_taichi.pdf · Taichi as of 2018 Taichi MLS-MPM-CPIC Simulator SIGGRAPH 2018, SCA 2018 Narrowband Topology

Taichi as of 2018Taichi MLS-MPM-CPIC Simulator

SIGGRAPH 2018, SCA 2018

Narrowband Topology Optimization SIGGRAPH Asia 2018

ChainQueen Differentiable Physics Engine, Taichi-GPU

(in submission to ICRA 2019)

#include <taichi> Advanced Computer Graphics@ MIT & UW

Computational Methods for Physical Systems@ Dartmouth …

,

Page 4: #include taichi.graphics/wp-content/uploads/2018/11/include_taichi.pdf · Taichi as of 2018 Taichi MLS-MPM-CPIC Simulator SIGGRAPH 2018, SCA 2018 Narrowband Topology

What is the minimal time to have a hackable computer graphics application

deployed?

Page 5: #include taichi.graphics/wp-content/uploads/2018/11/include_taichi.pdf · Taichi as of 2018 Taichi MLS-MPM-CPIC Simulator SIGGRAPH 2018, SCA 2018 Narrowband Topology

What is the minimal time to have a hackable computer graphics application

deployed?

Page 6: #include taichi.graphics/wp-content/uploads/2018/11/include_taichi.pdf · Taichi as of 2018 Taichi MLS-MPM-CPIC Simulator SIGGRAPH 2018, SCA 2018 Narrowband Topology

What is the minimal time to have a hackable computer graphics application

deployed?

Page 7: #include taichi.graphics/wp-content/uploads/2018/11/include_taichi.pdf · Taichi as of 2018 Taichi MLS-MPM-CPIC Simulator SIGGRAPH 2018, SCA 2018 Narrowband Topology

What is the minimal time to have a hackable computer graphics application

deployed?

Page 8: #include taichi.graphics/wp-content/uploads/2018/11/include_taichi.pdf · Taichi as of 2018 Taichi MLS-MPM-CPIC Simulator SIGGRAPH 2018, SCA 2018 Narrowband Topology

What is the minimal time to have a hackable computer graphics application

deployed?

Page 9: #include taichi.graphics/wp-content/uploads/2018/11/include_taichi.pdf · Taichi as of 2018 Taichi MLS-MPM-CPIC Simulator SIGGRAPH 2018, SCA 2018 Narrowband Topology

What increases deployment time?

✦ Large files

✦ Long build instructions

✦ Missing hardware (e.g. GPUs)

✦ Missing/wrong/broken external software dependencies

✦ Long compilation time

✦ Compilation errors

✦ Linking errors

✦ Slow, long turnaround time

Page 10: #include taichi.graphics/wp-content/uploads/2018/11/include_taichi.pdf · Taichi as of 2018 Taichi MLS-MPM-CPIC Simulator SIGGRAPH 2018, SCA 2018 Narrowband Topology

Related Work

✦ Virtual machines

✦ smallpt (hard to read, no GUI) ๏ smallpssmlt ๏ smallppm

✦ shader toys (limited computational patterns)

✦ #include <os>

✦ …

Page 11: #include taichi.graphics/wp-content/uploads/2018/11/include_taichi.pdf · Taichi as of 2018 Taichi MLS-MPM-CPIC Simulator SIGGRAPH 2018, SCA 2018 Narrowband Topology
Page 12: #include taichi.graphics/wp-content/uploads/2018/11/include_taichi.pdf · Taichi as of 2018 Taichi MLS-MPM-CPIC Simulator SIGGRAPH 2018, SCA 2018 Narrowband Topology

taichi.h (Single C++ header)

#include <taichi> demo implementation cpp

~100 lines of code

Page 13: #include taichi.graphics/wp-content/uploads/2018/11/include_taichi.pdf · Taichi as of 2018 Taichi MLS-MPM-CPIC Simulator SIGGRAPH 2018, SCA 2018 Narrowband Topology

Is it even possible?

Page 14: #include taichi.graphics/wp-content/uploads/2018/11/include_taichi.pdf · Taichi as of 2018 Taichi MLS-MPM-CPIC Simulator SIGGRAPH 2018, SCA 2018 Narrowband Topology

multigrid.cpp

sparse_grid.h conjugate_gradient.h

cstdio unistd.h immintrin.h

Page 15: #include taichi.graphics/wp-content/uploads/2018/11/include_taichi.pdf · Taichi as of 2018 Taichi MLS-MPM-CPIC Simulator SIGGRAPH 2018, SCA 2018 Narrowband Topology

Amalgamation

✦ Analyze #include’s and simulate pre-processor (recursively) ๏ Do not include non-taichi files ๏ painful (a lot of corner cases), but doable

✦ Benefits ๏ Faster compilation/execution speed (sqlite.h/c) ๏ Single header - extremely portable

Page 16: #include taichi.graphics/wp-content/uploads/2018/11/include_taichi.pdf · Taichi as of 2018 Taichi MLS-MPM-CPIC Simulator SIGGRAPH 2018, SCA 2018 Narrowband Topology

Eliminating Hardware Dependencies

✦No GPU -> No OpenGL

✦Software rasterizer

✦painful to write, but worthy….

Page 17: #include taichi.graphics/wp-content/uploads/2018/11/include_taichi.pdf · Taichi as of 2018 Taichi MLS-MPM-CPIC Simulator SIGGRAPH 2018, SCA 2018 Narrowband Topology

taichi.h (Single C++ header)

#include <taichi> demo implementation cpp

~100 lines of code

Helvetica.ttf Go-Regular.ttf

Page 18: #include taichi.graphics/wp-content/uploads/2018/11/include_taichi.pdf · Taichi as of 2018 Taichi MLS-MPM-CPIC Simulator SIGGRAPH 2018, SCA 2018 Narrowband Topology

No, no, no… No extra files!

Page 19: #include taichi.graphics/wp-content/uploads/2018/11/include_taichi.pdf · Taichi as of 2018 Taichi MLS-MPM-CPIC Simulator SIGGRAPH 2018, SCA 2018 Narrowband Topology
Page 20: #include taichi.graphics/wp-content/uploads/2018/11/include_taichi.pdf · Taichi as of 2018 Taichi MLS-MPM-CPIC Simulator SIGGRAPH 2018, SCA 2018 Narrowband Topology

Microsoft Visual Studio: Fatal error C1091:

compiler limit: string exceeds 65535 bytes in length

Page 21: #include taichi.graphics/wp-content/uploads/2018/11/include_taichi.pdf · Taichi as of 2018 Taichi MLS-MPM-CPIC Simulator SIGGRAPH 2018, SCA 2018 Narrowband Topology
Page 22: #include taichi.graphics/wp-content/uploads/2018/11/include_taichi.pdf · Taichi as of 2018 Taichi MLS-MPM-CPIC Simulator SIGGRAPH 2018, SCA 2018 Narrowband Topology

Opening a Window

✦Need to show the bitmap in memory on screen

✦Cannot depend on Qt

✦Cross-platform: manual engineering for all platforms

✦Windows (C API)

✦Linux X11 (C API)

✦OS X (Cocoa - Objective-C only)

Page 23: #include taichi.graphics/wp-content/uploads/2018/11/include_taichi.pdf · Taichi as of 2018 Taichi MLS-MPM-CPIC Simulator SIGGRAPH 2018, SCA 2018 Narrowband Topology

taichi.h (Single C++ header)

#include <taichi> demo implementation cpp

~100 lines of code

cocoa_gui.m

Page 24: #include taichi.graphics/wp-content/uploads/2018/11/include_taichi.pdf · Taichi as of 2018 Taichi MLS-MPM-CPIC Simulator SIGGRAPH 2018, SCA 2018 Narrowband Topology

No Objective-C!

Page 25: #include taichi.graphics/wp-content/uploads/2018/11/include_taichi.pdf · Taichi as of 2018 Taichi MLS-MPM-CPIC Simulator SIGGRAPH 2018, SCA 2018 Narrowband Topology

Opening a Window (OS X)✦ Run Objective-C code with pure-C++

[window setAcceptsMouseMovedEvents:YES] -> call(window, "setAcceptsMouseMovedEvents:", YES);

Page 26: #include taichi.graphics/wp-content/uploads/2018/11/include_taichi.pdf · Taichi as of 2018 Taichi MLS-MPM-CPIC Simulator SIGGRAPH 2018, SCA 2018 Narrowband Topology

Finally….

Page 27: #include taichi.graphics/wp-content/uploads/2018/11/include_taichi.pdf · Taichi as of 2018 Taichi MLS-MPM-CPIC Simulator SIGGRAPH 2018, SCA 2018 Narrowband Topology

Examples: Topology Optimisation (120 LoC)

Page 28: #include taichi.graphics/wp-content/uploads/2018/11/include_taichi.pdf · Taichi as of 2018 Taichi MLS-MPM-CPIC Simulator SIGGRAPH 2018, SCA 2018 Narrowband Topology

Examples: MLS-MPM (88 LoC)

Page 29: #include taichi.graphics/wp-content/uploads/2018/11/include_taichi.pdf · Taichi as of 2018 Taichi MLS-MPM-CPIC Simulator SIGGRAPH 2018, SCA 2018 Narrowband Topology

Examples: MLS-MPM Tetris (140 LoC)

Page 30: #include taichi.graphics/wp-content/uploads/2018/11/include_taichi.pdf · Taichi as of 2018 Taichi MLS-MPM-CPIC Simulator SIGGRAPH 2018, SCA 2018 Narrowband Topology

Pros

✦ Extremely Portable

✦ Easy to read, understand, build and hack

✦ Relatively long compilation time (5-10 seconds)

✦ Not suitable for large projects

Cons

Practical applications:

prototyping/education/learning/proof-of-simplicity

Page 31: #include taichi.graphics/wp-content/uploads/2018/11/include_taichi.pdf · Taichi as of 2018 Taichi MLS-MPM-CPIC Simulator SIGGRAPH 2018, SCA 2018 Narrowband Topology

10 seconds.

What is the minimal time to have a hackable computer graphics application

deployed?

Thank you! Questions are welcome!

Thank Andy, Tao, Liang, Beichen, Wojciech, Bo, Fanfu for testing & support