SlideShare ist ein Scribd-Unternehmen logo
1 von 24
Numba
NumPy-aware dynamic Python compiler

               Travis E. Oliphant


   SciPy 2012. Austin, TX, USA. July 18, 2012
Motivation
• Python is great for rapid development
  and high-level thinking-in-code
• It is slow for interior loops because lack
  of type information leads to a lot of
  indirection and “extra” code.
Motivation
• NumPy users have a lot of type
  information --- but only currently have
  one-size fits all pre-compiled, vectorized
  loops.
• Many new features envisioned will need
  the ability for high-level expressions to
  be compiled to machine code.
Goals
 • Most developers should not have to write
   anything but Python -- or other even higher-
   level Domain Specific Language (DSL).
 • Create faster code using array-expressions from
   NumPy users -- Fortran is the initial target
 • Take advantage of multi-core and GPUs for a
   subset of Python.
Why Not PyPy?
• PyPy does not work with CPython
• PyPy is a (meta) “tracing” JIT. Machine code is
  generated on the fly so there is no “build step” -- but
  we want to support a “build step” when justified
• PyPy tries to speed up everything -- we want to
  optimize more specifically on numeric codes
  (including complex numbers)
               More to the story...
Why not Cython?

• Cython is great for what it does, but...
• Cython creates extension modules which cannot be
  “unloaded” dynamically
• Cython requires a full C-compiler
• Cython doesn’t do type inference -- you have to
  declare types on everything
• Cython is another syntax to learn
What’s the real motivation...
• “Computed columns” for data-types
• Always been bothered by how to write a fast-version
  of “vectorize”
• and... I wanted to play with LLVM!
More Ranting
• The world needs more array-oriented compilers --
  Python has needed one for a decade at least.
• Array-oriented computing needs more light in CS
  curricula
• Most domain experts can write what they want at a
  high-level. Commonly this is then “translated” to a
  lower-level and then the compiler gets a hold of it.
  This is sub-optimal.
• Projects discussed are doing this, but still niche.
  Copperhead, Theano, etc.
More Ranting
• Today’s vector machines (and vector co-processors,
  or GPUS) were made for array-oriented computing.
• The software stack has just not caught up ---
  unfortunate because APL came out in 1963.
• There is a reason Fortran remains popular.
Array-Oriented Computing
• Loosely defined as “Organize data-together” and
 operate on it together (or in cache-size chunks) with
 array-level operations (e.g. NumPy)
              Object                           Attr1   Attr2   Attr3
              Attr1    Object
    Object                           Object1
              Attr2    Attr1
    Attr1
              Attr3    Attr2         Object2
    Attr2
                       Attr3
    Attr3                            Object3

              Object                 Object4
     Object   Attr1
                       Object        Object5
      Attr1   Attr2
                        Attr1
      Attr2   Attr3                  Object6
                        Attr2
      Attr3             Attr3
Goal:

        Numba should be the world’s best
           array-oriented compiler.
NumPy + Mamba = Numba
 Python Function                         Machine Code


                       LLVM-PY

                   LLVM Library
       ISPC   OpenCL    OpenMP    CUDA      CLANG

    Intel     AMD        Nvidia     Apple       ARM
Ufuncs


                Generalized
                 UFuncs
                                                          Python
                                                         Function
                 Window
                 Kernel
                  Funcs

                 Function-
                                                                    Uses of Numba




                   based
                 Indexing


                 Memory
                  Filters
                                                 Numba




NumPy Runtime
                I/O Filters



                Reduction
                 Filters


                Computed
                Columns
                              function pointer
Uses of Numba in SciPy

     optimize                   integrate


     special                       ode



     writing more of SciPy at high-level
Numba --- a deeper look

   Numba is a Python to LLVM translator. It
   translates Python to LLVM IR (the LLVM
   machinery is then used to create machine
  code from there). Numba is NumPy aware
    --- it understands NumPy’s type system,
      methods, C-API, and data-structures
