tAdd more content - brcon2020_adc - my presentation for brcon2020
 (HTM) git clone git://src.adamsgaard.dk/.brcon2020_adc
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) LICENSE
       ---
 (DIR) commit 09b939077731ac3cc1fbbb7d9e711c71dda9e1b4
 (DIR) parent 6191e26a6f7a379b8bf5cbaaf2d4932164778fe4
 (HTM) Author: Anders Damsgaard <anders@adamsgaard.dk>
       Date:   Sat, 25 Apr 2020 22:29:24 +0200
       
       Add more content
       
       Diffstat:
         M Makefile                            |       2 +-
         M brcon2020_adc.md                    |     271 +++++++++++++++++++++++++++++--
       
       2 files changed, 261 insertions(+), 12 deletions(-)
       ---
 (DIR) diff --git a/Makefile b/Makefile
       t@@ -5,7 +5,7 @@ pdf = $(src:.md=.pdf)
        txt = 0000-_brcon2020_-_2020-05-02.txt
        
        $(txt): $(src)
       -        #rm -f *.txt
       +        rm -f *.txt
                cat $(src) | md2point
        
        show: $(txt)
 (DIR) diff --git a/brcon2020_adc.md b/brcon2020_adc.md
       t@@ -1,3 +1,4 @@
       +Abstract:
        Numerical models are used extensively for simulating complex physical
        systems including fluid flows, astronomical events, weather, and
        climate.  Many researchers struggle to bring their model developments
       t@@ -10,6 +11,7 @@ doing model development in C and unix tools from the start minimizes
        porting headaches between platforms, reduces energy use on all
        systems, and ensures reproducibility of results.
        
       +
        ## brcon2020 - 2020-05-02
        
                title: Energy efficient programming in science
       t@@ -20,39 +22,286 @@ systems, and ensures reproducibility of results.
                       gopher://adamsgaard.dk
                       https://adamsgaard.dk
        
       -      
        
        ## About me
        
        Present:
       -* 33 y/o, linux/bsd user since 2002
       -* Postdoctoral scholar at Stanford University (Ca, US)
       +
       +* 33 y/o Dane, linux/bsd user since 2001
       +* #bitreich-en since 2019-12-16
       +* EDITOR=vi
       +* Postdoctoral scholar at Stanford University (US)
        * Lecturer at Aarhus University (DK)
        
        Previous:
       +
        * Scripps Institution of Oceanography (US)
        * National Oceanic and Atmospheric Administration (NOAA, US)
        * Princeton University (US)
        
        
       -## Typical flow
       +## About me
       +
       +Present:
       +
       +* 33 y/o dane, linux/bsd user since 2002
       +* #bitreich-en since 2019-12-16
       +* EDITOR=vi
       +* Postdoctoral scholar at Stanford University (US)
       +* Lecturer at Aarhus University (DK)
       +
       +Previous:
       +
       +* Scripps Institution of Oceanography (US)
       +* National Oceanic and Atmospheric Administration (NOAA, US)
       +* Princeton University (US)
       +
       +Academic interests:
       +
       +* ice sheets, glaciers, and climate
       +* earthquake physics and landslides
       +* modeling of fluid flows and granular materials
       +
       +## Numerical modeling
       +
       +* models used for complex physical systems (fluid flows, astronomical events, weather, climate)
       +* domains and physical processes split up into small, manageable chunks
       +
       +Numerical models are used extensively for simulating complex physical
       +systems including fluid flows, astronomical events, weather, and
       +climate.  Many researchers struggle to bring their model developments
       +from single-computer, interpreted languages to parallel high-performance
       +computing (HPC) systems.  There are initiatives to make interpreted
       +languages such as MATLAB, Python, and Julia feasible for HPC
       +programming.  In this talk I argue that the computational overhead
       +is far costlier than any potential development time saved.  Instead,
       +doing model development in C and unix tools from the start minimizes
       +porting headaches between platforms, reduces energy use on all
       +systems, and ensures reproducibility of results.
       +
       +
       +## Numerical modeling
       +
       +      task: Solve partial differential equations (PDEs) by stepping through time
       +            PDEs: conservation laws; mass, momentum, enthalpy
       +
       +   example: Heat diffusion through homogenous medium
       +
       +       ∂T
       +       -- = -k ∇² T
       +       ∂t
       +
       +    domain:
       +
       +       .---------------------------------------------------------------------.
       +       |                                                                     |
       +       |                                  T                                  |
       +       |                                                                     |
       +       '---------------------------------------------------------------------'
       +
       +
       +## Numerical modeling
       +
       +      task: Solve partial differential equations (PDEs) by stepping through time
       +            PDEs: conservation laws; mass, momentum, enthalpy
       +
       +   example: Heat diffusion through homogenous medium
       +
       +       ∂T
       +       -- = -k ∇² T
       +       ∂t
       +
       +    domain: discritize into n=7 cells
       +
       +       .---------+---------+---------+---------+---------+---------+---------.
       +       |         |         |         |         |         |         |         |
       +       |    T₁   |    T₂   |    T₃   |    T₄   |    T₅   |    T₆   |    T₇   |
       +       |         |         |         |         |         |         |         |
       +       '---------+---------+---------+---------+---------+---------+---------'
       +
       +## Numerical solution (high-level languages)
       +
       +      task: Solve partial differential equations (PDEs) by stepping through time
       +            PDEs: conservation laws; mass, momentum, enthalpy
       +
       +   example: Heat diffusion through homogenous medium
       +
       +       ∂T
       +       -- = -k ∇² T
       +       ∂t
       +
       +    domain: discritize into n=7 cells
       +
       +       .---------+---------+---------+---------+---------+---------+---------.
       +       |         |         |         |         |         |         |         |
       +       |    T₁   |    T₂   |    T₃   |    T₄   |    T₅   |    T₆   |    T₇   |
       +       |         |         |         |         |         |         |         |
       +       '---------+---------+---------+---------+---------+---------+---------'
       +
       +    MATLAB: sol = pdepe(0, @heat_pde, @heat_initial, @heat_bc, x, t);
       +
       +    Python: fenics.solve(lhs==rhs, heat_pde, heat_bc)
       +
       +     Julia: sol = solve(heat_pde, CVODE_BPF(linear_solver=:Diagonal); rel_tol, abs_tol)
       +
       +        (the above are not entirely equivalent, but you get the point...)
       +
       +
       +## Numerical modeling
       +
       +      task: Solve partial differential equations (PDEs) by stepping through time
       +            PDEs: conservation laws; mass, momentum, enthalpy
       +
       +   example: Heat diffusion through homogenous medium
       +
       +       ∂T
       +       -- = -k ∇² T
       +       ∂t
       +
       +    domain: discritize into n=7 cells
       +
       +       .---------+---------+---------+---------+---------+---------+---------.
       +       |         |         |         |         |         |         |         |
       +  t    |    T₁   |    T₂   |    T₃   |    T₄   |    T₅   |    T₆   |    T₇   |
       +       |         |         |         |         |         |         |         |
       +       '----|--\-+----|--\-+-/--|--\-+-/--|--\-+-/--|--\-+-/--|----+-/--|----'
       +            |   \     |   \ /   |   \ /   |   \ /   |   \ /   |     /   |  
       +            |    \    |    /    |    /    |    /    |    /    |    /    |   
       +            |     \   |   / \   |   / \   |   / \   |   / \   |   /     |    
       +       .----|----+-\--|--/-+-\--|--/-+-\--|--/-+-\--|--/-+-\--|--/-+----|----.
       +       |         |         |         |         |         |         |         |
       +  t+dt |    T₁   |    T₂   |    T₃   |    T₄   |    T₅   |    T₆   |    T₇   |
       +       |         |         |         |         |         |         |         |
       +       '---------+---------+---------+---------+---------+---------+---------'
       +
       +    example BC: outer boundaries constant temperature (T₁ & T₇)
       +
       +## Numerical solution (finite differences)
       +
       +       .---------+---------+---------+---------+---------+---------+---------.
       +       |         |         |         |         |         |         |         |
       +  t    |    T₁   |    T₂   |    T₃   |    T₄   |    T₅   |    T₆   |    T₇   |
       +       |         |         |         |         |         |         |         |
       +       '----|--\-+----|--\-+-/--|--\-+-/--|--\-+-/--|--\-+-/--|----+-/--|----'
       +            |   \     |   \ /   |   \ /   |   \ /   |   \ /   |     /   |  
       +            |    \    |    /    |    /    |    /    |    /    |    /    |   
       +            |     \   |   / \   |   / \   |   / \   |   / \   |   /     |    
       +       .----|----+-\--|--/-+-\--|--/-+-\--|--/-+-\--|--/-+-\--|--/-+----|----.
       +       |         |         |         |         |         |         |         |
       +  t+dt |    T₁   |    T₂   |    T₃   |    T₄   |    T₅   |    T₆   |    T₇   |
       +       |         |         |         |         |         |         |         |
       +       '---------+---------+---------+---------+---------+---------+---------'
       +
       +    explicit solution with central finite differences:
       +
       +        for (t=0.0; t<t_end; t+=dt) {
       +            for (i=1; i<n-1; i++)
       +                T_new[i] = T[i] - k*(T[i+1] - 2.0*T[i] + T[i-1])/(dx*dx) * dt;
       +        }
       +
       +    iterative Jacobian solution with central finite differences:
       +
       +        for (t=0.0; t<t_end; t+=dt) {
       +            for (i=1; i<n-1; i++)
       +                T_old[i] = T[i];
       +            do {
       +                for (i=1; i<n-1; i++) {
       +                    dT[i] = -k*(T[i+1] - 2.0*T[i] + T[i-1])/(dx*dx) * dt;
       +                    T_new[i] = T_old[i] + dT[i];
       +                }
       +            } while (r_norm_max < RTOL);
       +        }
       +
       +## HPC platforms
       +
       +* Free lunch is over
       +* Parallelization is key
       +
       +
       +
       +## From idea to application
       +
        
            1. Conceptualization
       +
       +      |
       +      v
       +
            2. Derivation of mathematical formulation
       +
       +      |
       +      v
       +
            3. Implementation in high-level language
       +
       +      |
       +      v
       +
            4. Re-implementation in low-level language
        
       -These are some points
        
       -* 1
       -* 2
       -    * 2.1
       -    * 2.2
       -* 3
       +## From idea to application
       +
       + ,-----------------------------------------------.
       + |  1. Conceptualization                         |
       + |                                               |
       + |    |                                          |
       + |    v                                          |          _
       + |                                               |     ___ | | __
       + |  2. Derivation of mathematical formulation    |    / _ \| |/ /
       + |                                               |   | (_) |   <
       + |    |                                          |    \___/|_|\_\
       + |    v                                          |
       + |                                               |
       + |  3. Implementation in high-level language     |
       + `-----------------------------------------------'
       +      |                                              _       _
       +      v                                             | | ___ | | __
       +                                                    | |/ _ \| |/ /
       +    4. Re-implementation in low-level language      |_| (_) |   <
       +                                                    (_)\___/|_|\_\
       +
       +
       +# Our scientific training includes learning how to make an solid idea,
       +# translate said idea into a set of equations, and how to implement it
       +# in high-level programming languages
       +
       +# using high-level languages:
       +#  - quick development == quick results
       +#  - loose touch with numerical workings
       +#  - develop non-transferrable skills
       +#  - code not transferrable between platforms
       +#  - use of loop structures discouraged, library calls encouraged
       +
       +# using high-level languages:
       +#  - slower development == delayed results
       +#  - gain intimate familiarity with numerical workings
       +#  - develop transferrable code and skills
       +#  - high computational performance when done right
       +
       +# requires basic C programming, usually no syscalls besides file IO
       +
       +
       +## Scaling problem
       +
       +New algorithms hard to implement in HPC codes
       +
       +
       +## A (non-)solution
       +
       +Port/apply high-level languages to HPC platforms
       +
       +high overhead on many machines -> substantially lower performance and energy efficiency
       +
       +## Measuring computational energy use
       +
       +
        
        ## Summary
        
       +* Programming in low-level languages during prototyping can save energy and frustration
       +
        
        ## Thanks
        
       -    __20h__ and Freenode/#bitreich-en
       +    20h & Freenode/#bitreich-en