Slide 1

Slide 1 text

Return of Wabi-Sabi: 
 Hastega Will Bring More and More Computational Power to Elixir Susumu Yamazaki (ZACKY) & Yuki Hisae (hisaway) Univ. of Kitakyushu / fukuoka.ex 1 © 2019 Susumu Yamazaki & Yuki Hisae

Slide 2

Slide 2 text

About Us • Susumu Yamazaki (ZACKY) • @ZACKY1972 • Associate Professor • NEW!
 The Leader of the Nudge Social Implementation Research Center • at Univ. of Kitakyushu • Adviser at fukuoka.ex • Co-author of Hastega 2 © 2019 Susumu Yamazaki & Yuki Hisae

Slide 3

Slide 3 text

About Us • Yuki Hisae (hisaway) • @hisawayex • Graduate Student
 at Univ. of Kitakyushu • Cast at fukuoka.ex • Co-author of Hastega • I’m so sorry but he is absent because 
 I couldn’t prepare enough budget for his traveling expenses from Japan… • He’ll appear later at a movie presentation 3 © 2019 Susumu Yamazaki & Yuki Hisae

Slide 4

Slide 4 text

Agenda 1. Introduction 2. A review of the previous talk at Lonestar ElixirConf 2019 3. Renaming Hastega 4. New features (Movie by hisaway) 5. Future roadmap 6. Our requests to cooperation 7. Epilogue 4 © 2019 Susumu Yamazaki & Yuki Hisae

Slide 5

Slide 5 text

ElixirConf JP Kokurajo The Approved event will be held on Sep. 7th
 at Kitakyushu (Kokura), Fukuoka, Japan 5 © 2019 Susumu Yamazaki & Yuki Hisae Thank you, Jim!

Slide 6

Slide 6 text

The Keynote of ElixirConf JP Kokurajo • Justin will talk on Nerves to Japanese people • At the top of the Kokurajo castle • I’ll explain why Justin, later… 6 © 2019 Susumu Yamazaki & Yuki Hisae

Slide 7

Slide 7 text

Then, I’ll talk on Hastega… 7 © 2019 Susumu Yamazaki & Yuki Hisae

Slide 8

Slide 8 text

At the José’s Keynote… 8 © 2019 Susumu Yamazaki & Yuki Hisae

Slide 9

Slide 9 text

© 2019 Susumu Yamazaki & Yuki Hisae © 2019 José Valim

Slide 10

Slide 10 text

My Previous Talk • Hastega was presented firstly at Lonestar ElixirConf 2019 • Under the view of the world of Wabi-Sabi, consists of Magic, Zen and Samurai • The movie is available at 
 https://youtu.be/lypqlGlK1So 10 © 2019 Susumu Yamazaki & Yuki Hisae

Slide 11

Slide 11 text

Hastega: Challenge for GPGPU on Elixir Susumu Yamazaki (ZACKY) Associate Professor at Univ. of Kitakyushu Adviser at fukuoka.ex

Slide 12

Slide 12 text

Our motivation

Slide 13

Slide 13 text

Data Explosion has come! 55.1 Exa bytes in 2013 It’s growing exponentially Year Amount of Data reported by Cisco 2013

Slide 14

Slide 14 text

We need more power! Computer Architecture: A Quantitative Approach But, evolution of CPU clock
 became over 15 years ago ↑2003 Year Clock rate

Slide 15

Slide 15 text

