SlideShare a Scribd company logo
Harmonic Stack for
Speed
2018/3/6
Yung-Yu Chen
https://www.linkedin.com/in/yungyuc/
The World Is Changing
❖ Computing helps human beings to change the world in
an unprecedented pace
❖ What are these?
30 cm in diameter, 1978
3 sizes, 3.5” smallest
Python as Your Computing Platform
❖ Python programming language is the way to go
❖ One language to rule them all
❖ Interactive analysis and visualization
❖ Data preparation and processing
❖ Workflow automation
❖ Distributed processing and parallel computing
❖ Join PyCon TW 2018, 1-2 June: https://tw.pycon.org/2018/
Interactive
❖ http://jupyter.org: run Python everywhere and code it
through browser
❖ https://matplotlib.org: de facto 2D plotting library
❖ https://www.vtk.org: versatile 3D visualization toolbox
❖ https://www.paraview.org: if you only want a
frontend
Data Manipulation
❖ http://pandas.pydata.org: de facto tool for data
analytics
❖ http://www.pytables.org: HDF5 hierarchical data
access
❖ http://unidata.github.io/netcdf4-python/: netCDF, yet
another data storage based on HDF5
Workflow Automation
❖ https://docs.python.org/3/library/argparse.html:
standard command-line argument processing
❖ https://github.com/saltstack/salt: cloud-oriented
automation for management and configuration
❖ AWS, GCE, Azure all offer SDK for Python
Concurrency
❖ https://docs.python.org/3/library/asyncio.html
❖ support native asynchronous constructs
❖ https://docs.python.org/3/library/multiprocessing.html
❖ parallel computing and distributed processing using multiple
processes
❖ http://zeromq.org/bindings:python
❖ socket communication
❖ http://pythonhosted.org/mpi4py/
❖ use MPI in Python
The Only Thing That Doesn’t Change, Is Change
❖ Way too many options for computing
❖ What an engineer should learn?
❖ Yes, I know, Python. But it’s all the tools with Python,
and not Python alone, right?
❖ Can we find something so fundamental that doesn’t
change?
Machine Code
❖ Computer can only execute machine code
❖ But it looks hard.
❖ And it is really hard.
_main:
0000000100001c80 pushq %rbp
0000000100001c81 movq %rsp, %rbp
0000000100001c84 subq $0x60, %rsp
0000000100001c88 leaq 0x2cd(%rip), %rax
0000000100001c8f movl $0x0, -0x4(%rbp)
0000000100001c96 movl %edi, -0x8(%rbp)
0000000100001c99 movq %rsi, -0x10(%rbp)
0000000100001c9d movq %rax, %rdi
0000000100001ca0 callq 0x100001ee8
...
C++: Compromise
❖ First, there was the C programming language
❖ It allows us to write a little bit more friendly code
❖ A compiler takes the code and turn it into assembly,
and it is then turned into machine code
❖ Some geniuses want to make something super powerful
but looks like C
❖ It produces the fastest possible machine code from
machine-friendly, convoluted concepts
Slow for Fast, Fast Is Slow
❖ It takes a lot of time to write code that computers run
fast
❖ C++ -> machine code
❖ Quickly written code takes additional time from
computers to interpret
❖ Python
❖ Ease of use and performance are competing. You cannot
get both.
As Easy as Python, as Fast as C++
❖ Create a new tool that serves both purposes?
❖ You need to re-create two whole eco-systems that
develop for 20-30 years
❖ Doesn’t sound very realistic, does it?
❖ How about using C++ for what needs speed, and
Python for everything else? Yes if we have a way to
bridge them!
pybind11
❖ C++, born in 1985 (development since 1979)
❖ ISO standard: C++98, 03, 11, 14, 17
❖ Python, born in 1991
❖ Community maintained
❖ C++11/14/17(/20) is referred to as modern C++ and usually just “C+
+11”
❖ C++ is notoriously hard, but modern C++ starts to make sense
❖ pybind11 is a tool allowing us to use exclusively modern C++ with
Python
Wrapping Tools for Python Abound
❖ So many software packages provide Python API
❖ pybind11, boost.python, Cython, ctypes, swig, etc.
❖ Python C API
Multi-Language Systems
❖ Recall the purpose: quickly make fast software
❖ Know very well the system fundamentals
❖ It’s always the key to a good software system
❖ In C++: core data structure and performance hotspots
❖ In Python: workflow and customization
Things to Learn
❖ Master your problem domain: mathematics and
mechanics
❖ Computer architecture
❖ Numerical analysis
❖ Practice Python and then C++ for 10 years
Mathematics and Mechanics
❖ Calculus
❖ Linear algebra
❖ Vector analysis
❖ Thermodynamics
❖ Continuum mechanics: solids and fluids
❖ Materials and chemistry
Computer Architecture
❖ Abstract description for how silicon is made for
computing
❖ What runs fast and what runs slow, and why
❖ How do you code to make the best use of the hardware
Numerical Analysis
❖ Turn mathematics into code; the mathematics describes
the physics
❖ Interpolation
❖ Equation solving
❖ Linear systems
❖ Optimization
How to Learn Python
❖ Python should be the first programming language to
learn because it’s easy to use
❖ Edit a text file and run it
❖ Open a browser and run it
print("hello, world") $ python3 hello.py
hello, world
Step 1: Install Runtime
❖ https://www.anaconda.com/download/
❖ Anaconda contains Python and a lot of useful software
packages.
❖ When one starts, it’s even difficult to find and install
software, but Anaconda solves the problem
❖ Use command line as much as possible
❖ If you can, use Linux (Ubuntu) or mac osx, which give you a
powerful command-line shell. Windows 10 professional has
one too, but not as popular as the Unixes.
Step 2: Interact
Programmers try and error and then CPR:
copy-paste-replace
Highly unlikely to get things right the
first time
Step 3: Review and Rewrite
❖ Continuously change the code
❖ Automatic testing is necessary
❖ No one can fully understand 10,000 lines of
code and make sure it’s right
❖ Architect the system
❖ Develop features piece by piece
❖ Connect components
❖ Reorganize structure to make it bigger
solvcon
!"" __init__.py
!"" anchor.py
!"" batch.py
!"" batch_torque.py
!"" block.py
!"" boundcond.py
!"" case.py
!"" case_core.py
!"" cloud.py
!"" cmdutil.py
!"" command.py
!"" conf.py
!"" connection.py
!"" dependency.py
!"" domain.py
!"" exception.py
!"" gendata.py
!"" helper.py
!"" hook.py
!"" io
#   !"" __init__.py
#   $"" ...
!"" mpy.py
!"" mthread.py
!"" parcel
#   !"" __init__.py
#   $"" ...
!"" rpc.py
!"" scuda.py
!"" solver.py
!"" testing.py
$"" ...
How to Learn C++
❖ Never starts with C++
❖ Benchmark first
❖ Use C++ when you need to control from byte to byte
❖ Keep in mind the differences between Python and C++
❖ Python function calls are 10x-100x slower than C++
❖ Python determines everything in runtime; C++
determines many things in compile time.
Compilation
Source file A
Construct 1
Construct 2
Source file B
Construct 1
Construct 2
Binary
Construct A.1
Construct B.2
Construct B.1
Construct A.2
…
Compile Runtime
input
data data
output
data data
Binary
Construct A.1
Construct B.2
Construct B.1
Construct A.2
}Pythondoesn’thaveit
Learn by Doing
❖ Incentive is utmost important: Program to solve your
problems
❖ After your 500,000 lines of code, you’ll get it
❖ If you don’t code enough, reading books doesn’t help
Your Job
❖ Make mobile app run faster? No problem
❖ Scale web page higher? You nail it
❖ Increase video game frame rate? Yes
❖ Crunch more data? Absolutely
❖ Make scientific discoveries? That’s what you do
❖ If you can quickly make computers run fast, jobs find
you

