Class: OpenCL::Mem
- Inherits:
-
FFI::ManagedStruct
- Object
- FFI::ManagedStruct
- OpenCL::Mem
- Defined in:
- lib/opencl_ruby_ffi/Mem.rb,
lib/opencl_ruby_ffi/opencl_ruby_ffi_base_gen.rb,
lib/opencl_ruby_ffi/opencl_ruby_ffi_base_gen.rb
Overview
Maps the cl_mem object of OpenCL
Defined Under Namespace
Classes: Flags, MigrationFlags, SVMFlags, Type
Constant Summary collapse
- READ_WRITE =
:stopdoc:
(1 << 0)
- WRITE_ONLY =
(1 << 1)
- READ_ONLY =
(1 << 2)
- USE_HOST_PTR =
(1 << 3)
- ALLOC_HOST_PTR =
(1 << 4)
- COPY_HOST_PTR =
(1 << 5)
- HOST_WRITE_ONLY =
(1 << 7)
- HOST_READ_ONLY =
(1 << 8)
- HOST_NO_ACCESS =
(1 << 9)
- SVM_FINE_GRAIN_BUFFER =
(1 << 10)
- SVM_ATOMICS =
(1 << 11)
- BUFFER =
0x10F0- IMAGE2D =
0x10F1- IMAGE3D =
0x10F2- IMAGE2D_ARRAY =
0x10F3- IMAGE1D =
0x10F4- IMAGE1D_ARRAY =
0x10F5- IMAGE1D_BUFFER =
0x10F6- PIPE =
0x10F7- TYPE =
0x1100- FLAGS =
0x1101- SIZE =
0x1102- HOST_PTR =
0x1103- MAP_COUNT =
0x1104- REFERENCE_COUNT =
0x1105- CONTEXT =
0x1106- ASSOCIATED_MEMOBJECT =
0x1107- OFFSET =
0x1108- USES_SVM_POINTER =
0x1109- HOST_UNCACHED_QCOM =
0x40A4- HOST_WRITEBACK_QCOM =
0x40A5- HOST_WRITETHROUGH_QCOM =
0x40A6- HOST_WRITE_COMBINING_QCOM =
0x40A7- ION_HOST_PTR_QCOM =
0x40A8
Class Method Summary collapse
-
.release(ptr) ⇒ Object
method called at Mem deletion, releases the object if aplicable.
Instance Method Summary collapse
-
#associated_memobject ⇒ Object
Returns the Buffer this Buffer was created from using create_sub_buffer.
-
#context ⇒ Object
Returns the Context associated to the Mem.
-
#get_info ⇒ Object
:method: host_ptr() Returns the host Pointer specified at Mem creation or the pointer + the ofsset if it is a sub-buffer.
-
#GL_mimap_level ⇒ Object
Returns the miplevel argument specified in create_from_GL_texture for Mem.
-
#GL_object_name ⇒ Object
Returns the name of the GL object associated with Mem.
-
#GL_object_type ⇒ Object
Returns the type of the GL object associated with Mem.
-
#GL_texture_target ⇒ Object
Returns the texture_target argument specified in create_from_GL_texture for Mem.
-
#initialize(ptr, retain = true) ⇒ Mem
constructor
Creates a new Mem and retains it if specified and aplicable.
-
#platform ⇒ Object
Returns the Platform associated to the Mem.
-
#prop ⇒ Object
:method: reference_count() Returns the Mem reference counter.
-
#set_destructor_callback(options = {}, &proc) ⇒ Object
Attaches a callback to memobj that will be called on the memobj destruction.
-
#to_s ⇒ Object
:startdoc:.
Constructor Details
#initialize(ptr, retain = true) ⇒ Mem
Creates a new Mem and retains it if specified and aplicable
2904 2905 2906 2907 2908 |
# File 'lib/opencl_ruby_ffi/opencl_ruby_ffi_base_gen.rb', line 2904 def initialize(ptr, retain = true) super(ptr) OpenCL.clRetainMemObject(ptr) if retain #STDERR.puts "Allocating Mem: #{ptr}" end |
Class Method Details
.release(ptr) ⇒ Object
method called at Mem deletion, releases the object if aplicable
2911 2912 2913 2914 2915 2916 2917 2918 2919 |
# File 'lib/opencl_ruby_ffi/opencl_ruby_ffi_base_gen.rb', line 2911 def self.release(ptr) #STDERR.puts "Releasing Mem: #{ptr}" #ref_count = FFI::MemoryPointer::new( :cl_uint ) #OpenCL.clGetMemObjectInfo(ptr, OpenCL::Mem::REFERENCE_COUNT, ref_count.size, ref_count, nil) #STDERR.puts "reference counter: #{ref_count.read_cl_uint}" error = OpenCL.clReleaseMemObject(ptr) #STDERR.puts "Object released! #{error}" error_check( error ) end |
Instance Method Details
#associated_memobject ⇒ Object
Returns the Buffer this Buffer was created from using create_sub_buffer
43 44 45 46 47 48 49 |
# File 'lib/opencl_ruby_ffi/Mem.rb', line 43 def associated_memobject ptr = FFI::MemoryPointer::new( Mem ) error = OpenCL.clGetMemObjectInfo(self, ASSOCIATED_MEMOBJECT, Mem.size, ptr, nil) error_check(error) return nil if ptr.read_pointer.null? return Mem::new( ptr.read_pointer ) end |
#context ⇒ Object
Returns the Context associated to the Mem
30 31 32 33 34 35 |
# File 'lib/opencl_ruby_ffi/Mem.rb', line 30 def context ptr = FFI::MemoryPointer::new( Context ) error = OpenCL.clGetMemObjectInfo(self, CONTEXT, Context.size, ptr, nil) error_check(error) return Context::new( ptr.read_pointer ) end |
#get_info ⇒ Object
:method: host_ptr() Returns the host Pointer specified at Mem creation or the pointer + the ofsset if it is a sub-buffer. A null Pointer is returned otherwise.
76 |
# File 'lib/opencl_ruby_ffi/Mem.rb', line 76 eval get_info("Mem", :cl_bool, "USES_SVM_POINTER") |
#GL_mimap_level ⇒ Object
Returns the miplevel argument specified in create_from_GL_texture for Mem
117 118 119 120 121 122 |
# File 'lib/opencl_ruby_ffi/Mem.rb', line 117 def GL_mimap_level param_value = FFI::MemoryPointer::new( :cl_GLint ) error = OpenCL.clGetGLTextureInfo( self, GL_MIPMAP_LEVEL, param_value.size, param_value, nil ) error_check(error) return param_value.read_cl_GLint end |
#GL_object_name ⇒ Object
Returns the name of the GL object associated with Mem
133 134 135 136 137 138 |
# File 'lib/opencl_ruby_ffi/Mem.rb', line 133 def GL_object_name param_value = FFI::MemoryPointer::new( :cl_GLuint ) error = OpenCL.clGetGLObjectInfo( self, nil, param_value ) error_check(error) return param_value.read_cl_GLuint end |
#GL_object_type ⇒ Object
Returns the type of the GL object associated with Mem
125 126 127 128 129 130 |
# File 'lib/opencl_ruby_ffi/Mem.rb', line 125 def GL_object_type param_value = FFI::MemoryPointer::new( :cl_gl_object_type ) error = OpenCL.clGetGLObjectInfo( self, param_value, nil ) error_check(error) return GLObjectType::new(param_value.read_cl_gl_object_type) end |
#GL_texture_target ⇒ Object
Returns the texture_target argument specified in create_from_GL_texture for Mem
109 110 111 112 113 114 |
# File 'lib/opencl_ruby_ffi/Mem.rb', line 109 def GL_texture_target param_value = FFI::MemoryPointer::new( :cl_GLenum ) error = OpenCL.clGetGLTextureInfo( self, GL_TEXTURE_TARGET, param_value.size, param_value, nil ) error_check(error) return param_value.read_cl_GLenum end |
#platform ⇒ Object
Returns the Platform associated to the Mem
38 39 40 |
# File 'lib/opencl_ruby_ffi/Mem.rb', line 38 def platform return self.context.platform end |
#prop ⇒ Object
:method: reference_count() Returns the Mem reference counter
58 59 60 |
# File 'lib/opencl_ruby_ffi/Mem.rb', line 58 %w( OFFSET SIZE ).each { |prop| eval get_info("Mem", :size_t, prop) } |
#set_destructor_callback(options = {}, &proc) ⇒ Object
Attaches a callback to memobj that will be called on the memobj destruction
Attributes
-
options- a hash containing named options -
block- if provided, a callback invoked when memobj is released. Signature of the callback is { |Mem, FFI::Pointer to user_data| … }
Options
-
:user_data- a Pointer (or convertible to Pointer using to_ptr) to the memory area to pass to the callback
103 104 105 106 |
# File 'lib/opencl_ruby_ffi/Mem.rb', line 103 def set_destructor_callback( = {}, &proc ) OpenCL.set_mem_object_destructor_callback( self, , &proc ) return self end |
#to_s ⇒ Object
:startdoc:
2922 2923 2924 2925 2926 2927 2928 |
# File 'lib/opencl_ruby_ffi/opencl_ruby_ffi_base_gen.rb', line 2922 def to_s if self.respond_to?(:name) then return self.name else return super end end |