-
Notifications
You must be signed in to change notification settings - Fork 21
Rubex v0.2 goals
This is a feature list for Rubex v0.2. Priority of the task is marked next to it.
Table of Contents
The GIL inhibits true multi-threading in Ruby. Rubex can be used as a medium for easily releasing the GIL and creating native threads.
The GIL releasing interface of Rubex will have two ways of interaction:
- Have a block named
no_gil
that will contain code that should be executed without the GIL. - Have C functions that will be tagged with
no_gil
and will run like that when invoked.
The second approach is very simple since it mainly involves making some modifications to the C function
Allow rubex programs to interface with GPUs using native CUDA APIs. This is the first priority for release v0.2. All functionality required for this should be implemented before this part is implemented.
Similar to native CUDA kernel support in Julia, we should have support in Ruby.
Since it is tough to augment the Ruby VM to support this, it can be done in an easier way using Rubex and RbCUDA. For example, a sample Rubex method that would compile to a native CUDA kernel can be defined with cudadef and written like this:
require 'rbcuda_native'
require 'rbcuda'
include RbCUDA::Driver
cdef kernel_vadd(a, b, c)
i = threadIdx().x
c[i] = a[i] + b[i]
return
end
# generate some data
len = 512
a = rand(len).to_i
b = rand(len).to_i
# allocate & upload to the GPU
d_a = GPU_Array.new(a)
d_b = GPU_Array.new(b)
d_c = GPU_Array.new(d_a)
# execute and fetch results. compile error is driver is not present.
kernel_vadd<<<cuda(1,len)>>>(d_a, d_b, d_c)
c = d_c.to_cpu_array
The v0.2 release will have things that are necessary for making GPU interfacing as streamlined as possible. Following are the language features that are required for this purpose:
- Support for require
- Support for constant scoping with ::
- Support for method calling-like syntax for Ruby constants.
- Ability to require other rubex files and 'loading' those functions into this file.
- Ability to call any function just like a simple script and not necessarily enclose inside functions.
Sample code:
require 'nokogiri'
def use_nokogiri
n = Nokogiri::HTML(open("index.html"))
puts(page.class)
end