More Related Content

What's hot

Pulumi. Modern Infrastructure as Code.
Pulumi. Modern Infrastructure as Code.Pulumi. Modern Infrastructure as Code.
Pulumi. Modern Infrastructure as Code.Yurii Bychenok
 
A First Look at Google's Go Programming Language
A First Look at Google's Go Programming LanguageA First Look at Google's Go Programming Language
A First Look at Google's Go Programming LanguageGanesh Samarthyam
 
Number of Computer Languages = 3
Number of Computer Languages = 3Number of Computer Languages = 3
Number of Computer Languages = 3Ram Sekhar
 
Beaker Notebook for Data Exploration
Beaker Notebook for Data ExplorationBeaker Notebook for Data Exploration
Beaker Notebook for Data Explorationscottcrespo
 
GPU Computing for Data Science
GPU Computing for Data Science GPU Computing for Data Science
GPU Computing for Data Science Domino Data Lab
 
What every C++ programmer should know about modern compilers (w/ comments, AC...
What every C++ programmer should know about modern compilers (w/ comments, AC...What every C++ programmer should know about modern compilers (w/ comments, AC...
What every C++ programmer should know about modern compilers (w/ comments, AC...Sławomir Zborowski
 
Scientific Plotting in Python
Scientific Plotting in PythonScientific Plotting in Python
Scientific Plotting in PythonJack Parmer
 
Introduction to Go programming
Introduction to Go programmingIntroduction to Go programming
Introduction to Go programmingExotel
 
Google Go! language
Google Go! languageGoogle Go! language
Google Go! languageAndré Mayer
 
Work Python, play Python~
Work Python, play Python~Work Python, play Python~
Work Python, play Python~Idee Liao
 
Building a high-performance, scalable ML & NLP platform with Python, Sheer El...
Building a high-performance, scalable ML & NLP platform with Python, Sheer El...Building a high-performance, scalable ML & NLP platform with Python, Sheer El...
Building a high-performance, scalable ML & NLP platform with Python, Sheer El...Pôle Systematic Paris-Region
 
Understanding how concurrency work in os
Understanding how concurrency work in osUnderstanding how concurrency work in os
Understanding how concurrency work in osGenchiLu1
 
Python Data Plotting and Visualisation Extravaganza
Python Data Plotting and Visualisation ExtravaganzaPython Data Plotting and Visualisation Extravaganza
Python Data Plotting and Visualisation ExtravaganzaGuy K. Kloss
 
Rust's Journey to Async/await
Rust's Journey to Async/awaitRust's Journey to Async/await
Rust's Journey to Async/awaitC4Media
 
Powering tensorflow with big data (apache spark, flink, and beam) dataworks...
Powering tensorflow with big data (apache spark, flink, and beam)   dataworks...Powering tensorflow with big data (apache spark, flink, and beam)   dataworks...
Powering tensorflow with big data (apache spark, flink, and beam) dataworks...Holden Karau
 

What's hot (20)

Pulumi. Modern Infrastructure as Code.
Pulumi. Modern Infrastructure as Code.Pulumi. Modern Infrastructure as Code.
Pulumi. Modern Infrastructure as Code.
 
A First Look at Google's Go Programming Language
A First Look at Google's Go Programming LanguageA First Look at Google's Go Programming Language
A First Look at Google's Go Programming Language
 
Number of Computer Languages = 3
Number of Computer Languages = 3Number of Computer Languages = 3
Number of Computer Languages = 3
 
Beaker Notebook for Data Exploration
Beaker Notebook for Data ExplorationBeaker Notebook for Data Exploration
Beaker Notebook for Data Exploration
 
GPU Computing for Data Science
GPU Computing for Data Science GPU Computing for Data Science
GPU Computing for Data Science
 
Programming Basics
Programming BasicsProgramming Basics
Programming Basics
 
What every C++ programmer should know about modern compilers (w/ comments, AC...
What every C++ programmer should know about modern compilers (w/ comments, AC...What every C++ programmer should know about modern compilers (w/ comments, AC...
What every C++ programmer should know about modern compilers (w/ comments, AC...
 
Does reporting takes lots of time
Does reporting takes lots of timeDoes reporting takes lots of time
Does reporting takes lots of time
 
Scientific Plotting in Python
Scientific Plotting in PythonScientific Plotting in Python
Scientific Plotting in Python
 
Introduction to Go programming
Introduction to Go programmingIntroduction to Go programming
Introduction to Go programming
 
Google Go! language
Google Go! languageGoogle Go! language
Google Go! language
 
Work Python, play Python~
Work Python, play Python~Work Python, play Python~
Work Python, play Python~
 
Building a high-performance, scalable ML & NLP platform with Python, Sheer El...
Building a high-performance, scalable ML & NLP platform with Python, Sheer El...Building a high-performance, scalable ML & NLP platform with Python, Sheer El...
Building a high-performance, scalable ML & NLP platform with Python, Sheer El...
 
Understanding how concurrency work in os
Understanding how concurrency work in osUnderstanding how concurrency work in os
Understanding how concurrency work in os
 
Go Language presentation
Go Language presentationGo Language presentation
Go Language presentation
 
Python Data Plotting and Visualisation Extravaganza
Python Data Plotting and Visualisation ExtravaganzaPython Data Plotting and Visualisation Extravaganza
Python Data Plotting and Visualisation Extravaganza
 
Rust's Journey to Async/await
Rust's Journey to Async/awaitRust's Journey to Async/await
Rust's Journey to Async/await
 
Powering tensorflow with big data (apache spark, flink, and beam) dataworks...
Powering tensorflow with big data (apache spark, flink, and beam)   dataworks...Powering tensorflow with big data (apache spark, flink, and beam)   dataworks...
Powering tensorflow with big data (apache spark, flink, and beam) dataworks...
 
OpenNMT
OpenNMTOpenNMT
OpenNMT
 
Python vs c++ ppt
Python vs c++ pptPython vs c++ ppt
Python vs c++ ppt
 

Similar to Harmonic Stack for Speed

Your interactive computing
Your interactive computingYour interactive computing
Your interactive computingYung-Yu Chen
 
Engineer Engineering Software
Engineer Engineering SoftwareEngineer Engineering Software
Engineer Engineering SoftwareYung-Yu Chen
 
Writing Fast Code (JP) - PyCon JP 2015
Writing Fast Code (JP) - PyCon JP 2015Writing Fast Code (JP) - PyCon JP 2015
Writing Fast Code (JP) - PyCon JP 2015Younggun Kim
 
from ai.backend import python @ pycontw2018
from ai.backend import python @ pycontw2018from ai.backend import python @ pycontw2018
from ai.backend import python @ pycontw2018Chun-Yu Tseng
 
Python Intro For Managers
Python Intro For ManagersPython Intro For Managers
Python Intro For ManagersAtul Shridhar
 
Interconnection Automation For All - Extended - MPS 2023
Interconnection Automation For All - Extended - MPS 2023Interconnection Automation For All - Extended - MPS 2023
Interconnection Automation For All - Extended - MPS 2023Chris Grundemann
 
Py4 inf 01-intro
Py4 inf 01-introPy4 inf 01-intro
Py4 inf 01-introIshaq Ali
 
Scaling systems for research computing
Scaling systems for research computingScaling systems for research computing
Scaling systems for research computingThe BioTeam Inc.
 
High Performance Machine Learning in R with H2O
High Performance Machine Learning in R with H2OHigh Performance Machine Learning in R with H2O
High Performance Machine Learning in R with H2OSri Ambati
 
Scylla Summit 2022: Learning Rust the Hard Way for a Production Kafka+ScyllaD...
Scylla Summit 2022: Learning Rust the Hard Way for a Production Kafka+ScyllaD...Scylla Summit 2022: Learning Rust the Hard Way for a Production Kafka+ScyllaD...
Scylla Summit 2022: Learning Rust the Hard Way for a Production Kafka+ScyllaD...ScyllaDB
 
Streaming 101: Hello World
Streaming 101:  Hello WorldStreaming 101:  Hello World
Streaming 101: Hello WorldJosh Fischer
 
Python in Industry
Python in IndustryPython in Industry
Python in IndustryDharmit Shah
 
Codebits Handivi
Codebits HandiviCodebits Handivi
Codebits Handivicfpinto
 
ch4-Software is Everywhere
ch4-Software is Everywherech4-Software is Everywhere
ch4-Software is Everywheressuser06ea42
 
On the Necessity and Inapplicability of Python
On the Necessity and Inapplicability of PythonOn the Necessity and Inapplicability of Python
On the Necessity and Inapplicability of PythonTakeshi Akutsu
 
On the necessity and inapplicability of python
On the necessity and inapplicability of pythonOn the necessity and inapplicability of python
On the necessity and inapplicability of pythonYung-Yu Chen
 
Ali alshehri c++_comparison between c++&python
Ali alshehri c++_comparison between c++&pythonAli alshehri c++_comparison between c++&python
Ali alshehri c++_comparison between c++&pythonAliAAAlshehri
 
Craftsmanship in Computational Work
Craftsmanship in Computational WorkCraftsmanship in Computational Work
Craftsmanship in Computational WorkYung-Yu Chen
 

Similar to Harmonic Stack for Speed (20)

Your interactive computing
Your interactive computingYour interactive computing
Your interactive computing
 
Engineer Engineering Software
Engineer Engineering SoftwareEngineer Engineering Software
Engineer Engineering Software
 
Writing Fast Code (JP) - PyCon JP 2015
Writing Fast Code (JP) - PyCon JP 2015Writing Fast Code (JP) - PyCon JP 2015
Writing Fast Code (JP) - PyCon JP 2015
 
from ai.backend import python @ pycontw2018
from ai.backend import python @ pycontw2018from ai.backend import python @ pycontw2018
from ai.backend import python @ pycontw2018
 
Python Intro For Managers
Python Intro For ManagersPython Intro For Managers
Python Intro For Managers
 
Interconnection Automation For All - Extended - MPS 2023
Interconnection Automation For All - Extended - MPS 2023Interconnection Automation For All - Extended - MPS 2023
Interconnection Automation For All - Extended - MPS 2023
 
PySide
PySidePySide
PySide
 
Py4 inf 01-intro
Py4 inf 01-introPy4 inf 01-intro
Py4 inf 01-intro
 
MODULE 1.pptx
MODULE 1.pptxMODULE 1.pptx
MODULE 1.pptx
 
Scaling systems for research computing
Scaling systems for research computingScaling systems for research computing
Scaling systems for research computing
 
High Performance Machine Learning in R with H2O
High Performance Machine Learning in R with H2OHigh Performance Machine Learning in R with H2O
High Performance Machine Learning in R with H2O
 
Scylla Summit 2022: Learning Rust the Hard Way for a Production Kafka+ScyllaD...
Scylla Summit 2022: Learning Rust the Hard Way for a Production Kafka+ScyllaD...Scylla Summit 2022: Learning Rust the Hard Way for a Production Kafka+ScyllaD...
Scylla Summit 2022: Learning Rust the Hard Way for a Production Kafka+ScyllaD...
 
Streaming 101: Hello World
Streaming 101:  Hello WorldStreaming 101:  Hello World
Streaming 101: Hello World
 
Python in Industry
Python in IndustryPython in Industry
Python in Industry
 
Codebits Handivi
Codebits HandiviCodebits Handivi
Codebits Handivi
 
ch4-Software is Everywhere
ch4-Software is Everywherech4-Software is Everywhere
ch4-Software is Everywhere
 
On the Necessity and Inapplicability of Python
On the Necessity and Inapplicability of PythonOn the Necessity and Inapplicability of Python
On the Necessity and Inapplicability of Python
 
On the necessity and inapplicability of python
On the necessity and inapplicability of pythonOn the necessity and inapplicability of python
On the necessity and inapplicability of python
 
Ali alshehri c++_comparison between c++&python
Ali alshehri c++_comparison between c++&pythonAli alshehri c++_comparison between c++&python
Ali alshehri c++_comparison between c++&python
 
Craftsmanship in Computational Work
Craftsmanship in Computational WorkCraftsmanship in Computational Work
Craftsmanship in Computational Work
 

More from Yung-Yu Chen

Write Python for Speed
Write Python for SpeedWrite Python for Speed
Write Python for SpeedYung-Yu Chen
 
SimpleArray between Python and C++
SimpleArray between Python and C++SimpleArray between Python and C++
SimpleArray between Python and C++Yung-Yu Chen
 
Write code and find a job
Write code and find a jobWrite code and find a job
Write code and find a jobYung-Yu Chen
 
Notes about moving from python to c++ py contw 2020
Notes about moving from python to c++ py contw 2020Notes about moving from python to c++ py contw 2020
Notes about moving from python to c++ py contw 2020Yung-Yu Chen
 
Take advantage of C++ from Python
Take advantage of C++ from PythonTake advantage of C++ from Python
Take advantage of C++ from PythonYung-Yu Chen
 
Start Wrap Episode 11: A New Rope
Start Wrap Episode 11: A New RopeStart Wrap Episode 11: A New Rope
Start Wrap Episode 11: A New RopeYung-Yu Chen
 

More from Yung-Yu Chen (6)

Write Python for Speed
Write Python for SpeedWrite Python for Speed
Write Python for Speed
 
SimpleArray between Python and C++
SimpleArray between Python and C++SimpleArray between Python and C++
SimpleArray between Python and C++
 
Write code and find a job
Write code and find a jobWrite code and find a job
Write code and find a job
 
Notes about moving from python to c++ py contw 2020
Notes about moving from python to c++ py contw 2020Notes about moving from python to c++ py contw 2020
Notes about moving from python to c++ py contw 2020
 
Take advantage of C++ from Python
Take advantage of C++ from PythonTake advantage of C++ from Python
Take advantage of C++ from Python
 
Start Wrap Episode 11: A New Rope
Start Wrap Episode 11: A New RopeStart Wrap Episode 11: A New Rope
Start Wrap Episode 11: A New Rope
 

Recently uploaded

Circulatory system_ Laplace law. Ohms law.reynaults law,baro-chemo-receptors-...
Circulatory system_ Laplace law. Ohms law.reynaults law,baro-chemo-receptors-...Circulatory system_ Laplace law. Ohms law.reynaults law,baro-chemo-receptors-...
Circulatory system_ Laplace law. Ohms law.reynaults law,baro-chemo-receptors-...muralinath2
 
A Giant Impact Origin for the First Subduction on Earth
A Giant Impact Origin for the First Subduction on EarthA Giant Impact Origin for the First Subduction on Earth
A Giant Impact Origin for the First Subduction on EarthSérgio Sacani
 
RNA INTERFERENCE: UNRAVELING GENETIC SILENCING
RNA INTERFERENCE: UNRAVELING GENETIC SILENCINGRNA INTERFERENCE: UNRAVELING GENETIC SILENCING
RNA INTERFERENCE: UNRAVELING GENETIC SILENCINGAADYARAJPANDEY1
 
GEOLOGICAL FIELD REPORT On Kaptai Rangamati Road-Cut Section.pdf
GEOLOGICAL FIELD REPORT  On  Kaptai Rangamati Road-Cut Section.pdfGEOLOGICAL FIELD REPORT  On  Kaptai Rangamati Road-Cut Section.pdf
GEOLOGICAL FIELD REPORT On Kaptai Rangamati Road-Cut Section.pdfUniversity of Barishal
 
Hemoglobin metabolism_pathophysiology.pptx
Hemoglobin metabolism_pathophysiology.pptxHemoglobin metabolism_pathophysiology.pptx
Hemoglobin metabolism_pathophysiology.pptxmuralinath2
 
Multi-source connectivity as the driver of solar wind variability in the heli...
Multi-source connectivity as the driver of solar wind variability in the heli...Multi-source connectivity as the driver of solar wind variability in the heli...
Multi-source connectivity as the driver of solar wind variability in the heli...Sérgio Sacani
 
Structures and textures of metamorphic rocks
Structures and textures of metamorphic rocksStructures and textures of metamorphic rocks
Structures and textures of metamorphic rockskumarmathi863
 
Lab report on liquid viscosity of glycerin
Lab report on liquid viscosity of glycerinLab report on liquid viscosity of glycerin
Lab report on liquid viscosity of glycerinossaicprecious19
 
Musical Meetups Knowledge Graph (MMKG): a collection of evidence for historic...
Musical Meetups Knowledge Graph (MMKG): a collection of evidence for historic...Musical Meetups Knowledge Graph (MMKG): a collection of evidence for historic...
Musical Meetups Knowledge Graph (MMKG): a collection of evidence for historic...Alba Morales
 
Anemia_ different types_causes_ conditions
Anemia_ different types_causes_ conditionsAnemia_ different types_causes_ conditions
Anemia_ different types_causes_ conditionsmuralinath2
 
Pests of Green Manures_Bionomics_IPM_Dr.UPR.pdf
Pests of Green Manures_Bionomics_IPM_Dr.UPR.pdfPests of Green Manures_Bionomics_IPM_Dr.UPR.pdf
Pests of Green Manures_Bionomics_IPM_Dr.UPR.pdfPirithiRaju
 
Richard's entangled aventures in wonderland
Richard's entangled aventures in wonderlandRichard's entangled aventures in wonderland
Richard's entangled aventures in wonderlandRichard Gill
 
word2vec, node2vec, graph2vec, X2vec: Towards a Theory of Vector Embeddings o...
word2vec, node2vec, graph2vec, X2vec: Towards a Theory of Vector Embeddings o...word2vec, node2vec, graph2vec, X2vec: Towards a Theory of Vector Embeddings o...
word2vec, node2vec, graph2vec, X2vec: Towards a Theory of Vector Embeddings o...Subhajit Sahu
 
(May 29th, 2024) Advancements in Intravital Microscopy- Insights for Preclini...
(May 29th, 2024) Advancements in Intravital Microscopy- Insights for Preclini...(May 29th, 2024) Advancements in Intravital Microscopy- Insights for Preclini...
(May 29th, 2024) Advancements in Intravital Microscopy- Insights for Preclini...Scintica Instrumentation
 
Gliese 12 b, a temperate Earth-sized planet at 12 parsecs discovered with TES...
Gliese 12 b, a temperate Earth-sized planet at 12 parsecs discovered with TES...Gliese 12 b, a temperate Earth-sized planet at 12 parsecs discovered with TES...
Gliese 12 b, a temperate Earth-sized planet at 12 parsecs discovered with TES...Sérgio Sacani
 
GBSN - Biochemistry (Unit 5) Chemistry of Lipids
GBSN - Biochemistry (Unit 5) Chemistry of LipidsGBSN - Biochemistry (Unit 5) Chemistry of Lipids
GBSN - Biochemistry (Unit 5) Chemistry of LipidsAreesha Ahmad
 
Comparative structure of adrenal gland in vertebrates
Comparative structure of adrenal gland in vertebratesComparative structure of adrenal gland in vertebrates
Comparative structure of adrenal gland in vertebratessachin783648
 
SAMPLING.pptx for analystical chemistry sample techniques
SAMPLING.pptx for analystical chemistry sample techniquesSAMPLING.pptx for analystical chemistry sample techniques
SAMPLING.pptx for analystical chemistry sample techniquesrodneykiptoo8
 
Shuaib Y-basedComprehensive mahmudj.pptx
Shuaib Y-basedComprehensive mahmudj.pptxShuaib Y-basedComprehensive mahmudj.pptx
Shuaib Y-basedComprehensive mahmudj.pptxMdAbuRayhan16
 
EY - Supply Chain Services 2018_template.pptx
EY - Supply Chain Services 2018_template.pptxEY - Supply Chain Services 2018_template.pptx
EY - Supply Chain Services 2018_template.pptxAlguinaldoKong
 

Recently uploaded (20)

Circulatory system_ Laplace law. Ohms law.reynaults law,baro-chemo-receptors-...
Circulatory system_ Laplace law. Ohms law.reynaults law,baro-chemo-receptors-...Circulatory system_ Laplace law. Ohms law.reynaults law,baro-chemo-receptors-...
Circulatory system_ Laplace law. Ohms law.reynaults law,baro-chemo-receptors-...
 
A Giant Impact Origin for the First Subduction on Earth
A Giant Impact Origin for the First Subduction on EarthA Giant Impact Origin for the First Subduction on Earth
A Giant Impact Origin for the First Subduction on Earth
 
RNA INTERFERENCE: UNRAVELING GENETIC SILENCING
RNA INTERFERENCE: UNRAVELING GENETIC SILENCINGRNA INTERFERENCE: UNRAVELING GENETIC SILENCING
RNA INTERFERENCE: UNRAVELING GENETIC SILENCING
 
GEOLOGICAL FIELD REPORT On Kaptai Rangamati Road-Cut Section.pdf
GEOLOGICAL FIELD REPORT  On  Kaptai Rangamati Road-Cut Section.pdfGEOLOGICAL FIELD REPORT  On  Kaptai Rangamati Road-Cut Section.pdf
GEOLOGICAL FIELD REPORT On Kaptai Rangamati Road-Cut Section.pdf
 
Hemoglobin metabolism_pathophysiology.pptx
Hemoglobin metabolism_pathophysiology.pptxHemoglobin metabolism_pathophysiology.pptx
Hemoglobin metabolism_pathophysiology.pptx
 
Multi-source connectivity as the driver of solar wind variability in the heli...
Multi-source connectivity as the driver of solar wind variability in the heli...Multi-source connectivity as the driver of solar wind variability in the heli...
Multi-source connectivity as the driver of solar wind variability in the heli...
 
Structures and textures of metamorphic rocks
Structures and textures of metamorphic rocksStructures and textures of metamorphic rocks
Structures and textures of metamorphic rocks
 
Lab report on liquid viscosity of glycerin
Lab report on liquid viscosity of glycerinLab report on liquid viscosity of glycerin
Lab report on liquid viscosity of glycerin
 
Musical Meetups Knowledge Graph (MMKG): a collection of evidence for historic...
Musical Meetups Knowledge Graph (MMKG): a collection of evidence for historic...Musical Meetups Knowledge Graph (MMKG): a collection of evidence for historic...
Musical Meetups Knowledge Graph (MMKG): a collection of evidence for historic...
 
Anemia_ different types_causes_ conditions
Anemia_ different types_causes_ conditionsAnemia_ different types_causes_ conditions
Anemia_ different types_causes_ conditions
 
Pests of Green Manures_Bionomics_IPM_Dr.UPR.pdf
Pests of Green Manures_Bionomics_IPM_Dr.UPR.pdfPests of Green Manures_Bionomics_IPM_Dr.UPR.pdf
Pests of Green Manures_Bionomics_IPM_Dr.UPR.pdf
 
Richard's entangled aventures in wonderland
Richard's entangled aventures in wonderlandRichard's entangled aventures in wonderland
Richard's entangled aventures in wonderland
 
word2vec, node2vec, graph2vec, X2vec: Towards a Theory of Vector Embeddings o...
word2vec, node2vec, graph2vec, X2vec: Towards a Theory of Vector Embeddings o...word2vec, node2vec, graph2vec, X2vec: Towards a Theory of Vector Embeddings o...
word2vec, node2vec, graph2vec, X2vec: Towards a Theory of Vector Embeddings o...
 
(May 29th, 2024) Advancements in Intravital Microscopy- Insights for Preclini...
(May 29th, 2024) Advancements in Intravital Microscopy- Insights for Preclini...(May 29th, 2024) Advancements in Intravital Microscopy- Insights for Preclini...
(May 29th, 2024) Advancements in Intravital Microscopy- Insights for Preclini...
 
Gliese 12 b, a temperate Earth-sized planet at 12 parsecs discovered with TES...
Gliese 12 b, a temperate Earth-sized planet at 12 parsecs discovered with TES...Gliese 12 b, a temperate Earth-sized planet at 12 parsecs discovered with TES...
Gliese 12 b, a temperate Earth-sized planet at 12 parsecs discovered with TES...
 
GBSN - Biochemistry (Unit 5) Chemistry of Lipids
GBSN - Biochemistry (Unit 5) Chemistry of LipidsGBSN - Biochemistry (Unit 5) Chemistry of Lipids
GBSN - Biochemistry (Unit 5) Chemistry of Lipids
 
Comparative structure of adrenal gland in vertebrates
Comparative structure of adrenal gland in vertebratesComparative structure of adrenal gland in vertebrates
Comparative structure of adrenal gland in vertebrates
 
SAMPLING.pptx for analystical chemistry sample techniques
SAMPLING.pptx for analystical chemistry sample techniquesSAMPLING.pptx for analystical chemistry sample techniques
SAMPLING.pptx for analystical chemistry sample techniques
 
Shuaib Y-basedComprehensive mahmudj.pptx
Shuaib Y-basedComprehensive mahmudj.pptxShuaib Y-basedComprehensive mahmudj.pptx
Shuaib Y-basedComprehensive mahmudj.pptx
 
EY - Supply Chain Services 2018_template.pptx
EY - Supply Chain Services 2018_template.pptxEY - Supply Chain Services 2018_template.pptx
EY - Supply Chain Services 2018_template.pptx
 

Harmonic Stack for Speed

  • 1. Harmonic Stack for Speed 2018/3/6 Yung-Yu Chen https://www.linkedin.com/in/yungyuc/
  • 2. The World Is Changing ❖ Computing helps human beings to change the world in an unprecedented pace ❖ What are these? 30 cm in diameter, 1978 3 sizes, 3.5” smallest
  • 3. Python as Your Computing Platform ❖ Python programming language is the way to go ❖ One language to rule them all ❖ Interactive analysis and visualization ❖ Data preparation and processing ❖ Workflow automation ❖ Distributed processing and parallel computing ❖ Join PyCon TW 2018, 1-2 June: https://tw.pycon.org/2018/
  • 4. Interactive ❖ http://jupyter.org: run Python everywhere and code it through browser ❖ https://matplotlib.org: de facto 2D plotting library ❖ https://www.vtk.org: versatile 3D visualization toolbox ❖ https://www.paraview.org: if you only want a frontend
  • 5. Data Manipulation ❖ http://pandas.pydata.org: de facto tool for data analytics ❖ http://www.pytables.org: HDF5 hierarchical data access ❖ http://unidata.github.io/netcdf4-python/: netCDF, yet another data storage based on HDF5
  • 6. Workflow Automation ❖ https://docs.python.org/3/library/argparse.html: standard command-line argument processing ❖ https://github.com/saltstack/salt: cloud-oriented automation for management and configuration ❖ AWS, GCE, Azure all offer SDK for Python
  • 7. Concurrency ❖ https://docs.python.org/3/library/asyncio.html ❖ support native asynchronous constructs ❖ https://docs.python.org/3/library/multiprocessing.html ❖ parallel computing and distributed processing using multiple processes ❖ http://zeromq.org/bindings:python ❖ socket communication ❖ http://pythonhosted.org/mpi4py/ ❖ use MPI in Python
  • 8.
  • 9. The Only Thing That Doesn’t Change, Is Change ❖ Way too many options for computing ❖ What an engineer should learn? ❖ Yes, I know, Python. But it’s all the tools with Python, and not Python alone, right? ❖ Can we find something so fundamental that doesn’t change?
  • 10. Machine Code ❖ Computer can only execute machine code ❖ But it looks hard. ❖ And it is really hard. _main: 0000000100001c80 pushq %rbp 0000000100001c81 movq %rsp, %rbp 0000000100001c84 subq $0x60, %rsp 0000000100001c88 leaq 0x2cd(%rip), %rax 0000000100001c8f movl $0x0, -0x4(%rbp) 0000000100001c96 movl %edi, -0x8(%rbp) 0000000100001c99 movq %rsi, -0x10(%rbp) 0000000100001c9d movq %rax, %rdi 0000000100001ca0 callq 0x100001ee8 ...
  • 11. C++: Compromise ❖ First, there was the C programming language ❖ It allows us to write a little bit more friendly code ❖ A compiler takes the code and turn it into assembly, and it is then turned into machine code ❖ Some geniuses want to make something super powerful but looks like C ❖ It produces the fastest possible machine code from machine-friendly, convoluted concepts
  • 12. Slow for Fast, Fast Is Slow ❖ It takes a lot of time to write code that computers run fast ❖ C++ -> machine code ❖ Quickly written code takes additional time from computers to interpret ❖ Python ❖ Ease of use and performance are competing. You cannot get both.
  • 13. As Easy as Python, as Fast as C++ ❖ Create a new tool that serves both purposes? ❖ You need to re-create two whole eco-systems that develop for 20-30 years ❖ Doesn’t sound very realistic, does it? ❖ How about using C++ for what needs speed, and Python for everything else? Yes if we have a way to bridge them!
  • 14. pybind11 ❖ C++, born in 1985 (development since 1979) ❖ ISO standard: C++98, 03, 11, 14, 17 ❖ Python, born in 1991 ❖ Community maintained ❖ C++11/14/17(/20) is referred to as modern C++ and usually just “C+ +11” ❖ C++ is notoriously hard, but modern C++ starts to make sense ❖ pybind11 is a tool allowing us to use exclusively modern C++ with Python
  • 15. Wrapping Tools for Python Abound ❖ So many software packages provide Python API ❖ pybind11, boost.python, Cython, ctypes, swig, etc. ❖ Python C API
  • 16. Multi-Language Systems ❖ Recall the purpose: quickly make fast software ❖ Know very well the system fundamentals ❖ It’s always the key to a good software system ❖ In C++: core data structure and performance hotspots ❖ In Python: workflow and customization
  • 17. Things to Learn ❖ Master your problem domain: mathematics and mechanics ❖ Computer architecture ❖ Numerical analysis ❖ Practice Python and then C++ for 10 years
  • 18. Mathematics and Mechanics ❖ Calculus ❖ Linear algebra ❖ Vector analysis ❖ Thermodynamics ❖ Continuum mechanics: solids and fluids ❖ Materials and chemistry
  • 19. Computer Architecture ❖ Abstract description for how silicon is made for computing ❖ What runs fast and what runs slow, and why ❖ How do you code to make the best use of the hardware
  • 20. Numerical Analysis ❖ Turn mathematics into code; the mathematics describes the physics ❖ Interpolation ❖ Equation solving ❖ Linear systems ❖ Optimization
  • 21. How to Learn Python ❖ Python should be the first programming language to learn because it’s easy to use ❖ Edit a text file and run it ❖ Open a browser and run it print("hello, world") $ python3 hello.py hello, world
  • 22. Step 1: Install Runtime ❖ https://www.anaconda.com/download/ ❖ Anaconda contains Python and a lot of useful software packages. ❖ When one starts, it’s even difficult to find and install software, but Anaconda solves the problem ❖ Use command line as much as possible ❖ If you can, use Linux (Ubuntu) or mac osx, which give you a powerful command-line shell. Windows 10 professional has one too, but not as popular as the Unixes.
  • 23. Step 2: Interact Programmers try and error and then CPR: copy-paste-replace Highly unlikely to get things right the first time
  • 24. Step 3: Review and Rewrite ❖ Continuously change the code ❖ Automatic testing is necessary ❖ No one can fully understand 10,000 lines of code and make sure it’s right ❖ Architect the system ❖ Develop features piece by piece ❖ Connect components ❖ Reorganize structure to make it bigger solvcon !"" __init__.py !"" anchor.py !"" batch.py !"" batch_torque.py !"" block.py !"" boundcond.py !"" case.py !"" case_core.py !"" cloud.py !"" cmdutil.py !"" command.py !"" conf.py !"" connection.py !"" dependency.py !"" domain.py !"" exception.py !"" gendata.py !"" helper.py !"" hook.py !"" io #   !"" __init__.py #   $"" ... !"" mpy.py !"" mthread.py !"" parcel #   !"" __init__.py #   $"" ... !"" rpc.py !"" scuda.py !"" solver.py !"" testing.py $"" ...
  • 25. How to Learn C++ ❖ Never starts with C++ ❖ Benchmark first ❖ Use C++ when you need to control from byte to byte ❖ Keep in mind the differences between Python and C++ ❖ Python function calls are 10x-100x slower than C++ ❖ Python determines everything in runtime; C++ determines many things in compile time.
  • 26. Compilation Source file A Construct 1 Construct 2 Source file B Construct 1 Construct 2 Binary Construct A.1 Construct B.2 Construct B.1 Construct A.2 … Compile Runtime input data data output data data Binary Construct A.1 Construct B.2 Construct B.1 Construct A.2 }Pythondoesn’thaveit
  • 27. Learn by Doing ❖ Incentive is utmost important: Program to solve your problems ❖ After your 500,000 lines of code, you’ll get it ❖ If you don’t code enough, reading books doesn’t help
  • 28. Your Job ❖ Make mobile app run faster? No problem ❖ Scale web page higher? You nail it ❖ Increase video game frame rate? Yes ❖ Crunch more data? Absolutely ❖ Make scientific discoveries? That’s what you do ❖ If you can quickly make computers run fast, jobs find you