A Lightning Talk at RubyConf 2016
A PoC-ish Trick: LLVM IRGeneration with RubyA Lightning Talk at RubyConf 2016Kei Sawada (@remore)
View Slide
a modern, fast, and open source language fordata science and technical computing
Julia is4 years old youngGood performance, as fast as CDynamic typingJulia hasCapability to call C functions directly withoutwrappers or special APIsa compiler that used LLVM to translate Juliaprograms into ef cient executable code
In short,
Write some Julia code then youwill 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.0julia>
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.0julia> function hello()"rubyconf"endhello (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.0julia> function hello()"rubyconf"endhello (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_instructionsFilename: noneSource line: 2pushq %rbpmovq %rsp, %rbpmovabsq $4447575696, %rax ## imm = 0x109189E90Source line: 2popq %rbpretjulia>
OK Julia is a thingBut we are in
What if
You can write some Ruby codewhich can be translated into Juliawhere you can get LLVM IR easily?
Ruby -> Julia -> LLVM IR
JulializerAllow you to convert your arbitraryRuby code into Julia code
Time to DEMO!
For more examples and attempts, check out:github.com/remore/julializergithub.com/remore/virtual_moduleThanks!