Numba -- written in Python
 • Numba itself is pure Python -- it uses (an
   updated) LLVM-py to interact with the LLVM
   C++ library to build a representation of the
   code in LLVM assembler.
 • LLVM then creates machine code (or a
   “bitcode” module which can be persisted or
   sent to another machine)
 • Machine-code is equivalent to a C-level
   function-pointer (e.g. a ctypes function)
Example
Examples
Demo
Status and Future
• Current master branch mostly due to Jon Riehl
  (Resilient Science) sponsored by Continuum
  Analytics, Inc. --- interprets bytecode directly
• New devel branch working with AST directly and
  making rapid progress
  - Mark Florrison (minivect)
  - Siu Kwan Lam (pymothoa)
Software Stack Future?
         Plateaus of Code re-use + DSLs
   SQL                                R
            TDPL                                Matlab


                    Python


             OBJC                C
  FORTRAN                                 C++



                     LLVM
Join Us!



      http://numba.github.com/numba

Weitere ähnliche Inhalte

Was ist angesagt?

2015年度先端GPGPUシミュレーション工学特論 第7回 総和計算(Atomic演算)
2015年度先端GPGPUシミュレーション工学特論 第7回 総和計算(Atomic演算)2015年度先端GPGPUシミュレーション工学特論 第7回 総和計算(Atomic演算)
2015年度先端GPGPUシミュレーション工学特論 第7回 総和計算(Atomic演算)
智啓 出川
 
OSI Veri Bağı Katmanı
OSI Veri Bağı KatmanıOSI Veri Bağı Katmanı
OSI Veri Bağı Katmanı
Talha Kabakus
 

Was ist angesagt? (20)

Spotify Discover Weekly: The machine learning behind your music recommendations
Spotify Discover Weekly: The machine learning behind your music recommendationsSpotify Discover Weekly: The machine learning behind your music recommendations
Spotify Discover Weekly: The machine learning behind your music recommendations
 
2015年度先端GPGPUシミュレーション工学特論 第7回 総和計算(Atomic演算)
2015年度先端GPGPUシミュレーション工学特論 第7回 総和計算(Atomic演算)2015年度先端GPGPUシミュレーション工学特論 第7回 総和計算(Atomic演算)
2015年度先端GPGPUシミュレーション工学特論 第7回 総和計算(Atomic演算)
 
計算力学シミュレーションに GPU は役立つのか?
計算力学シミュレーションに GPU は役立つのか?計算力学シミュレーションに GPU は役立つのか?
計算力学シミュレーションに GPU は役立つのか?
 
Pythonではじめる OpenAI Gymトレーニング
Pythonではじめる OpenAI GymトレーニングPythonではじめる OpenAI Gymトレーニング
Pythonではじめる OpenAI Gymトレーニング
 
Prophet at Scale: Using Prophet at scale to tune and forecast time series at ...
Prophet at Scale: Using Prophet at scale to tune and forecast time series at ...Prophet at Scale: Using Prophet at scale to tune and forecast time series at ...
Prophet at Scale: Using Prophet at scale to tune and forecast time series at ...
 
ダブリング
ダブリングダブリング
ダブリング
 
機械学習ゴリゴリ派のための数学とPython
機械学習ゴリゴリ派のための数学とPython機械学習ゴリゴリ派のための数学とPython
機械学習ゴリゴリ派のための数学とPython
 
CatBoost on GPU のひみつ
CatBoost on GPU のひみつCatBoost on GPU のひみつ
CatBoost on GPU のひみつ
 
IR Evaluation using Rank-Biased Precision
IR Evaluation using Rank-Biased PrecisionIR Evaluation using Rank-Biased Precision
IR Evaluation using Rank-Biased Precision
 
Top-K Off-Policy Correction for a REINFORCE Recommender System
Top-K Off-Policy Correction for a REINFORCE Recommender SystemTop-K Off-Policy Correction for a REINFORCE Recommender System
Top-K Off-Policy Correction for a REINFORCE Recommender System
 
