Class: OpenCL::Mem

Inherits:
ExtendedStruct show all
Includes:
OpenCL11, OpenCL20, OpenCL30
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,
lib/opencl_ruby_ffi/intel/unified_shared_memory_preview.rb

Overview

Maps the cl_mem object of OpenCL

Direct Known Subclasses

Buffer, Image, Pipe

Defined Under Namespace

Modules: OpenCL11, OpenCL20, OpenCL30 Classes: AdviceINTEL, AllocFlagsINTEL, Flags, MigrationFlags, MigrationFlagsINTEL, SVMFlags, Type, UnifiedSharedMemoryTypeINTEL

Instance Method Summary collapse

Methods included from OpenCL30

#properties

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



1268
1269
1270
1271
1272
# File 'lib/opencl_ruby_ffi/opencl_ruby_ffi_base_gen.rb', line 1268

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



48
49
50
51
52
53
54
55
# File 'lib/opencl_ruby_ffi/Mem.rb', line 48

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

#flagsObject

Returns the OpenCL::Mem::flags info

Returns:

  • cl_mem_flags



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

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

#gl_mimap_levelObject Also known as: GL_mimap_level

Returns the miplevel argument specified in create_from_GL_texture for Mem



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

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



90
91
92
93
94
95
# File 'lib/opencl_ruby_ffi/Mem.rb', line 90

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



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

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



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

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



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

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

#inspectObject



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

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



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

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

#platformObject

Returns the Platform associated to the Mem



58
59
60
# File 'lib/opencl_ruby_ffi/Mem.rb', line 58

def platform
  @_platform ||= self.context.platform
end

#reference_countObject

Returns the OpenCL::Mem::reference_count info

Returns:

  • cl_uint



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

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

#sizeObject

Returns the OpenCL::Mem::size info

Returns:

  • size_t



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

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

#typeObject

Returns the OpenCL::Mem::type info

Returns:

  • cl_mem_object_type



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

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

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
PROPERTIES =
0x110A
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
ALLOC_FLAGS_INTEL =
0x4195
TYPE_UNKNOWN_INTEL =
0x4196
TYPE_HOST_INTEL =
0x4197
TYPE_DEVICE_INTEL =
0x4198
TYPE_SHARED_INTEL =
0x4199
ALLOC_WRITE_COMBINED_INTEL =
(1 << 0)
ALLOC_TYPE_INTEL =
0x419A
ALLOC_BASE_PTR_INTEL =
0x419B
ALLOC_SIZE_INTEL =
0x419C
ALLOC_DEVICE_INTEL =
0x419D
ALLOC_INFO_TBD1_INTEL =
0x419E
ALLOC_INFO_TBD2_INTEL =
0x419F