All Projects → Nanosim-LIG → opencl-ruby

Nanosim-LIG / opencl-ruby

Licence: BSD-2-Clause license
OpenCL bindings for Ruby

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to opencl-ruby

deno bindgen
Simplified glue code generation for Deno FFI libraries written in Rust.
Stars: ✭ 142 (+273.68%)
Mutual labels:  ffi
ffi-clang
Ruby FFI bindings for libclang 3.4+.
Stars: ✭ 41 (+7.89%)
Mutual labels:  ffi
dcurl
Hardware-accelerated Multi-threaded IOTA PoW, drop-in replacement for ccurl
Stars: ✭ 39 (+2.63%)
Mutual labels:  opencl
fpga caffe
No description or website provided.
Stars: ✭ 116 (+205.26%)
Mutual labels:  opencl
lua-resty-openssl
FFI-based OpenSSL binding for OpenResty
Stars: ✭ 76 (+100%)
Mutual labels:  ffi
clr-loader
Loader for different .NET runtimes
Stars: ✭ 16 (-57.89%)
Mutual labels:  ffi
asmdot
[Unstable] Fast, zero-copy and lightweight (Arm | Mips | x86) assembler in (C | C++ | C# | Go | Haskell | Javascript | Nim | OCaml | Python | Rust).
Stars: ✭ 23 (-39.47%)
Mutual labels:  ffi
gr-clenabled
OpenCL/GPU-enabled common blocks for GNURadio
Stars: ✭ 63 (+65.79%)
Mutual labels:  opencl
rust-flutter-reactive
This is a sample app to improve consistency over Mobile App Development.
Stars: ✭ 25 (-34.21%)
Mutual labels:  ffi
nano-vanity
A NANO vanity address generator (supports OpenCL)
Stars: ✭ 83 (+118.42%)
Mutual labels:  opencl
Compiler-Principle
词法分析,LL(1) 文法分析,LR(1) 文法分析
Stars: ✭ 18 (-52.63%)
Mutual labels:  ffi
haskell-libui
Haskell bindings to the libui C library.
Stars: ✭ 45 (+18.42%)
Mutual labels:  ffi
wasm
Utilities for loading and running WASM modules from Dart code
Stars: ✭ 252 (+563.16%)
Mutual labels:  ffi
dlprimitives
Deep Learning Primitives and Mini-Framework for OpenCL
Stars: ✭ 65 (+71.05%)
Mutual labels:  opencl
john-packages
Community packages of John the Ripper (a Docker image, a Flatpak, a Windows PortableApp, and Ubuntu SNAP packages)
Stars: ✭ 31 (-18.42%)
Mutual labels:  opencl
denoffi
Deno Foreign Function Interface.
Stars: ✭ 37 (-2.63%)
Mutual labels:  ffi
ol
Otus Lisp (Ol in short) is a purely* functional dialect of Lisp.
Stars: ✭ 157 (+313.16%)
Mutual labels:  ffi
khiva-python
Python binding for Khiva library.
Stars: ✭ 44 (+15.79%)
Mutual labels:  opencl
Etaler
A flexable HTM (Hierarchical Temporal Memory) framework with full GPU support.
Stars: ✭ 79 (+107.89%)
Mutual labels:  opencl
ProjCL
GPU and vector-enabled map projections, geodesic calculations, and image warping 🌎🌍🌏
Stars: ✭ 81 (+113.16%)
Mutual labels:  opencl

opencl-ruby

Written by Brice Videau, 2013-2014

OpenCL bindings for Ruby

Up to date OpenCL bindings for Ruby. Written using FFI but heavily inspired by Seiya Nishizawa's work on the C bindings.

A gem can be built from this repository: opencl_ruby_ffi which provides the actual bindings.

Documentation can be found here:

https://nanosim-lig.github.io/opencl-ruby/

EXAMPLE:

require 'opencl_ruby_ffi'
require 'narray_ffi'

source = <<EOF
__kernel void addition( float2 alpha, __global const float *x, __global float *y) {
  size_t ig = get_global_id(0);
  y[ig] = (alpha.s0 + alpha.s1 + x[ig])*0.3333333333333333333f;
}
EOF

platform = OpenCL::platforms.first
device = platform.devices.first
context = OpenCL::create_context(device)
queue = context.create_command_queue(device, :properties => OpenCL::CommandQueue::PROFILING_ENABLE)
prog = context.create_program_with_source( source )
prog.build
a_in = NArray.sfloat(65536).random(1.0)
a_out = NArray.sfloat(65536)
f = OpenCL::Float2::new(3.0,2.0)
b_in = context.create_buffer(a_in.size * a_in.element_size, :flags => OpenCL::Mem::COPY_HOST_PTR, :host_ptr => a_in)
b_out = context.create_buffer(a_out.size * a_out.element_size)
event = prog.addition(queue, [65536], f, b_in, b_out, :local_work_size => [128])
# #Or if you want to be more OpenCL like:
# k = prog.create_kernel("addition")
# k.set_arg(0, f)
# k.set_arg(1, b_in)
# k.set_arg(2, b_out)
# event = queue.enqueue_ndrange_kernel(k, [65536],:local_work_size => [128])
queue.enqueue_read_buffer(b_out, a_out, :event_wait_list => [event])
queue.finish
diff = (a_in - a_out*3.0)
65536.times { |i|
  raise "Computation error #{i} : #{diff[i]+f.s0+f.s1}" if (diff[i]+f.s0+f.s1).abs > 0.00001
}
puts "Success!"
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].