OpenCL Runtime¶
Version Queries¶
-
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.
Error Reporting¶
-
class
pyopencl.Error¶ Base class for all PyOpenCL exceptions.
-
class
pyopencl.MemoryError¶
-
class
pyopencl.LogicError¶
-
class
pyopencl.RuntimeError¶
Constants¶
-
class
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
strrepresenting value.New in version 0.91.
-
-
class
pyopencl.affinity_domain_ext¶ -
L1_CACHE¶ Available with the
cl_ext_device_fissionextension.New in version 2011.1.
-
L2_CACHE¶ Available with the
cl_ext_device_fissionextension.New in version 2011.1.
-
L3_CACHE¶ Available with the
cl_ext_device_fissionextension.New in version 2011.1.
-
L4_CACHE¶ Available with the
cl_ext_device_fissionextension.New in version 2011.1.
-
NEXT_FISSIONABLE¶ Available with the
cl_ext_device_fissionextension.New in version 2011.1.
-
NUMA¶ Available with the
cl_ext_device_fissionextension.New in version 2011.1.
-
to_string(value)¶ Returns a
strrepresenting value.New in version 0.91.
-
-
class
pyopencl.channel_order¶ -
A¶
-
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.
-
to_string(value)¶ Returns a
strrepresenting value.New in version 0.91.
-
-
class
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
strrepresenting value.New in version 0.91.
-
-
class
pyopencl.command_execution_status¶ -
COMPLETE¶
-
QUEUED¶
-
RUNNING¶
-
SUBMITTED¶
-
to_string(value)¶ Returns a
strrepresenting value.New in version 0.91.
-
-
class
pyopencl.command_queue_info¶ -
CONTEXT¶
-
DEVICE¶
-
PROPERTIES¶
-
REFERENCE_COUNT¶
-
to_string(value)¶ Returns a
strrepresenting value.New in version 0.91.
-
-
class
pyopencl.command_queue_properties¶ -
OUT_OF_ORDER_EXEC_MODE_ENABLE¶
-
PROFILING_ENABLE¶
-
to_string(value)¶ Returns a
strrepresenting value.New in version 0.91.
-
-
class
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¶
-
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
strrepresenting value.New in version 0.91.
-
-
class
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
strrepresenting value.New in version 0.91.
-
-
class
pyopencl.context_properties¶ -
CGL_SHAREGROUP_KHR¶ Available with the
cl_khr_gl_sharingextension.New in version 0.92.
-
EGL_DISPLAY_KHR¶ Available with the
cl_khr_gl_sharingextension.New in version 0.92.
-
GLX_DISPLAY_KHR¶ Available with the
cl_khr_gl_sharingextension.New in version 0.92.
-
GL_CONTEXT_KHR¶ Available with the
cl_khr_gl_sharingextension.New in version 0.92.
-
OFFLINE_DEVICES_AMD¶ Available with the
cl_amd_offline_devicesextension.New in version 2011.1.
-
PLATFORM¶
-
WGL_HDC_KHR¶ Available with the
cl_khr_gl_sharingextension.New in version 0.92.
-
to_string(value)¶ Returns a
strrepresenting value.New in version 0.91.
-
-
class
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
strrepresenting value.New in version 0.91.
-
-
class
pyopencl.device_exec_capabilities¶ -
KERNEL¶
-
NATIVE_KERNEL¶
-
to_string(value)¶ Returns a
strrepresenting value.New in version 0.91.
-
-
class
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
strrepresenting value.New in version 0.91.
-
-
class
pyopencl.device_info¶ -
ADDRESS_BITS¶
-
AFFINITY_DOMAINS_EXT¶ Available with the
cl_ext_device_fissionextension.New in version 2011.1.
-
AVAILABLE¶
-
BOARD_NAME_AMD¶ Available with the
cl_amd_device_attribute_queryextension.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_queryextension.New in version 0.92.
-
COMPUTE_CAPABILITY_MINOR_NV¶ Available with the
cl_nv_device_attribute_queryextension.New in version 0.92.
-
DOUBLE_FP_CONFIG¶ Available with the
cl_khr_fp64extension.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_queryextension.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_queryextension.New in version 2013.2.
-
GLOBAL_MEM_CHANNEL_BANKS_AMD¶ Available with the
cl_amd_device_attribute_queryextension.New in version 2013.2.
-
GLOBAL_MEM_CHANNEL_BANK_WIDTH_AMD¶ Available with the
cl_amd_device_attribute_queryextension.New in version 2013.2.
-
GLOBAL_MEM_SIZE¶
-
GPU_OVERLAP_NV¶ Available with the
cl_nv_device_attribute_queryextension.New in version 0.92.
-
HALF_FP_CONFIG¶ Available with the
cl_khr_fp16extension.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_queryextension.New in version 0.92.
-
KERNEL_EXEC_TIMEOUT_NV¶ Available with the
cl_nv_device_attribute_queryextension.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_queryextension.New in version 2013.2.
-
LOCAL_MEM_SIZE¶
-
LOCAL_MEM_SIZE_PER_COMPUTE_UNIT_AMD¶ Available with the
cl_amd_device_attribute_queryextension.New in version 2013.2.
-
LOCAL_MEM_TYPE¶
-
MAX_ATOMIC_COUNTERS_EXT¶ Available with the
cl_ext_atomic_counters_64extension.New in version 2013.2.
-
MAX_CLOCK_FREQUENCY¶
-
MAX_COMPUTE_UNITS¶
-
MAX_CONSTANT_ARGS¶
-
MAX_CONSTANT_BUFFER_SIZE¶
-
MAX_MEM_ALLOC_SIZE¶
-
MAX_PARAMETER_SIZE¶
-
MAX_READ_IMAGE_ARGS¶
-
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.
-
PARENT_DEVICE_EXT¶ Available with the
cl_ext_device_fissionextension.New in version 2011.1.
-
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_STYLE_EXT¶ Available with the
cl_ext_device_fissionextension.New in version 2011.1.
-
PARTITION_TYPE¶ Available with OpenCL 1.2.
New in version 2011.2.
-
PARTITION_TYPES_EXT¶ Available with the
cl_ext_device_fissionextension.New in version 2011.1.
-
PLATFORM¶
-
PREFERRED_INTEROP_USER_SYNC¶ Available with OpenCL 1.2.
New in version 2011.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_queryextension.New in version 2013.2.
-
PROFILING_TIMER_RESOLUTION¶
-
QUEUE_PROPERTIES¶
-
REFERENCE_COUNT¶ Available with OpenCL 1.2.
New in version 2011.2.
-
REFERENCE_COUNT_EXT¶ Available with the
cl_ext_device_fissionextension.New in version 2011.1.
-
REGISTERS_PER_BLOCK_NV¶ Available with the
cl_nv_device_attribute_queryextension.New in version 0.92.
-
SIMD_INSTRUCTION_WIDTH_AMD¶ Available with the
cl_amd_device_attribute_queryextension.New in version 2013.2.
-
SIMD_PER_COMPUTE_UNIT_AMD¶ Available with the
cl_amd_device_attribute_queryextension.New in version 2013.2.
-
SIMD_WIDTH_AMD¶ Available with the
cl_amd_device_attribute_queryextension.New in version 2013.2.
-
SINGLE_FP_CONFIG¶
-
TOPOLOGY_AMD¶ Available with the
cl_amd_device_attribute_queryextension.New in version 2013.2.
-
TYPE¶
-
VENDOR¶
-
VENDOR_ID¶
-
VERSION¶
-
WARP_SIZE_NV¶ Available with the
cl_nv_device_attribute_queryextension.New in version 0.92.
-
WAVEFRONT_WIDTH_AMD¶ Available with the
cl_amd_device_attribute_queryextension.New in version 2013.2.
-
to_string(value)¶ Returns a
strrepresenting value.New in version 0.91.
-
-
class
pyopencl.device_local_mem_type¶ -
GLOBAL¶
-
LOCAL¶
-
to_string(value)¶ Returns a
strrepresenting value.New in version 0.91.
-
-
class
pyopencl.device_mem_cache_type¶ -
NONE¶
-
READ_ONLY_CACHE¶
-
READ_WRITE_CACHE¶
-
to_string(value)¶ Returns a
strrepresenting value.New in version 0.91.
-
-
class
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
strrepresenting value.New in version 0.91.
-
-
class
pyopencl.device_partition_property_ext¶ -
BY_AFFINITY_DOMAIN¶ Available with the
cl_ext_device_fissionextension.New in version 2011.1.
-
BY_COUNTS¶ Available with the
cl_ext_device_fissionextension.New in version 2011.1.
-
BY_NAMES¶ Available with the
cl_ext_device_fissionextension.New in version 2011.1.
-
EQUALLY¶ Available with the
cl_ext_device_fissionextension.New in version 2011.1.
-
PARTITION_BY_COUNTS_LIST_END¶ Available with the
cl_ext_device_fissionextension.New in version 2011.1.
-
PARTITION_BY_NAMES_LIST_END¶ Available with the
cl_ext_device_fissionextension.New in version 2011.1.
-
PROPERTIES_LIST_END¶ Available with the
cl_ext_device_fissionextension.New in version 2011.1.
-
to_string(value)¶ Returns a
strrepresenting value.New in version 0.91.
-
-
class
pyopencl.device_type¶ -
ACCELERATOR¶
-
ALL¶
-
CPU¶
-
CUSTOM¶ Available with OpenCL 1.2.
New in version 2011.2.
-
DEFAULT¶
-
GPU¶
-
to_string(value)¶ Returns a
strrepresenting value.New in version 0.91.
-
-
class
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
strrepresenting value.New in version 0.91.
-
-
class
pyopencl.filter_mode¶ -
LINEAR¶
-
NEAREST¶
-
to_string(value)¶ Returns a
strrepresenting value.New in version 0.91.
-
-
class
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
strrepresenting value.New in version 0.91.
-
-
class
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
strrepresenting value.New in version 0.91.
-
-
class
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
strrepresenting value.New in version 0.91.
-
-
class
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
strrepresenting value.New in version 0.91.
-
-
class
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
strrepresenting value.New in version 0.91.
-
-
class
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
strrepresenting value.New in version 0.91.
-
-
class
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.
-
to_string(value)¶ Returns a
strrepresenting value.New in version 0.91.
-
-
class
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
strrepresenting value.New in version 0.91.
-
-
class
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
strrepresenting value.New in version 0.91.
-
-
class
pyopencl.map_flags¶ -
READ¶
-
WRITE¶
-
WRITE_INVALIDATE_REGION¶ Available with OpenCL 1.2.
New in version 2011.2.
-
to_string(value)¶ Returns a
strrepresenting value.New in version 0.91.
-
-
class
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.
-
READ_ONLY¶
-
READ_WRITE¶
-
USE_HOST_PTR¶
-
USE_PERSISTENT_MEM_AMD¶ Available with the
cl_amd_device_memory_flagsextension.New in version 2011.1.
-
WRITE_ONLY¶
-
to_string(value)¶ Returns a
strrepresenting value.New in version 0.91.
-
-
class
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¶
-
to_string(value)¶ Returns a
strrepresenting value.New in version 0.91.
-
-
class
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
strrepresenting value.New in version 0.91.
-
-
class
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¶
-
to_string(value)¶ Returns a
strrepresenting value.New in version 0.91.
-
-
class
pyopencl.migrate_mem_object_flags_ext¶ -
to_string(value)¶ Returns a
strrepresenting value.New in version 0.91.
-
-
class
pyopencl.platform_info¶ -
EXTENSIONS¶
-
NAME¶
-
PROFILE¶
-
VENDOR¶
-
VERSION¶
-
to_string(value)¶ Returns a
strrepresenting value.New in version 0.91.
-
-
class
pyopencl.profiling_info¶ -
END¶
-
QUEUED¶
-
START¶
-
SUBMIT¶
-
to_string(value)¶ Returns a
strrepresenting value.New in version 0.91.
-
-
class
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
strrepresenting value.New in version 0.91.
-
-
class
pyopencl.program_build_info¶ -
BINARY_TYPE¶ Available with OpenCL 1.2.
New in version 2011.2.
-
LOG¶
-
OPTIONS¶
-
STATUS¶
-
to_string(value)¶ Returns a
strrepresenting value.New in version 0.91.
-
-
class
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
strrepresenting value.New in version 0.91.
-
-
class
pyopencl.program_kind¶ -
BINARY¶
-
SOURCE¶
-
UNKNOWN¶
-
bit_length¶
-
conjugate¶
-
denominator¶
-
imag¶
-
name¶
-
numerator¶
-
real¶
-
to_string(value)¶ Returns a
strrepresenting value.New in version 0.91.
-
-
class
pyopencl.sampler_info¶ -
ADDRESSING_MODE¶
-
CONTEXT¶
-
FILTER_MODE¶
-
NORMALIZED_COORDS¶
-
REFERENCE_COUNT¶
-
to_string(value)¶ Returns a
strrepresenting value.New in version 0.91.
-
-
class
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.
-
DEVICE_PARTITION_FAILED_EXT¶
-
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_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_sharingextension.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_PARTITION_COUNT_EXT¶
-
INVALID_PARTITION_NAME_EXT¶
-
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_icdextension.New in version 2011.1.
-
PROFILING_INFO_NOT_AVAILABLE¶
-
SUCCESS¶
-
to_string(value)¶ Returns a
strrepresenting value.New in version 0.91.
-
Platforms, Devices and Contexts¶
-
class
pyopencl.Platform¶ -
info¶ Lower case versions of the
platform_infoconstants may be used as attributes on instances of this class to directly query info attributes.
-
get_info(param)¶ See
platform_infofor values of param.
-
get_devices(device_type=device_type.ALL)¶ Return a list of devices matching device_type. See
device_typefor 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.
-
static
from_int_ptr((int)int_ptr_value) → Platform :¶ (static method) Return a new Python object referencing the C-level
cl_platform_idobject at the location pointed to by int_ptr_value. The relevantclRetain*()function will be called.New in version 2013.2.
-
int_ptr¶ Return an integer corresponding to the pointer value of the underlying
cl_platform_id. Usefrom_int_ptr()to turn back into a Python object.New in version 2013.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.)
-
-
class
pyopencl.Device¶ -
info¶ Lower case versions of the
device_infoconstants may be used as attributes on instances of this class to directly query info attributes.
-
get_info(param)¶ See
device_infofor values of param.
-
static
from_int_ptr((int)int_ptr_value) → Device :¶ (static method) Return a new Python object referencing the C-level
cl_device_idobject at the location pointed to by int_ptr_value. The relevantclRetain*()function will be called.New in version 2013.2.
-
int_ptr¶ Return an integer corresponding to the pointer value of the underlying
cl_device_id. Usefrom_int_ptr()to turn back into a Python object.New in version 2013.2.
Two instances of this class may be compared using ==” and ”!=”.
-
-
class
pyopencl.Context(devices=None, properties=None, dev_type=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 ofDeviceinstances, and dev_type is one of thedevice_typeconstants. If neither is specified, a context with a dev_type ofdevice_type.DEFAULTis created.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
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, andcontext_properties.CL_CGL_SHAREGROUP_KHRcontext_properties.CL_CGL_SHAREGROUP_APPLEthe 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_infoconstants may be used as attributes on instances of this class to directly query info attributes.
-
get_info(param)¶ See
context_infofor values of param.
-
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_propertyand dad representdevice_affinity_domain.PROPERTIES_LIST_END_EXT is added automatically.
Only available with CL 1.2.
New in version 2011.2.
-
create_sub_devices_ext(properties)¶ properties is an array of one (or more) of the forms:
[ dppe.EQUALLY, 8] [ dppe.BY_COUNTS, 5, 7, 9, dppe.PARTITION_BY_COUNTS_LIST_END] [ dppe.BY_NAMES, 5, 7, 9, dppe.PARTITION_BY_NAMES_LIST_END] [ dppe.BY_AFFINITY_DOMAIN, ad.L1_CACHE]
where dppe represents
device_partition_property_extand ad representaffinity_domain_ext.PROPERTIES_LIST_END_EXT is added automatically.
Only available with the cl_ext_device_fission extension.
New in version 2011.1.
-
static
from_int_ptr((int)int_ptr_value) → Context :¶ (static method) Return a new Python object referencing the C-level
cl_contextobject at the location pointed to by int_ptr_value. The relevantclRetain*()function will be called.New in version 2013.2.
-
int_ptr¶ Return an integer corresponding to the pointer value of the underlying
cl_context. Usefrom_int_ptr()to turn back into a Python object.New in version 2013.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.)
-
-
pyopencl.create_some_context(interactive=True)¶ 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.
Command Queues and Events¶
-
class
pyopencl.CommandQueue(context, device=None, properties=None)¶ Create a new command queue. properties is a bit field consisting of
command_queue_propertiesvalues.if device is None, one of the devices in context is chosen in an implementation-defined manner.
A
CommandQueuemay 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_infoconstants may be used as attributes on instances of this class to directly query info attributes.
-
get_info(param)¶ See
command_queue_infofor values of param.
-
set_property(prop, enable)¶ See
command_queue_propertiesfor possible values of prop. enable is abool.Unavailable in OpenCL 1.1 and newer.
-
flush()¶
-
finish()¶
-
static
from_int_ptr((int)int_ptr_value) → CommandQueue :¶ (static method) Return a new Python object referencing the C-level
cl_command_queueobject at the location pointed to by int_ptr_value. The relevantclRetain*()function will be called.New in version 2013.2.
-
int_ptr¶ Return an integer corresponding to the pointer value of the underlying
cl_command_queue. Usefrom_int_ptr()to turn back into a Python object.New in version 2013.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.)
-
-
class
pyopencl.Event¶ -
info¶ Lower case versions of the
event_infoconstants may be used as attributes on instances of this class to directly query info attributes.
-
profile.info¶ Lower case versions of the
profiling_infoconstants 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_infofor values of param.
-
get_profiling_info(param)¶ See
profiling_infofor values of param. Seeprofilefor an easier way of obtaining the same information.
-
wait()¶
-
static
from_int_ptr((int)int_ptr_value) → Event :¶ (static method) Return a new Python object referencing the C-level
cl_eventobject at the location pointed to by int_ptr_value. The relevantclRetain*()function will be called.New in version 2013.2.
-
int_ptr¶ Return an integer corresponding to the pointer value of the underlying
cl_event. Usefrom_int_ptr()to turn back into a Python object.New in version 2013.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.)
-
-
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.
-
class
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_statusfor possible values of status.
-
-
class
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.
-
Memory¶
-
class
pyopencl.MemoryObject¶ -
info¶ Lower case versions of the
mem_infoconstants 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.ndarrayof the given shape, dtype and order.
-
static
from_int_ptr((int)arg1) → object :¶ (static method) Return a new Python object referencing the C-level
cl_memobject at the location pointed to by int_ptr_value. The relevantclRetain*()function will be called.New in version 2013.2.
-
int_ptr¶ Return an integer corresponding to the pointer value of the underlying
cl_mem. Usefrom_int_ptr()to turn back into a Python object.New in version 2013.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.)
-
-
pyopencl.enqueue_migrate_mem_objects(queue, mem_objects, flags=0, wait_for=None)¶ Parameters: flags – from mem_migration_flagsNew 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_extNew in version 2011.2.
Only available with the cl_ext_migrate_memobject extension.
Buffers¶
-
class
pyopencl.Buffer(context, flags, size=0, hostbuf=None)¶ Create a
Buffer. Seemem_flagsfor values of flags. If hostbuf is specified, size defaults to the size of the specified buffer if it is passed as zero.Bufferinherits fromMemoryObject.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 aBufferor a Python buffer object is needed.Note that actual memory allocation in OpenCL may be deferred. Buffers are attached to a
Contextand 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 useenqueue_migrate_mem_objects()(if available) or simply perform a small transfer to the buffer. See alsopyopencl.tools.ImmediateAllocator.-
get_sub_region(origin, size, flags=0)¶ Only available in OpenCL 1.1 and newer.
-
__getitem__(slc)¶ slc is a
sliceobject indicating from which byte index range a sub-buffer is to be created. The flags argument ofget_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 ofpyopencl.Eventinstances for whose completion this command waits before starting exeuction.Only available with CL 1.2.
New in version 2011.2.
Image Formats¶
-
class
pyopencl.ImageFormat([channel_order, channel_type])¶ -
channel_order¶ See
channel_orderfor possible values.
-
channel_data_type¶ See
channel_typefor 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
strrepresentation 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.)
Changed in version 0.91: Constructor arguments added.
Changed in version 2013.2:
ImageFormatwas made comparable and hashable-
-
pyopencl.get_supported_image_formats(context, flags, image_type)¶ See
mem_flagsfor possible values of flags andmem_object_typefor possible values of image_type.
Images¶
-
Image(context, flags, format, shape=None, pitches=None, hostbuf=None, is_array=False, buffer=None): See
mem_flagsfor values of flags. shape is a 2- or 3-tuple. format is an instance ofImageFormat. 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.
Imageinherits fromMemoryObject.Note
If you want to load images from
numpy.ndarrayinstances or read images back into them, be aware that OpenCL images expect the x dimension to vary fastest, whereas in the default (C) order ofnumpyarrays, the last index varies fastest. If your array is arranged in the wrong order in memory, there are two possible fixes for this:- Convert the array to Fortran (column-major) order using
numpy.asarray(). - Pass ary.T.copy() to the image creation function.
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_infoandimage_infoconstants 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_infofor 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.)
- Convert the array to Fortran (column-major) order using
-
pyopencl.image_from_array(ctx, ary, num_channels=None, mode="r", norm_int=False)¶ Build a 2D or 3D
Imagefrom thenumpy.ndarrayary. 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
ImageFormatis 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 ofpyopencl.Eventinstances for whose completion this command waits before starting exeuction.Only available with CL 1.2.
New in version 2011.2.
Transfers¶
-
pyopencl.enqueue_copy(queue, dest, src, **kwargs)¶ Copy from
Image,Bufferor the host toImage,Bufferor the host. (Note: host-to-host copies are unsupported.)The following keyword arguments are available:
Parameters: - wait_for – (optional, default empty)
- is_blocking – Wait for completion. Defaults to True. (Available on any copy involving host memory)
Returns: A
NannyEventif the transfer involved a host-side buffer, otherwise anEvent.Note
Two types of ‘buffer’ occur in the arguments to this function,
Bufferand ‘host-side buffers’. The latter are defined by Python and commonly called buffer objects. Make sure to always be clear on whether aBufferor a Python buffer object is needed.Transfer
Buffer↔ hostParameters: 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: - byte_count – (optional) If not specified, defaults to the size of the source in versions 2012.x and earlier, and to the minimum of the size of the source and target from 2013.1 on.
- src_offset – (optional)
- dest_offset – (optional)
Rectangular
Buffer↔ host transfers (CL 1.1 and newer)Parameters: - buffer_origin –
tupleofintof length three or shorter. (mandatory) - host_origin –
tupleofintof length three or shorter. (mandatory) - region –
tupleofintof length three or shorter. (mandatory) - buffer_pitches –
tupleofintof length two or shorter. (optional, “tightly-packed” if unspecified) - host_pitches –
tupleofintof length two or shorter. (optional, “tightly-packed” if unspecified)
Transfer
Image↔ hostParameters: - origin –
tupleofintof length three or shorter. (mandatory) - region –
tupleofintof length three or shorter. (mandatory) - pitches –
tupleofintof length two or shorter. (optional)
Transfer
Buffer↔ImageParameters: - offset – offset in buffer (mandatory)
- origin –
tupleofintof length three or shorter. (mandatory) - region –
tupleofintof length three or shorter. (mandatory)
Transfer
Image↔ImageParameters: - src_origin –
tupleofintof length three or shorter. (mandatory) - dest_origin –
tupleofintof length three or shorter. (mandatory) - region –
tupleofintof length three or shorter. (mandatory)
Returns a new
pyopencl.Event. wait_for may either be None or a list ofpyopencl.Eventinstances for whose completion this command waits before starting exeuction.New in version 2011.1.
Mapping Memory into Host Address Space¶
-
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.Eventinstances for whose completion this command waits before starting exeuction. shape, dtype, and order have the same meaning as innumpy.empty(). Seemap_flagsfor possible values of flags. strides, if given, overrides order.Returns: a tuple (array, event). array is a numpy.ndarrayrepresenting the host side of the map. Its .base member contains aMemoryMap.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.Eventinstances for whose completion this command waits before starting exeuction. shape, dtype, and order have the same meaning as innumpy.empty(). Seemap_flagsfor possible values of flags. strides, if given, overrides order.Returns: a tuple (array, event). array is a numpy.ndarrayrepresenting the host side of the map. Its .base member contains aMemoryMap.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.
Samplers¶
-
class
pyopencl.Sampler(context, normalized_coords, addressing_mode, filter_mode)¶ normalized_coords is a
boolindicating whether to use coordinates between 0 and 1 (True) or the texture’s natural pixel size (False). Seeaddressing_modeandfilter_modefor possible argument values.-
info¶ Lower case versions of the
sampler_infoconstants may be used as attributes on instances of this class to directly query info attributes.
-
get_info(param)¶ See
sampler_infofor values of param.
-
static
from_int_ptr((int)int_ptr_value) → Sampler :¶ (static method) Return a new Python object referencing the C-level
cl_samplerobject at the location pointed to by int_ptr_value. The relevantclRetain*()function will be called.New in version 2013.2.
-
int_ptr¶ Return an integer corresponding to the pointer value of the underlying
cl_sampler. Usefrom_int_ptr()to turn back into a Python object.New in version 2013.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.)
-
Programs and Kernels¶
-
class
pyopencl.Program(context, src)¶ -
class
pyopencl.Program(context, devices, binaries) binaries must contain one binary for each entry in devices.
-
info¶ Lower case versions of the
program_infoconstants may be used as attributes on instances of this class to directly query info attributes.
-
get_info(param)¶ See
program_infofor values of param.
-
get_build_info(device, param)¶ See
program_build_infofor values of param.
-
build(options=[], devices=None)¶ options is a string of compiler flags. Returns self.
By default, built binaries are cached in an on-disk cache called
pyopencl-compiler-cache-vN-uidNAME-pyVERSIONin the directory returned bytempfile.gettempdir(). By setting the environment variablePYOPENCL_NO_CACHEto any non-empty value, this caching is suppressed. Any options found in the environment variablePYOPENCL_BUILD_OPTIONSwill be appended to options.Changed in version 2011.1: options may now also be a
listofstr.Changed in version 2013.1: Added
PYOPENCL_NO_CACHE. AddedPYOPENCL_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¶ Kernelobjects can be produced from a built (seebuild()) program simply by attribute lookup.Note
The
program_infoattributes live in the same name space and take precedence overKernelnames.
-
static
from_int_ptr((int)int_ptr_value) → _Program :¶ (static method) Return a new Python object referencing the C-level
cl_programobject at the location pointed to by int_ptr_value. The relevantclRetain*()function will be called.New in version 2013.2.
-
int_ptr¶ Return an integer corresponding to the pointer value of the underlying
cl_program. Usefrom_int_ptr()to turn back into a Python object.New in version 2013.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.)
-
-
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.
-
class
pyopencl.Kernel(program, name)¶ -
info¶ Lower case versions of the
kernel_infoconstants may be used as attributes on instances of this class to directly query info attributes.
-
get_info(param)¶ See
kernel_infofor values of param.
-
get_work_group_info(param, device)¶ See
kernel_work_group_infofor values of param.
-
get_arg_info(arg_index, param)¶ See
kernel_arg_infofor 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, ornumpy‘s sized scalars, such asnumpy.int32ornumpy.float64.Note
Note that Python’s own
intorfloatobjects will not work out of the box. SeeKernel.set_scalar_arg_dtypes()for a way to make them work. Alternatively, the standard library modulestructcan be used to convert Python’s native number types to binary data in astr.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
Kernelarguments. For each argument, arg_dtypes contains an entry. For non-scalars, this must be None. For scalars, it must be an object acceptable to thenumpy.dtypeconstructor, 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 usingset_args()to set each argument in turn. See the documentation forset_arg()to see what argument types are allowed. Returns a newpyopencl.Event. wait_for may either be None or a list ofpyopencl.Eventinstances 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 usingset_args()and then runsenqueue_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
tupleor None.tupleinstances are never validKernelarguments, 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.
-
static
from_int_ptr((int)int_ptr_value) → Kernel :¶ (static method) Return a new Python object referencing the C-level
cl_kernelobject at the location pointed to by int_ptr_value. The relevantclRetain*()function will be called.New in version 2013.2.
-
int_ptr¶ Return an integer corresponding to the pointer value of the underlying
cl_kernel. Usefrom_int_ptr()to turn back into a Python object.New in version 2013.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.)
-
-
class
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 ofpyopencl.Eventinstances 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 ofpyopencl.Eventinstances for whose completion this command waits before starting exeuction.
GL Interoperability¶
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
listofcontext_propertiesthat 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.
-
class
pyopencl.GLBuffer(context, flags, bufobj)¶ GLBufferinherits fromMemoryObject.-
gl_object¶
-
-
class
pyopencl.GLRenderBuffer(context, flags, bufobj)¶ GLRenderBufferinherits fromMemoryObject.-
gl_object¶
-
-
class
pyopencl.GLTexture(context, flags, texture_target, miplevel, texture, dims)¶ dims is either 2 or 3.
GLTextureinherits fromImage.-
gl_object¶
-
get_gl_texture_info(param)¶ See
gl_texture_infofor values of param. Only available when PyOpenCL is compiled with GL support. Seehave_gl().
-
-
pyopencl.enqueue_acquire_gl_objects(queue, mem_objects, wait_for=None)¶ mem_objects is a list of
MemoryObjectinstances. Returns a newpyopencl.Event. wait_for may either be None or a list ofpyopencl.Eventinstances 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
MemoryObjectinstances. Returns a newpyopencl.Event. wait_for may either be None or a list ofpyopencl.Eventinstances 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
Contextconstructor for the meaning of properties andgl_context_infofor param_name.Changed in version 2011.2: Accepts the platform argument. Using platform equal to None is deprecated as of PyOpenCL 2011.2.