We need more power! *OUFM$PSF
 &YUSFNF9 $MPDLT ()[ DPSFT *OUFM$PSFJ
 9& $MPDLT ()[ DPSFT •CPU clocks haven’t grown •# of cores is growing rapidly

Slide 16

Slide 16 text

We need more power! •# of cores is growing, but
 CPU clocks haven’t grown •It requires parallel computing to us

Slide 17

Slide 17 text

We need more power! •But we have no effective parallel programming languages •Multi-threaded programming is too early to be used correctly

Slide 18

Slide 18 text

Long, long distance… The world with
 destructive updates is…

Slide 19

Slide 19 text

Dystopia! © 2014, Teresa Prater

Slide 20

Slide 20 text

© 2011, Pavel Medzyun Their works become
 dystopia!

Slide 21

Slide 21 text

The reason of dystopia • Suppose some data are shared with some cores 4IBSFE%BUB $PSF #1 $PSF2 3.14

Slide 22

Slide 22 text

4IBSFE%BUB $PSF #1 $PSF2 3.14 →1.5 The reason of dystopia • If a core updates the shared data • then it notifies other cores, and they stop processing • It causes slow down Update Notify Stop processing

Slide 23

Slide 23 text

The reason of dystopia • If there are many cores,
 waiting time grows exponentially 4IBSFE%BUB $PSF #1 $PSF2 3.14 →1.5 Update Notify Stop processing

Slide 24

Slide 24 text

It causes dystopia! © 2014, Teresa Prater

Slide 25

Slide 25 text

Elixir is a drastic solution • Elixir is immutable • That is, it forbids all updates of shared data • Thus, the other cores don’t need to stop processing D 4IBSFE%BUB $PSF #1 $PSF2 3.14 Don’t Update Don’t need to stop processing

Slide 26

Slide 26 text

After a few years…

Slide 27

Slide 27 text

More pessimistic prediction 
 of Data Explosion 40 Zeta Bytes (= 40,000 Exa Bytes) in 2020 180 Zeta Bytes (= 180,000 Exa Bytes) in 2025 ©2014 IDC

Slide 28

Slide 28 text

© 3PZ#MVNFOUIBM To summarize our motivation,
 I have a question,

Slide 29

Slide 29 text

© 3PZ#MVNFOUIBM Will Elixir and Phoenix be really enough for the future Data Explosion?

Slide 30

Slide 30 text

Our solution:
 Hastega!!!

Slide 31

Slide 31 text

Hastega • It’s a magic!! • the highest evolved magic to accelerate our party in Final Fantasy!
 (Stronger than Haste) • It will be the highest evolved technology to accelerate our machines in the Elixir ecosystem! It’s inspired by Flow

Slide 32

Slide 32 text

Let’s cast a spell of Hastega on Samurai

Slide 33

Slide 33 text

4-8x faster than Elixir using Flow! and also faster than P-map
 (Parallel map) ↑ Slower ↓ Faster Flow

Slide 34

Slide 34 text

Overwhelming Effectiveness like a berserk Samurai

Slide 35

Slide 35 text

By the way,
 which is better, 
 recursive call and Enum.map?

Slide 36

Slide 36 text

Enum.map is simpler! It’s like Zen! ˜4UFQIBOF%"MV

Slide 37

Slide 37 text

Why is Enum.map Zen? • Zen is the essential beauty • The essential of programming is data transformation • Enum.map describes only data transformation list = 1..1_000_000 |> Enum.to_list list 
 |> Enum.map(&foo(&1))
 |> Enum.map(&bar(&1))

Slide 38

Slide 38 text

1..1_000_000 
 |> Enum.map(&foo(&1))
 |> Enum.map(&bar(&1)) 1..1_000_000
 |> Enum.to_list
 |> func()
 
 def func( [] ), do: [] def func( [ head | tail ] ) do
 [ head |> foo |> bar 
 | func(tail) ]
 end (A) (B) • The code A, B and C are equivalent. • A: in the loop style in Java • B: in the recursive call style • C: using Enum.map Comparison int i;
 int[] array = new int[1000000];
 for(i = 0; i < 1000000; i++)
 array[i] = i + 1;
 for(i = 0; i < 1000000; i++)
 array[i] = foo(array[i]);
 for(i = 0; i < 1000000; i++)
 array[i] = bar(array[i]); (C)

Slide 39

Slide 39 text

Why are they not Zen? • Loop operation describes flow of processing, loop counter and destructive update int i;
 int[] array = new int[1000000];
 for(i = 0; i < 1000000; i++)
 array[i] = i + 1;
 for(i = 0; i < 1000000; i++)
 array[i] = foo(array[i]);
 for(i = 0; i < 1000000; i++)
 array[i] = bar(array[i]);

Slide 40

Slide 40 text

Why are they not Zen? • Recursive call describes not data transformation but flow of processing 1..1_000_000
 |> Enum.to_list
 |> func()
 
 def func( [] ), do: [] def func( [ head | tail ] ) do
 [ head |> foo |> bar 
 | func(tail) ]
 end

Slide 41

Slide 41 text

1..1_000_000 
 |> Enum.map(&foo(&1))
 |> Enum.map(&bar(&1)) • We propose to call it the Elixir Zen style to write in Enum.map • It is a good programming custom • Because it’s more readable and maintainable The Elixir Zen style

Slide 42

Slide 42 text

Then, what will happen?

Slide 43

Slide 43 text

In Elixir on Erlang VM, the Elixir Zen style is 20 percents slower than recursive call list = 1..1_000_000 |> Enum.to_list list 
 |> Enum.map(&foo(&1))
 |> Enum.map(&bar(&1)) list
 |> func()
 
 def func( [] ), do: [] def func( [ head | tail ] ) do
 [ head |> foo |> bar 
 | func(tail) ]
 end 6msec ↑ Slower ↓ Faster Performance Evaluation

Slide 44

Slide 44 text

© 2011, Pavel Medzyun It’s Zen, but not Samurai…! It will cause dystopia!

Slide 45

Slide 45 text

• make the Elixir Zen styled code faster • by casting the spell of it on Samurai to be berserk • that is, to be transformed into the fastest native code, 
 using all computing resources, • not only multi-core CPUs (with SIMD instructions)
 but also GPUs Hastaga will… We feel it Wabi-Sabi

Slide 46

Slide 46 text

Inspiration from Enum.map • This code has a potential of 1,000,000 parallelism: • Each element will be transformed by the combination function of 
 foo and bar • There are no dependency between each other 1..1_000_000
 |> Enum.map(&foo(&1))
 |> Enum.map(&bar(&1))

Slide 47

Slide 47 text

GPUs • The State-of-the-art GPUs have 3,000+ SIMD cores with 1.5+GHz clocks

Slide 48

Slide 48 text

↑ Slower ↓ Faster Flow ↑ Slower ↓ Faster Performance of Hastega from Zen is much better than recursive call

Slide 49

Slide 49 text

Hastega makes the most beautiful code to be transformed the fastest!

Slide 50

Slide 50 text

My Previous Talk • Hastega was presented firstly at Lonestar ElixirConf 2019 • Under the view of the world of Wabi-Sabi, consists of Magic, Zen and Samurai • The movie is available at 
 https://youtu.be/lypqlGlK1So 50 © 2019 Susumu Yamazaki & Yuki Hisae

Slide 51

Slide 51 text

Renaming Hastega 51 © 2019 Susumu Yamazaki & Yuki Hisae

Slide 52

Slide 52 text

The Reason to Rename Hastega • We’ll rename Hastega 
 NOT because SQUARE ENIX pressers us to do so. • Because we should respect on it, we thought we should follow the regular procedure to use the name ‘Hastega’. • However, we’ll rename Hastega because we should continue NOT to use the name even with paying the effort, 
 BUT to focus it on research and development. 52 © 2019 Susumu Yamazaki & Yuki Hisae

Slide 53

Slide 53 text

Renaming Method To decide the new name, 
 we read classical literatures, 
 after… 53 © 2019 Susumu Yamazaki & Yuki Hisae

Slide 54

Slide 54 text

© 2019 Susumu Yamazaki & Yuki Hisae Japanese Era: Reiwa © ಺ֳ׭๪಺ֳ޿ใࣨ

Slide 55

Slide 55 text

© 2019 Susumu Yamazaki & Yuki Hisae

Slide 56

Slide 56 text

Renaming Method To decide the new name, 
 we read classical literatures, 
 after Reiwa, 
 the name of the new Japanese era. 56 © 2019 Susumu Yamazaki & Yuki Hisae

Slide 57

Slide 57 text

In the Previous Talk… We made a presentation
 using two symbols:
 Zen and Samurai. 57 © 2019 Susumu Yamazaki & Yuki Hisae

Slide 58

Slide 58 text

The Symbol of Zen and Samurai • There is a suitable symbol including Zen and Samurai, • He is Musashi Miyamoto, 
 the strongest famous Samurai, 
 who also masters Zen. 58 © 2019 Susumu Yamazaki & Yuki Hisae

Slide 59

Slide 59 text

The Duel on Ganryu-jima • The most famous Musashi's duel is with Kojiro Sasaki at the Ganryu-jima (Ganryu island) on Apr. 13th, 1612. 59 © 2019 Susumu Yamazaki & Yuki Hisae

Slide 60

Slide 60 text

60 © 2019 Susumu Yamazaki & Yuki Hisae ʆ Ganryu-Jima Kammon straits
 (between Honshu
 and Kyushu) Kitakyushu city
 (I came from here!) Kyushu Honshu Japan © OpenStreetMap contributors Where is Ganryu-jima ( (\F)?

Slide 61

Slide 61 text

© 2019 Susumu Yamazaki & Yuki Hisae • Musashi was invited by the lord of Kokura-jo, 
 which is in the center of Kitakyushu, 
 but also Kojiro had been invited. • Kojiro and Musashi conflicted many times. • So, they decided to duel at Ganryu-jima to settle the conflict. © nimame

Slide 62

Slide 62 text

© 2019 Susumu Yamazaki & Yuki Hisae • Kojiro used a famous sword, Bizen-Nagamitsu.
 It earned a nickname ‘Monohoshi-zao’ (a cloth pole) 
 because it is so long as a cloth pole.

Slide 63

Slide 63 text

Tsubame-gaeshi ( $S ) • Kojiro’s skill of the sword is named ”Tsubame-gaeshi”, • grip it reversely, • swing the sword, and • flip it down
 as fast as a swallow (Tsubame). 63 © 2019 Susumu Yamazaki & Yuki Hisae

Slide 64

Slide 64 text

© 2019 Susumu Yamazaki & Yuki Hisae • Contrastingly, Musashi used infamous two swords, which are made from hard wooden paddles of a small ship near the duel spot, 
 but one of them is longer than Kojiro’s sword.

Slide 65

Slide 65 text

Strategy 1: Time Control • Kojiro arrived in time (8 o’clock)
 but Musashi was late (around noon) deliberately. • Kojiro was irritated,
 and said “You are late, Musashi. Do you feel cowardly?” 65 © 2019 Susumu Yamazaki & Yuki Hisae

Slide 66

Slide 66 text

Strategy 2: Dazzling • Musashi appeared and stood with his back to the sun. • Kojiro cannot see him well because of glare. 66 © 2019 Susumu Yamazaki & Yuki Hisae

Slide 67

Slide 67 text

Strategy 3: Provocation • Kojiro drew his sword and threw his sheath into the sea. • Then, Musashi said, 
 “You must lose, because a winner never throw his sheath away.” • Kojiro got angry with his words. 67 © 2019 Susumu Yamazaki & Yuki Hisae

Slide 68

Slide 68 text

Strategy 4: Quick Deadly Swing • Kojiro swung his sword and cut Musashi’s forehead, • but at the same time, Musashi jumped, swung his sword down and smashed Kojiro’s body. • Kojiro died immediately. 68 © 2019 Susumu Yamazaki & Yuki Hisae

Slide 69

Slide 69 text

69 © 2019 Susumu Yamazaki & Yuki Hisae • Musashi wrote his masterpiece, • The Book of Five Rings = 
 Five “Elemental Ways” 
 of Bushi-do: 
 Earth(C), Water(<), Fire(&), Wind(P) and Emptiness()) About 40 Years after the duel…

Slide 70

Slide 70 text

So, we decided the new name of Hastega from the concept of 
 the Five “Elemental Ways”. 70 © 2019 Susumu Yamazaki & Yuki Hisae

Slide 71

Slide 71 text

Pelemay = The Penta (Five) “Elemental Way”: 
 Freedom, Insight, Beauty, 
 Efficiency and Robustness 71 © 2019 Susumu Yamazaki & Yuki Hisae

Slide 72

Slide 72 text

This symbol is also similar to Lonestar,
 where I made a presentation at ElixirConf for the first time!!! 72 © 2019 Susumu Yamazaki & Yuki Hisae

Slide 73

Slide 73 text

Freedom (Emptiness: )) • Musashi beat Kojiro, 
 using infamous swords but wooden swords. • He chose weapons without any biases 
 but with consideration on the essence of martial arts. 73 © 2019 Susumu Yamazaki & Yuki Hisae IZJIZ 
 QTI3X
 ɹɹ“Having attained the principles, you leave them; 
 ɹɹfor in the Way of the Martial Arts there is a
 ɹɹnatural freedom.” 
 ɹɹ— The Book of Five Rings (Musashi Miyamoto)

Slide 74

Slide 74 text

Freedom (Emptiness: )) • Transform Elixir Zen styled code into the fastest native code, 
 using all computing resources, • not only multi-core CPUs (with SIMD instructions)
 but also GPUs in all of client, edge and server. • with all of existing parallel and/or distributed computing libraries: CUDA, OpenCL, Metal, OpenBLAS, WebGL, Lumen, etc. 74 © 2019 Susumu Yamazaki & Yuki Hisae

