pyopencl.
VERSION
¶Gives the numeric version of PyOpenCL as a variable-length tuple of integers. Enables easy version checks such as VERSION >= (0, 93).
pyopencl.
VERSION_STATUS
¶A text string such as “rc4” or “beta” qualifying the status of the release.
pyopencl.
VERSION_TEXT
¶The full release name (such as “0.93rc4”) in string form.
pyopencl.
get_cl_header_version
()¶Return a variable-length tuple of integers representing the version of the OpenCL header against which PyOpenCL was compiled.
New in version 0.92.
pyopencl.
Error
¶Base class for all PyOpenCL exceptions.
pyopencl.
MemoryError
¶pyopencl.
LogicError
¶pyopencl.
RuntimeError
¶pyopencl.
addressing_mode
¶CLAMP
¶CLAMP_TO_EDGE
¶MIRRORED_REPEAT
¶Available with OpenCL 1.1.
New in version 0.92.
NONE
¶REPEAT
¶to_string
(value)¶Returns a str
representing value.
New in version 0.91.
pyopencl.
cffi_array
¶T
¶all
¶any
¶argmax
¶argmin
¶argpartition
¶argsort
¶astype
¶base
¶byteswap
¶choose
¶clip
¶compress
¶conj
¶conjugate
¶copy
¶ctypes
¶cumprod
¶cumsum
¶data
¶diagonal
¶dot
¶dtype
¶dump
¶dumps
¶fill
¶flags
¶flat
¶flatten
¶getfield
¶imag
¶item
¶itemset
¶itemsize
¶max
¶mean
¶min
¶nbytes
¶ndim
¶newbyteorder
¶nonzero
¶partition
¶prod
¶ptp
¶put
¶ravel
¶real
¶repeat
¶reshape
¶resize
¶round
¶searchsorted
¶setfield
¶setflags
¶shape
¶size
¶sort
¶squeeze
¶std
¶strides
¶sum
¶swapaxes
¶take
¶tobytes
¶tofile
¶tolist
¶tostring
¶trace
¶transpose
¶var
¶view
¶to_string
(value)¶Returns a str
representing value.
New in version 0.91.
pyopencl.
channel_order
¶A
¶ABGR
¶Available with OpenCL 2.0.
New in version 2015.2.
BGRA
¶INTENSITY
¶LUMINANCE
¶R
¶RA
¶RG
¶RGB
¶RGBA
¶RGBx
¶Available with OpenCL 1.1.
New in version 0.92.
RGx
¶Available with OpenCL 1.1.
New in version 0.92.
Rx
¶Available with OpenCL 1.1.
New in version 0.92.
sBGRA
¶Available with OpenCL 2.0.
New in version 2015.2.
sRGB
¶Available with OpenCL 2.0.
New in version 2015.2.
sRGBA
¶Available with OpenCL 2.0.
New in version 2015.2.
sRGBx
¶Available with OpenCL 2.0.
New in version 2015.2.
to_string
(value)¶Returns a str
representing value.
New in version 0.91.
pyopencl.
channel_type
¶FLOAT
¶HALF_FLOAT
¶SIGNED_INT16
¶SIGNED_INT32
¶SIGNED_INT8
¶SNORM_INT16
¶SNORM_INT8
¶UNORM_INT16
¶UNORM_INT8
¶UNORM_INT_101010
¶UNORM_SHORT_555
¶UNORM_SHORT_565
¶UNSIGNED_INT16
¶UNSIGNED_INT32
¶UNSIGNED_INT8
¶to_string
(value)¶Returns a str
representing value.
New in version 0.91.
pyopencl.
command_execution_status
¶COMPLETE
¶QUEUED
¶RUNNING
¶SUBMITTED
¶to_string
(value)¶Returns a str
representing value.
New in version 0.91.
pyopencl.
command_queue_info
¶CONTEXT
¶DEVICE
¶PROPERTIES
¶REFERENCE_COUNT
¶to_string
(value)¶Returns a str
representing value.
New in version 0.91.
pyopencl.
command_queue_properties
¶ON_DEVICE
¶Available with OpenCL 2.0.
New in version 2015.2.
ON_DEVICE_DEFAULT
¶Available with OpenCL 2.0.
New in version 2015.2.
OUT_OF_ORDER_EXEC_MODE_ENABLE
¶PROFILING_ENABLE
¶to_string
(value)¶Returns a str
representing value.
New in version 0.91.
pyopencl.
command_type
¶ACQUIRE_GL_OBJECTS
¶BARRIER
¶Available with OpenCL 1.2.
New in version 2011.2.
COPY_BUFFER
¶COPY_BUFFER_RECT
¶Available with OpenCL 1.1.
New in version 0.92.
COPY_BUFFER_TO_IMAGE
¶COPY_IMAGE
¶COPY_IMAGE_TO_BUFFER
¶FILL_BUFFER
¶Available with OpenCL 1.2.
New in version 2011.2.
FILL_IMAGE
¶Available with OpenCL 1.2.
New in version 2011.2.
MAP_BUFFER
¶MAP_IMAGE
¶MARKER
¶MIGRATE_MEM_OBJECTS
¶Available with OpenCL 1.2.
New in version 2011.2.
NATIVE_KERNEL
¶NDRANGE_KERNEL
¶READ_BUFFER
¶READ_BUFFER_RECT
¶Available with OpenCL 1.1.
New in version 0.92.
READ_IMAGE
¶RELEASE_GL_OBJECTS
¶SVM_FREE
¶Available with OpenCL 2.0.
New in version 2015.2.
SVM_MAP
¶Available with OpenCL 2.0.
New in version 2015.2.
SVM_MEMCPY
¶Available with OpenCL 2.0.
New in version 2015.2.
SVM_MEMFILL
¶Available with OpenCL 2.0.
New in version 2015.2.
SVM_UNMAP
¶Available with OpenCL 2.0.
New in version 2015.2.
TASK
¶UNMAP_MEM_OBJECT
¶USER
¶Available with OpenCL 1.1.
New in version 0.92.
WRITE_BUFFER
¶WRITE_BUFFER_RECT
¶Available with OpenCL 1.1.
New in version 0.92.
WRITE_IMAGE
¶to_string
(value)¶Returns a str
representing value.
New in version 0.91.
pyopencl.
context_info
¶DEVICES
¶INTEROP_USER_SYNC
¶Available with OpenCL 1.2.
New in version 2011.2.
NUM_DEVICES
¶Available with OpenCL 1.1.
New in version 0.92.
PROPERTIES
¶REFERENCE_COUNT
¶to_string
(value)¶Returns a str
representing value.
New in version 0.91.
pyopencl.
context_properties
¶CGL_SHAREGROUP_KHR
¶Available with the cl_khr_gl_sharing
extension.
New in version 0.92.
EGL_DISPLAY_KHR
¶Available with the cl_khr_gl_sharing
extension.
New in version 0.92.
GLX_DISPLAY_KHR
¶Available with the cl_khr_gl_sharing
extension.
New in version 0.92.
GL_CONTEXT_KHR
¶Available with the cl_khr_gl_sharing
extension.
New in version 0.92.
OFFLINE_DEVICES_AMD
¶Available with the cl_amd_offline_devices
extension.
New in version 2011.1.
PLATFORM
¶WGL_HDC_KHR
¶Available with the cl_khr_gl_sharing
extension.
New in version 0.92.
to_string
(value)¶Returns a str
representing value.
New in version 0.91.
pyopencl.
device_affinity_domain
¶L1_CACHE
¶Available with OpenCL 1.2.
New in version 2011.2.
L2_CACHE
¶Available with OpenCL 1.2.
New in version 2011.2.
L3_CACHE
¶Available with OpenCL 1.2.
New in version 2011.2.
L4_CACHE
¶Available with OpenCL 1.2.
New in version 2011.2.
NEXT_PARTITIONABLE
¶NUMA
¶Available with OpenCL 1.2.
New in version 2011.2.
to_string
(value)¶Returns a str
representing value.
New in version 0.91.
pyopencl.
device_exec_capabilities
¶KERNEL
¶NATIVE_KERNEL
¶to_string
(value)¶Returns a str
representing value.
New in version 0.91.
pyopencl.
device_fp_config
¶CORRECTLY_ROUNDED_DIVIDE_SQRT
¶Available with OpenCL 1.2.
New in version 2011.2.
DENORM
¶FMA
¶INF_NAN
¶ROUND_TO_INF
¶ROUND_TO_NEAREST
¶ROUND_TO_ZERO
¶SOFT_FLOAT
¶Available with OpenCL 1.1.
New in version 0.92.
to_string
(value)¶Returns a str
representing value.
New in version 0.91.
pyopencl.
device_info
¶ADDRESS_BITS
¶AVAILABLE
¶BOARD_NAME_AMD
¶Available with the cl_amd_device_attribute_query
extension.
New in version 2013.2.
BUILT_IN_KERNELS
¶Available with OpenCL 1.2.
New in version 2011.2.
COMPILER_AVAILABLE
¶COMPUTE_CAPABILITY_MAJOR_NV
¶Available with the cl_nv_device_attribute_query
extension.
New in version 0.92.
COMPUTE_CAPABILITY_MINOR_NV
¶Available with the cl_nv_device_attribute_query
extension.
New in version 0.92.
DOUBLE_FP_CONFIG
¶Available with the cl_khr_fp64
extension.
New in version 2011.1.
DRIVER_VERSION
¶ENDIAN_LITTLE
¶ERROR_CORRECTION_SUPPORT
¶EXECUTION_CAPABILITIES
¶EXTENSIONS
¶GLOBAL_FREE_MEMORY_AMD
¶Available with the cl_amd_device_attribute_query
extension.
New in version 2013.2.
GLOBAL_MEM_CACHELINE_SIZE
¶GLOBAL_MEM_CACHE_SIZE
¶GLOBAL_MEM_CACHE_TYPE
¶GLOBAL_MEM_CHANNELS_AMD
¶Available with the cl_amd_device_attribute_query
extension.
New in version 2013.2.
GLOBAL_MEM_CHANNEL_BANKS_AMD
¶Available with the cl_amd_device_attribute_query
extension.
New in version 2013.2.
GLOBAL_MEM_CHANNEL_BANK_WIDTH_AMD
¶Available with the cl_amd_device_attribute_query
extension.
New in version 2013.2.
GLOBAL_MEM_SIZE
¶GLOBAL_VARIABLE_PREFERRED_TOTAL_SIZE
¶Available with OpenCL 2.0.
New in version 2015.2.
GPU_OVERLAP_NV
¶Available with the cl_nv_device_attribute_query
extension.
New in version 0.92.
HALF_FP_CONFIG
¶Available with the cl_khr_fp16
extension.
New in version 2011.1.
HOST_UNIFIED_MEMORY
¶Available with OpenCL 1.1.
New in version 0.92.
IMAGE2D_MAX_HEIGHT
¶IMAGE2D_MAX_WIDTH
¶IMAGE3D_MAX_DEPTH
¶IMAGE3D_MAX_HEIGHT
¶IMAGE3D_MAX_WIDTH
¶IMAGE_MAX_ARRAY_SIZE
¶Available with OpenCL 1.2.
New in version 2011.2.
IMAGE_MAX_BUFFER_SIZE
¶Available with OpenCL 1.2.
New in version 2011.2.
IMAGE_SUPPORT
¶INTEGRATED_MEMORY_NV
¶Available with the cl_nv_device_attribute_query
extension.
New in version 0.92.
KERNEL_EXEC_TIMEOUT_NV
¶Available with the cl_nv_device_attribute_query
extension.
New in version 0.92.
LINKER_AVAILABLE
¶Available with OpenCL 1.2.
New in version 2011.2.
LOCAL_MEM_BANKS_AMD
¶Available with the cl_amd_device_attribute_query
extension.
New in version 2013.2.
LOCAL_MEM_SIZE
¶LOCAL_MEM_SIZE_PER_COMPUTE_UNIT_AMD
¶Available with the cl_amd_device_attribute_query
extension.
New in version 2013.2.
LOCAL_MEM_TYPE
¶MAX_ATOMIC_COUNTERS_EXT
¶Available with the cl_ext_atomic_counters_64
extension.
New in version 2013.2.
MAX_CLOCK_FREQUENCY
¶MAX_COMPUTE_UNITS
¶MAX_CONSTANT_ARGS
¶MAX_CONSTANT_BUFFER_SIZE
¶MAX_GLOBAL_VARIABLE_SIZE
¶Available with OpenCL 2.0.
New in version 2015.2.
MAX_MEM_ALLOC_SIZE
¶MAX_ON_DEVICE_EVENTS
¶Available with OpenCL 2.0.
New in version 2015.2.
MAX_ON_DEVICE_QUEUES
¶Available with OpenCL 2.0.
New in version 2015.2.
MAX_PARAMETER_SIZE
¶MAX_PIPE_ARGS
¶Available with OpenCL 2.0.
New in version 2015.2.
MAX_READ_IMAGE_ARGS
¶MAX_READ_WRITE_IMAGE_ARGS
¶Available with OpenCL 2.0.
New in version 2015.2.
MAX_SAMPLERS
¶MAX_WORK_GROUP_SIZE
¶MAX_WORK_ITEM_DIMENSIONS
¶MAX_WORK_ITEM_SIZES
¶MAX_WRITE_IMAGE_ARGS
¶MEM_BASE_ADDR_ALIGN
¶MIN_DATA_TYPE_ALIGN_SIZE
¶NAME
¶NATIVE_VECTOR_WIDTH_CHAR
¶Available with OpenCL 1.1.
New in version 0.92.
NATIVE_VECTOR_WIDTH_DOUBLE
¶Available with OpenCL 1.1.
New in version 0.92.
NATIVE_VECTOR_WIDTH_FLOAT
¶Available with OpenCL 1.1.
New in version 0.92.
NATIVE_VECTOR_WIDTH_HALF
¶Available with OpenCL 1.1.
New in version 0.92.
NATIVE_VECTOR_WIDTH_INT
¶Available with OpenCL 1.1.
New in version 0.92.
NATIVE_VECTOR_WIDTH_LONG
¶Available with OpenCL 1.1.
New in version 0.92.
NATIVE_VECTOR_WIDTH_SHORT
¶Available with OpenCL 1.1.
New in version 0.92.
OPENCL_C_VERSION
¶Available with OpenCL 1.1.
New in version 0.92.
PARENT_DEVICE
¶Available with OpenCL 1.2.
New in version 2011.2.
PARTITION_AFFINITY_DOMAIN
¶Available with OpenCL 1.2.
New in version 2011.2.
PARTITION_MAX_SUB_DEVICES
¶Available with OpenCL 1.2.
New in version 2011.2.
PARTITION_PROPERTIES
¶Available with OpenCL 1.2.
New in version 2011.2.
PARTITION_TYPE
¶Available with OpenCL 1.2.
New in version 2011.2.
PIPE_MAX_ACTIVE_RESERVATIONS
¶Available with OpenCL 2.0.
New in version 2015.2.
PIPE_MAX_PACKET_SIZE
¶Available with OpenCL 2.0.
New in version 2015.2.
PLATFORM
¶PREFERRED_GLOBAL_ATOMIC_ALIGNMENT
¶Available with OpenCL 2.0.
New in version 2015.2.
PREFERRED_INTEROP_USER_SYNC
¶Available with OpenCL 1.2.
New in version 2011.2.
PREFERRED_LOCAL_ATOMIC_ALIGNMENT
¶Available with OpenCL 2.0.
New in version 2015.2.
PREFERRED_PLATFORM_ATOMIC_ALIGNMENT
¶Available with OpenCL 2.0.
New in version 2015.2.
PREFERRED_VECTOR_WIDTH_CHAR
¶PREFERRED_VECTOR_WIDTH_DOUBLE
¶PREFERRED_VECTOR_WIDTH_FLOAT
¶PREFERRED_VECTOR_WIDTH_HALF
¶Available with OpenCL 1.1.
New in version 0.92.
PREFERRED_VECTOR_WIDTH_INT
¶PREFERRED_VECTOR_WIDTH_LONG
¶PREFERRED_VECTOR_WIDTH_SHORT
¶PRINTF_BUFFER_SIZE
¶Available with OpenCL 1.2.
New in version 2011.2.
PROFILE
¶PROFILING_TIMER_OFFSET_AMD
¶Available with the cl_amd_device_attribute_query
extension.
New in version 2013.2.
PROFILING_TIMER_RESOLUTION
¶QUEUE_ON_DEVICE_MAX_SIZE
¶Available with OpenCL 2.0.
New in version 2015.2.
QUEUE_ON_DEVICE_PREFERRED_SIZE
¶Available with OpenCL 2.0.
New in version 2015.2.
QUEUE_ON_DEVICE_PROPERTIES
¶Available with OpenCL 2.0.
New in version 2015.2.
QUEUE_ON_HOST_PROPERTIES
¶QUEUE_PROPERTIES
¶REFERENCE_COUNT
¶Available with OpenCL 1.2.
New in version 2011.2.
REGISTERS_PER_BLOCK_NV
¶Available with the cl_nv_device_attribute_query
extension.
New in version 0.92.
SIMD_INSTRUCTION_WIDTH_AMD
¶Available with the cl_amd_device_attribute_query
extension.
New in version 2013.2.
SIMD_PER_COMPUTE_UNIT_AMD
¶Available with the cl_amd_device_attribute_query
extension.
New in version 2013.2.
SIMD_WIDTH_AMD
¶Available with the cl_amd_device_attribute_query
extension.
New in version 2013.2.
SINGLE_FP_CONFIG
¶SVM_CAPABILITIES
¶Available with OpenCL 2.0.
New in version 2015.2.
TOPOLOGY_AMD
¶Available with the cl_amd_device_attribute_query
extension.
New in version 2013.2.
TYPE
¶VENDOR
¶VENDOR_ID
¶VERSION
¶WARP_SIZE_NV
¶Available with the cl_nv_device_attribute_query
extension.
New in version 0.92.
WAVEFRONT_WIDTH_AMD
¶Available with the cl_amd_device_attribute_query
extension.
New in version 2013.2.
to_string
(value)¶Returns a str
representing value.
New in version 0.91.
pyopencl.
device_local_mem_type
¶GLOBAL
¶LOCAL
¶to_string
(value)¶Returns a str
representing value.
New in version 0.91.
pyopencl.
device_mem_cache_type
¶NONE
¶READ_ONLY_CACHE
¶READ_WRITE_CACHE
¶to_string
(value)¶Returns a str
representing value.
New in version 0.91.
pyopencl.
device_partition_property
¶BY_AFFINITY_DOMAIN
¶Available with OpenCL 1.2.
New in version 2011.2.
BY_COUNTS
¶Available with OpenCL 1.2.
New in version 2011.2.
BY_COUNTS_LIST_END
¶EQUALLY
¶Available with OpenCL 1.2.
New in version 2011.2.
to_string
(value)¶Returns a str
representing value.
New in version 0.91.
pyopencl.
device_svm_capabilities
¶ATOMICS
¶Available with OpenCL 2.0.
New in version 2015.2.
COARSE_GRAIN_BUFFER
¶Available with OpenCL 2.0.
New in version 2015.2.
FINE_GRAIN_BUFFER
¶Available with OpenCL 2.0.
New in version 2015.2.
FINE_GRAIN_SYSTEM
¶Available with OpenCL 2.0.
New in version 2015.2.
to_string
(value)¶Returns a str
representing value.
New in version 0.91.
pyopencl.
device_type
¶ACCELERATOR
¶ALL
¶CPU
¶CUSTOM
¶Available with OpenCL 1.2.
New in version 2011.2.
DEFAULT
¶GPU
¶to_string
(value)¶Returns a str
representing value.
New in version 0.91.
pyopencl.
event_info
¶COMMAND_EXECUTION_STATUS
¶COMMAND_QUEUE
¶COMMAND_TYPE
¶CONTEXT
¶Available with OpenCL 1.1.
New in version 0.92.
REFERENCE_COUNT
¶to_string
(value)¶Returns a str
representing value.
New in version 0.91.
pyopencl.
filter_mode
¶LINEAR
¶NEAREST
¶to_string
(value)¶Returns a str
representing value.
New in version 0.91.
pyopencl.
gl_context_info
¶Only available when PyOpenCL is compiled with GL support.
See have_gl()
.
CURRENT_DEVICE_FOR_GL_CONTEXT_KHR
¶DEVICES_FOR_GL_CONTEXT_KHR
¶to_string
(value)¶Returns a str
representing value.
New in version 0.91.
pyopencl.
gl_object_type
¶Only available when PyOpenCL is compiled with GL support.
See have_gl()
.
BUFFER
¶RENDERBUFFER
¶TEXTURE2D
¶TEXTURE3D
¶to_string
(value)¶Returns a str
representing value.
New in version 0.91.
pyopencl.
gl_texture_info
¶Only available when PyOpenCL is compiled with GL support.
See have_gl()
.
MIPMAP_LEVEL
¶TEXTURE_TARGET
¶to_string
(value)¶Returns a str
representing value.
New in version 0.91.
pyopencl.
image_info
¶ARRAY_SIZE
¶Available with OpenCL 1.2.
New in version 2011.2.
BUFFER
¶Available with OpenCL 1.2.
New in version 2011.2.
DEPTH
¶ELEMENT_SIZE
¶FORMAT
¶HEIGHT
¶NUM_MIP_LEVELS
¶Available with OpenCL 1.2.
New in version 2011.2.
NUM_SAMPLES
¶Available with OpenCL 1.2.
New in version 2011.2.
ROW_PITCH
¶SLICE_PITCH
¶WIDTH
¶to_string
(value)¶Returns a str
representing value.
New in version 0.91.
pyopencl.
kernel_arg_access_qualifier
¶NONE
¶Available with OpenCL 1.2.
New in version 2011.2.
READ_ONLY
¶Available with OpenCL 1.2.
New in version 2011.2.
READ_WRITE
¶Available with OpenCL 1.2.
New in version 2011.2.
WRITE_ONLY
¶Available with OpenCL 1.2.
New in version 2011.2.
to_string
(value)¶Returns a str
representing value.
New in version 0.91.
pyopencl.
kernel_arg_address_qualifier
¶CONSTANT
¶Available with OpenCL 1.2.
New in version 2011.2.
GLOBAL
¶Available with OpenCL 1.2.
New in version 2011.2.
LOCAL
¶Available with OpenCL 1.2.
New in version 2011.2.
PRIVATE
¶Available with OpenCL 1.2.
New in version 2011.2.
to_string
(value)¶Returns a str
representing value.
New in version 0.91.
pyopencl.
kernel_arg_info
¶ACCESS_QUALIFIER
¶Available with OpenCL 1.2.
New in version 2011.2.
ADDRESS_QUALIFIER
¶Available with OpenCL 1.2.
New in version 2011.2.
NAME
¶TYPE_NAME
¶Available with OpenCL 1.2.
New in version 2011.2.
TYPE_QUALIFIER
¶Available with OpenCL 1.2.
New in version 2015.2.
to_string
(value)¶Returns a str
representing value.
New in version 0.91.
pyopencl.
kernel_arg_type_qualifier
¶CONST
¶Available with OpenCL 1.2.
New in version 2015.2.
NONE
¶Available with OpenCL 1.2.
New in version 2015.2.
PIPE
¶Available with OpenCL 2.0.
New in version 2015.2.
RESTRICT
¶Available with OpenCL 1.2.
New in version 2015.2.
VOLATILE
¶Available with OpenCL 1.2.
New in version 2015.2.
to_string
(value)¶Returns a str
representing value.
New in version 0.91.
pyopencl.
kernel_info
¶ATTRIBUTES
¶Available with OpenCL 1.2.
New in version 2011.2.
CONTEXT
¶FUNCTION_NAME
¶NUM_ARGS
¶PROGRAM
¶REFERENCE_COUNT
¶to_string
(value)¶Returns a str
representing value.
New in version 0.91.
pyopencl.
kernel_work_group_info
¶COMPILE_WORK_GROUP_SIZE
¶GLOBAL_WORK_SIZE
¶Available with OpenCL 1.2.
New in version 2011.2.
LOCAL_MEM_SIZE
¶PREFERRED_WORK_GROUP_SIZE_MULTIPLE
¶Available with OpenCL 1.1.
New in version 0.92.
PRIVATE_MEM_SIZE
¶Available with OpenCL 1.1.
New in version 0.92.
WORK_GROUP_SIZE
¶to_string
(value)¶Returns a str
representing value.
New in version 0.91.
pyopencl.
map_flags
¶READ
¶WRITE
¶WRITE_INVALIDATE_REGION
¶Available with OpenCL 1.2.
New in version 2011.2.
to_string
(value)¶Returns a str
representing value.
New in version 0.91.
pyopencl.
mem_flags
¶ALLOC_HOST_PTR
¶COPY_HOST_PTR
¶HOST_NO_ACCESS
¶HOST_READ_ONLY
¶HOST_WRITE_ONLY
¶Available with OpenCL 1.2.
New in version 2011.2.
KERNEL_READ_AND_WRITE
¶Available with OpenCL 2.0.
New in version 2015.2.
READ_ONLY
¶READ_WRITE
¶USE_HOST_PTR
¶USE_PERSISTENT_MEM_AMD
¶Available with the cl_amd_device_memory_flags
extension.
New in version 2011.1.
WRITE_ONLY
¶to_string
(value)¶Returns a str
representing value.
New in version 0.91.
pyopencl.
mem_info
¶ASSOCIATED_MEMOBJECT
¶Available with OpenCL 1.1.
New in version 0.92.
CONTEXT
¶FLAGS
¶HOST_PTR
¶MAP_COUNT
¶OFFSET
¶Available with OpenCL 1.1.
New in version 0.92.
REFERENCE_COUNT
¶SIZE
¶TYPE
¶USES_SVM_POINTER
¶Available with OpenCL 2.0.
New in version 2015.2.
to_string
(value)¶Returns a str
representing value.
New in version 0.91.
pyopencl.
mem_migration_flags
¶CONTENT_UNDEFINED
¶Available with OpenCL 1.2.
New in version 2011.2.
HOST
¶Available with OpenCL 1.2.
New in version 2011.2.
to_string
(value)¶Returns a str
representing value.
New in version 0.91.
pyopencl.
mem_migration_flags_ext
¶to_string
(value)¶Returns a str
representing value.
New in version 0.91.
pyopencl.
mem_object_type
¶BUFFER
¶IMAGE1D
¶Available with OpenCL 1.2.
New in version 2011.2.
IMAGE1D_ARRAY
¶Available with OpenCL 1.2.
New in version 2011.2.
IMAGE1D_BUFFER
¶Available with OpenCL 1.2.
New in version 2011.2.
IMAGE2D
¶IMAGE2D_ARRAY
¶Available with OpenCL 1.2.
New in version 2011.2.
IMAGE3D
¶PIPE
¶Available with OpenCL 2.0.
New in version 2015.2.
to_string
(value)¶Returns a str
representing value.
New in version 0.91.
pyopencl.
migrate_mem_object_flags_ext
¶to_string
(value)¶Returns a str
representing value.
New in version 0.91.
pyopencl.
platform_info
¶EXTENSIONS
¶NAME
¶PROFILE
¶VENDOR
¶VERSION
¶to_string
(value)¶Returns a str
representing value.
New in version 0.91.
pyopencl.
profiling_info
¶COMPLETE
¶Available with OpenCL 2.0.
New in version 2015.2.
END
¶QUEUED
¶START
¶SUBMIT
¶to_string
(value)¶Returns a str
representing value.
New in version 0.91.
pyopencl.
program_binary_type
¶COMPILED_OBJECT
¶Available with OpenCL 1.2.
New in version 2011.2.
EXECUTABLE
¶Available with OpenCL 1.2.
New in version 2011.2.
LIBRARY
¶Available with OpenCL 1.2.
New in version 2011.2.
NONE
¶Available with OpenCL 1.2.
New in version 2011.2.
to_string
(value)¶Returns a str
representing value.
New in version 0.91.
pyopencl.
program_build_info
¶BINARY_TYPE
¶Available with OpenCL 1.2.
New in version 2011.2.
GLOBAL_VARIABLE_TOTAL_SIZE
¶Available with OpenCL 2.0.
New in version 2015.2.
LOG
¶OPTIONS
¶STATUS
¶to_string
(value)¶Returns a str
representing value.
New in version 0.91.
pyopencl.
program_info
¶BINARIES
¶BINARY_SIZES
¶CONTEXT
¶DEVICES
¶KERNEL_NAMES
¶Available with OpenCL 1.2.
New in version 2011.2.
NUM_DEVICES
¶NUM_KERNELS
¶Available with OpenCL 1.2.
New in version 2011.2.
REFERENCE_COUNT
¶SOURCE
¶to_string
(value)¶Returns a str
representing value.
New in version 0.91.
pyopencl.
program_kind
¶BINARY
¶SOURCE
¶UNKNOWN
¶to_string
(value)¶Returns a str
representing value.
New in version 0.91.
pyopencl.
queue_properties
¶PROPERTIES
¶Available with OpenCL 2.0.
New in version 2015.2.
SIZE
¶Available with OpenCL 2.0.
New in version 2015.2.
to_string
(value)¶Returns a str
representing value.
New in version 0.91.
pyopencl.
sampler_info
¶ADDRESSING_MODE
¶CONTEXT
¶FILTER_MODE
¶LOD_MAX
¶Available with OpenCL 2.0.
New in version 2015.2.
LOD_MIN
¶Available with OpenCL 2.0.
New in version 2015.2.
MIP_FILTER_MODE
¶Available with OpenCL 2.0.
New in version 2015.2.
NORMALIZED_COORDS
¶REFERENCE_COUNT
¶to_string
(value)¶Returns a str
representing value.
New in version 0.91.
pyopencl.
status_code
¶BUILD_PROGRAM_FAILURE
¶COMPILER_NOT_AVAILABLE
¶COMPILE_PROGRAM_FAILURE
¶Available with OpenCL 1.2.
New in version 2011.2.
DEVICE_NOT_AVAILABLE
¶DEVICE_NOT_FOUND
¶DEVICE_PARTITION_FAILED
¶Available with OpenCL 1.2.
New in version 2011.2.
EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST
¶Available with OpenCL 1.1.
New in version 0.92.
IMAGE_FORMAT_MISMATCH
¶IMAGE_FORMAT_NOT_SUPPORTED
¶INVALID_ARG_INDEX
¶INVALID_ARG_SIZE
¶INVALID_ARG_VALUE
¶INVALID_BINARY
¶INVALID_BUFFER_SIZE
¶INVALID_BUILD_OPTIONS
¶INVALID_COMMAND_QUEUE
¶INVALID_COMPILER_OPTIONS
¶Available with OpenCL 1.2.
New in version 2011.2.
INVALID_CONTEXT
¶INVALID_DEVICE
¶INVALID_DEVICE_PARTITION_COUNT
¶Available with OpenCL 1.2.
New in version 2011.2.
INVALID_DEVICE_QUEUE
¶Available with OpenCL 2.0.
New in version 2015.2.
INVALID_DEVICE_TYPE
¶INVALID_EVENT
¶INVALID_EVENT_WAIT_LIST
¶INVALID_GLOBAL_OFFSET
¶INVALID_GLOBAL_WORK_SIZE
¶Available with OpenCL 1.1.
New in version 0.92.
INVALID_GL_OBJECT
¶INVALID_GL_SHAREGROUP_REFERENCE_KHR
¶Available with the cl_khr_gl_sharing
extension.
New in version 0.92.
INVALID_HOST_PTR
¶INVALID_IMAGE_DESCRIPTOR
¶Available with OpenCL 1.2.
New in version 2011.2.
INVALID_IMAGE_FORMAT_DESCRIPTOR
¶INVALID_IMAGE_SIZE
¶INVALID_KERNEL
¶INVALID_KERNEL_ARGS
¶INVALID_KERNEL_DEFINITION
¶INVALID_KERNEL_NAME
¶INVALID_LINKER_OPTIONS
¶Available with OpenCL 1.2.
New in version 2011.2.
INVALID_MEM_OBJECT
¶INVALID_MIP_LEVEL
¶INVALID_OPERATION
¶INVALID_PIPE_SIZE
¶Available with OpenCL 2.0.
New in version 2015.2.
INVALID_PLATFORM
¶INVALID_PROGRAM
¶INVALID_PROGRAM_EXECUTABLE
¶INVALID_QUEUE_PROPERTIES
¶INVALID_SAMPLER
¶INVALID_VALUE
¶INVALID_WORK_DIMENSION
¶INVALID_WORK_GROUP_SIZE
¶INVALID_WORK_ITEM_SIZE
¶KERNEL_ARG_INFO_NOT_AVAILABLE
¶Available with OpenCL 1.2.
New in version 2011.2.
LINKER_NOT_AVAILABLE
¶Available with OpenCL 1.2.
New in version 2011.2.
LINK_PROGRAM_FAILURE
¶Available with OpenCL 1.2.
New in version 2011.2.
MAP_FAILURE
¶MEM_COPY_OVERLAP
¶MEM_OBJECT_ALLOCATION_FAILURE
¶MISALIGNED_SUB_BUFFER_OFFSET
¶Available with OpenCL 1.1.
New in version 0.92.
OUT_OF_HOST_MEMORY
¶OUT_OF_RESOURCES
¶PLATFORM_NOT_FOUND_KHR
¶Available with the cl_khr_icd
extension.
New in version 2011.1.
PROFILING_INFO_NOT_AVAILABLE
¶SUCCESS
¶to_string
(value)¶Returns a str
representing value.
New in version 0.91.
pyopencl.
svm_mem_flags
¶READ_ONLY
¶Available with OpenCL 2.0.
New in version 2015.2.
READ_WRITE
¶Available with OpenCL 2.0.
New in version 2015.2.
SVM_ATOMICS
¶Available with OpenCL 2.0.
New in version 2015.2.
SVM_FINE_GRAIN_BUFFER
¶Available with OpenCL 2.0.
New in version 2015.2.
WRITE_ONLY
¶Available with OpenCL 2.0.
New in version 2015.2.
to_string
(value)¶Returns a str
representing value.
New in version 0.91.
pyopencl.
Platform
¶info
¶Lower case versions of the platform_info
constants
may be used as attributes on instances of this class
to directly query info attributes.
get_info
(param)¶See platform_info
for values of param.
get_devices
(device_type=device_type.ALL)¶Return a list of devices matching device_type.
See device_type
for values of device_type.
Changed in version 2013.2: This used to raise an exception if no matching devices were found. Now, it will simply return an empty list.
from_int_ptr
(int_ptr_value, retain=True)¶Constructs a pyopencl
handle from a C-level pointer (given as
the integer int_ptr_value). If retain is True (the defauult)
pyopencl
will call clRetainXXX
on the provided object. If
the previous owner of the object will not release the reference,
retain should be set to False, to effectively transfer ownership to
pyopencl
.
Changed in version 2016.1: retain added
int_ptr
¶Instances of this class are hashable, and two instances of this class may be compared using “==” and ”!=”. (Hashability was added in version 2011.2.) Two objects are considered the same if the underlying OpenCL object is the same, as established by C pointer equality.
pyopencl.
Device
¶info
¶Lower case versions of the device_info
constants
may be used as attributes on instances of this class
to directly query info attributes.
get_info
(param)¶See device_info
for values of param.
from_int_ptr
(int_ptr_value, retain=True)¶Constructs a pyopencl
handle from a C-level pointer (given as
the integer int_ptr_value). If retain is True (the defauult)
pyopencl
will call clRetainXXX
on the provided object. If
the previous owner of the object will not release the reference,
retain should be set to False, to effectively transfer ownership to
pyopencl
.
Changed in version 2016.1: retain added
int_ptr
¶create_sub_devices
(properties)¶properties is an array of one (or more) of the forms:
[ dpp.EQUALLY, 8]
[ dpp.BY_COUNTS, 5, 7, 9, dpp.PARTITION_BY_COUNTS_LIST_END]
[ dpp.BY_NAMES, 5, 7, 9, dpp.PARTITION_BY_NAMES_LIST_END]
[ dpp.BY_AFFINITY_DOMAIN, dad.L1_CACHE]
where dpp represents device_partition_property
and dad represent device_affinity_domain
.
PROPERTIES_LIST_END_EXT is added automatically.
Only available with CL 1.2.
New in version 2011.2.
Two instances of this class may be compared using ==” and ”!=”.
pyopencl.
Context
(devices=None, properties=None, dev_type=None, cache_dir=None)¶Create a new context. properties is a list of key-value
tuples, where each key must be one of context_properties
.
At most one of devices and dev_type may be not None, where
devices is a list of Device
instances, and
dev_type is one of the device_type
constants.
If neither is specified, a context with a dev_type of
device_type.DEFAULT
is created.
If cache_dir is not None - it will be used as default cache_dir
for all its’ Program
instances builds (see also Program.build()
).
Note
Calling the constructor with no arguments will fail for recent
CL drivers that support the OpenCL ICD. If you want similar,
just-give-me-a-context-already behavior, we recommend
create_some_context()
. See, e.g. this
explanation by AMD.
Note
Because of how OpenCL changed in order to support Installable Client Drivers (ICDs) in OpenCL 1.1, the following will look reasonable but often actually not work:
import pyopencl as cl
ctx = cl.Context(dev_type=cl.device_type.ALL)
Instead, make sure to choose a platform when choosing a device by type:
import pyopencl as cl
platforms = cl.get_platforms()
ctx = cl.Context(
dev_type=cl.device_type.ALL,
properties=[(cl.context_properties.PLATFORM, platforms[0])])
Note
For
context_properties.CL_GL_CONTEXT_KHR
,
context_properties.CL_EGL_DISPLAY_KHR
,
context_properties.CL_GLX_DISPLAY_KHR
,
context_properties.CL_WGL_HDC_KHR
, and
context_properties.CL_CGL_SHAREGROUP_KHR
context_properties.CL_CGL_SHAREGROUP_APPLE
the value in the key-value pair is a PyOpenGL context or display
instance.
Changed in version 0.91.2: Constructor arguments dev_type added.
info
¶Lower case versions of the context_info
constants
may be used as attributes on instances of this class
to directly query info attributes.
get_info
(param)¶See context_info
for values of param.
from_int_ptr
(int_ptr_value, retain=True)¶Constructs a pyopencl
handle from a C-level pointer (given as
the integer int_ptr_value). If retain is True (the defauult)
pyopencl
will call clRetainXXX
on the provided object. If
the previous owner of the object will not release the reference,
retain should be set to False, to effectively transfer ownership to
pyopencl
.
Changed in version 2016.1: retain added
int_ptr
¶Instances of this class are hashable, and two instances of this class may be compared using “==” and ”!=”. (Hashability was added in version 2011.2.) Two objects are considered the same if the underlying OpenCL object is the same, as established by C pointer equality.
pyopencl.
create_some_context
(interactive=True, answers=None, cache_dir=None)¶Create a Context
‘somehow’.
If multiple choices for platform and/or device exist, interactive is True, and sys.stdin.isatty() is also True, then the user is queried about which device should be chosen. Otherwise, a device is chosen in an implementation-defined manner.
pyopencl.
CommandQueue
(context, device=None, properties=None)¶Create a new command queue. properties is a bit field
consisting of command_queue_properties
values.
if device is None, one of the devices in context is chosen in an implementation-defined manner.
A CommandQueue
may be used as a context manager, like this:
with cl.CommandQueue(self.cl_context) as queue:
enqueue_stuff(queue, ...)
finish()
is automatically called at the end of the context.
New in version 2013.1: Context manager capability.
info
¶Lower case versions of the command_queue_info
constants
may be used as attributes on instances of this class
to directly query info attributes.
get_info
(param)¶See command_queue_info
for values of param.
set_property
(prop, enable)¶See command_queue_properties
for possible values of prop.
enable is a bool
.
Unavailable in OpenCL 1.1 and newer.
flush
()¶finish
()¶from_int_ptr
(int_ptr_value, retain=True)¶Constructs a pyopencl
handle from a C-level pointer (given as
the integer int_ptr_value). If retain is True (the defauult)
pyopencl
will call clRetainXXX
on the provided object. If
the previous owner of the object will not release the reference,
retain should be set to False, to effectively transfer ownership to
pyopencl
.
Changed in version 2016.1: retain added
int_ptr
¶Instances of this class are hashable, and two instances of this class may be compared using “==” and ”!=”. (Hashability was added in version 2011.2.) Two objects are considered the same if the underlying OpenCL object is the same, as established by C pointer equality.
pyopencl.
Event
¶info
¶Lower case versions of the event_info
constants
may be used as attributes on instances of this class
to directly query info attributes.
profile.
info
¶Lower case versions of the profiling_info
constants
may be used as attributes on the attribute profile of this
class to directly query profiling info.
For example, you may use evt.profile.end instead of evt.get_profiling_info(pyopencl.profiling_info.END).
get_info
(param)¶See event_info
for values of param.
get_profiling_info
(param)¶See profiling_info
for values of param.
See profile
for an easier way of obtaining
the same information.
wait
()¶from_int_ptr
(int_ptr_value, retain=True)¶Constructs a pyopencl
handle from a C-level pointer (given as
the integer int_ptr_value). If retain is True (the defauult)
pyopencl
will call clRetainXXX
on the provided object. If
the previous owner of the object will not release the reference,
retain should be set to False, to effectively transfer ownership to
pyopencl
.
Changed in version 2016.1: retain added
int_ptr
¶set_callback
(type, cb)¶Add the callback cb with signature cb(status)
to the callback
queue for the event status type (one of the values of
command_execution_status
, except command_execution_status.QUEUED
).
See the OpenCL specification for restrictions on what cb may and may not do.
New in version 2015.2.
Instances of this class are hashable, and two instances of this class may be compared using “==” and ”!=”. (Hashability was added in version 2011.2.) Two objects are considered the same if the underlying OpenCL object is the same, as established by C pointer equality.
pyopencl.
wait_for_events
(events)¶pyopencl.
enqueue_barrier
(queue, wait_for=None)¶Enqueues a barrier operation. which ensures that all queued commands in command_queue have finished execution. This command is a synchronization point.
New in version 0.91.5.
Changed in version 2011.2: Takes wait_for and returns an Event
pyopencl.
enqueue_marker
(queue, wait_for=None)¶Returns an Event
.
Changed in version 2011.2: Takes wait_for.
pyopencl.
UserEvent
(context)¶A subclass of Event
. Only available with OpenCL 1.1 and newer.
New in version 0.92.
set_status
(status)¶See command_execution_status
for possible values of status.
pyopencl.
NannyEvent
¶Transfers between host and device return events of this type. They hold a reference to the host-side buffer and wait for the transfer to complete when they are freed. Therefore, they can safely release the reference to the object they’re guarding upon destruction.
A subclass of Event
.
New in version 2011.2.
get_ward
()¶wait
()¶In addition to performing the same wait as Event.wait()
, this
method also releases the reference to the guarded object.
pyopencl.
MemoryObject
¶info
¶Lower case versions of the mem_info
constants
may be used as attributes on instances of this class
to directly query info attributes.
hostbuf
¶release
()¶get_host_array
(shape, dtype, order="C")¶Return the memory object’s associated host memory
area as a numpy.ndarray
of the given shape,
dtype and order.
from_int_ptr
(int_ptr_value, retain=True)¶Constructs a pyopencl
handle from a C-level pointer (given as
the integer int_ptr_value). If retain is True (the defauult)
pyopencl
will call clRetainXXX
on the provided object. If
the previous owner of the object will not release the reference,
retain should be set to False, to effectively transfer ownership to
pyopencl
.
Changed in version 2016.1: retain added
int_ptr
¶Instances of this class are hashable, and two instances of this class may be compared using “==” and ”!=”. (Hashability was added in version 2011.2.) Two objects are considered the same if the underlying OpenCL object is the same, as established by C pointer equality.
pyopencl.
enqueue_migrate_mem_objects
(queue, mem_objects, flags=0, wait_for=None)¶Parameters: | flags – from mem_migration_flags |
---|
New in version 2011.2.
Only available with CL 1.2.
pyopencl.
enqueue_migrate_mem_object_ext
(queue, mem_objects, flags=0, wait_for=None)¶Parameters: | flags – from migrate_mem_object_flags_ext |
---|
New in version 2011.2.
Only available with the cl_ext_migrate_memobject extension.
pyopencl.
Buffer
(context, flags, size=0, hostbuf=None)¶Create a Buffer
.
See mem_flags
for values of flags.
If hostbuf is specified, size defaults to the size of
the specified buffer if it is passed as zero.
Buffer
inherits from MemoryObject
.
Note
Python also defines a type of buffer object,
and PyOpenCL interacts with those, too, as the host-side
target of enqueue_copy()
. Make sure to always be
clear on whether a Buffer
or a Python buffer
object is needed.
Note that actual memory allocation in OpenCL may be deferred.
Buffers are attached to a Context
and are only
moved to a device once the buffer is used on that device.
That is also the point when out-of-memory errors will occur.
If you’d like to be sure that there’s enough memory for
your allocation, either use enqueue_migrate_mem_objects()
(if available) or simply perform a small transfer to the
buffer. See also pyopencl.tools.ImmediateAllocator
.
get_sub_region
(origin, size, flags=0)¶Only available in OpenCL 1.1 and newer.
__getitem__
(slc)¶slc is a slice
object indicating from which byte index range
a sub-buffer is to be created. The flags argument of
get_sub_region()
is set to the same flags with which self was
created.
pyopencl.
enqueue_fill_buffer
(queue, mem, pattern, offset, size, wait_for=None)¶Parameters: | pattern – a buffer object (likely a numpy.ndarray ) |
---|
Returns a new pyopencl.Event
. wait_for
may either be None or a list of pyopencl.Event
instances for
whose completion this command waits before starting exeuction.
Only available with CL 1.2.
New in version 2011.2.
pyopencl.
ImageFormat
([channel_order, channel_type])¶channel_order
¶See channel_order
for possible values.
channel_data_type
¶See channel_type
for possible values.
channel_count
¶New in version 0.91.5.
dtype_size
¶New in version 0.91.5.
itemsize
¶New in version 0.91.5.
__repr__
()¶Returns a str
representation of the image format.
New in version 0.91.
Instances of this class are hashable, and two instances of this class may be compared using “==” and ”!=”. (Hashability was added in version 2011.2.) Two objects are considered the same if the underlying OpenCL object is the same, as established by C pointer equality.
Changed in version 0.91: Constructor arguments added.
Changed in version 2013.2: ImageFormat
was made comparable and hashable
pyopencl.
get_supported_image_formats
(context, flags, image_type)¶See mem_flags
for possible values of flags
and mem_object_type
for possible values of image_type.
Image(context, flags, format, shape=None, pitches=None, hostbuf=None, is_array=False, buffer=None):
See mem_flags
for values of flags.
shape is a 2- or 3-tuple. format is an instance of ImageFormat
.
pitches is a 1-tuple for 2D images and a 2-tuple for 3D images, indicating
the distance in bytes from one scan line to the next, and from one 2D image
slice to the next.
If hostbuf is given and shape is None, then hostbuf.shape is used as the shape parameter.
Image
inherits from MemoryObject
.
Note
If you want to load images from numpy.ndarray
instances or read images
back into them, be aware that OpenCL images expect the x dimension to vary
fastest, whereas in the default (C) order of numpy
arrays, the last index
varies fastest. If your array is arranged in the wrong order in memory,
there are two possible fixes for this:
numpy.asarray()
.New in version 0.91.
Changed in version 2011.2: Added is_array and buffer, which are only available on CL 1.2 and newer.
pyopencl.
info
¶Lower case versions of the mem_info
and image_info
constants
may be used as attributes on instances of this class
to directly query info attributes.
pyopencl.
shape
¶Return the value of the shape constructor argument as a tuple
.
pyopencl.
get_image_info
(param)¶See image_info
for values of param.
pyopencl.
release
()¶Instances of this class are hashable, and two instances of this class may be compared using “==” and ”!=”. (Hashability was added in version 2011.2.) Two objects are considered the same if the underlying OpenCL object is the same, as established by C pointer equality.
pyopencl.
image_from_array
(ctx, ary, num_channels=None, mode="r", norm_int=False)¶Build a 2D or 3D Image
from the numpy.ndarray
ary. If
num_channels is greater than one, the last dimension of ary must be
identical to num_channels. ary must be in C order. If num_channels is
not given, it defaults to 1 for scalar types and the number of entries
for Vector Types.
The ImageFormat
is chosen as the first num_channels components
of “RGBA”.
Parameters: | mode – “r” or “w” for read/write |
---|
Note
When reading from the image object, the indices passed to read_imagef are in the reverse order from what they would be when accessing ary from Python.
If norm_int is True, then the integer values are normalized to a floating point scale of 0..1 when read.
New in version 2011.2.
pyopencl.
enqueue_fill_image
(queue, mem, color, origin, region, wait_for=None)¶Parameters: | color – a buffer object (likely a numpy.ndarray ) |
---|
Returns a new pyopencl.Event
. wait_for
may either be None or a list of pyopencl.Event
instances for
whose completion this command waits before starting exeuction.
Only available with CL 1.2.
New in version 2011.2.
pyopencl.
enqueue_copy
(queue, dest, src, **kwargs)¶Copy from Image
, Buffer
or the host to
Image
, Buffer
or the host. (Note: host-to-host
copies are unsupported.)
The following keyword arguments are available:
Parameters: |
|
---|---|
Returns: | A |
Note
Two types of ‘buffer’ occur in the arguments to this function,
Buffer
and ‘host-side buffers’. The latter are
defined by Python and commonly called buffer objects.
Make sure to always be clear on whether a Buffer
or a
Python buffer object is needed.
Transfer Buffer
↔ host
Parameters: | device_offset – offset in bytes (optional) |
---|
Note
The size of the transfer is controlled by the size of the
of the host-side buffer. If the host-side buffer
is a numpy.ndarray
, you can control the transfer size by
transfering into a smaller ‘view’ of the target array, like this:
cl.enqueue_copy(queue, large_dest_numpy_array[:15], src_buffer)
Parameters: |
|
---|
Rectangular Buffer
↔ host transfers (CL 1.1 and newer)
Parameters: |
|
---|
Rectangular Buffer
↔ Buffer
transfers (CL 1.1 and newer)
Parameters: |
|
---|
Transfer Image
↔ host
Parameters: |
|
---|
Transfer Buffer
↔ Image
Parameters: |
|
---|
Transfer Image
↔ Image
Parameters: |
|
---|
Returns a new pyopencl.Event
. wait_for
may either be None or a list of pyopencl.Event
instances for
whose completion this command waits before starting exeuction.
New in version 2011.1.
pyopencl.
enqueue_map_buffer
(queue, buf, flags, offset, shape, dtype, order="C", strides=None, wait_for=None, is_blocking=True)¶wait_for
may either be None or a list of pyopencl.Event
instances for
whose completion this command waits before starting exeuction.
shape, dtype, and order have the same meaning
as in numpy.empty()
.
See map_flags
for possible values of flags.
strides, if given, overrides order.
Returns: | a tuple (array, event). array is a
numpy.ndarray representing the host side
of the map. Its .base member contains a
MemoryMap . |
---|
Changed in version 2011.1: is_blocking now defaults to True.
Changed in version 2013.1: order now defaults to “C”.
Changed in version 2013.2: Added strides argument.
pyopencl.
enqueue_map_image
(queue, buf, flags, origin, region, shape, dtype, order="C", strides=None, wait_for=None, is_blocking=True)¶wait_for
may either be None or a list of pyopencl.Event
instances for
whose completion this command waits before starting exeuction.
shape, dtype, and order have the same meaning
as in numpy.empty()
.
See map_flags
for possible values of flags.
strides, if given, overrides order.
Returns: | a tuple (array, event). array is a
numpy.ndarray representing the host side
of the map. Its .base member contains a
MemoryMap . |
---|
Changed in version 2011.1: is_blocking now defaults to True.
Changed in version 2013.1: order now defaults to “C”.
Changed in version 2013.2: Added strides argument.
pyopencl.
Sampler
(context, normalized_coords, addressing_mode, filter_mode)¶normalized_coords is a bool
indicating whether
to use coordinates between 0 and 1 (True) or the texture’s
natural pixel size (False).
See addressing_mode
and filter_mode
for possible
argument values.
info
¶Lower case versions of the sampler_info
constants
may be used as attributes on instances of this class
to directly query info attributes.
get_info
(param)¶See sampler_info
for values of param.
from_int_ptr
(int_ptr_value, retain=True)¶Constructs a pyopencl
handle from a C-level pointer (given as
the integer int_ptr_value). If retain is True (the defauult)
pyopencl
will call clRetainXXX
on the provided object. If
the previous owner of the object will not release the reference,
retain should be set to False, to effectively transfer ownership to
pyopencl
.
Changed in version 2016.1: retain added
int_ptr
¶Instances of this class are hashable, and two instances of this class may be compared using “==” and ”!=”. (Hashability was added in version 2011.2.) Two objects are considered the same if the underlying OpenCL object is the same, as established by C pointer equality.
pyopencl.
Program
(context, src)¶pyopencl.
Program
(context, devices, binaries)binaries must contain one binary for each entry in devices.
info
¶Lower case versions of the program_info
constants
may be used as attributes on instances of this class
to directly query info attributes.
get_info
(param)¶See program_info
for values of param.
get_build_info
(device, param)¶See program_build_info
for values of param.
build
(options=[], devices=None, cache_dir=None)¶options is a string of compiler flags. Returns self.
If cache_dir is not None - built binaries are cached in an on-disk cache
with given path.
If passed cache_dir is None, but context of this program was created with
not-None cache_dir - it will be used as cache directory.
If passed cache_dir is None and context was created with None cache_dir:
built binaries will be cached in an on-disk cache called
pyopencl-compiler-cache-vN-uidNAME-pyVERSION
in the directory
returned by tempfile.gettempdir()
. By setting the environment
variable PYOPENCL_NO_CACHE
to any non-empty value, this
caching is suppressed. Any options found in the environment variable
PYOPENCL_BUILD_OPTIONS
will be appended to options.
Changed in version 2011.1: options may now also be a list
of str
.
Changed in version 2013.1: Added PYOPENCL_NO_CACHE
.
Added PYOPENCL_BUILD_OPTIONS
.
compile
(self, options=[], devices=None, headers=[])¶Parameters: | headers – a list of tuples (name, program). |
---|
Only available with CL 1.2.
New in version 2011.2.
kernel_name
¶You may use program.kernel_name
to obtain a Kernel
objects from a program. Note that every lookup of this type
produces a new kernel object, so that this won’t work:
prg.sum.set_args(a_g, b_g, res_g)
ev = cl.enqueue_nd_range_kernel(queue, prg.sum, a_np.shape, None)
Instead, either use the (recommended, stateless) calling interface:
prg.sum(queue, prg.sum, a_np.shape, None)
or keep the kernel in a temporary variable:
sum_knl = prg.sum
sum_knl.set_args(a_g, b_g, res_g)
ev = cl.enqueue_nd_range_kernel(queue, sum_knl, a_np.shape, None)
Note that the Program
has to be built (see build()
) in
order for this to work simply by attribute lookup.
Note
The program_info
attributes live
in the same name space and take precedence over
Kernel
names.
from_int_ptr
(int_ptr_value)¶Constructs a pyopencl
handle from a C-level pointer (given as
the integer int_ptr_value). If retain is True (the defauult)
pyopencl
will call clRetainXXX
on the provided object. If
the previous owner of the object will not release the reference,
retain should be set to False, to effectively transfer ownership to
pyopencl
.
Changed in version 2016.1: retain added
int_ptr
¶Instances of this class are hashable, and two instances of this class may be compared using “==” and ”!=”. (Hashability was added in version 2011.2.) Two objects are considered the same if the underlying OpenCL object is the same, as established by C pointer equality.
pyopencl.
create_program_with_built_in_kernels
(context, devices, kernel_names)¶Only available with CL 1.2.
New in version 2011.2.
pyopencl.
link_program
(context, programs, options=[], devices=None)¶Only available with CL 1.2.
New in version 2011.2.
pyopencl.
unload_platform_compiler
(platform)¶Only available with CL 1.2.
New in version 2011.2.
pyopencl.
Kernel
(program, name)¶info
¶Lower case versions of the kernel_info
constants
may be used as attributes on instances of this class
to directly query info attributes.
get_info
(param)¶See kernel_info
for values of param.
get_work_group_info
(param, device)¶See kernel_work_group_info
for values of param.
get_arg_info
(arg_index, param)¶See kernel_arg_info
for values of param.
Only available in OpenCL 1.2 and newer.
set_arg
(self, index, arg)¶arg may be
None: This may be passed for __global memory references to pass a NULL pointer to the kernel.
Anything that satisfies the Python buffer interface,
in particular numpy.ndarray
, str
,
or numpy
‘s sized scalars, such as numpy.int32
or numpy.float64
.
Note
Note that Python’s own int
or float
objects will not work out of the box. See
Kernel.set_scalar_arg_dtypes()
for a way to make
them work. Alternatively, the standard library module
struct
can be used to convert Python’s native
number types to binary data in a str
.
An instance of MemoryObject
. (e.g. Buffer
,
Image
, etc.)
An instance of LocalMemory
.
An instance of Sampler
.
set_scalar_arg_dtypes
(arg_dtypes)¶Inform the wrapper about the sized types of scalar
Kernel
arguments. For each argument,
arg_dtypes contains an entry. For non-scalars,
this must be None. For scalars, it must be an
object acceptable to the numpy.dtype
constructor, indicating that the corresponding
scalar argument is of that type.
After invoking this function with the proper information, most suitable number types will automatically be cast to the right type for kernel invocation.
Note
The information set by this rountine is attached to a single kernel instance. A new kernel instance is created every time you use program.kernel attribute access. The following will therefore not work:
prg = cl.Program(...).build()
prg.kernel.set_scalar_arg_dtypes(...)
prg.kernel(queue, n_globals, None, args)
__call__
(queue, global_size, local_size, *args, global_offset=None, wait_for=None, g_times_l=False)¶Use enqueue_nd_range_kernel()
to enqueue a kernel execution, after using
set_args()
to set each argument in turn. See the documentation for
set_arg()
to see what argument types are allowed.
Returns a new pyopencl.Event
. wait_for
may either be None or a list of pyopencl.Event
instances for
whose completion this command waits before starting exeuction.
None may be passed for local_size.
If g_times_l is specified, the global size will be multiplied by the local size. (which makes the behavior more like Nvidia CUDA) In this case, global_size and local_size also do not have to have the same number of dimensions.
Note
__call__()
is not thread-safe. It sets the arguments using set_args()
and then runs enqueue_nd_range_kernel()
. Another thread could race it
in doing the same things, with undefined outcome. This issue is inherited
from the C-level OpenCL API. The recommended solution is to make a kernel
(i.e. access prg.kernel_name, which corresponds to making a new kernel)
for every thread that may enqueue calls to the kernel.
A solution involving implicit locks was discussed and decided against on the mailing list in October 2012.
Changed in version 0.92: local_size was promoted to third positional argument from being a
keyword argument. The old keyword argument usage will continue to
be accepted with a warning throughout the 0.92 release cycle.
This is a backward-compatible change (just barely!) because
local_size as third positional argument can only be a
tuple
or None. tuple
instances are never valid
Kernel
arguments, and None is valid as an argument, but
its treatment in the wrapper had a bug (now fixed) that prevented
it from working.
Changed in version 2011.1: Added the g_times_l keyword arg.
capture_call
(filename, queue, global_size, local_size, *args, global_offset=None, wait_for=None, g_times_l=False)¶This method supports the exact same interface as __call__()
, but
instead of invoking the kernel, it writes a self-contained PyOpenCL program
to filename that reproduces this invocation. Data and kernel source code
will be packaged up in filename‘s source code.
This is mainly intended as a debugging aid. For example, it can be used to automate the task of creating a small, self-contained test case for an observed problem. It can also help separate a misbehaving kernel from a potentially large or time-consuming outer code.
To use, simply change:
evt = my_kernel(queue, gsize, lsize, arg1, arg2, ...)
to:
evt = my_kernel.capture_call("bug.py", queue, gsize, lsize, arg1, arg2, ...)
New in version 2013.1.
from_int_ptr
(int_ptr_value, retain=True)¶Constructs a pyopencl
handle from a C-level pointer (given as
the integer int_ptr_value). If retain is True (the defauult)
pyopencl
will call clRetainXXX
on the provided object. If
the previous owner of the object will not release the reference,
retain should be set to False, to effectively transfer ownership to
pyopencl
.
Changed in version 2016.1: retain added
int_ptr
¶Instances of this class are hashable, and two instances of this class may be compared using “==” and ”!=”. (Hashability was added in version 2011.2.) Two objects are considered the same if the underlying OpenCL object is the same, as established by C pointer equality.
pyopencl.
LocalMemory
(size)¶A helper class to pass __local memory arguments to kernels.
New in version 0.91.2.
size
¶The size of local buffer in bytes to be provided.
pyopencl.
enqueue_nd_range_kernel
(queue, kernel, global_work_size, local_work_size, global_work_offset=None, wait_for=None, g_times_l=False)¶Returns a new pyopencl.Event
. wait_for
may either be None or a list of pyopencl.Event
instances for
whose completion this command waits before starting exeuction.
If g_times_l is specified, the global size will be multiplied by the local size. (which makes the behavior more like Nvidia CUDA) In this case, global_size and local_size also do not have to have the same number of dimensions.
Changed in version 2011.1: Added the g_times_l keyword arg.
pyopencl.
enqueue_task
(queue, kernel, wait_for=None)¶Returns a new pyopencl.Event
. wait_for
may either be None or a list of pyopencl.Event
instances for
whose completion this command waits before starting exeuction.
Functionality in this section is only available when PyOpenCL is compiled
with GL support. See have_gl()
.
New in version 0.91.
pyopencl.
have_gl
()¶Return True if PyOpenCL was compiled with OpenGL interoperability, otherwise False.
pyopencl.
get_gl_sharing_context_properties
()¶Return a list
of context_properties
that will
allow a newly created context to share the currently active GL
context.
Get share group handle for current CGL context.
Apple OS X only.
New in version 2011.1.
pyopencl.
GLBuffer
(context, flags, bufobj)¶GLBuffer
inherits from MemoryObject
.
gl_object
¶pyopencl.
GLRenderBuffer
(context, flags, bufobj)¶GLRenderBuffer
inherits from MemoryObject
.
gl_object
¶pyopencl.
GLTexture
(context, flags, texture_target, miplevel, texture, dims)¶GLTexture
inherits from Image
. Only available in OpenCL 1.2
and newer.
gl_object
¶get_gl_texture_info
(param)¶See gl_texture_info
for values of param. Only available when PyOpenCL is compiled with GL support. See have_gl()
.
pyopencl.
enqueue_acquire_gl_objects
(queue, mem_objects, wait_for=None)¶mem_objects is a list of MemoryObject
instances.
Returns a new pyopencl.Event
. wait_for
may either be None or a list of pyopencl.Event
instances for
whose completion this command waits before starting exeuction.
pyopencl.
enqueue_release_gl_objects
(queue, mem_objects, wait_for=None)¶mem_objects is a list of MemoryObject
instances. Returns a new pyopencl.Event
. wait_for
may either be None or a list of pyopencl.Event
instances for
whose completion this command waits before starting exeuction.
pyopencl.
get_gl_context_info_khr
(properties, param_name, platform=None)¶Get information on which CL device corresponds to a given GL/EGL/WGL/CGL device.
See the Context
constructor for the meaning of
properties and gl_context_info
for param_name.
Changed in version 2011.2: Accepts the platform argument. Using platform equal to None is deprecated as of PyOpenCL 2011.2.