Class: OpenCL::SVMPointer

Inherits:
Pointer
  • Object
show all
Defined in:
lib/opencl_ruby_ffi/SVM.rb

Overview

maps the SVM pointer type

Instance Method Summary collapse

Constructor Details

#initialize(address, context, base = nil) ⇒ SVMPointer

create a new SVMPointer from its address and the context it pertains to



8
9
10
11
12
13
14
15
16
# File 'lib/opencl_ruby_ffi/SVM.rb', line 8

def initialize( address, context, base = nil )
  super( address )
  @context = context
  if base then
    @base = base
  else
    @base = address
  end
end

Instance Method Details

#+(offset) ⇒ Object

creates a new SVMPointer relative to an existing one from an offset



28
29
30
# File 'lib/opencl_ruby_ffi/SVM.rb', line 28

def +( offset )
  self.slice(offset, self.size - offset)
end

#freeObject

frees the parent memory region associated to this SVMPointer



33
34
35
# File 'lib/opencl_ruby_ffi/SVM.rb', line 33

def free
  return OpenCL::svm_free( @context, @base )
end

#inspectObject



18
19
20
# File 'lib/opencl_ruby_ffi/SVM.rb', line 18

def inspect
  return "#<#{self.class.name}: 0x#{address.to_s(16)} (#{size})>"
end

#slice(offset, size) ⇒ Object



22
23
24
25
# File 'lib/opencl_ruby_ffi/SVM.rb', line 22

def slice(offset, size)
  res = super(offset, size)
  return slef.class.new( res, @context, @base )
end