Slide 75

Slide 75 text

Insight (Wind: P) • The reason why Musashi uses wooden swords is that it is necessary • to use a longer sword than Kojiro’s and • to be able to swing quicker • and that he choose lighter material than steel, • which can be obtained near the duel spot and • which has enough hardness to kill a person by only one stroke. 75 © 2019 Susumu Yamazaki & Yuki Hisae

Slide 76

Slide 76 text

Insight (Wind: P) His insight is so freedom
 that he can continue to win all of the battles. 76 © 2019 Susumu Yamazaki & Yuki Hisae • 7/VY._/
 “Develop a discerning eye in all matters”. • V+6 /
 “Understand what cannot be seen by the eye”.
 — The Book of Five Rings (Musashi Miyamoto)

Slide 77

Slide 77 text

Insight (Wind: P) • The user of Pelemay don’t have to be concerned about details
 because Pelemay gains enough insights into 
 and makes full use of 
 code optimization and safety. • Examples of tools for insights:
 Type systems, static analysis, data-level optimization, etc. 77 © 2019 Susumu Yamazaki & Yuki Hisae

Slide 78

Slide 78 text

Beauty (Fire: &) Musashi masters not only Samurai but also Zen. 78 © 2019 Susumu Yamazaki & Yuki Hisae • 7^6
 “Touch upon all of the arts”. • 79IB/
 “Know the Ways of all occupations”. — The Book of Five Rings (Musashi Miyamoto)

