Class: OpenCL::Mem

Inherits:
ExtendedStruct show all
Includes:
OpenCL11, OpenCL20
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,
lib/opencl_ruby_ffi/khr/d3d10_sharing.rb,
lib/opencl_ruby_ffi/khr/d3d11_sharing.rb,
lib/opencl_ruby_ffi/khr/dx9_media_sharing.rb

Overview

Maps the cl_mem object of OpenCL

Direct Known Subclasses

Buffer, Image, Pipe

Defined Under Namespace

Modules: OpenCL11, OpenCL20 Classes: Flags, MigrationFlags, SVMFlags, Type

Constant Summary collapse

READ_WRITE =
(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)
KERNEL_READ_AND_WRITE =
(1 << 12)
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
D3D10_RESOURCE_KHR =
0x4015
D3D11_RESOURCE_KHR =
0x401E
DX9_MEDIA_ADAPTER_TYPE_KHR =
0x2028
DX9_MEDIA_SURFACE_INFO_KHR =
0x2029

Instance Method Summary collapse

Methods included from OpenCL20

#uses_svm_pointer

Methods included from OpenCL11

#associated_memobject, #offset, #set_destructor_callback

Methods inherited from ExtendedStruct

register_extension

Constructor Details

#initialize(ptr, retain = true) ⇒ Mem

Creates a new Mem and retains it if specified and aplicable



1201
1202
1203
1204
1205
# File 'lib/opencl_ruby_ffi/opencl_ruby_ffi_base_gen.rb', line 1201

def initialize(ptr, retain = true)
  super(ptr)
  OpenCL.clRetainMemObject(ptr) if retain
  #STDERR.puts "Allocating Mem: #{ptr}"
end

Instance Method Details

#contextObject

Returns the Context associated to the Mem



40
41
42
43
44
45
# File 'lib/opencl_ruby_ffi/Mem.rb', line 40

def context
  ptr = MemoryPointer::new( Context )
  error = OpenCL.clGetMemObjectInfo(self, CONTEXT, Context.size, ptr, nil)
  error_check(error)
  return Context::new( ptr.read_pointer )
end

#flagsObject

Returns the OpenCL::Mem::flags info

Returns:

  • cl_mem_flags



33
# File 'lib/opencl_ruby_ffi/Mem.rb', line 33

get_info("Mem", :cl_mem_flags, "flags")

#gl_mimap_levelObject Also known as: GL_mimap_level

Returns the miplevel argument specified in create_from_GL_texture for Mem



62
63
64
65
66
67
# File 'lib/opencl_ruby_ffi/Mem.rb', line 62

def gl_mimap_level
  param_value = 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_nameObject Also known as: GL_object_name

Returns the name of the GL object associated with Mem



80
81
82
83
84
85
# File 'lib/opencl_ruby_ffi/Mem.rb', line 80

def gl_object_name
  param_value = MemoryPointer::new( :cl_GLuint )
  error = OpenCL.clGetGLObjectInfo( self, nil, param_value )
  error_check(error)
  return param_value.read_cl_GLuint
end

#gl_object_typeObject Also known as: GL_object_type

Returns the type of the GL object associated with Mem



71
72
73
74
75
76
# File 'lib/opencl_ruby_ffi/Mem.rb', line 71

def gl_object_type
  param_value = 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_targetObject Also known as: GL_texture_target

Returns the texture_target argument specified in create_from_GL_texture for Mem



53
54
55
56
57
58
# File 'lib/opencl_ruby_ffi/Mem.rb', line 53

def gl_texture_target
  param_value = 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

#host_ptrObject

Returns the OpenCL::Mem::host_ptr info

Returns:

  • pointer



35
# File 'lib/opencl_ruby_ffi/Mem.rb', line 35

get_info("Mem", :pointer, "host_ptr")

#inspectObject



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

def inspect
  f = flags
  return "#<#{self.class.name}: #{size}#{ 0 != f.to_i ? " (#{f})" : ""}>"
end

#map_countObject

Returns the OpenCL::Mem::map_count info

Returns:

  • cl_uint



36
# File 'lib/opencl_ruby_ffi/Mem.rb', line 36

get_info("Mem", :cl_uint, "map_count")

#platformObject

Returns the Platform associated to the Mem



48
49
50
# File 'lib/opencl_ruby_ffi/Mem.rb', line 48

def platform
  return self.context.platform
end

#reference_countObject

Returns the OpenCL::Mem::reference_count info

Returns:

  • cl_uint



37
# File 'lib/opencl_ruby_ffi/Mem.rb', line 37

get_info("Mem", :cl_uint, "reference_count")

#sizeObject

Returns the OpenCL::Mem::size info

Returns:

  • size_t



34
# File 'lib/opencl_ruby_ffi/Mem.rb', line 34

get_info("Mem", :size_t, "size")

#typeObject

Returns the OpenCL::Mem::type info

Returns:

  • cl_mem_object_type



32
# File 'lib/opencl_ruby_ffi/Mem.rb', line 32

get_info("Mem", :cl_mem_object_type, "type")