Introduction to Recommendation System
Introduction to Recommendation SystemIntroduction to Recommendation System
Introduction to Recommendation System
 
動的計画法
動的計画法動的計画法
動的計画法
 
NeurIPS'21参加報告 tanimoto_public
NeurIPS'21参加報告 tanimoto_publicNeurIPS'21参加報告 tanimoto_public
NeurIPS'21参加報告 tanimoto_public
 
Recsys 2014 Tutorial - The Recommender Problem Revisited
Recsys 2014 Tutorial - The Recommender Problem RevisitedRecsys 2014 Tutorial - The Recommender Problem Revisited
Recsys 2014 Tutorial - The Recommender Problem Revisited
 
NumPy闇入門
NumPy闇入門NumPy闇入門
NumPy闇入門
 
機械学習 / Deep Learning 大全 (1) 機械学習基礎編
機械学習 / Deep Learning 大全 (1) 機械学習基礎編機械学習 / Deep Learning 大全 (1) 機械学習基礎編
機械学習 / Deep Learning 大全 (1) 機械学習基礎編
 
C++ 11 range-based for loop
C++ 11   range-based for loopC++ 11   range-based for loop
C++ 11 range-based for loop
 
(SURVEY) Semi Supervised Learning
(SURVEY) Semi Supervised Learning(SURVEY) Semi Supervised Learning
(SURVEY) Semi Supervised Learning
 
OSI Veri Bağı Katmanı
OSI Veri Bağı KatmanıOSI Veri Bağı Katmanı
OSI Veri Bağı Katmanı
 
はじめての機械学習
はじめての機械学習はじめての機械学習
はじめての機械学習
 

Andere mochten auch

Buzzwords Numba Presentation
Buzzwords Numba PresentationBuzzwords Numba Presentation
Buzzwords Numba Presentation
kammeyer
 
Numba: Flexible analytics written in Python with machine-code speeds and avo...
Numba:  Flexible analytics written in Python with machine-code speeds and avo...Numba:  Flexible analytics written in Python with machine-code speeds and avo...
Numba: Flexible analytics written in Python with machine-code speeds and avo...
PyData
 

Andere mochten auch (11)

ニューラル機械翻訳の動向@IBIS2017
ニューラル機械翻訳の動向@IBIS2017ニューラル機械翻訳の動向@IBIS2017
ニューラル機械翻訳の動向@IBIS2017
 
GPU Computing With Apache Spark And Python
GPU Computing With Apache Spark And PythonGPU Computing With Apache Spark And Python
GPU Computing With Apache Spark And Python
 
The State of High-Performance Computing in the Open-Source R Ecosystem
The State of High-Performance Computing in the Open-Source R EcosystemThe State of High-Performance Computing in the Open-Source R Ecosystem
The State of High-Performance Computing in the Open-Source R Ecosystem
 
Buzzwords Numba Presentation
Buzzwords Numba PresentationBuzzwords Numba Presentation
Buzzwords Numba Presentation
 
Numba: Flexible analytics written in Python with machine-code speeds and avo...
Numba:  Flexible analytics written in Python with machine-code speeds and avo...Numba:  Flexible analytics written in Python with machine-code speeds and avo...
Numba: Flexible analytics written in Python with machine-code speeds and avo...
 
Accelerate Your Python* Code through Profiling, Tuning, and Compilation Part ...
Accelerate Your Python* Code through Profiling, Tuning, and Compilation Part ...Accelerate Your Python* Code through Profiling, Tuning, and Compilation Part ...
Accelerate Your Python* Code through Profiling, Tuning, and Compilation Part ...
 
Numba: Array-oriented Python Compiler for NumPy
Numba: Array-oriented Python Compiler for NumPyNumba: Array-oriented Python Compiler for NumPy
Numba: Array-oriented Python Compiler for NumPy
 