Slide 79

Slide 79 text

Beauty (Fire: &) Elixir Zen Style: Programming as Data Transformation Make the most beautiful code to be transformed the fastest code 79 © 2019 Susumu Yamazaki & Yuki Hisae list = 1..1_000_000
 |> Enum.to_list list 
 |> Enum.map(&foo(&1))
 |> Enum.map(&bar(&1))

Slide 80

Slide 80 text

Efficiency (Water: <) Musashi swings quicker than Kojiro,
 reducing idleness in all respects. 80 © 2019 Susumu Yamazaki & Yuki Hisae • W[ / /
 “Do not involve yourself with the impractical”. — The Book of Five Rings (Musashi Miyamoto)

Slide 81

Slide 81 text

Efficiency (Water: <) • Gain enough computational power for Data Explosion • Make the most beautiful code to be transformed the fastest native code without redundancy 81 © 2019 Susumu Yamazaki & Yuki Hisae

Slide 82

Slide 82 text

Robustness (Earth: C) Musashi moves quick but carefully, to hold the initiative. 82 © 2019 Susumu Yamazaki & Yuki Hisae • L%40:8
 “Do not let it speed up even when you are involved in quick actions”. • /]O/
 “Pay attention to even small things”. — The Book of Five Rings (Musashi Miyamoto) This produces robustness to respond any situation.

