Module: CooCoo::CUDA::DeviceBuffer::FFI
- Extended by:
- FFI::Library
- Defined in:
- lib/coo-coo/cuda/device_buffer/ffi.rb
Class Method Summary collapse
- .buffer_function(*args) ⇒ Object
- .call_buffer(func, *args) ⇒ Object
- .call_func(func, *args) ⇒ Object
Class Method Details
.buffer_function(*args) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/coo-coo/cuda/device_buffer/ffi.rb', line 11 def self.buffer_function(*args) if args.size == 3 func, args, return_type = args meth = func elsif args.size == 4 meth, func, args, return_type = args else raise ArgumentError.new("Wrong number of arguments: (given #{args.size}, expected 3 or 4") end attach_function("buffer_#{func}", args, return_type) caller = if return_type.kind_of?(Symbol) :call_func else :call_buffer end class_eval <<-EOT def self.#{meth}(*call_args) #{caller}(:#{func}, *call_args) end EOT end |
.call_buffer(func, *args) ⇒ Object
95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/coo-coo/cuda/device_buffer/ffi.rb', line 95 def self.call_buffer(func, *args) retries = 0 r = send("buffer_#{func}", *args) raise NullResultError.new if r.null? r rescue NullResultError raise if retries > 1 retries += 1 CUDA.collect_garbage retry end |