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
970
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
820
How I made a pure-Ruby word2vec program more than 3x faster
remore
3
2.1k
Code, Arguments and Startups
remore
0
1.4k
詳解🔍Burn🔥
remore
4
5k
DockerCon 2015 Quick Recap
remore
0
380
dockerfileview: A Dockerfile viewer to trace ancestry of the base image
remore
2
390
Burn: 8-Bit Game Development With Ruby
remore
3
660
Other Decks in Technology
See All in Technology
OpenShiftクラスターのアップグレード自動化への挑戦! / OpenShift Cluster Upgrade Automation
skitamura7446
0
210
SignalR を使ったアプリケーション開発をより快適に!
nenonaninu
0
700
書籍を書きました。 そう、VS Codeで。
takumanakagame
4
4.6k
re:Inventの完全招待制イベント Building a Roadmap to SaaSについて / Building a Roadmap to SaaS an invitation only event at reinvent
yayoi_dd
0
150
S3とCloudWatch Logsの見直しから始めるコスト削減 / Cost saving S3 and CloudWatch Logs
shonansurvivors
0
270
目指せCoverage100%! AutoScale環境におけるSavings Plans購入戦略 / JAWS-UG_SRE_Coverage
taishin
0
520
スクラムマスターの悩みどころを赤裸々に告白します
nagata03
0
120
私見「UNIXの考え方」/20230124-kameda-unix-phylosophy
opelab
1
170
NGINXENG JP#2 - 4-NGINX-エンジニアリング勉強会
hiropo20
0
130
データ分析基盤の要件分析の話(202201_JEDAI)
yabooun
0
340
230125 古いタブレットの活用 かーでぃさん
comucal
PRO
0
17k
MarvelClient Upgrade 64bit クライアントへの自動アップグレード設定
mitsuru_katoh
0
190
Featured
See All Featured
Agile that works and the tools we love
rasmusluckow
320
20k
Music & Morning Musume
bryan
37
4.6k
The Brand Is Dead. Long Live the Brand.
mthomps
48
2.9k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
109
16k
Faster Mobile Websites
deanohume
295
29k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
349
27k
Statistics for Hackers
jakevdp
785
210k
Atom: Resistance is Futile
akmur
256
24k
The Invisible Side of Design
smashingmag
292
48k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
7
590
10 Git Anti Patterns You Should be Aware of
lemiorhan
643
54k
Pencils Down: Stop Designing & Start Developing
hursman
114
10k
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!