Slide 83

Slide 83 text

Robustness (Earth: C) • Erlang’s mind: Robustness over untrusted efficiency • The user of Pelemay don’t have to be concerned about details
 because Pelemay produces enough robustness to keep safety. 83 © 2019 Susumu Yamazaki & Yuki Hisae

Slide 84

Slide 84 text

Pelemay = The Penta (Five) “Elemental Way”: 
 Freedom, Insight, Beauty, 
 Efficiency and Robustness 84 © 2019 Susumu Yamazaki & Yuki Hisae

Slide 85

Slide 85 text

New Features: Movie by hisaway 85 © 2019 Susumu Yamazaki & Yuki Hisae

Slide 86

Slide 86 text

Pelemay d/FX'FBUVSFd

Slide 87

Slide 87 text

About Me !2 c:VLJ)JTBF )*4"8": c!IJTBXBZFY c(SBEVBUF4UVEFOU cBU6OJWPG,JUBLZVTIV c$BTUPGGVLVPLBFY c$PBVUIPSPG)BTUFHB Thank Jim!!

Slide 88

Slide 88 text

1. Explain with Sample Code • Parallelization( Example 1 ) • Optimization( Example 2 ) 2. About AST 3. Optimization Steps 4. Restriction Agenda !3

Slide 89