米国のペネトレーションテスト事情(ssmjp)
米国のペネトレーションテスト事情(ssmjp)米国のペネトレーションテスト事情(ssmjp)
米国のペネトレーションテスト事情(ssmjp)
 
[Microsoft Tech Summit 2017] マイクロサービスだけじゃない! コンテナー オーケストレーターとしての「Azure Servic...
[Microsoft Tech Summit 2017] マイクロサービスだけじゃない! コンテナー オーケストレーターとしての「Azure Servic...[Microsoft Tech Summit 2017] マイクロサービスだけじゃない! コンテナー オーケストレーターとしての「Azure Servic...
[Microsoft Tech Summit 2017] マイクロサービスだけじゃない! コンテナー オーケストレーターとしての「Azure Servic...
 
チームで取り組む!アクセシビリティコーディング&デザイン
チームで取り組む!アクセシビリティコーディング&デザインチームで取り組む!アクセシビリティコーディング&デザイン
チームで取り組む!アクセシビリティコーディング&デザイン
 
4つの戦犯から考えるサービスづくりの失敗
4つの戦犯から考えるサービスづくりの失敗4つの戦犯から考えるサービスづくりの失敗
4つの戦犯から考えるサービスづくりの失敗
 

Ähnlich wie Numba

RabbitMQ with python and ruby RuPy 2009
RabbitMQ with python and ruby RuPy 2009RabbitMQ with python and ruby RuPy 2009
RabbitMQ with python and ruby RuPy 2009
Paolo Negri
 

Ähnlich wie Numba (20)

The Joy of SciPy
The Joy of SciPyThe Joy of SciPy
The Joy of SciPy
 
Numba lightning
Numba lightningNumba lightning
Numba lightning
 
Scale up and Scale Out Anaconda and PyData
Scale up and Scale Out Anaconda and PyDataScale up and Scale Out Anaconda and PyData
Scale up and Scale Out Anaconda and PyData
 
Python in the real world : from everyday applications to advanced robotics
Python in the real world : from everyday applications to advanced roboticsPython in the real world : from everyday applications to advanced robotics
Python in the real world : from everyday applications to advanced robotics
 
Travis Oliphant "Python for Speed, Scale, and Science"
Travis Oliphant "Python for Speed, Scale, and Science"Travis Oliphant "Python for Speed, Scale, and Science"
Travis Oliphant "Python for Speed, Scale, and Science"
 
PyData Boston 2013
PyData Boston 2013PyData Boston 2013
PyData Boston 2013
 
Toward a gui remote-sensing environment built over OTB
Toward a gui remote-sensing environment built over OTBToward a gui remote-sensing environment built over OTB
Toward a gui remote-sensing environment built over OTB
 
Python for ML.pptx
Python for ML.pptxPython for ML.pptx
Python for ML.pptx
 
Pythonic doesn't mean slow!
Pythonic doesn't mean slow!Pythonic doesn't mean slow!
Pythonic doesn't mean slow!
 
RabbitMQ with python and ruby RuPy 2009
RabbitMQ with python and ruby RuPy 2009RabbitMQ with python and ruby RuPy 2009
RabbitMQ with python and ruby RuPy 2009
 
Basic of python for data analysis
Basic of python for data analysisBasic of python for data analysis
Basic of python for data analysis
 
Building SciPy kernels with Pythran
Building SciPy kernels with PythranBuilding SciPy kernels with Pythran
Building SciPy kernels with Pythran
 
Elasticwulf Pycon Talk
Elasticwulf Pycon TalkElasticwulf Pycon Talk
Elasticwulf Pycon Talk
 
Multicore
MulticoreMulticore
Multicore
 
PyCon2022 - Building Python Extensions
PyCon2022 - Building Python ExtensionsPyCon2022 - Building Python Extensions
PyCon2022 - Building Python Extensions
 
Python for Science and Engineering: a presentation to A*STAR and the Singapor...
Python for Science and Engineering: a presentation to A*STAR and the Singapor...Python for Science and Engineering: a presentation to A*STAR and the Singapor...
Python for Science and Engineering: a presentation to A*STAR and the Singapor...
 
