Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
A PoC-ish Trick: LLVM IR Generation with Ruby
remore
November 11, 2016
Technology
1
900
A PoC-ish Trick: LLVM IR Generation with Ruby
A Lightning Talk at RubyConf 2016
remore
November 11, 2016
Tweet
Share
More Decks by remore
See All by remore
Prototyping Kubernetes CRI With Ruby and gRPC
remore
3
790
How I made a pure-Ruby word2vec program more than 3x faster
remore
3
1.9k
Code, Arguments and Startups
remore
0
1.3k
詳解🔍Burn🔥
remore
4
4.9k
DockerCon 2015 Quick Recap
remore
0
370
dockerfileview: A Dockerfile viewer to trace ancestry of the base image
remore
2
370
Burn: 8-Bit Game Development With Ruby
remore
3
630
Other Decks in Technology
See All in Technology
Puny to Powerful PostgreSQL Rails Apps
andyatkinson
PRO
0
210
Microsoft 365の中でのPower BIの利用 / M365VM2022
ishiayaya
0
1.5k
Deeplearning from almost scratch
hn410
0
580
SRENEXT2022 組織にSREを実装していくまでの道のり
marnie0301
1
230
JAWS-UG 朝会 #33 登壇資料
takakuni
0
370
220510 プロセスマイニングを学ぶ PLAY与田さん
comucal
PRO
0
660
New Features in C# 10/11
chack411
0
740
20220510_簡単にできるコスト異常検出(Cost Anomaly Detection) /jaws-ug-asa-cost-anomaly-detection-20220510
emiki
2
310
Power BIのモバイルと都 +1 / Tokyo
ishiayaya
0
140
プロダクトグロースと技術のベースアップを両立させるRettyのアプリ開発スタイル / Achieve Product Growth and Tech Update
imaizume
1
270
⚡Lightdashを試してみた
k_data_analyst
0
140
次期LTSに備えよ!AOS 6.1 HCI Core 編
smzksts
0
170
Featured
See All Featured
Keith and Marios Guide to Fast Websites
keithpitt
404
21k
Visualization
eitanlees
124
11k
How New CSS Is Changing Everything About Graphic Design on the Web
jensimmons
212
11k
What's in a price? How to price your products and services
michaelherold
229
9.3k
No one is an island. Learnings from fostering a developers community.
thoeni
9
1.1k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
498
130k
Code Reviewing Like a Champion
maltzj
506
37k
The Brand Is Dead. Long Live the Brand.
mthomps
45
2.7k
Build your cross-platform service in a week with App Engine
jlugia
219
17k
Six Lessons from altMBA
skipperchong
14
1.3k
The Illustrated Children's Guide to Kubernetes
chrisshort
14
34k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
236
1M
Transcript
A PoC-ish Trick: LLVM IR Generation with Ruby A Lightning
Talk at RubyConf 2016 Kei Sawada (@remore)
None
a modern, fast, and open source language for data science
and technical computing
Julia is 4 years old young Good performance, as fast
as C Dynamic typing Julia has Capability to call C functions directly without wrappers or special APIs a compiler that used LLVM to translate Julia programs into ef cient executable code
In short,
Write some Julia code then you will get LLVM IR
without hassle
debussy:~ guest$ julia _ _ _ _(_)_ | A fresh
approach to technical computin (_) | (_) (_) | Documentation: http://docs.julialang.o _ _ _| |_ __ _ | Type "?help" for help. | | | | | | |/ _` | | | | |_| | | | (_| | | Version 0.4.6 (2016-06-19 17:16 UTC) _/ |\__'_|_|_|\__'_| | |__/ | x86_64-apple-darwin15.5.0 julia>
debussy:~ guest$ julia _ _ _ _(_)_ | A fresh
approach to technical computin (_) | (_) (_) | Documentation: http://docs.julialang.o _ _ _| |_ __ _ | Type "?help" for help. | | | | | | |/ _` | | | | |_| | | | (_| | | Version 0.4.6 (2016-06-19 17:16 UTC) _/ |\__'_|_|_|\__'_| | |__/ | x86_64-apple-darwin15.5.0 julia> function hello() "rubyconf" end hello (generic function with 1 method) julia>
debussy:~ guest$ julia _ _ _ _(_)_ | A fresh
approach to technical computin (_) | (_) (_) | Documentation: http://docs.julialang.o _ _ _| |_ __ _ | Type "?help" for help. | | | | | | |/ _` | | | | |_| | | | (_| | | Version 0.4.6 (2016-06-19 17:16 UTC) _/ |\__'_|_|_|\__'_| | |__/ | x86_64-apple-darwin15.5.0 julia> function hello() "rubyconf" end hello (generic function with 1 method) julia> hello() "rubyconf" julia>
julia> code_llvm(hello, ()) define %jl_value_t* @julia_hello_21549() { top: ret %jl_value_t*
inttoptr (i64 4447575696 to %jl_value_t*) } julia>
julia> code_llvm(hello, ()) define %jl_value_t* @julia_hello_21549() { top: ret %jl_value_t*
inttoptr (i64 4447575696 to %jl_value_t*) } julia> code_native(hello, ()) .section __TEXT,__text,regular,pure_instructions Filename: none Source line: 2 pushq %rbp movq %rsp, %rbp movabsq $4447575696, %rax ## imm = 0x109189E90 Source line: 2 popq %rbp ret julia>
OK Julia is a thing But we are in
None
What if
You can write some Ruby code which can be translated
into Julia where you can get LLVM IR easily?
Ruby -> Julia -> LLVM IR
None
Julializer Allow you to convert your arbitrary Ruby code into
Julia code
Time to DEMO!
For more examples and attempts, check out: github.com/remore/julializer github.com/remore/virtual_module Thanks!