Slide 89 text

Example 1

Slide 90

Slide 90 text

Enum Code w/o Optimization !5 ˎ 2 Example 1 Accelerating... ᶃ ↓ ᶄ ↓ ᶅ ↓ ᶆ ↓ ᶇ ↓ ᶈ ↓ ᶉ ↓ ᶊ ↓ defhastega def list_mult_2(list) do list |> Enum.map(& &1 * 2) end end Not Parallelized nor Accelerated

Slide 91

Slide 91 text

SIMD Parallelization !6 Parallelized by SIMD Instructions ᶃ ᶄ ˎ 2 (Insert arg:2 in c program) Example 1 def list_mult_2(list) do list |> HastegaNif.map_mult end

Slide 92

Slide 92 text

Example 2

Slide 93

Slide 93 text

Enum Code w/o Optimization !8 defhastega end def sample(list) do list |> Enum.map(& &1 * 2) |> Enum.map(& &1 + 1) end Example 2 Accelerating... Not Parallelized nor Accelerated ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ 1 3 4 5 6 7 8 2 ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ 9 11 12 13 14 15 16 10

Slide 94

Slide 94 text

SIMD Parallelization Example 2 def sample(list) do list |> HastegaNif.map_mult |> HastegaNif.map_plus end !9 Parallelized with SIMD Instructions ˎ 2 + 1 Blocked It needs redundant 2 steps of iterations for the calculation!

Slide 95

Slide 95 text

We Need Optimization!

Slide 96

Slide 96 text

Program fusion d/FXGFBUVSFd

Slide 97

Slide 97 text

• One of optimization techniques • It is implemented on GHC Haskell Compiler. • It makes some functions be fused into one function, removing temporary data. Program Fusion !12 We make a prototype of map/map fusion.

Slide 98

Slide 98 text

Fused SIMD Parallelization !13 Parallelized with SIMD Instructions ˎ 2 + 1 • It is faster,
 if cache memory is enough. • It can be calculated
 w/o temporary data Fused SIMD Instructions Example 2 def sample(list) do list |> HastegaNif.map_mult_plus end

Slide 99

Slide 99 text

About AST Though you need knowledge of AST to understand Pelemay mechanism.

Slide 100

Slide 100 text

"CPVU"45 !15 An Abstract Syntax Tree is 
 one of code expressions,
 composed of literals, three-element tuples and lists. 1 + 2 {function, meta, args} Example iex> quote do: 1+2 {:+, [context: Elixir, import: Kernel], [1, 2]} Graphical Notation of ASTʢG.N.ASTʣ