Parallelism in a NumPy-based program
Parallelism in a NumPy-based programParallelism in a NumPy-based program
Parallelism in a NumPy-based program
 
Keynote at Converge 2019
Keynote at Converge 2019Keynote at Converge 2019
Keynote at Converge 2019
 
SciPy 2019: How to Accelerate an Existing Codebase with Numba
SciPy 2019: How to Accelerate an Existing Codebase with NumbaSciPy 2019: How to Accelerate an Existing Codebase with Numba
SciPy 2019: How to Accelerate an Existing Codebase with Numba
 
Concurrency and Python - PyCon MY 2015
Concurrency and Python - PyCon MY 2015Concurrency and Python - PyCon MY 2015
Concurrency and Python - PyCon MY 2015
 

Mehr von Travis Oliphant

Mehr von Travis Oliphant (17)

Array computing and the evolution of SciPy, NumPy, and PyData
Array computing and the evolution of SciPy, NumPy, and PyDataArray computing and the evolution of SciPy, NumPy, and PyData
Array computing and the evolution of SciPy, NumPy, and PyData
 
SciPy Latin America 2019
SciPy Latin America 2019SciPy Latin America 2019
SciPy Latin America 2019
 
PyCon Estonia 2019
PyCon Estonia 2019PyCon Estonia 2019
PyCon Estonia 2019
 
Standardizing arrays -- Microsoft Presentation
Standardizing arrays -- Microsoft PresentationStandardizing arrays -- Microsoft Presentation
Standardizing arrays -- Microsoft Presentation
 
Scaling Python to CPUs and GPUs
Scaling Python to CPUs and GPUsScaling Python to CPUs and GPUs
Scaling Python to CPUs and GPUs
 
PyData Barcelona Keynote
PyData Barcelona KeynotePyData Barcelona Keynote
PyData Barcelona Keynote
 
Python for Data Science with Anaconda
Python for Data Science with AnacondaPython for Data Science with Anaconda
Python for Data Science with Anaconda
 
Fast and Scalable Python
Fast and Scalable PythonFast and Scalable Python
Fast and Scalable Python
 
Scaling PyData Up and Out
Scaling PyData Up and OutScaling PyData Up and Out
Scaling PyData Up and Out
 
Python as the Zen of Data Science
Python as the Zen of Data SciencePython as the Zen of Data Science
Python as the Zen of Data Science
 
Anaconda and PyData Solutions
Anaconda and PyData SolutionsAnaconda and PyData Solutions
Anaconda and PyData Solutions
 
Continuum Analytics and Python
Continuum Analytics and PythonContinuum Analytics and Python
Continuum Analytics and Python
 
Bids talk 9.18
Bids talk 9.18Bids talk 9.18
Bids talk 9.18
 
Effectively using Open Source with conda
Effectively using Open Source with condaEffectively using Open Source with conda
Effectively using Open Source with conda
 
London level39
London level39London level39
London level39
 
Blaze: a large-scale, array-oriented infrastructure for Python
Blaze: a large-scale, array-oriented infrastructure for PythonBlaze: a large-scale, array-oriented infrastructure for Python
Blaze: a large-scale, array-oriented infrastructure for Python
 
PyData Introduction
PyData IntroductionPyData Introduction
PyData Introduction
 

Kürzlich hochgeladen

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Kürzlich hochgeladen (20)

2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 

