Module: OpenCL
- Extended by:
- FFI::Library
- Defined in:
- lib/opencl_ruby_ffi/opencl_ruby_ffi_base.rb,
lib/opencl_ruby_ffi/Mem.rb,
lib/opencl_ruby_ffi/SVM.rb,
lib/opencl_ruby_ffi/Pipe.rb,
lib/opencl_ruby_ffi/Event.rb,
lib/opencl_ruby_ffi/Image.rb,
lib/opencl_ruby_ffi/Buffer.rb,
lib/opencl_ruby_ffi/Device.rb,
lib/opencl_ruby_ffi/Kernel.rb,
lib/opencl_ruby_ffi/Context.rb,
lib/opencl_ruby_ffi/Program.rb,
lib/opencl_ruby_ffi/Sampler.rb,
lib/opencl_ruby_ffi/Platform.rb,
lib/opencl_ruby_ffi/CommandQueue.rb,
lib/opencl_ruby_ffi/Arithmetic_gen.rb,
lib/opencl_ruby_ffi/opencl_ruby_ffi_base_gen.rb
Overview
Maps the OpenCL API using FFI.
Defined Under Namespace
Classes: AddressingMode, Bitfield, Buffer, BufferRegion, BuildStatus, ChannelOrder, ChannelType, Char, Char16, Char2, Char4, Char8, CommandExecutionStatus, CommandQueue, CommandType, Context, Device, Double, Double16, Double2, Double4, Double8, Enum, EnumInt, Error, Event, FilterMode, Float, Float16, Float2, Float4, Float8, GLObjectType, GLsync, Half, Half16, Half2, Half4, Half8, Image, ImageDesc, ImageFormat, Int, Int16, Int2, Int4, Int8, Kernel, Long, Long16, Long2, Long4, Long8, MapFlags, Mem, Pipe, Platform, Program, SVMPointer, Sampler, Short, Short16, Short2, Short4, Short8, UChar, UChar16, UChar2, UChar4, UChar8, UInt, UInt16, UInt2, UInt4, UInt8, ULong, ULong16, ULong2, ULong4, ULong8, UShort, UShort16, UShort2, UShort4, UShort8
Constant Summary collapse
- SUCCESS =
:stopdoc:
0
- DEVICE_NOT_FOUND =
-1
- DEVICE_NOT_AVAILABLE =
-2
- COMPILER_NOT_AVAILABLE =
-3
- MEM_OBJECT_ALLOCATION_FAILURE =
-4
- OUT_OF_RESOURCES =
-5
- OUT_OF_HOST_MEMORY =
-6
- PROFILING_INFO_NOT_AVAILABLE =
-7
- MEM_COPY_OVERLAP =
-8
- IMAGE_FORMAT_MISMATCH =
-9
- IMAGE_FORMAT_NOT_SUPPORTED =
-10
- BUILD_PROGRAM_FAILURE =
-11
- MAP_FAILURE =
-12
- MISALIGNED_SUB_BUFFER_OFFSET =
-13
- EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST =
-14
- COMPILE_PROGRAM_FAILURE =
-15
- LINKER_NOT_AVAILABLE =
-16
- LINK_PROGRAM_FAILURE =
-17
- DEVICE_PARTITION_FAILED =
-18
- KERNEL_ARG_INFO_NOT_AVAILABLE =
-19
- INVALID_VALUE =
-30
- INVALID_DEVICE_TYPE =
-31
- INVALID_PLATFORM =
-32
- INVALID_DEVICE =
-33
- INVALID_CONTEXT =
-34
- INVALID_QUEUE_PROPERTIES =
-35
- INVALID_COMMAND_QUEUE =
-36
- INVALID_HOST_PTR =
-37
- INVALID_MEM_OBJECT =
-38
- INVALID_IMAGE_FORMAT_DESCRIPTOR =
-39
- INVALID_IMAGE_SIZE =
-40
- INVALID_SAMPLER =
-41
- INVALID_BINARY =
-42
- INVALID_BUILD_OPTIONS =
-43
- INVALID_PROGRAM =
-44
- INVALID_PROGRAM_EXECUTABLE =
-45
- INVALID_KERNEL_NAME =
-46
- INVALID_KERNEL_DEFINITION =
-47
- INVALID_KERNEL =
-48
- INVALID_ARG_INDEX =
-49
- INVALID_ARG_VALUE =
-50
- INVALID_ARG_SIZE =
-51
- INVALID_KERNEL_ARGS =
-52
- INVALID_WORK_DIMENSION =
-53
- INVALID_WORK_GROUP_SIZE =
-54
- INVALID_WORK_ITEM_SIZE =
-55
- INVALID_GLOBAL_OFFSET =
-56
- INVALID_EVENT_WAIT_LIST =
-57
- INVALID_EVENT =
-58
- INVALID_OPERATION =
-59
- INVALID_GL_OBJECT =
-60
- INVALID_BUFFER_SIZE =
-61
- INVALID_MIP_LEVEL =
-62
- INVALID_GLOBAL_WORK_SIZE =
-63
- INVALID_PROPERTY =
-64
- INVALID_IMAGE_DESCRIPTOR =
-65
- INVALID_COMPILER_OPTIONS =
-66
- INVALID_LINKER_OPTIONS =
-67
- INVALID_DEVICE_PARTITION_COUNT =
-68
- INVALID_PIPE_SIZE =
-69
- INVALID_DEVICE_QUEUE =
-70
- VERSION_1_0 =
1
- VERSION_1_1 =
1
- VERSION_1_2 =
1
- VERSION_2_0 =
1
- FALSE =
0
- TRUE =
1
- BLOCKING =
TRUE
- NON_BLOCKING =
FALSE
- PLATFORM_PROFILE =
0x0900
- PLATFORM_VERSION =
0x0901
- PLATFORM_NAME =
0x0902
- PLATFORM_VENDOR =
0x0903
- PLATFORM_EXTENSIONS =
0x0904
- DEVICE_TYPE_DEFAULT =
(1 << 0)
- DEVICE_TYPE_CPU =
(1 << 1)
- DEVICE_TYPE_GPU =
(1 << 2)
- DEVICE_TYPE_ACCELERATOR =
(1 << 3)
- DEVICE_TYPE_CUSTOM =
(1 << 4)
- DEVICE_TYPE_ALL =
0xFFFFFFFF
- DEVICE_TYPE =
0x1000
- DEVICE_VENDOR_ID =
0x1001
- DEVICE_MAX_COMPUTE_UNITS =
0x1002
- DEVICE_MAX_WORK_ITEM_DIMENSIONS =
0x1003
- DEVICE_MAX_WORK_GROUP_SIZE =
0x1004
- DEVICE_MAX_WORK_ITEM_SIZES =
0x1005
- DEVICE_PREFERRED_VECTOR_WIDTH_CHAR =
0x1006
- DEVICE_PREFERRED_VECTOR_WIDTH_SHORT =
0x1007
- DEVICE_PREFERRED_VECTOR_WIDTH_INT =
0x1008
- DEVICE_PREFERRED_VECTOR_WIDTH_LONG =
0x1009
- DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT =
0x100A
- DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE =
0x100B
- DEVICE_MAX_CLOCK_FREQUENCY =
0x100C
- DEVICE_ADDRESS_BITS =
0x100D
- DEVICE_MAX_READ_IMAGE_ARGS =
0x100E
- DEVICE_MAX_WRITE_IMAGE_ARGS =
0x100F
- DEVICE_MAX_MEM_ALLOC_SIZE =
0x1010
- DEVICE_IMAGE2D_MAX_WIDTH =
0x1011
- DEVICE_IMAGE2D_MAX_HEIGHT =
0x1012
- DEVICE_IMAGE3D_MAX_WIDTH =
0x1013
- DEVICE_IMAGE3D_MAX_HEIGHT =
0x1014
- DEVICE_IMAGE3D_MAX_DEPTH =
0x1015
- DEVICE_IMAGE_SUPPORT =
0x1016
- DEVICE_MAX_PARAMETER_SIZE =
0x1017
- DEVICE_MAX_SAMPLERS =
0x1018
- DEVICE_MEM_BASE_ADDR_ALIGN =
0x1019
- DEVICE_MIN_DATA_TYPE_ALIGN_SIZE =
0x101A
- DEVICE_SINGLE_FP_CONFIG =
0x101B
- DEVICE_GLOBAL_MEM_CACHE_TYPE =
0x101C
- DEVICE_GLOBAL_MEM_CACHELINE_SIZE =
0x101D
- DEVICE_GLOBAL_MEM_CACHE_SIZE =
0x101E
- DEVICE_GLOBAL_MEM_SIZE =
0x101F
- DEVICE_MAX_CONSTANT_BUFFER_SIZE =
0x1020
- DEVICE_MAX_CONSTANT_ARGS =
0x1021
- DEVICE_LOCAL_MEM_TYPE =
0x1022
- DEVICE_LOCAL_MEM_SIZE =
0x1023
- DEVICE_ERROR_CORRECTION_SUPPORT =
0x1024
- DEVICE_PROFILING_TIMER_RESOLUTION =
0x1025
- DEVICE_ENDIAN_LITTLE =
0x1026
- DEVICE_AVAILABLE =
0x1027
- DEVICE_COMPILER_AVAILABLE =
0x1028
- DEVICE_EXECUTION_CAPABILITIES =
0x1029
- DEVICE_QUEUE_PROPERTIES =
0x102A
- DEVICE_QUEUE_ON_HOST_PROPERTIES =
0x102A
- DEVICE_NAME =
0x102B
- DEVICE_VENDOR =
0x102C
- DRIVER_VERSION =
0x102D
- DEVICE_PROFILE =
0x102E
- DEVICE_VERSION =
0x102F
- DEVICE_EXTENSIONS =
0x1030
- DEVICE_PLATFORM =
0x1031
- DEVICE_DOUBLE_FP_CONFIG =
0x1032
- DEVICE_PREFERRED_VECTOR_WIDTH_HALF =
0x1034
- DEVICE_HOST_UNIFIED_MEMORY =
0x1035
- DEVICE_NATIVE_VECTOR_WIDTH_CHAR =
0x1036
- DEVICE_NATIVE_VECTOR_WIDTH_SHORT =
0x1037
- DEVICE_NATIVE_VECTOR_WIDTH_INT =
0x1038
- DEVICE_NATIVE_VECTOR_WIDTH_LONG =
0x1039
- DEVICE_NATIVE_VECTOR_WIDTH_FLOAT =
0x103A
- DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE =
0x103B
- DEVICE_NATIVE_VECTOR_WIDTH_HALF =
0x103C
- DEVICE_OPENCL_C_VERSION =
0x103D
- DEVICE_LINKER_AVAILABLE =
0x103E
- DEVICE_BUILT_IN_KERNELS =
0x103F
- DEVICE_IMAGE_MAX_BUFFER_SIZE =
0x1040
- DEVICE_IMAGE_MAX_ARRAY_SIZE =
0x1041
- DEVICE_PARENT_DEVICE =
0x1042
- DEVICE_PARTITION_MAX_SUB_DEVICES =
0x1043
- DEVICE_PARTITION_PROPERTIES =
0x1044
- DEVICE_PARTITION_AFFINITY_DOMAIN =
0x1045
- DEVICE_PARTITION_TYPE =
0x1046
- DEVICE_REFERENCE_COUNT =
0x1047
- DEVICE_PREFERRED_INTEROP_USER_SYNC =
0x1048
- DEVICE_PRINTF_BUFFER_SIZE =
0x1049
- DEVICE_IMAGE_PITCH_ALIGNMENT =
0x104A
- DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT =
0x104B
- DEVICE_MAX_READ_WRITE_IMAGE_ARGS =
0x104C
- DEVICE_MAX_GLOBAL_VARIABLE_SIZE =
0x104D
- DEVICE_QUEUE_ON_DEVICE_PROPERTIES =
0x104E
- DEVICE_QUEUE_ON_DEVICE_PREFERRED_SIZE =
0x104F
- DEVICE_QUEUE_ON_DEVICE_MAX_SIZE =
0x1050
- DEVICE_MAX_ON_DEVICE_QUEUES =
0x1051
- DEVICE_MAX_ON_DEVICE_EVENTS =
0x1052
- DEVICE_SVM_CAPABILITIES =
0x1053
- DEVICE_GLOBAL_VARIABLE_PREFERRED_TOTAL_SIZE =
0x1054
- DEVICE_MAX_PIPE_ARGS =
0x1055
- DEVICE_PIPE_MAX_ACTIVE_RESERVATIONS =
0x1056
- DEVICE_PIPE_MAX_PACKET_SIZE =
0x1057
- DEVICE_PREFERRED_PLATFORM_ATOMIC_ALIGNMENT =
0x1058
- DEVICE_PREFERRED_GLOBAL_ATOMIC_ALIGNMENT =
0x1059
- DEVICE_PREFERRED_LOCAL_ATOMIC_ALIGNMENT =
0x105A
- FP_DENORM =
(1 << 0)
- FP_INF_NAN =
(1 << 1)
- FP_ROUND_TO_NEAREST =
(1 << 2)
- FP_ROUND_TO_ZERO =
(1 << 3)
- FP_ROUND_TO_INF =
(1 << 4)
- FP_FMA =
(1 << 5)
- FP_SOFT_FLOAT =
(1 << 6)
- FP_CORRECTLY_ROUNDED_DIVIDE_SQRT =
(1 << 7)
- NONE =
0x0
- READ_ONLY_CACHE =
0x1
- READ_WRITE_CACHE =
0x2
- LOCAL =
0x1
- GLOBAL =
0x2
- EXEC_KERNEL =
(1 << 0)
- EXEC_NATIVE_KERNEL =
(1 << 1)
- QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE =
(1 << 0)
- QUEUE_PROFILING_ENABLE =
(1 << 1)
- QUEUE_ON_DEVICE =
(1 << 2)
- QUEUE_ON_DEVICE_DEFAULT =
(1 << 3)
- CONTEXT_REFERENCE_COUNT =
0x1080
- CONTEXT_DEVICES =
0x1081
- CONTEXT_PROPERTIES =
0x1082
- CONTEXT_NUM_DEVICES =
0x1083
- CONTEXT_PLATFORM =
0x1084
- CONTEXT_INTEROP_USER_SYNC =
0x1085
- DEVICE_PARTITION_EQUALLY =
0x1086
- DEVICE_PARTITION_BY_COUNTS =
0x1087
- DEVICE_PARTITION_BY_COUNTS_LIST_END =
0x0
- DEVICE_PARTITION_BY_AFFINITY_DOMAIN =
0x1088
- DEVICE_AFFINITY_DOMAIN_NUMA =
(1 << 0)
- DEVICE_AFFINITY_DOMAIN_L4_CACHE =
(1 << 1)
- DEVICE_AFFINITY_DOMAIN_L3_CACHE =
(1 << 2)
- DEVICE_AFFINITY_DOMAIN_L2_CACHE =
(1 << 3)
- DEVICE_AFFINITY_DOMAIN_L1_CACHE =
(1 << 4)
- DEVICE_AFFINITY_DOMAIN_NEXT_PARTITIONABLE =
(1 << 5)
- DEVICE_SVM_COARSE_GRAIN_BUFFER =
(1 << 0)
- DEVICE_SVM_FINE_GRAIN_BUFFER =
(1 << 1)
- DEVICE_SVM_FINE_GRAIN_SYSTEM =
(1 << 2)
- DEVICE_SVM_ATOMICS =
(1 << 3)
- QUEUE_CONTEXT =
0x1090
- QUEUE_DEVICE =
0x1091
- QUEUE_REFERENCE_COUNT =
0x1092
- QUEUE_PROPERTIES =
0x1093
- QUEUE_SIZE =
0x1094
- MEM_READ_WRITE =
(1 << 0)
- MEM_WRITE_ONLY =
(1 << 1)
- MEM_READ_ONLY =
(1 << 2)
- MEM_USE_HOST_PTR =
(1 << 3)
- MEM_ALLOC_HOST_PTR =
(1 << 4)
- MEM_COPY_HOST_PTR =
(1 << 5)
- MEM_HOST_WRITE_ONLY =
(1 << 7)
- MEM_HOST_READ_ONLY =
(1 << 8)
- MEM_HOST_NO_ACCESS =
(1 << 9)
- MEM_SVM_FINE_GRAIN_BUFFER =
(1 << 10)
- MEM_SVM_ATOMICS =
(1 << 11)
- MIGRATE_MEM_OBJECT_HOST =
(1 << 0)
- MIGRATE_MEM_OBJECT_CONTENT_UNDEFINED =
(1 << 1)
- R =
0x10B0
- A =
0x10B1
- RG =
0x10B2
- RA =
0x10B3
- RGB =
0x10B4
- RGBA =
0x10B5
- BGRA =
0x10B6
- ARGB =
0x10B7
- INTENSITY =
0x10B8
- LUMINANCE =
0x10B9
- Rx =
0x10BA
- RGx =
0x10BB
- RGBx =
0x10BC
- DEPTH =
0x10BD
- DEPTH_STENCIL =
0x10BE
- ABGR =
0x10C3
- SNORM_INT8 =
0x10D0
- SNORM_INT16 =
0x10D1
- UNORM_INT8 =
0x10D2
- UNORM_INT16 =
0x10D3
- UNORM_SHORT_565 =
0x10D4
- UNORM_SHORT_555 =
0x10D5
- UNORM_INT_101010 =
0x10D6
- SIGNED_INT8 =
0x10D7
- SIGNED_INT16 =
0x10D8
- SIGNED_INT32 =
0x10D9
- UNSIGNED_INT8 =
0x10DA
- UNSIGNED_INT16 =
0x10DB
- UNSIGNED_INT32 =
0x10DC
- HALF_FLOAT =
0x10DD
- FLOAT =
0x10DE
- UNORM_INT24 =
0x10DF
- MEM_OBJECT_BUFFER =
0x10F0
- MEM_OBJECT_IMAGE2D =
0x10F1
- MEM_OBJECT_IMAGE3D =
0x10F2
- MEM_OBJECT_IMAGE2D_ARRAY =
0x10F3
- MEM_OBJECT_IMAGE1D =
0x10F4
- MEM_OBJECT_IMAGE1D_ARRAY =
0x10F5
- MEM_OBJECT_IMAGE1D_BUFFER =
0x10F6
- MEM_OBJECT_PIPE =
0x10F7
- MEM_TYPE =
0x1100
- MEM_FLAGS =
0x1101
- MEM_SIZE =
0x1102
- MEM_HOST_PTR =
0x1103
- MEM_MAP_COUNT =
0x1104
- MEM_REFERENCE_COUNT =
0x1105
- MEM_CONTEXT =
0x1106
- MEM_ASSOCIATED_MEMOBJECT =
0x1107
- MEM_OFFSET =
0x1108
- MEM_USES_SVM_POINTER =
0x1109
- IMAGE_FORMAT =
0x1110
- IMAGE_ELEMENT_SIZE =
0x1111
- IMAGE_ROW_PITCH =
0x1112
- IMAGE_SLICE_PITCH =
0x1113
- IMAGE_WIDTH =
0x1114
- IMAGE_HEIGHT =
0x1115
- IMAGE_DEPTH =
0x1116
- IMAGE_ARRAY_SIZE =
0x1117
- IMAGE_BUFFER =
0x1118
- IMAGE_NUM_MIP_LEVELS =
0x1119
- IMAGE_NUM_SAMPLES =
0x111A
- PIPE_PACKET_SIZE =
0x1120
- PIPE_MAX_PACKETS =
0x1121
- ADDRESS_NONE =
0x1130
- ADDRESS_CLAMP_TO_EDGE =
0x1131
- ADDRESS_CLAMP =
0x1132
- ADDRESS_REPEAT =
0x1133
- ADDRESS_MIRRORED_REPEAT =
0x1134
- FILTER_NEAREST =
0x1140
- FILTER_LINEAR =
0x1141
- SAMPLER_REFERENCE_COUNT =
0x1150
- SAMPLER_CONTEXT =
0x1151
- SAMPLER_NORMALIZED_COORDS =
0x1152
- SAMPLER_ADDRESSING_MODE =
0x1153
- SAMPLER_FILTER_MODE =
0x1154
- SAMPLER_MIP_FILTER_MODE =
0x1155
- SAMPLER_LOD_MIN =
0x1156
- SAMPLER_LOD_MAX =
0x1157
- MAP_READ =
(1 << 0)
- MAP_WRITE =
(1 << 1)
- MAP_WRITE_INVALIDATE_REGION =
(1 << 2)
- PROGRAM_REFERENCE_COUNT =
0x1160
- PROGRAM_CONTEXT =
0x1161
- PROGRAM_NUM_DEVICES =
0x1162
- PROGRAM_DEVICES =
0x1163
- PROGRAM_SOURCE =
0x1164
- PROGRAM_BINARY_SIZES =
0x1165
- PROGRAM_BINARIES =
0x1166
- PROGRAM_NUM_KERNELS =
0x1167
- PROGRAM_KERNEL_NAMES =
0x1168
- PROGRAM_BUILD_STATUS =
0x1181
- PROGRAM_BUILD_OPTIONS =
0x1182
- PROGRAM_BUILD_LOG =
0x1183
- PROGRAM_BINARY_TYPE =
0x1184
- PROGRAM_BUILD_GLOBAL_VARIABLE_TOTAL_SIZE =
0x1185
- PROGRAM_BINARY_TYPE_NONE =
0x0
- PROGRAM_BINARY_TYPE_COMPILED_OBJECT =
0x1
- PROGRAM_BINARY_TYPE_LIBRARY =
0x2
- PROGRAM_BINARY_TYPE_EXECUTABLE =
0x4
- BUILD_SUCCESS =
0
- BUILD_NONE =
-1
- BUILD_ERROR =
-2
- BUILD_IN_PROGRESS =
-3
- KERNEL_FUNCTION_NAME =
0x1190
- KERNEL_NUM_ARGS =
0x1191
- KERNEL_REFERENCE_COUNT =
0x1192
- KERNEL_CONTEXT =
0x1193
- KERNEL_PROGRAM =
0x1194
- KERNEL_ATTRIBUTES =
0x1195
- KERNEL_ARG_ADDRESS_QUALIFIER =
0x1196
- KERNEL_ARG_ACCESS_QUALIFIER =
0x1197
- KERNEL_ARG_TYPE_NAME =
0x1198
- KERNEL_ARG_TYPE_QUALIFIER =
0x1199
- KERNEL_ARG_NAME =
0x119A
- KERNEL_ARG_ADDRESS_GLOBAL =
0x119B
- KERNEL_ARG_ADDRESS_LOCAL =
0x119C
- KERNEL_ARG_ADDRESS_CONSTANT =
0x119D
- KERNEL_ARG_ADDRESS_PRIVATE =
0x119E
- KERNEL_ARG_ACCESS_READ_ONLY =
0x11A0
- KERNEL_ARG_ACCESS_WRITE_ONLY =
0x11A1
- KERNEL_ARG_ACCESS_READ_WRITE =
0x11A2
- KERNEL_ARG_ACCESS_NONE =
0x11A3
- KERNEL_ARG_TYPE_NONE =
0
- KERNEL_ARG_TYPE_CONST =
(1 << 0)
- KERNEL_ARG_TYPE_RESTRICT =
(1 << 1)
- KERNEL_ARG_TYPE_VOLATILE =
(1 << 2)
- KERNEL_ARG_TYPE_PIPE =
(1 << 3)
- KERNEL_WORK_GROUP_SIZE =
0x11B0
- KERNEL_COMPILE_WORK_GROUP_SIZE =
0x11B1
- KERNEL_LOCAL_MEM_SIZE =
0x11B2
- KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE =
0x11B3
- KERNEL_PRIVATE_MEM_SIZE =
0x11B4
- KERNEL_GLOBAL_WORK_SIZE =
0x11B5
- KERNEL_EXEC_INFO_SVM_PTRS =
0x11B6
- KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM =
0x11B7
- EVENT_COMMAND_QUEUE =
0x11D0
- EVENT_COMMAND_TYPE =
0x11D1
- EVENT_REFERENCE_COUNT =
0x11D2
- EVENT_COMMAND_EXECUTION_STATUS =
0x11D3
- EVENT_CONTEXT =
0x11D4
- COMMAND_NDRANGE_KERNEL =
0x11F0
- COMMAND_TASK =
0x11F1
- COMMAND_NATIVE_KERNEL =
0x11F2
- COMMAND_READ_BUFFER =
0x11F3
- COMMAND_WRITE_BUFFER =
0x11F4
- COMMAND_COPY_BUFFER =
0x11F5
- COMMAND_READ_IMAGE =
0x11F6
- COMMAND_WRITE_IMAGE =
0x11F7
- COMMAND_COPY_IMAGE =
0x11F8
- COMMAND_COPY_IMAGE_TO_BUFFER =
0x11F9
- COMMAND_COPY_BUFFER_TO_IMAGE =
0x11FA
- COMMAND_MAP_BUFFER =
0x11FB
- COMMAND_MAP_IMAGE =
0x11FC
- COMMAND_UNMAP_MEM_OBJECT =
0x11FD
- COMMAND_MARKER =
0x11FE
- COMMAND_ACQUIRE_GL_OBJECTS =
0x11FF
- COMMAND_RELEASE_GL_OBJECTS =
0x1200
- COMMAND_READ_BUFFER_RECT =
0x1201
- COMMAND_WRITE_BUFFER_RECT =
0x1202
- COMMAND_COPY_BUFFER_RECT =
0x1203
- COMMAND_USER =
0x1204
- COMMAND_BARRIER =
0x1205
- COMMAND_MIGRATE_MEM_OBJECTS =
0x1206
- COMMAND_FILL_BUFFER =
0x1207
- COMMAND_FILL_IMAGE =
0x1208
- COMMAND_SVM_FREE =
0x1209
- COMMAND_SVM_MEMCPY =
0x120A
- COMMAND_SVM_MEMFILL =
0x120B
- COMMAND_SVM_MAP =
0x120C
- COMMAND_SVM_UNMAP =
0x120D
- COMPLETE =
0x0
- RUNNING =
0x1
- SUBMITTED =
0x2
- QUEUED =
0x3
- BUFFER_CREATE_TYPE_REGION =
0x1220
- PROFILING_COMMAND_QUEUED =
0x1280
- PROFILING_COMMAND_SUBMIT =
0x1281
- PROFILING_COMMAND_START =
0x1282
- PROFILING_COMMAND_END =
0x1283
- PROFILING_COMMAND_COMPLETE =
0x1284
- GL_OBJECT_BUFFER =
0x2000
- GL_OBJECT_TEXTURE2D =
0x2001
- GL_OBJECT_TEXTURE3D =
0x2002
- GL_OBJECT_RENDERBUFFER =
0x2003
- GL_OBJECT_TEXTURE2D_ARRAY =
0x200E
- GL_OBJECT_TEXTURE1D =
0x200F
- GL_OBJECT_TEXTURE1D_ARRAY =
0x2010
- GL_OBJECT_TEXTURE_BUFFER =
0x2011
- GL_TEXTURE_TARGET =
0x2004
- GL_MIPMAP_LEVEL =
0x2005
- GL_NUM_SAMPLES =
0x2012
- INVALID_GL_SHAREGROUP_REFERENCE_KHR =
-1000
- CURRENT_DEVICE_FOR_GL_CONTEXT_KHR =
0x2006
- DEVICES_FOR_GL_CONTEXT_KHR =
0x2007
- GL_CONTEXT_KHR =
0x2008
- EGL_DISPLAY_KHR =
0x2009
- GLX_DISPLAY_KHR =
0x200A
- WGL_HDC_KHR =
0x200B
- CGL_SHAREGROUP_KHR =
0x200C
- DEVICE_HALF_FP_CONFIG =
0x1033
- PLATFORM_ICD_SUFFIX_KHR =
0x0920
- PLATFORM_NOT_FOUND_KHR =
-1001
- CONTEXT_MEMORY_INITIALIZE_KHR =
0x200E
- DEVICE_TERMINATE_CAPABILITY_KHR =
0x200F
- CONTEXT_TERMINATE_KHR =
0x2010
- DEVICE_SPIR_VERSIONS =
0x40E0
- PROGRAM_BINARY_TYPE_INTERMEDIATE =
0x40E1
- DEVICE_COMPUTE_CAPABILITY_MAJOR_NV =
0x4000
- DEVICE_COMPUTE_CAPABILITY_MINOR_NV =
0x4001
- DEVICE_REGISTERS_PER_BLOCK_NV =
0x4002
- DEVICE_WARP_SIZE_NV =
0x4003
- DEVICE_GPU_OVERLAP_NV =
0x4004
- DEVICE_KERNEL_EXEC_TIMEOUT_NV =
0x4005
- DEVICE_INTEGRATED_MEMORY_NV =
0x4006
- DEVICE_PROFILING_TIMER_OFFSET_AMD =
0x4036
- PRINTF_CALLBACK_ARM =
0x40B0
- PRINTF_BUFFERSIZE_ARM =
0x40B1
- DEVICE_PAGE_SIZE_QCOM =
0x40A1
- IMAGE_ROW_ALIGNMENT_QCOM =
0x40A2
- IMAGE_SLICE_ALIGNMENT_QCOM =
0x40A3
- MEM_HOST_UNCACHED_QCOM =
0x40A4
- MEM_HOST_WRITEBACK_QCOM =
0x40A5
- MEM_HOST_WRITETHROUGH_QCOM =
0x40A6
- MEM_HOST_WRITE_COMBINING_QCOM =
0x40A7
- MEM_ION_HOST_PTR_QCOM =
0x40A8
- @@type_converter =
{ :cl_device_type => OpenCL::Device::Type, :cl_device_fp_config => OpenCL::Device::FPConfig, :cl_device_mem_cache_type => OpenCL::Device::MemCacheType, :cl_device_local_mem_type => OpenCL::Device::LocalMemType, :cl_device_exec_capabilities => OpenCL::Device::ExecCapabilities, :cl_command_queue_properties => OpenCL::CommandQueue::Properties, :cl_device_affinity_domain => OpenCL::Device::AffinityDomain, :cl_device_svm_capabilities => OpenCL::Device::SVMCapabilities, :cl_channel_order => OpenCL::ChannelOrder, :cl_channel_type => OpenCL::ChannelType, :cl_mem_flags => OpenCL::Mem::Flags, :cl_mem_object_type => OpenCL::Mem::Type, :cl_mem_migration_flags => OpenCL::Mem::MigrationFlags, :cl_addressing_mode => OpenCL::AddressingMode, :cl_filter_mode => OpenCL::FilterMode, :cl_map_flags => OpenCL::MapFlags, :cl_program_binary_type => OpenCL::Program::BinaryType, :cl_kernel_arg_address_qualifier => OpenCL::Kernel::Arg::AddressQualifier, :cl_kernel_arg_access_qualifier => OpenCL::Kernel::Arg::AccessQualifier, :cl_kernel_arg_type_qualifier => OpenCL::Kernel::Arg::TypeQualifier, :cl_command_type => OpenCL::CommandType, :cl_build_status => OpenCL::BuildStatus }
- @@callbacks =
[]
Class Method Summary collapse
-
.build_program(program, options = {}, &block) ⇒ Object
Builds (compile and link) a Program created from sources or binary.
-
.compile_program(program, options = {}, &block) ⇒ Object
Compiles a Program created from sources.
-
.convert_type(type) ⇒ Object
Converts a type from a symbol to an OpenCL class if a convertion is found.
-
.create_buffer(context, size, options = {}) ⇒ Object
Creates a Buffer.
-
.create_command_queue(context, device, options = {}) ⇒ Object
Creates a CommandQueue targeting the specified Device.
-
.create_context(devices, options = {}, &block) ⇒ Object
Creates an Context using the specified devices.
-
.create_context_from_type(type, options = {}, &block) ⇒ Object
Creates an Context using devices of the selected type.
-
.create_from_GL_buffer(context, bufobj, options = {}) ⇒ Object
Creates Buffer from an opengl buffer.
-
.create_from_GL_render_buffer(context, renderbuffer, options = {}) ⇒ Object
Creates an Image from an OpenGL render buffer.
-
.create_from_GL_texture(context, texture_target, texture, options = {}) ⇒ Object
Creates an Image from an OpenGL texture.
-
.create_from_GL_texture_2D(context, texture_target, texture, options = {}) ⇒ Object
Creates an Image from an OpenGL 2D texture.
-
.create_from_GL_texture_3D(context, texture_target, texture, options = {}) ⇒ Object
Creates an Image from an OpenGL 3D texture.
-
.create_image(context, format, desc, options = {}) ⇒ Object
Creates an Image.
-
.create_image_1D(context, format, width, options = {}) ⇒ Object
Creates a 1D Image.
-
.create_image_2D(context, format, width, height, options = {}) ⇒ Object
Creates a 2D Image.
-
.create_image_3D(context, format, width, height, depth, options = {}) ⇒ Object
Creates a 3D Image.
-
.create_kernel(program, name) ⇒ Object
Returns the Kernel corresponding the the specified name in the given Program.
-
.create_kernels_in_program(program) ⇒ Object
Creates an Array of Kernel corresponding to the kernels defined inside the Program.
-
.create_pipe(context, pipe_packet_size, pipe_max_packets, options = {}) ⇒ Object
Creates a Pipe.
-
.create_program_with_binary(context, device_list, binaries) ⇒ Object
Creates a Program from binary.
-
.create_program_with_built_in_kernels(context, device_list, kernel_names) ⇒ Object
Creates a Program from a list of built in kernel names.
-
.create_program_with_source(context, strings) ⇒ Object
Creates a Program from sources.
-
.create_sampler(context, options = {}) ⇒ Object
Creates a Sampler.
-
.create_sub_buffer(buffer, type, info, options = {}) ⇒ Object
Creates a Buffer from a sub part of an existing Buffer.
-
.create_sub_devices(in_device, properties) ⇒ Object
Splits a Device in serveral sub-devices.
-
.create_user_event(context) ⇒ Object
Creates a user Event.
-
.enqueue_acquire_GL_object(command_queue, mem_objects, options = {}) ⇒ Object
Acquire OpenCL Mem objects that have been created from OpenGL objects.
-
.enqueue_barrier(command_queue, events = []) ⇒ Object
Enqueues a barrier that prevents subsequent execution to take place in the command queue, until the barrier is considered finished.
-
.enqueue_copy_buffer(command_queue, src_buffer, dst_buffer, options = {}) ⇒ Object
Enqueues a command to copy data from a Buffer object into another Buffer object.
-
.enqueue_copy_buffer_rect(command_queue, src_buffer, dst_buffer, region, options = {}) ⇒ Object
Enqueues a command to copy a rectangular region into a Buffer object from another Buffer object.
-
.enqueue_copy_buffer_to_image(command_queue, src_buffer, dst_image, options = {}) ⇒ Object
Enqueues a command to copy a Buffer into an Image.
-
.enqueue_copy_image(command_queue, src_image, dst_image, options = {}) ⇒ Object
Enqueues a command to copy from an Image into an Image.
-
.enqueue_copy_image_to_buffer(command_queue, src_image, dst_buffer, options = {}) ⇒ Object
Enqueues a command to copy an Image into a Buffer.
-
.enqueue_fill_buffer(command_queue, buffer, pattern, options = {}) ⇒ Object
Enqueues a command to fill a Buffer with the given pattern.
-
.enqueue_fill_image(command_queue, image, fill_color, options = {}) ⇒ Object
Enqueues a command to fill an Image with the given color.
-
.enqueue_map_buffer(command_queue, buffer, map_flags, options = {}) ⇒ Object
Enqueues a command to map aa Buffer into host memory.
-
.enqueue_map_image(command_queue, image, map_flags, options = {}) ⇒ Object
Enqueues a command to map an Image into host memory.
-
.enqueue_marker(command_queue, events = []) ⇒ Object
Enqueues a marker.
-
.enqueue_migrate_mem_objects(command_queue, mem_objects, options = {}) ⇒ Object
Enqueues a command to indicate which device a set of memory objects should be migrated to.
-
.enqueue_native_kernel(command_queue, options = {}, &func) ⇒ Object
Enqueues a native kernel.
-
.enqueue_NDrange_kernel(command_queue, kernel, global_work_size, options = {}) ⇒ Object
Enqueues a kernel as a NDrange.
-
.enqueue_read_buffer(command_queue, buffer, ptr, options = {}) ⇒ Object
Enqueues a command to read from a Buffer object to host memory.
-
.enqueue_read_buffer_rect(command_queue, buffer, ptr, region, options = {}) ⇒ Object
Enqueues a command to read from a rectangular region from a Buffer object to host memory.
-
.enqueue_read_image(command_queue, image, ptr, options = {}) ⇒ Object
Enqueues a command to copy from an Image into host memory.
-
.enqueue_release_GL_object(command_queue, mem_objects, options = {}) ⇒ Object
Release OpenCL Mem objects that have been created from OpenGL objects and previously acquired.
-
.enqueue_svm_fill(command_queue, svm_ptr, pattern, size, options = {}) ⇒ Object
Enqueues a command to fill a an SVM memory area.
-
.enqueue_svm_free(command_queue, svm_pointers, options = {}, &block) ⇒ Object
Enqueues a command that frees SVMPointers (or Pointers using a callback).
-
.enqueue_svm_map(command_queue, svm_ptr, size, map_flags, options = {}) ⇒ Object
Enqueues a command to map an Image into host memory.
-
.enqueue_svm_memcpy(command_queue, dst_ptr, src_ptr, size, options = {}) ⇒ Object
Enqueues a command to copy from or to an SVMPointer.
-
.enqueue_svm_unmap(command_queue, svm_ptr, options = {}) ⇒ Object
Enqueues a command to unmap a previously mapped SVM memory area.
-
.enqueue_task(command_queue, kernel, options = {}) ⇒ Object
Enqueues a kernel as a task.
-
.enqueue_unmap_mem_object(command_queue, mem_obj, mapped_ptr, options = {}) ⇒ Object
Enqueues a command to unmap a previously mapped region of a memory object.
-
.enqueue_wait_for_events(command_queue, events) ⇒ Object
Enqueues a barrier on a list of envents.
-
.enqueue_write_buffer(command_queue, buffer, ptr, options = {}) ⇒ Object
Enqueues a command to write to a Buffer object from host memory.
-
.enqueue_write_buffer_rect(command_queue, buffer, ptr, region, options = {}) ⇒ Object
Enqueues a command to write to a rectangular region in a Buffer object from host memory.
-
.enqueue_write_image(command_queue, image, ptr, options = {}) ⇒ Object
Enqueues a command to copy from host memory into an Image.
-
.error_check(errcode) ⇒ Object
checks if a :cl_int corresponds to an Error code and raises the apropriate OpenCL::Error.
-
.finish(command_queue) ⇒ Object
Blocks until all the commands in the queue have completed.
-
.flush(command_queue) ⇒ Object
Issues all the commands in a CommandQueue to the Device.
-
.get_command_queue_properties(options) ⇒ Object
Extracts the :properties named option (for a CommandQueue) from the hash given and returns the properties values.
-
.get_context_properties(options) ⇒ Object
Extracts the :properties named option (for a Context) from the hash given and returns an FFI:Pointer to a 0 terminated list of properties.
-
.get_event_wait_list(options) ⇒ Object
Extracts the :event_wait_list named option from the hash given and returns a tuple containing the number of events and a pointer to those events.
-
.get_extension_function(name, return_type, param_types, options = {}) ⇒ Object
Returns an FFI::Function corresponding to an extension function.
-
.get_extension_function_for_platform(platform, name, return_type, param_types, options = {}) ⇒ Object
Returns an FFI::Function corresponding to an extension function for the Platform.
-
.get_flags(options) ⇒ Object
Extracts the :flags named option from the hash given and returns the flags value.
-
.get_info(klass, type, name) ⇒ Object
Generates a new method for klass that use the apropriate clGetKlassInfo, to read an element of the given type.
-
.get_info_array(klass, type, name) ⇒ Object
Generates a new method for klass that use the apropriate clGetKlassInfo, to read an Array of element of the given type.
-
.get_origin_region(image, options, origin_symbol, region_symbol) ⇒ Object
Extracts the origin_symbol and region_symbol named options for image from the given hash.
-
.get_platforms ⇒ Object
(also: platforms)
Returns an Array of Platforms containing the available OpenCL platforms.
-
.link_program(context, input_programs, options = {}, &block) ⇒ Object
Links a set of compiled programs for all device in a Context, or a subset of devices.
-
.set_event_callback(event, command_exec_callback_type, options = {}, &proc) ⇒ Object
Attaches a callback to event that will be called on the given transition.
-
.set_kernel_arg(kernel, index, value, size = nil) ⇒ Object
Set the index th argument of Kernel to value.
-
.set_kernel_arg_svm_pointer(kernel, index, value) ⇒ Object
Set the index th argument of Kernel to value.
-
.set_mem_object_destructor_callback(memobj, options = {}, &proc) ⇒ Object
Attaches a callback to memobj the will be called on memobj destruction.
-
.set_user_event_status(event, execution_status) ⇒ Object
Sets the satus of user Event to the given execution status.
-
.svm_alloc(context, size, options = {}) ⇒ Object
Creates an SVMPointer pointing to an SVM area of memory.
-
.svm_free(context, svm_pointer) ⇒ Object
Frees an SVMPointer.
-
.unload_compiler ⇒ Object
Unloads the compiler.
-
.unload_platform_compiler(platform) ⇒ Object
Unloads a Platform compiler.
-
.wait_for_events(event_list) ⇒ Object
Waits for the command identified by Event objects to complete.
Class Method Details
.build_program(program, options = {}, &block) ⇒ Object
Builds (compile and link) a Program created from sources or binary
Attributes
-
program
- the program to build -
options
- a hash containing named options -
block
- if provided, a callback invoked when the Program is built. Signature of the callback is { |Program, FFI::Pointer to user_data| … }
Options
-
:device_list
- an Array of Device to build the program for -
:options
- a String containing the options to use for the build -
:user_data
- a Pointer (or convertible to Pointer using to_ptr) to the memory area to pass to the callback
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/opencl_ruby_ffi/Program.rb', line 16 def self.build_program(program, = {}, &block) @@callbacks.push( block ) if block devices = [:device_list] devices = [devices].flatten if devices devices_p = nil num_devices = 0 if devices and devices.size > 0 then num_devices = devices.size devices_p = FFI::MemoryPointer::new( Device, num_devices) num_devices.times { |indx| devices_p[indx].write_pointer(devices[indx]) } end opt = "" opt = [:options] if [:options] = FFI::MemoryPointer.from_string(opt) error = OpenCL.clBuildProgram(program, num_devices, devices_p, , block, [:user_data] ) OpenCL.error_check(error) return program end |
.compile_program(program, options = {}, &block) ⇒ Object
Compiles a Program created from sources
Attributes
-
program
- the program to build -
options
- a Hash containing named options -
block
- if provided, a callback invoked when the Program is compiled. Signature of the callback is { |Program, FFI::Pointer to user_data| … }
Options
-
:device_list
- an Array of Device to build the program for -
:user_data
- a Pointer (or convertible to Pointer using to_ptr) to the memory area to pass to the callback -
:options
- a String containing the options to use for the compilation -
:input_headers
- a Hash containing pairs of : String: header_include_name => Program: header
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/opencl_ruby_ffi/Program.rb', line 93 def self.compile_program(program, = {}, &block) @@callback.push( block ) if block devices = [:device_list] devices = [devices].flatten if devices devices_p = nil num_devices = 0 if devices and devices.size > 0 then num_devices = devices.size devices_p = FFI::MemoryPointer::new( Device, num_devices) num_devices.times { |indx| devices_p[indx].write_pointer(devices[indx]) } end opt = "" opt = [:options] if [:options] = FFI::MemoryPointer.from_string(opt) headers = [:input_headers] headers_p = nil header_include_names = nil num_headers = 0 num_headers = headers.length if headers if num_headers then headers_p = FFI::MemoryPointer::new( Program, num_headers ) header_include_names = FFI::MemoryPointer::new( :pointer, num_headers ) indx = 0 headers.each { |key, value| headers_p[indx].write_pointer(value) header_include_names[indx] = FFI::MemoryPointer.from_string(key) indx = indx + 1 } end error = OpenCL.clCompileProgram(program, num_devices, devices_p, , num_headers, headers_p, header_include_names, block, [:user_data] ) OpenCL.error_check(error) return program end |
.convert_type(type) ⇒ Object
Converts a type from a symbol to an OpenCL class if a convertion is found
66 67 68 |
# File 'lib/opencl_ruby_ffi/opencl_ruby_ffi_base.rb', line 66 def self.convert_type(type) return @@type_converter[type] end |
.create_buffer(context, size, options = {}) ⇒ Object
Creates a Buffer
Attributes
-
context
- Context the created Buffer will be associated to -
size
- size of the Buffer to be created -
options
- a hash containing named options
Options
-
:flags
- a single or an Array of :cl_mem_flags specifying the flags to be used when creating the Buffer -
:host_ptr
- if provided, the Pointer (or convertible to Pointer using to_ptr) to the memory area to use
15 16 17 18 19 20 21 22 |
# File 'lib/opencl_ruby_ffi/Buffer.rb', line 15 def self.create_buffer( context, size, = {} ) flags = OpenCL.get_flags( ) host_ptr = [:host_ptr] error = FFI::MemoryPointer::new( :cl_int ) buff = OpenCL.clCreateBuffer(context, flags, size, host_ptr, error) OpenCL.error_check(error.read_cl_int) return OpenCL::Buffer::new( buff, false ) end |
.create_command_queue(context, device, options = {}) ⇒ Object
Creates a CommandQueue targeting the specified Device
Attributes
-
context
- the Context the CommandQueue will be associated with -
device
- the Device targetted by the CommandQueue being created -
options
- a hash containing named options
Options
-
:properties
- a single or an Array of :cl_command_queue_properties -
:size
- the size of the command queue ( if ON_DEVICE is specified in the properties ) 2.0+ only
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 37 def self.create_command_queue( context, device, = {} ) properties = OpenCL.get_command_queue_properties( ) size = [:size] error = FFI::MemoryPointer::new( :cl_int ) if context.platform.version_number < 2.0 then cmd = OpenCL.clCreateCommandQueue( context, device, properties, error ) else props = nil if properties.to_i != 0 or size then props_size = 0 props_size += 2 if properties.to_i != 0 props_size += 2 if size props_size += 1 if props_size > 0 props = FFI::MemoryPointer::new( :cl_queue_properties, props_size ) i=0 if properties.to_i != 0 then props[i].write_cl_queue_properties( OpenCL::Queue::PROPERTIES ) props[i+1].write_cl_queue_properties( properties.to_i ) i += 2 end if size then props[i].write_cl_queue_properties( OpenCL::Queue::SIZE ) props[i+1].write_cl_queue_properties( size ) i += 2 end props[i].write_cl_queue_properties( 0 ) end cmd = OpenCL.clCreateCommandQueueWithProperties( context, device, props, error ) end OpenCL.error_check(error.read_cl_int) return OpenCL::CommandQueue::new(cmd, false) end |
.create_context(devices, options = {}, &block) ⇒ Object
Creates an Context using the specified devices
Attributes
-
devices
- array of Device or a single Device -
options
- a hash containing named options -
block
- if provided, a callback invoked when error arise in the context. Signature of the callback is { |FFI::Pointer to null terminated c string, FFI::Pointer to binary data, :size_t number of bytes of binary data, FFI::Pointer to user_data| … }
Options
-
:properties
- a list of :cl_context_properties -
:user_data
- an FFI::Pointer or an object that can be converted into one using to_ptr. The pointer is passed to the callback.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/opencl_ruby_ffi/Context.rb', line 15 def self.create_context(devices, = {}, &block) @@callbacks.push( block ) if block devs = [devices].flatten pointer = FFI::MemoryPointer::new( Device, devs.size) devs.size.times { |indx| pointer.put_pointer(indx, devs[indx]) } properties = OpenCL.get_context_properties( ) user_data = [:user_data] error = FFI::MemoryPointer::new( :cl_int ) ptr = OpenCL.clCreateContext(properties, devs.size, pointer, block, user_data, error) OpenCL.error_check(error.read_cl_int) return OpenCL::Context::new(ptr, false) end |
.create_context_from_type(type, options = {}, &block) ⇒ Object
Creates an Context using devices of the selected type
Attributes
-
type
- array of Device or a single Device -
options
- a hash containing named options -
block
- if provided, a callback invoked when error arise in the context. Signature of the callback is { |FFI::Pointer to null terminated c string, FFI::Pointer to binary data, :size_t number of bytes of binary data, FFI::Pointer to user_data| … }
Options
-
:properties
- a list of :cl_context_properties -
:user_data
- an FFI::Pointer or an object that can be converted into one using to_ptr. The pointer is passed to the callback.
42 43 44 45 46 47 48 49 50 |
# File 'lib/opencl_ruby_ffi/Context.rb', line 42 def self.create_context_from_type(type, = {}, &block) @@callbacks.push( block ) if block properties = OpenCL.get_context_properties( ) user_data = [:user_data] error = FFI::MemoryPointer::new( :cl_int ) ptr = OpenCL.clCreateContextFromType(properties, type, block, user_data, error) OpenCL.error_check(error.read_cl_int) return OpenCL::Context::new(ptr, false) end |
.create_from_GL_buffer(context, bufobj, options = {}) ⇒ Object
Creates Buffer from an opengl buffer
Attributes
-
context
- Context the created Buffer will be associated to -
bufobj
- opengl buffer object -
options
- a hash containing named options
Options
-
:flags
- a single or an Array of :cl_mem_flags specifying the flags to be used when creating the Image
56 57 58 59 60 61 62 |
# File 'lib/opencl_ruby_ffi/Buffer.rb', line 56 def self.create_from_GL_buffer( context, bufobj, = {} ) flags = OpenCL.get_flags( ) error = FFI::MemoryPointer::new( :cl_int ) buff = OpenCL.clCreateFromGLBuffer( context, flags, bufobj, error ) OpenCL.error_check(error.read_cl_int) return OpenCL::Buffer::new( buff, false ) end |
.create_from_GL_render_buffer(context, renderbuffer, options = {}) ⇒ Object
Creates an Image from an OpenGL render buffer
Attributes
-
context
- Context the created Image will be associated to -
renderbuf
- opengl render buffer -
options
- a hash containing named options
Options
-
:flags
- a single or an Array of :cl_mem_flags specifying the flags to be used when creating the Image (default OpenCL::Mem::READ_WRITE)
115 116 117 118 119 120 121 |
# File 'lib/opencl_ruby_ffi/Image.rb', line 115 def self.create_from_GL_render_buffer( context, renderbuffer, = {} ) flags = OpenCL.get_flags( ) error = FFI::MemoryPointer::new( :cl_int ) img = OpenCL.clCreateFromGLRenderBuffer( context, flags, renderbuffer, error ) OpenCL.error_check(error.read_cl_int) return OpenCL::Image::new( img, false ) end |
.create_from_GL_texture(context, texture_target, texture, options = {}) ⇒ Object
Creates an Image from an OpenGL texture
Attributes
-
context
- Context the created Image will be associated to -
texture_target
- a :GLenum defining the image type of texture -
texture
- a :GLuint specifying the name of the texture -
options
- a hash containing named options
Options
-
:miplevel
- a :GLint specifying the mipmap level to be used (default 0) -
:flags
- a single or an Array of :cl_mem_flags specifying the flags to be used when creating the Image (default OpenCL::Mem::READ_WRITE)
136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/opencl_ruby_ffi/Image.rb', line 136 def self.create_from_GL_texture( context, texture_target, texture, = {} ) if context.platform.version_number < 1.2 then OpenCL.error_check(OpenCL::INVALID_OPERATION) end flags = OpenCL.get_flags( ) miplevel = 0 miplevel = [:miplevel] if [:miplevel] error = FFI::MemoryPointer::new( :cl_int ) img = OpenCL.clCreateFromGLTexture( context, flags, texture_target, miplevel, texture, error ) OpenCL.error_check(error.read_cl_int) return OpenCL::Image::new( img, false ) end |
.create_from_GL_texture_2D(context, texture_target, texture, options = {}) ⇒ Object
Creates an Image from an OpenGL 2D texture
Attributes
-
texture_target
- a :GLenum defining the image type of texture -
texture
- a :GLuint specifying the name of the texture -
options
- a hash containing named options
Options
-
:miplevel
- a :GLint specifying the mipmap level to be used (default 0) -
:flags
- a single or an Array of :cl_mem_flags specifying the flags to be used when creating the Image
161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/opencl_ruby_ffi/Image.rb', line 161 def self.create_from_GL_texture_2D( context, texture_target, texture, = {} ) if context.platform.version_number > 1.1 then return OpenCL.create_from_GL_texture( context, texture_target, texture, ) end flags = OpenCL.get_flags( ) miplevel = 0 miplevel = [:miplevel] if [:miplevel] error = FFI::MemoryPointer::new( :cl_int ) img = OpenCL.clCreateFromGLTexture2D( context, flags, texture_target, miplevel, texture, error ) OpenCL.error_check(error.read_cl_int) return OpenCL::Image::new( img, false ) end |
.create_from_GL_texture_3D(context, texture_target, texture, options = {}) ⇒ Object
Creates an Image from an OpenGL 3D texture
Attributes
-
texture_target
- a :GLenum defining the image type of texture -
texture
- a :GLuint specifying the name of the texture -
options
- a hash containing named options
Options
-
:miplevel
- a :GLint specifying the mipmap level to be used (default 0) -
:flags
- a single or an Array of :cl_mem_flags specifying the flags to be used when creating the Image
186 187 188 189 190 191 192 193 194 195 196 197 |
# File 'lib/opencl_ruby_ffi/Image.rb', line 186 def self.create_from_GL_texture_3D( context, texture_target, texture, = {} ) if context.platform.version_number > 1.1 then return OpenCL.create_from_GL_texture( context, texture_target, texture, ) end flags = OpenCL.get_flags( ) miplevel = 0 miplevel = [:miplevel] if [:miplevel] error = FFI::MemoryPointer::new( :cl_int ) img = OpenCL.clCreateFromGLTexture3D( context, flags, texture_target, miplevel, texture, error ) OpenCL.error_check(error.read_cl_int) return OpenCL::Image::new( img, false ) end |
.create_image(context, format, desc, options = {}) ⇒ Object
Creates an Image
Attributes
-
context
- Context the created Image will be associated to -
format
- an ImageFormat -
desc
- an ImageDesc
Options
-
:flags
- a single or an Array of :cl_mem_flags specifying the flags to be used when creating the Image -
:host_ptr
- if provided, the Pointer (or convertible to Pointer using to_ptr) to the memory area to use
15 16 17 18 19 20 21 22 |
# File 'lib/opencl_ruby_ffi/Image.rb', line 15 def self.create_image( context, format, desc, = {} ) flags = OpenCL.get_flags( ) host_ptr = [:host_ptr] error = FFI::MemoryPointer::new( :cl_int ) img_ptr = OpenCL.clCreateImage( context, flags, format, desc, host_ptr, error ) OpenCL.error_check(error.read_cl_int) return OpenCL::Image::new(img_ptr, false) end |
.create_image_1D(context, format, width, options = {}) ⇒ Object
Creates a 1D Image
Attributes
-
context
- Context the created Image will be associated to -
format
- an ImageFormat -
width
- width of the image
Options
-
:flags
- a single or an Array of :cl_mem_flags specifying the flags to be used when creating the Image -
:host_ptr
- if provided, the Pointer (or convertible to Pointer using to_ptr) to the memory area to use
36 37 38 39 40 41 42 43 |
# File 'lib/opencl_ruby_ffi/Image.rb', line 36 def self.create_image_1D( context, format, width, = {} ) if context.platform.version_number > 1.1 then desc = OpenCL::ImageDesc::new(OpenCL::Mem::IMAGE1D, width, 0, 0, 0, 0, 0, 0, 0, nil) return OpenCL.create_image( context, format, desc, ) else OpenCL.error_check(OpenCL::Error::INVALID_OPERATION) end end |
.create_image_2D(context, format, width, height, options = {}) ⇒ Object
Creates a 2D Image
Attributes
-
context
- Context the created Image will be associated to -
format
- an ImageFormat -
width
- width of the image
Options
-
:flags
- a single or an Array of :cl_mem_flags specifying the flags to be used when creating the Image -
:host_ptr
- if provided, the Pointer (or convertible to Pointer using to_ptr) to the memory area to use -
:row_pitch
- if provided the row_pitch of data in host_ptr
58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/opencl_ruby_ffi/Image.rb', line 58 def self.create_image_2D( context, format, width, height, = {} ) row_pitch = 0 row_pitch = [:row_pitch] if [:row_pitch] if context.platform.version_number > 1.1 then desc = OpenCL::ImageDesc::new(OpenCL::Mem::IMAGE2D, width, height, 0, 0, row_pitch, 0, 0, 0, nil) return OpenCL.create_image( context, format, desc, ) end flags = OpenCL.get_flags( ) host_ptr = [:host_ptr] error = FFI::MemoryPointer::new( :cl_int ) img_ptr = OpenCL.clCreateImage2D( context, flags, format, width, height, row_pitch, host_ptr, error ) OpenCL.error_check(error.read_cl_int) return OpenCL::Image::new(img_ptr, false) end |
.create_image_3D(context, format, width, height, depth, options = {}) ⇒ Object
Creates a 3D Image
Attributes
-
context
- Context the created Image will be associated to -
format
- an ImageFormat -
width
- width of the image
Options
-
:flags
- a single or an Array of :cl_mem_flags specifying the flags to be used when creating the Image -
:host_ptr
- if provided, the Pointer (or convertible to Pointer using to_ptr) to the memory area to use -
:row_pitch
- if provided the row_pitch of data in host_ptr -
:slice_pitch
- if provided the slice_pitch of data in host_ptr
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/opencl_ruby_ffi/Image.rb', line 87 def self.create_image_3D( context, format, width, height, depth, = {} ) row_pitch = 0 row_pitch = [:row_pitch] if [:row_pitch] slice_pitch = 0 slice_pitch = [:slice_pitch] if [:slice_pitch] if context.platform.version_number > 1.1 then desc = OpenCL::ImageDesc::new(OpenCL::Mem::IMAGE3D, width, height, depth, 0, row_pitch, slice_pitch, 0, 0, nil) return OpenCL.create_image( context, format, desc, flags, data ) end flags = OpenCL.get_flags( ) host_ptr = [:host_ptr] error = FFI::MemoryPointer::new( :cl_int ) img_ptr = OpenCL.clCreateImage3D( context, fs, format, width, height, depth, row_pitch, slice_pitch, d, error ) OpenCL.error_check(error.read_cl_int) return OpenCL::Image::new(img_ptr, false) end |
.create_kernel(program, name) ⇒ Object
Returns the Kernel corresponding the the specified name in the given Program
18 19 20 21 22 23 |
# File 'lib/opencl_ruby_ffi/Kernel.rb', line 18 def self.create_kernel(program, name) error = FFI::MemoryPointer::new( :cl_int ) kernel_ptr = OpenCL.clCreateKernel(program, name, error) OpenCL.error_check(error.read_cl_int) return OpenCL::Kernel::new( kernel_ptr, false ) end |
.create_kernels_in_program(program) ⇒ Object
Creates an Array of Kernel corresponding to the kernels defined inside the Program
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/opencl_ruby_ffi/Kernel.rb', line 4 def self.create_kernels_in_program( program ) num_ptr = FFI::MemoryPointer::new( :cl_uint ) error = OpenCL. clCreateKernelsInProgram( program, 0, nil, num_ptr ) OpenCL.error_check(error) num_kernels = num_ptr.read_cl_uint kernels_ptr = FFI::MemoryPointer::new( OpenCL::Kernel, num_kernels ) error = OpenCL. clCreateKernelsInProgram( program, num_kernels, kernels_ptr, 0 ) OpenCL.error_check(error) return kernels_ptr.get_array_of_pointer(0, num_kernels).collect { |kernel_ptr| OpenCL::Kernel::new(kernel_ptr, false) } end |
.create_pipe(context, pipe_packet_size, pipe_max_packets, options = {}) ⇒ Object
Creates a Pipe
Attributes
-
context
- Context the created Pipe will be associated to -
pipe_packet_size
- size of a packet in the Pipe -
pipe_max_packets
- size of the Pipe in packet
Options
-
:flags
- a single or an Array of :cl_mem_flags specifying the flags to be used when creating the Pipe
14 15 16 17 18 19 20 21 |
# File 'lib/opencl_ruby_ffi/Pipe.rb', line 14 def self.create_pipe( context, pipe_packet_size, pipe_max_packets, = {} ) OpenCL.error_check(OpenCL::INVALID_OPERATION) if self.context.platform.version_number < 2.0 flags = OpenCL.get_flags( ) error = FFI::MemoryPointer::new( :cl_int ) pipe_ptr = OpenCL::clCreatePipe( context, flags, pipe_packet_size, pipe_max_packets, nil, error) OpenCL.error_check(error.read_cl_int) return OpenCL::Pipe::new(pipe_ptr, false) end |
.create_program_with_binary(context, device_list, binaries) ⇒ Object
Creates a Program from binary
Attributes
-
context
- Context the created Program will be associated to -
device_list
- an Array of Device to create the program for. Can throw an OpenCL::Invalid value if the number of supplied devices is different from the number of supplied binaries. -
binaries
- Array of binaries
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
# File 'lib/opencl_ruby_ffi/Program.rb', line 158 def self.create_program_with_binary(context, device_list, binaries) bins = [binaries].flatten num_devices = bins.length devices = [device_list].flatten OpenCL.error_check(OpenCL::INVALID_VALUE) if devices.length != bins.length devices_p = FFI::MemoryPointer::new( Device, num_devices ) lengths = FFI::MemoryPointer::new( :size_t, num_devices ) binaries_p = FFI::MemoryPointer::new( :pointer, num_devices ) num_devices.times { |indx| devices_p[indx].write_pointer(devices[indx]) lengths[indx].write_size_t(binaries[indx].size) p = FFI::MemoryPointer::new(binaries[indx].size) p.write_bytes(binaries[indx]) binaries_p[indx].write_pointer(p) } binary_status = FFI::MemoryPointer::new( :cl_int, num_devices ) error = FFI::MemoryPointer::new( :cl_int ) prog = OpenCL.clCreateProgramWithBinary(context, num_devices, devices_p, lengths, binaries_p, binary_status, error) OpenCL.error_check(error.read_cl_int) d_s = [] num_devices.times { |indx| d_s.push [ devices[indx], binary_status[indx].read_cl_int ] } return [ OpenCL::Program::new(prog, false), d_s ] end |
.create_program_with_built_in_kernels(context, device_list, kernel_names) ⇒ Object
Creates a Program from a list of built in kernel names
Attributes
-
context
- Context the created Program will be associated to -
device_list
- an Array of Device to create the program for -
kernel_names
- a single or an Array of String representing the kernel names
136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/opencl_ruby_ffi/Program.rb', line 136 def self.create_program_with_built_in_kernels(context, device_list, kernel_names) devices = [device_list].flatten num_devices = devices.length devices_p = FFI::MemoryPointer::new( Device, num_devices ) num_devices.times { |indx| devices_p[indx].write_pointer(devices[indx]) } names = [kernel_names].flatten.join(",") names_p = FFI::MemoryPointer.from_string(names) error = FFI::MemoryPointer::new( :cl_int ) prog = OpenCL.clCreateProgramWithBuiltInKernels( context, num_devices, devices_p, names_p, error ) OpenCL.error_check(error.read_cl_int) return OpenCL::Program::new(prog, false) end |
.create_program_with_source(context, strings) ⇒ Object
Creates a Program from sources
Attributes
-
context
- Context the created Program will be associated to -
strings
- a single or an Array of String repesenting the program source code
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 |
# File 'lib/opencl_ruby_ffi/Program.rb', line 190 def self.create_program_with_source(context, strings) strs = nil if not strings then raise OpenCL::Error::new(OpenCL::Error.getErrorString(OpenCL::Error::INVALID_VALUE)) else strs = [strings].flatten end n_strs = strs.size strs_lengths = FFI::MemoryPointer::new( :size_t, n_strs ) c_strs = FFI::MemoryPointer::new( :pointer, n_strs ) c_strs_p = [] strs.each { |str| if str then c_strs_p.push (FFI::MemoryPointer.from_string(str)) end } raise OpenCL::Error::new(OpenCL::Error.getErrorString(OpenCL::Error::INVALID_VALUE)) if c_strs_p.size == 0 c_strs = FFI::MemoryPointer::new( :pointer, c_strs_p.size ) c_strs_length = FFI::MemoryPointer::new( :size_t, c_strs_p.size ) c_strs_p.each_with_index { |p, i| c_strs[i].write_pointer(p) c_strs_length[i].write_size_t(p.size) } error = FFI::MemoryPointer::new( :cl_int ) program_ptr = OpenCL.clCreateProgramWithSource(context, c_strs_p.size, c_strs, c_strs_length, error) OpenCL.error_check(error.read_cl_int) return OpenCL::Program::new( program_ptr, false ) end |
.create_sampler(context, options = {}) ⇒ Object
Creates a Sampler
Attributes
-
context
- Context the created Sampler will be associated to
Options
-
:normalized_coords
- a :cl_bool specifying if the image coordinates are normalized -
:addressing_mode
- a :cl_addressing_mode specifying how out-of-range image coordinates are handled when reading from an image -
:filter_mode
- a :cl_filter_mode specifying the type of filter that must be applied when reading an image -
:mip_filter_mode
- the filtering mode to use if using mimaps (default CL_FILTER_NONE, requires cl_khr_mipmap_image) -
:lod_min
- floating point value representing the minimal LOD (default 0.0f, requires cl_khr_mipmap_image) -
:lod_max
- floating point value representing the maximal LOD (default MAXFLOAT, requires cl_khr_mipmap_image)
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/opencl_ruby_ffi/Sampler.rb', line 17 def self.create_sampler( context, = {} ) normalized_coords = OpenCL::TRUE normalized_coords = [:normalized_coords] if [:normalized_coords] addressing_mode = OpenCL::AddressingMode::CLAMP addressing_mode = [:addressing_mode] if [:addressing_mode] filter_mode = OpenCL::FilterMode::NEAREST filter_mode = [:filter_mode] if [:filter_mode] error = FFI::MemoryPointer::new( :cl_int ) if context.platform.version_number < 2.0 then sampler_ptr = OpenCL.clCreateSampler( context, normalized_coords, addressing_mode, filter_mode, error ) else prop_size = 7 prop_size += 2 if [:mip_filter_mode] prop_size += 2 if [:lod_min] prop_size += 2 if [:lod_max] properties = FFI::MemoryPointer::new( :cl_sampler_properties) properties[0].write_cl_sampler_properties( OpenCL::Sampler::NORMALIZED_COORDS ) properties[1].write_cl_sampler_properties( normalized_coords ) properties[2].write_cl_sampler_properties( OpenCL::Sampler::ADDRESSING_MODE ) properties[3].write_cl_sampler_properties( addressing_mode ) properties[4].write_cl_sampler_properties( OpenCL::Sampler::FILTER_MODE ) properties[5].write_cl_sampler_properties( filter_mode ) prop_indx = 6 if [:mip_filter_mode] then properties[prop_indx].write_cl_sampler_properties( OpenCL::Sampler::MIP_FILTER_MODE ) properties[prop_indx+1].write_cl_sampler_properties( [:mip_filter_mode] ) prop_indx += 2 end if [:lod_min] then properties[prop_indx].write_cl_sampler_properties( OpenCL::Sampler::LOD_MIN ) properties[prop_indx+1].write_float( [:lod_min] ) prop_indx += 2 end if [:lod_max] then properties[prop_indx].write_cl_sampler_properties( OpenCL::Sampler::LOD_MAX ) properties[prop_indx+1].write_float( [:lod_max] ) prop_indx += 2 end properties[prop_indx].write_cl_sampler_properties( 0 ) sampler_ptr = OpenCL.clCreateSamplerWithProperties( context, properties, error ) end OpenCL.error_check(error.read_cl_int) OpenCL::Sampler::new(sampler_ptr, false) end |
.create_sub_buffer(buffer, type, info, options = {}) ⇒ Object
Creates a Buffer from a sub part of an existing Buffer
Attributes
-
buffer
- source Buffer -
type
- type of sub-buffer to create. Only OpenCL::BUFFER_CREATE_TYPE_REGION is supported for now -
info
- inf reguarding the type of sub-buffer created. if type == OpenCL::BUFFER_CREATE_TYPE_REGION, info is a BufferRegion -
options
- a hash containing named options
Options
-
:flags
- a single or an Array of :cl_mem_flags specifying the flags to be used when creating the Buffer
36 37 38 39 40 41 42 43 |
# File 'lib/opencl_ruby_ffi/Buffer.rb', line 36 def self.create_sub_buffer( buffer, type, info, = {} ) OpenCL.error_check(OpenCL::INVALID_OPERATION) if buffer.platform.version_number < 1.1 flags = OpenCL.get_flags( ) error = FFI::MemoryPointer::new( :cl_int ) buff = OpenCL.clCreateSubBuffer( buffer, flags, type, info, error) OpenCL.error_check(error.read_cl_int) return OpenCL::Buffer::new( buff, false ) end |
.create_sub_devices(in_device, properties) ⇒ Object
Splits a Device in serveral sub-devices
Attributes
-
in_device
- the Device to be partitioned -
properties
- an Array of cl_device_partition_property
Returns
an Array of Device
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/opencl_ruby_ffi/Device.rb', line 13 def self.create_sub_devices( in_device, properties ) OpenCL.error_check(OpenCL::INVALID_OPERATION) if in_device.platform.version_number < 1.2 props = FFI::MemoryPointer::new( :cl_device_partition_property, properties.length + 1 ) properties.each_with_index { |e,i| props[i].write_cl_device_partition_property(e) } props[properties.length].write_cl_device_partition_property(0) device_number_ptr = FFI::MemoryPointer::new( :cl_uint ) error = OpenCL.clCreateSubDevice( in_device, props, 0, nil, device_number_ptr ) OpenCL.error_check(error) device_number = device_number_ptr.read_cl_uint devices_ptr = FFI::MemoryPointer::new( OpenCL::Device, device_number ) error = OpenCL.clCreateSubDevice( in_device, props, device_number, devices_ptr, nil ) OpenCL.error_check(error) devices_ptr.get_array_of_pointer(0, device_number).collect { |device_ptr| OpenCL::Device::new(device_ptr, false) } end |
.create_user_event(context) ⇒ Object
Creates a user Event
Attributes
-
context
- Context the created Event will be associated to
38 39 40 41 42 43 44 |
# File 'lib/opencl_ruby_ffi/Event.rb', line 38 def self.create_user_event(context) OpenCL.error_check(OpenCL::INVALID_OPERATION) if context.platform.version_number < 1.1 error = FFI::MemoryPointer::new(:cl_int) event = OpenCL.clCreateUserEvent(context, error) OpenCL.error_check(error.read_cl_int) return OpenCL::Event::new(event, false) end |
.enqueue_acquire_GL_object(command_queue, mem_objects, options = {}) ⇒ Object
Acquire OpenCL Mem objects that have been created from OpenGL objects
Attributes
-
command_queue
- CommandQueue used to execute the acquire command -
mem_objects
- a single or an Array of Mem objects -
options
- a hash containing named options
Options
-
:event_wait_list
- if provided, a list of Event to wait upon before executing the command
Returns
the Event associated with the command
552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 |
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 552 def self.enqueue_acquire_GL_object( command_queue, mem_objects, = {} ) num_objs = [mem_objects].flatten.length objs = nil if num_objs > 0 then objs = FFI::MemoryPointer::new( OpenCL::Mem, num_objs ) [mem_objects].flatten.each_with_index { |o, i| objs[i].write_pointer(e) } end num_events, events = OpenCL.get_event_wait_list( ) event = FFI::MemoryPointer::new( OpenCL::Event ) error = OpenCL.clEnqueueAcquireGLObject( command_queue, num_objs, objs, num_events, events, event ) OpenCL.error_check(error) return OpenCL::Event::new(event.read_pointer, false) end |
.enqueue_barrier(command_queue, events = []) ⇒ Object
Enqueues a barrier that prevents subsequent execution to take place in the command queue, until the barrier is considered finished
Attributes
-
command_queue
- CommandQueue used to execute the command -
events
- an optional single or Array of Event to wait upon before the barrier is considered finished
Returns
an Event if implementation version is >= 1.2, nil otherwise
982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 |
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 982 def self.( command_queue, events = [] ) if command_queue.context.platform.version_number < 1.2 then num_events = [events].flatten.length if num_events > 0 then evts = FFI::MemoryPointer::new( OpenCL::Event, num_events ) [events].flatten.each_with_index { |e, i| evts[i].write_pointer(e) } error = OpenCL.clnqueueWaitForEvents( command_queue, num_events, evts ) else error = OpenCL.clEnqueueBarrier( command_queue ) end OpenCL.error_check(error) return nil else num_events = [events].flatten.length evts = nil if num_events > 0 then evts = FFI::MemoryPointer::new( OpenCL::Event, num_events ) [events].flatten.each_with_index { |e, i| evts[i].write_pointer(e) } end event = FFI::MemoryPointer::new( OpenCL::Event ) error = OpenCL.clEnqueueBarrierWithWaitList( command_queue, num_events, evts, event ) OpenCL.error_check(error) return OpenCL::Event::new(event.read_pointer, false) end end |
.enqueue_copy_buffer(command_queue, src_buffer, dst_buffer, options = {}) ⇒ Object
Enqueues a command to copy data from a Buffer object into another Buffer object
Attributes
-
command_queue
- CommandQueue used to execute the write command -
src_buffer
- the Buffer to be read from -
dst_buffer
- the Buffer to be written to -
options
- a hash containing named options
Options
-
:event_wait_list
- if provided, a list of Event to wait upon before executing the command -
:src_offset
- if provided indicates the offset inside the src Buffer of the area to copy, else 0 -
:dst_offset
- if provided indicates the offset inside the dst Buffer of the area to write to, else 0 -
:size
- if provided indicates the size of data to copy, else the maximum possible is copied
Returns
the Event associated with the command
454 455 456 457 458 459 460 461 462 463 464 465 466 |
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 454 def self.enqueue_copy_buffer(command_queue, src_buffer, dst_buffer, = {}) src_offset = 0 src_offset = [:src_offset] if [:src_offset] dst_offset = 0 dst_offset = [:dst_offset] if [:dst_offset] size = [ src_buffer.size - src_offset, dst_buffer.size - dst_offset ].min size = [:size] if [:size] num_events, events = OpenCL.get_event_wait_list( ) event = FFI::MemoryPointer::new( OpenCL::Event ) error = OpenCL.clEnqueueCopyBuffer(command_queue, src_buffer, dst_buffer, src_offset, dst_offset, size, num_events, events, event) OpenCL.error_check(error) return OpenCL::Event::new(event.read_pointer, false) end |
.enqueue_copy_buffer_rect(command_queue, src_buffer, dst_buffer, region, options = {}) ⇒ Object
Enqueues a command to copy a rectangular region into a Buffer object from another Buffer object
Attributes
-
command_queue
- CommandQueue used to execute the write command -
src_buffer
- the Buffer to be read from -
dst_buffer
- the Buffer to be written to -
region
- the region to write in the Buffer -
options
- a hash containing named options
Options
-
:event_wait_list
- if provided, a list of Event to wait upon before executing the command -
:src_origin
- if provided indicates the origin inside the src Buffer of the area to copy, else [0, 0, 0] -
:dst_origin
- if provided indicates the origin inside the dst Buffer of the area to write to, else [0, 0, 0] -
:src_row_pitch
- if provided indicates the row pitch inside the src Buffer, else 0 -
:src_slice_pitch
- if provided indicates the slice pitch inside the src Buffer, else 0 -
:dst_row_pitch
- if provided indicates the row pitch inside the dst Buffer, else 0 -
:dst_slice_pitch
- if provided indicates the slice pitch inside the dst Buffer area, else 0
Returns
the Event associated with the command
387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 |
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 387 def self.enqueue_copy_buffer_rect(command_queue, src_buffer, dst_buffer, region, = {}) OpenCL.error_check(OpenCL::INVALID_OPERATION) if command_queue.context.platform.version_number < 1.1 src_origin = FFI::MemoryPointer::new( :size_t, 3 ) (0..2).each { |i| src_origin[i].write_size_t(0) } if [:src_origin] then [:src_origin].each_with_index { |e, i| src_origin[i].write_size_t(e) } end dst_origin = FFI::MemoryPointer::new( :size_t, 3 ) (0..2).each { |i| dst_origin[i].write_size_t(0) } if [:dst_origin] then [:dst_origin].each_with_index { |e, i| dst_origin[i].write_size_t(e) } end r = FFI::MemoryPointer::new( :size_t, 3 ) (0..2).each { |i| r[i].write_size_t(0) } region[0..3].each_with_index { |e, i| r[i].write_size_t(e) } src_row_pitch = [:src_row_pitch] if not src_row_pitch then src_row_pitch = 0 end src_slice_pitch = [:src_slice_pitch] if not src_slice_pitch then src_slice_pitch = 0 end dst_row_pitch = [:dst_row_pitch] if not dst_row_pitch then dst_row_pitch = 0 end dst_slice_pitch = [:dst_slice_pitch] if not dst_slice_pitch then dst_slice_pitch = 0 end num_events, events = OpenCL.get_event_wait_list( ) event = FFI::MemoryPointer::new( OpenCL::Event ) error = OpenCL.clEnqueueCopyBufferRect(command_queue, src_buffer, dst_buffer, src_origin, dst_origin, r, src_row_pitch, src_slice_pitch, dst_row_pitch, dst_slice_pitch, num_events, events, event) OpenCL.error_check(error) return OpenCL::Event::new(event.read_pointer, false) end |
.enqueue_copy_buffer_to_image(command_queue, src_buffer, dst_image, options = {}) ⇒ Object
Enqueues a command to copy a Buffer into an Image
Attributes
-
command_queue
- CommandQueue used to execute the copy command -
src_buffer
- the Buffer to be read from -
dst_image
- the Image to be written to -
options
- a hash containing named options
Options
-
:event_wait_list
- if provided, a list of Event to wait upon before executing the command -
:dst_origin
- if provided indicates the origin of the region to write into the Image, else [0, 0, 0] -
:region
- if provided indicates the dimension of the region to copy, else the maximum region is copied -
:src_offset
- if provided indicates the offset inside the Buffer, else 0
Returns
the Event associated with the command
710 711 712 713 714 715 716 717 718 719 |
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 710 def self.enqueue_copy_buffer_to_image(command_queue, src_buffer, dst_image, = {}) dst_origin, region = OpenCL.get_origin_region( dst_image, , :dst_origin, :region ) src_offset = 0 src_offset = [:src_offset] if [:src_offset] num_events, events = OpenCL.get_event_wait_list( ) event = FFI::MemoryPointer::new( OpenCL::Event ) error = OpenCL.clEnqueueCopyBufferToImage( command_queue, src_buffer, dst_image, src_offset, dst_origin, region, num_events, events, event ) OpenCL.error_check(error) return OpenCL::Event::new(event.read_pointer, false) end |
.enqueue_copy_image(command_queue, src_image, dst_image, options = {}) ⇒ Object
Enqueues a command to copy from an Image into an Image
Attributes
-
command_queue
- CommandQueue used to execute the copy command -
src_image
- the Image to be written to -
dst_image
- the Image to be written to -
options
- a hash containing named options
Options
-
:event_wait_list
- if provided, a list of Event to wait upon before executing the command -
:src_origin
- if provided indicates the origin of the region to read into the src Image, else [0, 0, 0] -
:dst_origin
- if provided indicates the origin of the region to write into the dst Image, else [0, 0, 0] -
:region
- if provided indicates the dimension of the region to copy, else the maximum region is copied
Returns
the Event associated with the command
779 780 781 782 783 784 785 786 787 788 789 790 791 |
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 779 def self.enqueue_copy_image( command_queue, src_image, dst_image, = {} ) src_origin, src_region = OpenCL.get_origin_region( src_image, , :src_origin, :region ) dst_origin, dst_region = OpenCL.get_origin_region( dst_image, , :dst_origin, :region ) region = FFI::MemoryPointer::new( :size_t, 3 ) (0..2).each { |i| region[i].write_size_t( [src_region[i].read_size_t, dst_region[i].read_size_t].min ) } num_events, events = OpenCL.get_event_wait_list( ) event = FFI::MemoryPointer::new( OpenCL::Event ) error = OpenCL.clEnqueueCopyImage( command_queue, src_image, dst_image, src_origin, dst_origin, region, num_events, events, event ) OpenCL.error_check(error) return OpenCL::Event::new(event.read_pointer, false) end |
.enqueue_copy_image_to_buffer(command_queue, src_image, dst_buffer, options = {}) ⇒ Object
Enqueues a command to copy an Image into a Buffer
Attributes
-
command_queue
- CommandQueue used to execute the copy command -
src_image
- the Image to be read from -
dst_buffer
- the Buffer to be written to -
options
- a hash containing named options
Options
-
:event_wait_list
- if provided, a list of Event to wait upon before executing the command -
:src_origin
- if provided indicates the origin of the region to copy from the Image, else [0, 0, 0] -
:region
- if provided indicates the dimension of the region to copy, else the maximum region is copied -
:dst_offset
- if provided indicates the offset inside the Buffer, else 0
Returns
the Event associated with the command
680 681 682 683 684 685 686 687 688 689 |
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 680 def self.enqueue_copy_image_to_buffer( command_queue, src_image, dst_buffer, = {} ) src_origin, region = OpenCL.get_origin_region( src_image, , :src_origin, :region ) dst_offset = 0 dst_offset = [:dst_offset] if [:dst_offset] num_events, events = OpenCL.get_event_wait_list( ) event = FFI::MemoryPointer::new( OpenCL::Event ) error = OpenCL.clEnqueueCopyImageToBuffer( command_queue, src_image, dst_buffer, src_origin, region, dst_offset, num_events, events, event ) OpenCL.error_check(error) return OpenCL::Event::new(event.read_pointer, false) end |
.enqueue_fill_buffer(command_queue, buffer, pattern, options = {}) ⇒ Object
Enqueues a command to fill a Buffer with the given pattern
Attributes
-
command_queue
- CommandQueue used to execute the fill command -
buffer
- a Buffer object to be filled -
pattern
- the Pointer (or convertible to Pointer using to_ptr) to the memory area where the pattern is stored -
options
- a hash containing named options
Options
-
:event_wait_list
- if provided, a list of Event to wait upon before executing the command -
:offset
- if provided indicates the offset inside the Buffer of the area to be filled, else 0 -
:size
- if provided indicates the size of data to fill, else the maximum size is filled -
:pattern_size
- if provided indicates the size of the pattern, else the maximum pattern data is used
Returns
the Event associated with the command
618 619 620 621 622 623 624 625 626 627 628 629 630 631 |
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 618 def self.enqueue_fill_buffer( command_queue, buffer, pattern, = {} ) OpenCL.error_check(OpenCL::INVALID_OPERATION) if command_queue.context.platform.version_number < 1.1 offset = 0 offset = [:offset] if [:offset] pattern_size = pattern.size pattern_size = [:pattern_size] if [:pattern_size] size = (buffer.size - offset) % pattern_size size = [:size] if [:size] num_events, events = OpenCL.get_event_wait_list( ) event = FFI::MemoryPointer::new( OpenCL::Event ) error = OpenCL.clEnqueueFillBuffer( command_queue, buffer, pattern, pattern_size, offset, size, num_events, events, event ) OpenCL.error_check(error) return OpenCL::Event::new(event.read_pointer, false) end |
.enqueue_fill_image(command_queue, image, fill_color, options = {}) ⇒ Object
Enqueues a command to fill an Image with the given color
Attributes
-
command_queue
- CommandQueue used to execute the fill command -
image
- an Image object to be filled -
fill_color
- the Pointer (or convertible to Pointer using to_ptr) to the memory area where the color is stored -
options
- a hash containing named options
Options
-
:event_wait_list
- if provided, a list of Event to wait upon before executing the command -
:origin
- if provided indicates the origin of the region to fill inside the Image, else [0, 0, 0] -
:region
- if provided indicates the dimension of the region to fill, else the maximum region is filled
Returns
the Event associated with the command
651 652 653 654 655 656 657 658 659 |
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 651 def self.enqueue_fill_image( command_queue, image, fill_color, = {} ) OpenCL.error_check(OpenCL::INVALID_OPERATION) if command_queue.context.platform.version_number < 1.1 origin, region = OpenCL.get_origin_region( image, , :origin, :region ) num_events, events = OpenCL.get_event_wait_list( ) event = FFI::MemoryPointer::new( OpenCL::Event ) error = OpenCL.clEnqueueFillImage( command_queue, image, fill_color, origin, region, num_events, events, event ) OpenCL.error_check(error) return OpenCL::Event::new(event.read_pointer, false) end |
.enqueue_map_buffer(command_queue, buffer, map_flags, options = {}) ⇒ Object
Enqueues a command to map aa Buffer into host memory
Attributes
-
command_queue
- CommandQueue used to execute the map command -
buffer
- the Buffer object to map -
map_flags
- a single or an Array of :cl_map_flags flags -
options
- a hash containing named options
Options
-
:event_wait_list
- if provided, a list of Event to wait upon before executing the command -
:blocking_map
- if provided indicates if the command blocks until the region is mapped -
:blocking
- if provided indicates if the command blocks until the region is mapped -
:offset
- if provided the offset inside the Buffer region to map, else 0 -
:size
- if provided the size of the region in the Buffer to map, else the largest possible size is used
Returns
an Array composed of [event, pointer] where:
-
event
- the Event associated with the command -
pointer
- a Pointer to the mapped memory region
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 168 def self.enqueue_map_buffer( command_queue, buffer, map_flags, = {} ) blocking = OpenCL::FALSE blocking = OpenCL::TRUE if [:blocking] or [:blocking_map] flags = OpenCL.get_flags( {:flags => map_flags} ) offset = 0 offset = [:offset] if [:offset] size = buffer.size - offset size = [:size] - offset if [:size] num_events, events = OpenCL.get_event_wait_list( ) event = FFI::MemoryPointer::new( OpenCL::Event ) error = FFI::MemoryPointer::new( :cl_int ) ptr = OpenCL.clEnqueueMapBuffer( command_queue, buffer, blocking, flags, offset, size, num_events, events, event, error ) OpenCL.error_check( error.read_cl_int ) ev = OpenCL::Event::new( event.read_ptr, false ) return [ev, ptr] end |
.enqueue_map_image(command_queue, image, map_flags, options = {}) ⇒ Object
Enqueues a command to map an Image into host memory
Attributes
-
command_queue
- CommandQueue used to execute the map command -
image
- the Image object to map -
map_flags
- a single or an Array of :cl_map_flags flags -
options
- a hash containing named options
Options
-
:event_wait_list
- if provided, a list of Event to wait upon before executing the command -
:blocking_map
- if provided indicates if the command blocks until the region is mapped -
:blocking
- if provided indicates if the command blocks until the region is mapped -
:origin
- if provided the origin in the Image of the region to map, else [0, 0, 0] -
:region
- if provided the region in the image to map, else the largest possible area is used
Returns
an Array composed of [event, pointer, image_row_pitch, image_slice_pitch] where:
-
event
- the Event associated with the command -
pointer
- a Pointer to the mapped memory region -
image_row_pitch
- the row pitch of the mapped region -
image_slice_pitch
- the slice pitch of the mapped region
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 128 def self.enqueue_map_image( command_queue, image, map_flags, = {} ) blocking = OpenCL::FALSE blocking = OpenCL::TRUE if [:blocking] or [:blocking_map] flags = OpenCL.get_flags( {:flags => map_flags} ) origin, region = OpenCL.get_origin_region( image, , :origin, :region ) num_events, events = OpenCL.get_event_wait_list( ) image_row_pitch = FFI::MemoryPointer::new( :size_t ) image_slice_pitch = FFI::MemoryPointer::new( :size_t ) event = FFI::MemoryPointer::new( OpenCL::Event ) error = FFI::MemoryPointer::new( :cl_int ) ptr = OpenCL.clEnqueueMapImage( command_queue, image, blocking, flags, origin, region, image_row_pitch, image_slice_pitch, num_events, events, event, error ) OpenCL.error_check( error.read_cl_int ) ev = OpenCL::Event::new( event.read_ptr, false ) return [ev, ptr, image_row_pitch.read_size_t, image_slice_pitch.read_size_t] end |
.enqueue_marker(command_queue, events = []) ⇒ Object
Enqueues a marker
Attributes
-
command_queue
- CommandQueue used to execute the command -
events
- an optional single or Array of Event to wait upon before the marker is considered finished, if not provided all previous command are waited for before the marker is considered finished (unavailable if implementation version < 1.2 )
Returns
an Event
1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 |
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 1022 def self.enqueue_marker( command_queue, events = [] ) event = FFI::MemoryPointer::new( OpenCL::Event ) if command_queue.context.platform.version_number < 1.2 then error = OpenCL.clEnqueueMarker( command_queue, event ) else num_events = [events].flatten.length evts = nil if num_events > 0 then evts = FFI::MemoryPointer::new( OpenCL::Event, num_events ) [events].flatten.each_with_index { |e, i| evts[i].write_pointer(e) } end error = OpenCL.clEnqueueMarkerWithWaitList( command_queue, num_events, evts, event ) end OpenCL.error_check(error) return OpenCL::Event::new(event.read_pointer, false) end |
.enqueue_migrate_mem_objects(command_queue, mem_objects, options = {}) ⇒ Object
Enqueues a command to indicate which device a set of memory objects should be migrated to
Attributes
-
command_queue
- objects will be migrated to the device associated with this CommandQueue -
mem_objects
- the Mem objects to migrate -
options
- a hash containing named options
Options
-
:flags
- a single or an Array of :cl_mem_migration flags -
:event_wait_list
- if provided, a list of Event to wait upon before executing the command
Returns
the Event associated with the command
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 86 def self.enqueue_migrate_mem_objects( command_queue, mem_objects, = {} ) OpenCL.error_check(OpenCL::INVALID_OPERATION) if command_queue.context.platform.version_number < 1.2 num_mem_objects = [mem_objects].flatten.length mem_list = nil if num_mem_objects > 0 then mem_list = FFI::MemoryPointer::new( OpenCL::Mem, num_mem_objects ) [mem_objects].flatten.each_with_index { |e, i| mem_list[i].write_pointer(e) } end flags = OpenCL.get_flags( ) num_events, events = OpenCL.get_event_wait_list( ) event = FFI::MemoryPointer::new( OpenCL::Event ) error = OpenCL.clEnqueueMigrateMemObjects( command_queue, num_mem_objects, mem_list, flags, num_events, events, event ) OpenCL.error_check( error ) return OpenCL::Event::new( event.read_ptr, false ) end |
.enqueue_native_kernel(command_queue, options = {}, &func) ⇒ Object
Enqueues a native kernel
Attributes
-
command_queue
- CommandQueue used to execute the command -
options
- a hash containing named options -
func
- a Proc object to execute
Options
-
:args
- if provided, a list of arguments to pass to the kernel. Arguments should have a size method and be convertible to Pointer with to_ptr -
:mem_list
- if provided, a hash containing Buffer objects and their index inside the argument list. -
:event_wait_list
- if provided, a list of Event to wait upon before executing the command
Returns
the Event associated with the command
848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 |
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 848 def self.enqueue_native_kernel( command_queue, = {}, &func ) arguments = [:args] arg_offset = [] args = nil args_size = 0 if arguments then [arguments].flatten.each { |e| arg_offset.push(arg_size) args_size += e.size } args = FFI::MemoryPointer::new(args_size) [arguments].flatten.each_with_index { |e, i| args.put_bytes(arg_offset[i], e.to_ptr.read_bytes(e.size)) } end num_mem_objects = 0 mem_list = nil if [:mem_list] then num_mem_objects = [:mem_list].length if num_mem_objects > 0 then mem_list = FFI::MemoryPointer::new( OpenCL::Mem, num_mem_objects ) mem_loc = FFI::MemoryPointer::new( :pointer, num_mem_objects ) i = 0 [:mem_list].each { |key, value| mem_list[i].write_pointer(key) mem_loc[i].write_pointer(args+arg_offset[value]) i = i + 1 } end end num_events, events = OpenCL.get_event_wait_list( ) event = FFI::MemoryPointer::new( OpenCL::Event ) error = OpenCL.clEnqueueNativeKernel( command_queue, func, args, args_size, num_mem_objects, mem_list, mem_loc, num_events, events, event ) OpenCL.error_check(error) return OpenCL::Event::new(event.read_pointer, false) end |
.enqueue_NDrange_kernel(command_queue, kernel, global_work_size, options = {}) ⇒ Object
Enqueues a kernel as a NDrange
Attributes
-
command_queue
- CommandQueue used to execute the command -
kernel
- a Kernel object to execute -
global_work_size
- dimensions of the work -
options
- a hash containing named options
Options
-
:event_wait_list
- if provided, a list of Event to wait upon before executing the command -
:local_work_size
- if provided, dimensions of the local work group size -
:global_work_offset
- if provided, offset inside the global work size
Returns
the Event associated with the command
932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 |
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 932 def self.enqueue_NDrange_kernel( command_queue, kernel, global_work_size, ={} ) gws = FFI::MemoryPointer::new( :size_t, global_work_size.length ) global_work_size.each_with_index { |g, i| gws[i].write_size_t(g) } lws = nil if [:local_work_size] then lws = FFI::MemoryPointer::new( :size_t, global_work_size.length ) global_work_size.each_index { |i| lws[i].write_size_t([:local_work_size][i]) } end gwo = nil if [:global_work_offset] then gwo = FFI::MemoryPointer::new( :size_t, global_work_size.length ) global_work_size.each_index { |i| gwo[i].write_size_t([:global_work_offset][i]) } end num_events, events = OpenCL.get_event_wait_list( ) event = FFI::MemoryPointer::new( OpenCL::Event ) error = OpenCL.clEnqueueNDRangeKernel(command_queue, kernel, global_work_size.length, gwo, gws, lws, num_events, events, event) OpenCL.error_check(error) return OpenCL::Event::new(event.read_pointer, false) end |
.enqueue_read_buffer(command_queue, buffer, ptr, options = {}) ⇒ Object
Enqueues a command to read from a Buffer object to host memory
Attributes
-
command_queue
- CommandQueue used to execute the read command -
buffer
- the Buffer to be read from -
ptr
- the Pointer (or convertible to Pointer using to_ptr) to the memory area to use -
options
- a hash containing named options
Options
-
:event_wait_list
- if provided, a list of Event to wait upon before executing the command -
:blocking_read
- if provided indicates if the command blocks until the region is read -
:blocking
- if provided indicates if the command blocks until the region is read -
:offset
- if provided indicates the offset inside the Buffer of the area to read from, else 0 -
:size
- if provided indicates the size of data to copy, else the maximum data is copied
Returns
the Event associated with the command
523 524 525 526 527 528 529 530 531 532 533 534 535 |
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 523 def self.enqueue_read_buffer( command_queue, buffer, ptr, = {} ) blocking = OpenCL::FALSE blocking = OpenCL::TRUE if [:blocking] or [:blocking_read] offset = 0 offset = [:offset] if [:offset] size = buffer.size - offset size = [:size] if [:size] num_events, events = OpenCL.get_event_wait_list( ) event = FFI::MemoryPointer::new( OpenCL::Event ) error = OpenCL.clEnqueueReadBuffer(command_queue, buffer, blocking, offset, size, ptr, num_events, events, event) OpenCL.error_check(error) return OpenCL::Event::new(event.read_pointer, false) end |
.enqueue_read_buffer_rect(command_queue, buffer, ptr, region, options = {}) ⇒ Object
Enqueues a command to read from a rectangular region from a Buffer object to host memory
Attributes
-
command_queue
- CommandQueue used to execute the read command -
buffer
- the Buffer to be read from -
ptr
- the Pointer (or convertible to Pointer using to_ptr) to the memory area to use -
region
- the region in the Buffer to copy -
options
- a hash containing named options
Options
-
:event_wait_list
- if provided, a list of Event to wait upon before executing the command -
:blocking_read
- if provided indicates if the command blocks until the region is read -
:blocking
- if provided indicates if the command blocks until the region is read -
:buffer_origin
- if provided indicates the origin inside the buffer of the area to copy, else [0, 0, 0] -
:host_origin
- if provided indicates the origin inside the target host area, else [0, 0, 0] -
:buffer_row_pitch
- if provided indicates the row pitch inside the buffer, else 0 -
:buffer_slice_pitch
- if provided indicates the slice pitch inside the buffer, else 0 -
:host_row_pitch
- if provided indicates the row pitch inside the host area, else 0 -
:host_slice_pitch
- if provided indicates the slice pitch inside the host area, else 0
Returns
the Event associated with the command
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 |
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 235 def self.enqueue_read_buffer_rect( command_queue, buffer, ptr, region, = {} ) OpenCL.error_check(OpenCL::INVALID_OPERATION) if command_queue.context.platform.version_number < 1.1 blocking = OpenCL::FALSE blocking = OpenCL::TRUE if [:blocking] or [:blocking_read] buffer_origin = FFI::MemoryPointer::new( :size_t, 3 ) (0..2).each { |i| buffer_origin[i].write_size_t(0) } bo = [:src_origin] ? [:src_origin] : [:buffer_origin] if bo then bo.each_with_index { |e, i| buffer_origin[i].write_size_t(e) } end host_origin = FFI::MemoryPointer::new( :size_t, 3 ) (0..2).each { |i| host_origin[i].write_size_t(0) } ho = [:dst_origin] ? [:dst_origin] : [:host_origin] if ho then ho.each_with_index { |e, i| host_origin[i].write_size_t(e) } end r = FFI::MemoryPointer::new( :size_t, 3 ) (0..2).each { |i| r[i].write_size_t(0) } region[0..3].each_with_index { |e, i| r[i].write_size_t(e) } buffer_row_pitch = [:src_row_pitch] ? [:src_row_pitch] : [:buffer_row_pitch] if not buffer_row_pitch then buffer_row_pitch = 0 end buffer_slice_pitch = [:src_slice_pitch] ? [:src_slice_pitch] : [:buffer_slice_pitch] if not buffer_slice_pitch then buffer_slice_pitch = 0 end host_row_pitch = [:dst_row_pitch] ? [:dst_row_pitch] : [:host_row_pitch] if not host_row_pitch then host_row_pitch = 0 end host_slice_pitch = [:dst_slice_pitch] ? [:dst_slice_pitch] : [:host_slice_pitch] if not host_slice_pitch then host_slice_pitch = 0 end num_events, events = OpenCL.get_event_wait_list( ) event = FFI::MemoryPointer::new( OpenCL::Event ) error = OpenCL.clEnqueueReadBufferRect(command_queue, buffer, blocking, buffer_origin, host_origin, r, buffer_row_pitch, buffer_slice_pitch, host_row_pitch, host_slice_pitch, ptr, num_events, events, event) OpenCL.error_check(error) return OpenCL::Event::new(event.read_pointer, false) end |
.enqueue_read_image(command_queue, image, ptr, options = {}) ⇒ Object
Enqueues a command to copy from an Image into host memory
Attributes
-
command_queue
- CommandQueue used to execute the read command -
image
- the Image to be written to -
ptr
- the Pointer (or convertible to Pointer using to_ptr) to the memory area to use -
options
- a hash containing named options
Options
-
:event_wait_list
- if provided, a list of Event to wait upon before executing the command -
:blocking_read
- if provided indicates if the command blocks until the region is read. -
:blocking
- if provided indicates if the command blocks until the region is read -
:origin
- if provided indicates the origin of the region to read from the Image, else [0, 0, 0] -
:region
- if provided indicates the dimension of the region to copy, else the maximum region is copied -
:row_pitch
- if provided indicates the row pitch inside the host area, else 0 -
:slice_pitch
- if provided indicates the slice pitch inside the host area, else 0
Returns
the Event associated with the command
815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 |
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 815 def self.enqueue_read_image( command_queue, image, ptr, = {} ) blocking = OpenCL::FALSE blocking = OpenCL::TRUE if [:blocking] or [:blocking_read] origin, region = OpenCL.get_origin_region( image, , :origin, :region ) row_pitch = 0 row_pitch = [:row_pitch] if [:row_pitch] slice_pitch = 0 slice_pitch = [:slice_pitch] if [:slice_pitch] num_events, events = OpenCL.get_event_wait_list( ) event = FFI::MemoryPointer::new( OpenCL::Event ) error = OpenCL.clEnqueueReadImage( command_queue, image, blocking, origin, region, row_pitch, slice_pitch, ptr, num_events, events, event ) OpenCL.error_check(error) return OpenCL::Event::new(event.read_pointer, false) end |
.enqueue_release_GL_object(command_queue, mem_objects, options = {}) ⇒ Object
Release OpenCL Mem objects that have been created from OpenGL objects and previously acquired
Attributes
-
command_queue
- CommandQueue used to execute the release command -
mem_objects
- a single or an Array of Mem objects -
options
- a hash containing named options
Options
-
:event_wait_list
- if provided, a list of Event to wait upon before executing the command
Returns
the Event associated with the command
583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 |
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 583 def self.enqueue_release_GL_object( command_queue, mem_objects, = {} ) num_objs = [mem_objects].flatten.length objs = nil if num_objs > 0 then objs = FFI::MemoryPointer::new( OpenCL::Mem, num_objs ) [mem_objects].flatten.each_with_index { |o, i| objs[i].write_pointer(e) } end num_events, events = OpenCL.get_event_wait_list( ) event = FFI::MemoryPointer::new( OpenCL::Event ) error = OpenCL.clEnqueueReleaseGLObject( command_queue, num_objs, objs, num_events, events, event ) OpenCL.error_check(error) return OpenCL::Event::new(event.read_pointer, false) end |
.enqueue_svm_fill(command_queue, svm_ptr, pattern, size, options = {}) ⇒ Object
Enqueues a command to fill a an SVM memory area
Attributes
-
command_queue
- CommandQueue used to execute the write command -
svm_ptr
- the SVMPointer to the area to fill -
pattern
- the Pointer (or convertible to Pointer using to_ptr) to the memory area where the pattern is stored -
size
- the size of the area to fill
Options
-
:event_wait_list
- if provided, a list of Event to wait upon before executing the command -
:pattern_size
- if provided indicates the size of the pattern, else the maximum pattern data is used
Returns
the Event associated with the command
143 144 145 146 147 148 149 150 151 |
# File 'lib/opencl_ruby_ffi/SVM.rb', line 143 def self.enqueue_svm_fill(command_queue, svm_ptr, pattern, size, = {}) num_events, events = OpenCL.get_event_wait_list( ) pattern_size = pattern.size pattern_size = [:pattern_size] if [:pattern_size] event = FFI::MemoryPointer::new( OpenCL::Event ) error = OpenCL.clEnqueueSVMFill(command_queue, svm_ptr, pattern, pattern_size, size, num_events, events, event) OpenCL.error_check(error) return OpenCL::Event::new(event.read_pointer, false) end |
.enqueue_svm_free(command_queue, svm_pointers, options = {}, &block) ⇒ Object
Enqueues a command that frees SVMPointers (or Pointers using a callback)
Attributes
-
command_queue
- CommandQueue used to execute the write command -
svm_pointer
- a single or an Array of SVMPointer (or Pointer) -
options
- a hash containing named options -
block
- if provided, a callback invoked to free the pointers. Signature of the callback is { |CommandQueue, num_pointers, FFI::Pointer to an array of num_pointers Pointers, FFI::Pointer to user_data| … }
Options
-
:event_wait_list
- if provided, a list of Event to wait upon before executing the command -
:user_data
- if provided, a Pointer (or convertible to using to_ptr) that will be passed to the callback
Returns
the Event associated with the command
82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/opencl_ruby_ffi/SVM.rb', line 82 def self.enqueue_svm_free(command_queue, svm_pointers, = {}, &block) pointers = [svm_pointers].flatten num_pointers = pointers.length ptr = FFI::MemoryPointer::new( :pointer, num_pointers) pointers.each_with_index { |p, indx| ptr[indx].write_pointer(p) } num_events, events = OpenCL.get_event_wait_list( ) event = FFI::MemoryPointer::new( OpenCL::Event ) error = OpenCL.clEnqueueSVMFree(command_queue, num_pointers, ptr, block, [:user_data], num_events, events, event) OpenCL.error_check(error) return OpenCL::Event::new(event.read_pointer, false) end |
.enqueue_svm_map(command_queue, svm_ptr, size, map_flags, options = {}) ⇒ Object
Enqueues a command to map an Image into host memory
Attributes
-
command_queue
- CommandQueue used to execute the map command -
svm_ptr
- the SVMPointer to the area to map -
size
- the size of the region to map -
map_flags
- a single or an Array of :cl_map_flags flags -
options
- a hash containing named options
Options
-
:event_wait_list
- if provided, a list of Event to wait upon before executing the command -
:blocking_map
- if provided indicates if the command blocks until the region is mapped -
:blocking
- if provided indicates if the command blocks until the region is mapped
Returns
the Event associated with the command
172 173 174 175 176 177 178 179 180 181 |
# File 'lib/opencl_ruby_ffi/SVM.rb', line 172 def self.enqueue_svm_map( command_queue, svm_ptr, size, map_flags, = {} ) blocking = OpenCL::FALSE blocking = OpenCL::TRUE if [:blocking] or [:blocking_map] flags = OpenCL.get_flags( {:flags => map_flags} ) num_events, events = OpenCL.get_event_wait_list( ) event = FFI::MemoryPointer::new( OpenCL::Event ) error = OpenCL.clEnqueueSVMMap( command_queue, blocking, flags, svm_ptr, size, num_events, events, event ) OpenCL.error_check( error.read_cl_int ) return OpenCL::Event::new( event.read_ptr, false ) end |
.enqueue_svm_memcpy(command_queue, dst_ptr, src_ptr, size, options = {}) ⇒ Object
Enqueues a command to copy from or to an SVMPointer
Attributes
-
command_queue
- CommandQueue used to execute the write command -
dst_ptr
- the Pointer (or convertible to Pointer using to_ptr) or SVMPointer to be written to -
src_ptr
- the Pointer (or convertible to Pointer using to_ptr) or SVMPointer to be read from -
size
- the size of data to copy -
options
- a hash containing named options
Options
-
:event_wait_list
- if provided, a list of Event to wait upon before executing the command -
:blocking_copy
- if provided indicates if the command blocks until the copy finishes -
:blocking
- if provided indicates if the command blocks until the copy finishes
Returns
the Event associated with the command
115 116 117 118 119 120 121 122 123 124 |
# File 'lib/opencl_ruby_ffi/SVM.rb', line 115 def self.enqueue_svm_memcpy(command_queue, dst_ptr, src_ptr, size, = {}) OpenCL.error_check(OpenCL::INVALID_OPERATION) if command_queue.context.platform.version_number < 2.0 blocking = OpenCL::FALSE blocking = OpenCL::TRUE if [:blocking] or [:blocking_copy] num_events, events = OpenCL.get_event_wait_list( ) event = FFI::MemoryPointer::new( OpenCL::Event ) error = OpenCL.clEnqueueSVMMemcpy(command_queue, blocking, dst_ptr, src_ptr, size, num_events, events, event) OpenCL.error_check(error) return OpenCL::Event::new(event.read_pointer, false) end |
.enqueue_svm_unmap(command_queue, svm_ptr, options = {}) ⇒ Object
Enqueues a command to unmap a previously mapped SVM memory area
Attributes
-
command_queue
- CommandQueue used to execute the unmap command -
svm_ptr
- the SVMPointer of the area to be unmapped -
options
- a hash containing named options
Options
-
:event_wait_list
- if provided, a list of Event to wait upon before executing the command
Returns
the Event associated with the command
198 199 200 201 202 203 204 |
# File 'lib/opencl_ruby_ffi/SVM.rb', line 198 def self.enqueue_svm_unmap( command_queue, svm_ptr, = {} ) num_events, events = OpenCL.get_event_wait_list( ) event = FFI::MemoryPointer::new( OpenCL::Event ) error = OpenCL.clEnqueueSVMUnmap( command_queue, svm_ptr, num_events, events, event ) OpenCL.error_check( error ) return OpenCL::Event::new( event.read_ptr, false ) end |
.enqueue_task(command_queue, kernel, options = {}) ⇒ Object
Enqueues a kernel as a task
Attributes
-
command_queue
- CommandQueue used to execute the command -
kernel
- a Kernel object to execute -
options
- a hash containing named options
Options
-
:event_wait_list
- if provided, a list of Event to wait upon before executing the command
Returns
the Event associated with the command
900 901 902 903 904 905 906 907 908 909 910 911 912 |
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 900 def self.enqueue_task( command_queue, kernel, = {} ) if queue.context.platform.version_number < 2.0 then num_events, events = OpenCL.get_event_wait_list( ) event = FFI::MemoryPointer::new( OpenCL::Event ) error = OpenCL.clEnqueueTask( command_queue, kernel, num_events, events, event ) OpenCL.error_check(error) return OpenCL::Event::new(event.read_pointer, false) else opts = .dup opts[:local_work_size] = [1] return OpenCL.enqueue_NDrange_kernel( command_queue, kernel, [1], opts ) end end |
.enqueue_unmap_mem_object(command_queue, mem_obj, mapped_ptr, options = {}) ⇒ Object
Enqueues a command to unmap a previously mapped region of a memory object
Attributes
-
command_queue
- CommandQueue used to execute the unmap command -
mem_obj
- the Mem object that was previously mapped -
mapped_ptr
- the Pointer previously returned by a map command -
options
- a hash containing named options
Options
-
:event_wait_list
- if provided, a list of Event to wait upon before executing the command
Returns
the Event associated with the command
202 203 204 205 206 207 208 |
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 202 def self.enqueue_unmap_mem_object( command_queue, mem_obj, mapped_ptr, = {} ) num_events, events = OpenCL.get_event_wait_list( ) event = FFI::MemoryPointer::new( OpenCL::Event ) error = OpenCL.clEnqueueUnmapMemObject( command_queue, mem_obj, mapped_ptr, num_events, events, event ) OpenCL.error_check( error ) return OpenCL::Event::new( event.read_ptr, false ) end |
.enqueue_wait_for_events(command_queue, events) ⇒ Object
Enqueues a barrier on a list of envents
Attributes
-
command_queue
- CommandQueue used to execute the command -
events
- a single or an Array of Event to wait upon before the barrier is considered finished
Returns
an Event if implementation version is >= 1.2, nil otherwise
968 969 970 |
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 968 def self.enqueue_wait_for_events( command_queue, events ) return OpenCL.( command_queue, events ) end |
.enqueue_write_buffer(command_queue, buffer, ptr, options = {}) ⇒ Object
Enqueues a command to write to a Buffer object from host memory
Attributes
-
command_queue
- CommandQueue used to execute the write command -
buffer
- the Buffer to be written to -
ptr
- the Pointer (or convertible to Pointer using to_ptr) to the memory area to use -
options
- a hash containing named options
Options
-
:event_wait_list
- if provided, a list of Event to wait upon before executing the command -
:blocking_write
- if provided indicates if the command blocks until the region is written. -
:blocking
- if provided indicates if the command blocks until the region is written -
:offset
- if provided indicates the offset inside the Buffer of the area to read from, else 0 -
:size
- if provided indicates the size of data to copy, else the maximum data is copied
Returns
the Event associated with the command
489 490 491 492 493 494 495 496 497 498 499 500 501 |
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 489 def self.enqueue_write_buffer( command_queue, buffer, ptr, = {} ) blocking = OpenCL::FALSE blocking = OpenCL::TRUE if [:blocking] or [:blocking_write] offset = 0 offset = [:offset] if [:offset] size = buffer.size - offset size = [:size] if [:size] num_events, events = OpenCL.get_event_wait_list( ) event = FFI::MemoryPointer::new( OpenCL::Event ) error = OpenCL.clEnqueueWriteBuffer(command_queue, buffer, blocking, offset, size, ptr, num_events, events, event) OpenCL.error_check(error) return OpenCL::Event::new(event.read_pointer, false) end |
.enqueue_write_buffer_rect(command_queue, buffer, ptr, region, options = {}) ⇒ Object
Enqueues a command to write to a rectangular region in a Buffer object from host memory
Attributes
-
command_queue
- CommandQueue used to execute the write command -
buffer
- the Buffer to be written to -
ptr
- the Pointer (or convertible to Pointer using to_ptr) to the memory area to use -
region
- the region to write in the Buffer -
options
- a hash containing named options
Options
-
:event_wait_list
- if provided, a list of Event to wait upon before executing the command -
:blocking_write
- if provided indicates if the command blocks until the region is written -
:blocking
- if provided indicates if the command blocks until the region is written -
:buffer_origin
- if provided indicates the origin inside the buffer of the area to copy, else [0, 0, 0] -
:host_origin
- if provided indicates the origin inside the target host area, else [0, 0, 0] -
:buffer_row_pitch
- if provided indicates the row pitch inside the buffer, else 0 -
:buffer_slice_pitch
- if provided indicates the slice pitch inside the buffer, else 0 -
:host_row_pitch
- if provided indicates the row pitch inside the host area, else 0 -
:host_slice_pitch
- if provided indicates the slice pitch inside the host area, else 0
Returns
the Event associated with the command
312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 |
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 312 def self.enqueue_write_buffer_rect(command_queue, buffer, ptr, region, = {}) OpenCL.error_check(OpenCL::INVALID_OPERATION) if command_queue.context.platform.version_number < 1.1 blocking = OpenCL::FALSE blocking = OpenCL::TRUE if [:blocking] or [:blocking_write] buffer_origin = FFI::MemoryPointer::new( :size_t, 3 ) (0..2).each { |i| buffer_origin[i].write_size_t(0) } bo = [:dst_origin] ? [:dst_origin] : [:buffer_origin] if bo then bo.each_with_index { |e, i| buffer_origin[i].write_size_t(e) } end host_origin = FFI::MemoryPointer::new( :size_t, 3 ) (0..2).each { |i| host_origin[i].write_size_t(0) } ho = [:src_origin] ? [:src_origin] : [:host_origin] if ho then ho.each_with_index { |e, i| host_origin[i].write_size_t(e) } end r = FFI::MemoryPointer::new( :size_t, 3 ) (0..2).each { |i| r[i].write_size_t(0) } region[0..3].each_with_index { |e, i| r[i].write_size_t(e) } buffer_row_pitch = [:dst_row_pitch] ? [:dst_row_pitch] : [:buffer_row_pitch] if not buffer_row_pitch then buffer_row_pitch = 0 end buffer_slice_pitch = [:dst_slice_pitch] ? [:dst_slice_pitch] : [:buffer_slice_pitch] if not buffer_slice_pitch then buffer_slice_pitch = 0 end host_row_pitch = [:src_row_pitch] ? [:src_row_pitch] : [:host_row_pitch] if not host_row_pitch then host_row_pitch = 0 end host_slice_pitch = [:src_slice_pitch] ? [:src_slice_pitch] : [:host_slice_pitch] if not host_slice_pitch then host_slice_pitch = 0 end num_events, events = OpenCL.get_event_wait_list( ) event = FFI::MemoryPointer::new( OpenCL::Event ) error = OpenCL.clEnqueueWriteBufferRect(command_queue, buffer, blocking, buffer_origin, host_origin, r, buffer_row_pitch, buffer_slice_pitch, host_row_pitch, host_slice_pitch, ptr, num_events, events, event) OpenCL.error_check(error) return OpenCL::Event::new(event.read_pointer, false) end |
.enqueue_write_image(command_queue, image, ptr, options = {}) ⇒ Object
Enqueues a command to copy from host memory into an Image
Attributes
-
command_queue
- CommandQueue used to execute the write command -
image
- the Image to be written to -
ptr
- the Pointer (or convertible to Pointer using to_ptr) to the memory area to use -
options
- a hash containing named options
Options
-
:event_wait_list
- if provided, a list of Event to wait upon before executing the command -
:blocking_write
- if provided indicates if the command blocks until the region is written. -
:blocking
- if provided indicates if the command blocks until the region is written -
:origin
- if provided indicates the origin of the region to write into the Image, else [0, 0, 0] -
:region
- if provided indicates the dimension of the region to copy, else the maximum region is copied -
:input_row_pitch
- if provided indicates the row pitch inside the host area, else 0 -
:input_slice_pitch
- if provided indicates the slice pitch inside the host area, else 0
Returns
the Event associated with the command
743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 |
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 743 def self.enqueue_write_image(command_queue, image, ptr, = {}) blocking = OpenCL::FALSE blocking = OpenCL::TRUE if [:blocking] or [:blocking_write] origin, region = OpenCL.get_origin_region( image, , :origin, :region ) input_row_pitch = 0 input_row_pitch = [:input_row_pitch] if [:input_row_pitch] input_slice_pitch = 0 input_slice_pitch = [:input_slice_pitch] if [:input_slice_pitch] num_events, events = OpenCL.get_event_wait_list( ) event = FFI::MemoryPointer::new( OpenCL::Event ) error = OpenCL.clEnqueueWriteImage( command_queue, image, blocking, origin, region, input_row_pitch, input_slice_pitch, ptr, num_events, events, event ) OpenCL.error_check(error) return OpenCL::Event::new(event.read_pointer, false) end |
.error_check(errcode) ⇒ Object
checks if a :cl_int corresponds to an Error code and raises the apropriate OpenCL::Error
255 256 257 |
# File 'lib/opencl_ruby_ffi/opencl_ruby_ffi_base.rb', line 255 def self.error_check(errcode) raise OpenCL::Error::new(OpenCL::Error.get_error_string(errcode)) if errcode != SUCCESS end |
.finish(command_queue) ⇒ Object
Blocks until all the commands in the queue have completed
Attributes
-
command_queue
- the CommandQueue to finish
8 9 10 11 12 |
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 8 def self.finish( command_queue ) error = OpenCL.clFinish( command_queue ) OpenCL.error_check( error ) return command_queue end |
.flush(command_queue) ⇒ Object
Issues all the commands in a CommandQueue to the Device
Attributes
-
command_queue
- the CommandQueue to flush
19 20 21 22 23 |
# File 'lib/opencl_ruby_ffi/CommandQueue.rb', line 19 def self.flush( command_queue ) error = OpenCL.clFlush( command_queue ) OpenCL.error_check( error ) return command_queue end |
.get_command_queue_properties(options) ⇒ Object
Extracts the :properties named option (for a CommandQueue) from the hash given and returns the properties values
198 199 200 201 202 203 204 205 206 207 208 |
# File 'lib/opencl_ruby_ffi/opencl_ruby_ffi_base.rb', line 198 def self.get_command_queue_properties( ) properties = OpenCL::CommandQueue::Properties::new(0) if [:properties] then if [:properties].respond_to?(:each) then [:properties].each { |f| properties = properties | f } else properties = properties | [:properties] end end return properties end |
.get_context_properties(options) ⇒ Object
Extracts the :properties named option (for a Context) from the hash given and returns an FFI:Pointer to a 0 terminated list of properties
242 243 244 245 246 247 248 249 250 251 252 |
# File 'lib/opencl_ruby_ffi/opencl_ruby_ffi_base.rb', line 242 def self.get_context_properties( ) properties = nil if [:properties] then properties = FFI::MemoryPointer::new( :cl_context_properties, [:properties].length + 1 ) [:properties].each_with_index { |e,i| properties[i].write_cl_context_properties(e) } properties[[:properties].length].write_cl_context_properties(0) end return properties end |
.get_event_wait_list(options) ⇒ Object
Extracts the :event_wait_list named option from the hash given and returns a tuple containing the number of events and a pointer to those events
182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
# File 'lib/opencl_ruby_ffi/opencl_ruby_ffi_base.rb', line 182 def self.get_event_wait_list( ) num_events = 0 events = nil if [:event_wait_list] then num_events = [:event_wait_list].length if num_events > 0 then events = FFI::MemoryPointer::new( Event, num_events ) [:event_wait_list].each_with_index { |e, i| events[i].write_pointer(e) } end end return [ num_events, events ] end |
.get_extension_function(name, return_type, param_types, options = {}) ⇒ Object
Returns an FFI::Function corresponding to an extension function
Attributes
-
name
- a String representing the name of the function -
return_type
- the type of data returned by the function -
param_types
- an Array of types, corresponding to the parameters type -
options
- if given, a hash of named options that will be given to FFI::Function::new. See FFI doc for details.
30 31 32 33 34 35 |
# File 'lib/opencl_ruby_ffi/Platform.rb', line 30 def self.get_extension_function( name, return_type, param_types, = {} ) name_p = FFI::MemoryPointer.from_string(name) ptr = OpenCL.clGetExtensionFunctionAddress( name_p ) return nil if ptr.null? return FFI::Function::new(return_type, param_types, ptr, ) end |
.get_extension_function_for_platform(platform, name, return_type, param_types, options = {}) ⇒ Object
Returns an FFI::Function corresponding to an extension function for the Platform
Attributes
-
platform
- the Platform to be queried -
name
- a String representing the name of the function -
return_type
- the type of data returned by the function -
param_types
- an Array of types, corresponding to the parameters type -
options
- if given, a hash of named options that will be given to FFI::Function::new. See FFI doc for details.
46 47 48 49 50 51 52 |
# File 'lib/opencl_ruby_ffi/Platform.rb', line 46 def self.get_extension_function_for_platform( platform, name, return_type, param_types, = {} ) OpenCL.error_check(OpenCL::INVALID_OPERATION) if self.version_number < 1.2 name_p = FFI::MemoryPointer.from_string(name) ptr = OpenCL.clGetExtensionFunctionAddressForPlatform( platform, name_p ) return nil if ptr.null? return FFI::Function::new(return_type, param_types, ptr, ) end |
.get_flags(options) ⇒ Object
Extracts the :flags named option from the hash given and returns the flags value
169 170 171 172 173 174 175 176 177 178 179 |
# File 'lib/opencl_ruby_ffi/opencl_ruby_ffi_base.rb', line 169 def self.get_flags( ) flags = 0 if [:flags] then if [:flags].respond_to?(:each) then [:flags].each { |f| flags = flags | f } else flags = [:flags] end end return flags end |
.get_info(klass, type, name) ⇒ Object
Generates a new method for klass that use the apropriate clGetKlassInfo, to read an element of the given type. The info queried is specified by name.
295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 |
# File 'lib/opencl_ruby_ffi/opencl_ruby_ffi_base.rb', line 295 def self.get_info(klass, type, name) klass_name = klass klass_name = "MemObject" if klass == "Mem" s = <<EOF def #{name.downcase} ptr1 = FFI::MemoryPointer::new( :size_t, 1) error = OpenCL.clGet#{klass_name}Info(self, #{klass}::#{name}, 0, nil, ptr1) OpenCL.error_check(error) ptr2 = FFI::MemoryPointer::new( ptr1.read_size_t ) error = OpenCL.clGet#{klass_name}Info(self, #{klass}::#{name}, ptr1.read_size_t, ptr2, nil) OpenCL.error_check(error) EOF if(OpenCL::convert_type(type)) then s += <<EOF return OpenCL::convert_type(:#{type})::new(ptr2.read_#{type}) end EOF else s += <<EOF return ptr2.read_#{type} end EOF end return s end |
.get_info_array(klass, type, name) ⇒ Object
Generates a new method for klass that use the apropriate clGetKlassInfo, to read an Array of element of the given type. The info queried is specified by name.
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 |
# File 'lib/opencl_ruby_ffi/opencl_ruby_ffi_base.rb', line 260 def self.get_info_array(klass, type, name) klass_name = klass klass_name = "MemObject" if klass == "Mem" s = <<EOF def #{name.downcase} ptr1 = FFI::MemoryPointer::new( :size_t, 1) error = OpenCL.clGet#{klass_name}Info(self, #{klass}::#{name}, 0, nil, ptr1) OpenCL.error_check(error) EOF if ( klass == "Device" and name == "PARTITION_TYPE" ) or ( klass == "Context" and name == "PROPERTIES" ) then s+= <<EOF return [] if ptr1.read_size_t == 0 EOF end s += <<EOF ptr2 = FFI::MemoryPointer::new( ptr1.read_size_t ) error = OpenCL.clGet#{klass_name}Info(self, #{klass}::#{name}, ptr1.read_size_t, ptr2, nil) OpenCL.error_check(error) arr = ptr2.get_array_of_#{type}(0, ptr1.read_size_t/ FFI.find_type(:#{type}).size) EOF if ( klass == "Device" and ( name == "PARTITION_TYPE" or name == "PARTITION_PROPERTIES" ) ) or ( klass == "Context" and name == "PROPERTIES" ) then s+= <<EOF return arr.reject! { |e| e == 0 } end EOF else s+= <<EOF return arr end EOF end return s end |
.get_origin_region(image, options, origin_symbol, region_symbol) ⇒ Object
Extracts the origin_symbol and region_symbol named options for image from the given hash. Returns the read (or detemined suitable) origin and region in a tuple
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 |
# File 'lib/opencl_ruby_ffi/opencl_ruby_ffi_base.rb', line 211 def self.get_origin_region( image, , origin_symbol, region_symbol ) origin = FFI::MemoryPointer::new( :size_t, 3 ) (0..2).each { |i| origin[i].write_size_t(0) } if [origin_symbol] then [origin_symbol].each_with_index { |e, i| origin[i].write_size_t(e) } end region = FFI::MemoryPointer::new( :size_t, 3 ) (0..2).each { |i| region[i].write_size_t(1) } if [region_symbol] then [region_symbol].each_with_index { |e, i| region[i].write_size_t(e) } else region[0].write_size_t( image.width - origin[0].read_size_t ) if image.type == OpenCL::Mem::IMAGE1D_ARRAY then region[1].write_size_t( image.array_size - origin[1].read_size_t ) else region[1].write_size_t( image.height != 0 ? image.height - origin[1].read_size_t : 1 ) end if image.type == OpenCL::Mem::IMAGE2D_ARRAY then region[2].write_size_t( image.array_size - origin[2].read_size_t ) else region[2].write_size_t( image.depth != 0 ? image.depth - origin[2].read_size_t : 1 ) end end return [origin, region] end |
.get_platforms ⇒ Object Also known as: platforms
Returns an Array of Platforms containing the available OpenCL platforms
55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/opencl_ruby_ffi/Platform.rb', line 55 def self.get_platforms ptr1 = FFI::MemoryPointer::new(:cl_uint , 1) error = OpenCL::clGetPlatformIDs(0, nil, ptr1) OpenCL.error_check(error) ptr2 = FFI::MemoryPointer::new(:pointer, ptr1.read_uint) error = OpenCL::clGetPlatformIDs(ptr1.read_uint(), ptr2, nil) OpenCL.error_check(error) return ptr2.get_array_of_pointer(0,ptr1.read_uint()).collect { |platform_ptr| OpenCL::Platform::new(platform_ptr, false) } end |
.link_program(context, input_programs, options = {}, &block) ⇒ Object
Links a set of compiled programs for all device in a Context, or a subset of devices
Attributes
-
context
- Context the created Program will be associated with -
input_programs
- a single or an Array of Program -
options
- a Hash containing named options -
block
- if provided, a callback invoked when the Program is built. Signature of the callback is { |Program, FFI::Pointer to user_data| … }
Options
-
:device_list
- an Array of Device to build the program for -
:options
- a String containing the options to use for the build -
:user_data
- a Pointer (or convertible to Pointer using to_ptr) to the memory area to pass to the callback
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/opencl_ruby_ffi/Program.rb', line 51 def self.link_program(context, input_programs, = {}, &block) @@callbacks.push( block ) if block devices = [:device_list] devices = [devices].flatten if devices devices_p = nil num_devices = 0 if devices and devices.size > 0 then num_devices = devices.size devices_p = FFI::MemoryPointer::new( Device, num_devices) num_devices.times { |indx| devices_p[indx].write_pointer(devices[indx]) } end opt = "" opt = [:options] if [:options] = FFI::MemoryPointer.from_string(opt) programs = [input_programs].flatten num_programs = programs.length programs_p = FFI::MemoryPointer::new( Program, num_programs ) programs.each_with_index { |e, i| programs_p[i].write_pointer(e) } error = FFI::MemoryPointer::new( :cl_int ) prog = OpenCL.clLinkProgram( context, num_devices, devices_p, , num_programs, programs_p, block, [:user_data], error) OpenCL.error_check(error.read_cl_int) return OpenCL::Program::new( prog, false ) end |
.set_event_callback(event, command_exec_callback_type, options = {}, &proc) ⇒ Object
Attaches a callback to event that will be called on the given transition
Attributes
-
event
- the Event to attach the callback to -
options
- a hash containing named options -
block
- a callback invoked when the given event occurs. Signature of the callback is { |Event, :cl_int event_command_exec_status, 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
26 27 28 29 30 31 |
# File 'lib/opencl_ruby_ffi/Event.rb', line 26 def self.set_event_callback( event, command_exec_callback_type, = {}, &proc ) OpenCL.error_check(OpenCL::INVALID_OPERATION) if event.context.platform.version_number < 1.1 error = OpenCL.clSetEventCallback( event, command_exec_callback_type, proc, [:user_data] ) OpenCL.error_check(error) return self end |
.set_kernel_arg(kernel, index, value, size = nil) ⇒ Object
Set the index th argument of Kernel to value. size of value can be specified
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/opencl_ruby_ffi/Kernel.rb', line 26 def self.set_kernel_arg( kernel, index, value, size = nil ) sz = size sz = value.class.size if sz == nil val = value if value.kind_of?(OpenCL::Mem) then val = FFI::MemoryPointer::new( OpenCL::Mem ) val.write_pointer(value.to_ptr) end error = OpenCL.clSetKernelArg( kernel, index, sz, val ) OpenCL.error_check(error) end |
.set_kernel_arg_svm_pointer(kernel, index, value) ⇒ Object
Set the index th argument of Kernel to value. Value must be within a SVM memory area
58 59 60 61 62 63 |
# File 'lib/opencl_ruby_ffi/SVM.rb', line 58 def self.set_kernel_arg_svm_pointer( kernel, index, value ) OpenCL.error_check(OpenCL::INVALID_OPERATION) if kernel.context.platform.version_number < 2.0 error = OpenCL.clSetKernelArgSVMPointer( kernel, index, val ) OpenCL.error_check(error) return kernel end |
.set_mem_object_destructor_callback(memobj, options = {}, &proc) ⇒ Object
Attaches a callback to memobj the will be called on memobj destruction
Attributes
-
memobj
- the Mem to attach the callback to -
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
14 15 16 17 18 19 |
# File 'lib/opencl_ruby_ffi/Mem.rb', line 14 def self.set_mem_object_destructor_callback( memobj, = {}, &proc ) @@callbacks.push( block ) if block error = OpenCL.clSetMemObjectDestructorCallback( memobj, block, [:user_data] ) OpenCL.error_check(error) return self end |
.set_user_event_status(event, execution_status) ⇒ Object
Sets the satus of user Event to the given execution status
47 48 49 50 51 52 |
# File 'lib/opencl_ruby_ffi/Event.rb', line 47 def self.set_user_event_status( event, execution_status ) OpenCL.error_check(OpenCL::INVALID_OPERATION) if event.context.platform.version_number < 1.1 error = OpenCL.clSetUserEventStatus( event, execution_status ) OpenCL.error_check(error) return self end |
.svm_alloc(context, size, options = {}) ⇒ Object
Creates an SVMPointer pointing to an SVM area of memory
Attributes
-
context
- the Context in which to allocate the memory -
size
- the size of the mmemory area to allocate -
options
- a hash containing named options
Options
-
:alignment
- imposes the minimum alignment in byte
36 37 38 39 40 41 42 43 44 |
# File 'lib/opencl_ruby_ffi/SVM.rb', line 36 def self.svm_alloc(context, size, = {}) OpenCL.error_check(OpenCL::INVALID_OPERATION) if context.platform.version_number < 2.0 flags = OpenCL::get_flags() alignment = 0 alignment = [:alignment] if [:alignment] ptr = OpenCL.clSVMAlloc( context, flags, size, alignment ) raise OpenCL::Error::new(OpenCL::Error.getErrorString(OpenCL::Error::MEM_OBJECT_ALLOCATION_FAILURE)) if ptr.null? return OpenCL::SVMPointer::new( ptr, context ) end |
.svm_free(context, svm_pointer) ⇒ Object
Frees an SVMPointer
Attributes
-
context
- the Context in which to deallocate the memory -
svm_pointer
- the SVMPointer to deallocate
52 53 54 55 |
# File 'lib/opencl_ruby_ffi/SVM.rb', line 52 def self.svm_free(context, svm_pointer) OpenCL.error_check(OpenCL::INVALID_OPERATION) if context.platform.version_number < 2.0 return OpenCL.clSVMFree( context, svm_pointer ) end |
.unload_compiler ⇒ Object
Unloads the compiler
16 17 18 19 20 |
# File 'lib/opencl_ruby_ffi/Platform.rb', line 16 def self.unload_compiler error = OpenCL.clUnloadCompiler() OpenCL.error_check(error) return nil end |
.unload_platform_compiler(platform) ⇒ Object
Unloads a Platform compiler
Attributes
-
platform
- the Platform to have it’s compiler unloaded
8 9 10 11 12 13 |
# File 'lib/opencl_ruby_ffi/Platform.rb', line 8 def self.unload_platform_compiler(platform) OpenCL.error_check(OpenCL::INVALID_OPERATION) if self.version_number < 1.2 error = OpenCL.clUnloadPlatformCompiler( platform ) OpenCL.error_check(error) return platform end |
.wait_for_events(event_list) ⇒ Object
Waits for the command identified by Event objects to complete
Attributes
-
event_list
- a single or an Array of Event to wait upon before returning
8 9 10 11 12 13 |
# File 'lib/opencl_ruby_ffi/Event.rb', line 8 def self.wait_for_events(event_list) num_events, events = OpenCL.get_event_wait_list( {:event_wait_list => event_list } ) error = OpenCL.clWaitForEvents(num_events, events) OpenCL.error_check(error) return nil end |