Slide 101

Slide 101 text

"CPVU"45 !16 Example G.N. AST Enum.map &1 1 & ❇ [1, 2, 3] |> iex> quote do: [1, 2, 3] |> Enum.map(& &1 * 2) {:|>, [context: Elixir, import: Kernel], [ [1, 2, 3], {{:., [], [{:__aliases__, [alias: false], [:Enum]}, :map]}, [], [{:&, [], [{:*, [context: Elixir, import: Kernel], [{:&, [], [1]}, 2]}]}]} ]} , using Enum.map

Slide 102

Slide 102 text

/PU'VTFE"45 !17 |> List |> Enum.map &1 + 1 & Enum.map &1 ❇ 2 & list |> Enum.map(& &1 * 2) |> Enum.map(& &1 + 1) Example 2

Slide 103

Slide 103 text

'VTFE"45 !18 Functions in Enum.map are fused into one function. |> |> + & Enum.map &1 1 ❇ & 2 List Enum.map list |> Enum.map(& (&1 * 2) + 1) Fuzed code Example 2

Slide 104

Slide 104 text

Optimization Steps

Slide 105

Slide 105 text

defmodule Sample do end Step 1 ~ 3 !20 defhastega do def list_mult_2(list) do list |> Enum.map( fn x -> x * 2 end ) end end 1. Find Enum.map 2. Analyze Anonymous Functions 3. Register(ETS) following information as Map. %{ module: :enum, function: :map, nif_name: :list_mult_2, args: [x, 2], operators: [ˎ] } &54

Slide 106

Slide 106 text

Step 4,5 !21 4. Insert NIF in the AST Enum.map &1 1 & ❇ [1, 2, 3] |> HastegaNif.map_mult After implement [1, 2, 3] |> 5. Apply Step 1 ~ 4 to each macro

Slide 107

Slide 107 text

Step 6-2 !22 6. Receiving Map from ETS, and ... 6-1. Generate Elixir's functions # This file was generated by Hastega.Generator.Interface defmodule HastegaNif do @on_load :load_nifs def load_nifs do :erlang.load_nif('./priv/libnif', 0) end def map_mult(_arg1), do: raise "NIF map_mult/1 not implemented" end

Slide 108

Slide 108 text

Step6-2 !23 6-2. Generate NIF Code static ERL_NIF_TERM map_mult(ErlNifEnv *env, int argc, const ERL_NIF_TERM argv[]) { ... } - We used loop vectorization. - It is a compile option of LLVM.

Slide 109

Slide 109 text

Step7 !24 7. Compile NIF on Custom Mix Task, using Clang defmodule Mix.Tasks.Compile.Native do use Mix.Task def run(_) do File.mkdir_p("priv") Mix.shell.cmd("make priv/libnif.so") :ok end end lib/mix/tasks/compile/native.ex - Prepare Makefile

Slide 110

Slide 110 text

1. Find Enum.map with a specific macro 2. Analyze internal anonymous functions 3. Register(ETS) following information as Map. 1. Module 2. Original function name 3. Function name for NIF 4. Value of Anonymous Function 4. Insert NIF in AST 5. Do Step 1 ~ 4 to each macro 6. Receiving Map from ETS, and... 1. Generate NIF Code 2. Generate Elixir's functions 7. Compile NIF as Custom Mix Task, using Clang All Procedure !25

Slide 111

Slide 111 text

• Support a sequence of Enum.map including ONLY anonymous functions • That contains ONLY combination of operators, plus(+), minus(-), multiply(*), divide(/) and remainder (rem) Restrictions !26

Slide 112

Slide 112 text

Thank you for listening!

Slide 113

Slide 113 text

New Features: Movie by hisaway 85 © 2019 Susumu Yamazaki & Yuki Hisae

Slide 114

Slide 114 text

Demo 86 © 2019 Susumu Yamazaki & Yuki Hisae

Slide 115

Slide 115 text

Future Roadmap of Research and Development 87 © 2019 Susumu Yamazaki & Yuki Hisae