Numba

  • 1. Numba NumPy-aware dynamic Python compiler Travis E. Oliphant SciPy 2012. Austin, TX, USA. July 18, 2012
  • 2. Motivation • Python is great for rapid development and high-level thinking-in-code • It is slow for interior loops because lack of type information leads to a lot of indirection and “extra” code.
  • 3. Motivation • NumPy users have a lot of type information --- but only currently have one-size fits all pre-compiled, vectorized loops. • Many new features envisioned will need the ability for high-level expressions to be compiled to machine code.
  • 4. Goals • Most developers should not have to write anything but Python -- or other even higher- level Domain Specific Language (DSL). • Create faster code using array-expressions from NumPy users -- Fortran is the initial target • Take advantage of multi-core and GPUs for a subset of Python.
  • 5. Why Not PyPy? • PyPy does not work with CPython • PyPy is a (meta) “tracing” JIT. Machine code is generated on the fly so there is no “build step” -- but we want to support a “build step” when justified • PyPy tries to speed up everything -- we want to optimize more specifically on numeric codes (including complex numbers) More to the story...
  • 6. Why not Cython? • Cython is great for what it does, but... • Cython creates extension modules which cannot be “unloaded” dynamically • Cython requires a full C-compiler • Cython doesn’t do type inference -- you have to declare types on everything • Cython is another syntax to learn
  • 7. What’s the real motivation... • “Computed columns” for data-types • Always been bothered by how to write a fast-version of “vectorize” • and... I wanted to play with LLVM!
  • 8. More Ranting • The world needs more array-oriented compilers -- Python has needed one for a decade at least. • Array-oriented computing needs more light in CS curricula • Most domain experts can write what they want at a high-level. Commonly this is then “translated” to a lower-level and then the compiler gets a hold of it. This is sub-optimal. • Projects discussed are doing this, but still niche. Copperhead, Theano, etc.
  • 9. More Ranting • Today’s vector machines (and vector co-processors, or GPUS) were made for array-oriented computing. • The software stack has just not caught up --- unfortunate because APL came out in 1963. • There is a reason Fortran remains popular.
  • 10. Array-Oriented Computing • Loosely defined as “Organize data-together” and operate on it together (or in cache-size chunks) with array-level operations (e.g. NumPy) Object Attr1 Attr2 Attr3 Attr1 Object Object Object1 Attr2 Attr1 Attr1 Attr3 Attr2 Object2 Attr2 Attr3 Attr3 Object3 Object Object4 Object Attr1 Object Object5 Attr1 Attr2 Attr1 Attr2 Attr3 Object6 Attr2 Attr3 Attr3
  • 11. Goal: Numba should be the world’s best array-oriented compiler.
  • 12. NumPy + Mamba = Numba Python Function Machine Code LLVM-PY LLVM Library ISPC OpenCL OpenMP CUDA CLANG Intel AMD Nvidia Apple ARM
  • 13. Ufuncs Generalized UFuncs Python Function Window Kernel Funcs Function- Uses of Numba based Indexing Memory Filters Numba NumPy Runtime I/O Filters Reduction Filters Computed Columns function pointer
  • 14. Uses of Numba in SciPy optimize integrate special ode writing more of SciPy at high-level
  • 15. Numba --- a deeper look Numba is a Python to LLVM translator. It translates Python to LLVM IR (the LLVM machinery is then used to create machine code from there). Numba is NumPy aware --- it understands NumPy’s type system, methods, C-API, and data-structures
  • 16. Numba -- written in Python • Numba itself is pure Python -- it uses (an updated) LLVM-py to interact with the LLVM C++ library to build a representation of the code in LLVM assembler. • LLVM then creates machine code (or a “bitcode” module which can be persisted or sent to another machine) • Machine-code is equivalent to a C-level function-pointer (e.g. a ctypes function)
  • 19.
  • 20.
  • 21. Demo
  • 22. Status and Future • Current master branch mostly due to Jon Riehl (Resilient Science) sponsored by Continuum Analytics, Inc. --- interprets bytecode directly • New devel branch working with AST directly and making rapid progress - Mark Florrison (minivect) - Siu Kwan Lam (pymothoa)
  • 23. Software Stack Future? Plateaus of Code re-use + DSLs SQL R TDPL Matlab Python OBJC C FORTRAN C++ LLVM
  • 24. Join Us! http://numba.github.com/numba

Hinweis der Redaktion

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n