Slide 116

Slide 116 text

Future work 1 • Pelemay will support existing software libraries such as CUDA, OpenBLAS, OpenCL, Metal, WebGL, Lumen, etc. for Freedom and Efficiency of the five “elemental way”. • It brings more computational power with CPUs and GPUs in all of client, edge and server. • It will work with a brand-new mechanism realized by our original research! 88 © 2019 Susumu Yamazaki & Yuki Hisae

Slide 117

Slide 117 text

© 2019 Susumu Yamazaki & Yuki Hisae © 2019 José Valim is renamed Pelemay

Slide 118

Slide 118 text

Future work 2 • Pelemay will be able to compile not only a sequence of Enum.map with anonymous function that consist of arithmetic operation but also any functions. • Pelemay will act as a high performance compiler of Elixir! 90 © 2019 Susumu Yamazaki & Yuki Hisae

Slide 119

Slide 119 text

Future work 3 • Pelemay will support multi-core CPUs with high efficiency of time and memory. • It will work with a brand-new multi-tasking mechanism realized by our original research! 91 © 2019 Susumu Yamazaki & Yuki Hisae

Slide 120

Slide 120 text

Our Requests to Cooperation 92 © 2019 Susumu Yamazaki & Yuki Hisae

Slide 121

Slide 121 text

Our Requests to Cooperation • We need more profiling data to analyze wider and deeper. • It aims to optimize not only Elixir but also Phoenix and Nerves. • So, we’ll release an optional profiler to adapt Pelemay. • Would you adopt not only Pelemay but also the profiler? 93 © 2019 Susumu Yamazaki & Yuki Hisae

Slide 122

Slide 122 text

Epilogue 94 © 2019 Susumu Yamazaki & Yuki Hisae

Slide 123

Slide 123 text

ElixirConf JP Kokurajo The Approved event will be held on Sep. 7th
 at Kitakyushu (Kokura), Fukuoka, Japan 95 © 2019 Susumu Yamazaki & Yuki Hisae Thank you, Jim!

Slide 124

Slide 124 text

History of Kitakyushu (1/4) • The battle of Dan-no-ura 
 ( A"? ) • The end battle of the Genpei War
 ( ,R-? ) • On Apr. 25th, 1185 • The beginning of the age of Samurai 96 © 2019 Susumu Yamazaki & Yuki Hisae

Slide 125

Slide 125 text

History of Kitakyushu (2/4) • The duel at Ganryu-jima 
 ( (\F*H ) • On Apr. 13th, 1612 • The turning point in the age of Samurai 97 © 2019 Susumu Yamazaki & Yuki Hisae

Slide 126

Slide 126 text

History of Kitakyushu (3/4) • Meiji Restoration 
 ( U2!; ) • The Second Chōshū expedition
 ( @K1D5=G ) • In Summer, 1866 • The Yahata Steel Works
 ( '#NM>E6 ) • The first steelworks of Japan • Opened on Feb. 5th, 1901 • The End of the age of Samurai, and 
 the beginning of the age of industrialization 98 © 2019 Susumu Yamazaki & Yuki Hisae

Slide 127

Slide 127 text

History of Kitakyushu (4/4) On Sep. 7th, 2019 The new age of industrialization!! 99 © 2019 Susumu Yamazaki & Yuki Hisae

Slide 128

Slide 128 text

The Historical Keynote • Why Justin? • I believe Nerves will bring the new revolution to the Japanese manufacturing industries • Kitakyushu has many manufacturing industries • The keynote at Kokurajo will be a symbol of regeneration of all Japanese industries 100 © 2019 Susumu Yamazaki & Yuki Hisae

Slide 129

Slide 129 text

The new age of Elixir, Phoenix, Nerves and Pelemay has come! 101 © 2019 Susumu Yamazaki & Yuki Hisae © 2012 Plataformatec © 2014 Chris McCord © 2015 the Nerves Project developers © 2018 Susumu Yamazaki & Yuki Hisae

Slide 130

Slide 130 text

We’ll be back! to share new research results