Skip to content

Commit

Permalink
Support for OpenCL 2.0 constants/GetInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
inducer committed Sep 15, 2015
1 parent 70ef580 commit d6652d1
Show file tree
Hide file tree
Showing 10 changed files with 262 additions and 127 deletions.
97 changes: 94 additions & 3 deletions doc/make_constants.py
@@ -1,5 +1,5 @@
from __future__ import absolute_import
from __future__ import print_function
from __future__ import absolute_import, print_function

__copyright__ = "Copyright (C) 2009 Andreas Kloeckner"

__license__ = """
Expand Down Expand Up @@ -29,6 +29,8 @@
gl_sharing = ("cl_khr_gl_sharing", "0.92")
cl_11 = ("CL_1.1", "0.92")
cl_12 = ("CL_1.2", "2011.2")
cl_12_2015 = ("CL_1.2", "2015.2")
cl_20 = ("CL_2.0", "2015.2")
amd_devattr = ("cl_amd_device_attribute_query", "2013.2")


Expand Down Expand Up @@ -72,6 +74,9 @@ def get_extra_lines(tup):
"INVALID_LINKER_OPTIONS": cl_12,
"INVALID_DEVICE_PARTITION_COUNT": cl_12,

"INVALID_PIPE_SIZE": cl_20,
"INVALID_DEVICE_QUEUE": cl_20,

},

cl.device_info: {
Expand Down Expand Up @@ -137,13 +142,33 @@ def get_extra_lines(tup):
"REFERENCE_COUNT": cl_12,
"PREFERRED_INTEROP_USER_SYNC": cl_12,
"PRINTF_BUFFER_SIZE": cl_12,

"DEVICE_ON_HOST_PROPERTIES": cl_20,

"MAX_READ_WRITE_IMAGE_ARGS": cl_20,
"MAX_GLOBAL_VARIABLE_SIZE": cl_20,
"QUEUE_ON_DEVICE_PROPERTIES": cl_20,
"QUEUE_ON_DEVICE_PREFERRED_SIZE": cl_20,
"QUEUE_ON_DEVICE_MAX_SIZE": cl_20,
"MAX_ON_DEVICE_QUEUES": cl_20,
"MAX_ON_DEVICE_EVENTS": cl_20,
"SVM_CAPABILITIES": cl_20,
"GLOBAL_VARIABLE_PREFERRED_TOTAL_SIZE": cl_20,
"MAX_PIPE_ARGS": cl_20,
"PIPE_MAX_ACTIVE_RESERVATIONS": cl_20,
"PIPE_MAX_PACKET_SIZE": cl_20,
"PREFERRED_PLATFORM_ATOMIC_ALIGNMENT": cl_20,
"PREFERRED_GLOBAL_ATOMIC_ALIGNMENT": cl_20,
"PREFERRED_LOCAL_ATOMIC_ALIGNMENT": cl_20,
},

cl.mem_object_type: {
"IMAGE2D_ARRAY": cl_12,
"IMAGE1D": cl_12,
"IMAGE1D_ARRAY": cl_12,
"IMAGE1D_BUFFER": cl_12,

"PIPE": cl_20,
},

cl.device_type: {
Expand All @@ -166,6 +191,11 @@ def get_extra_lines(tup):
"CORRECTLY_ROUNDED_DIVIDE_SQRT": cl_12,
},

cl.command_queue_properties: {
"ON_DEVICE": cl_20,
"ON_DEVICE_DEFAULT": cl_20,
},

cl.context_info: {
"NUM_DEVICES": cl_11,
"INTEROP_USER_SYNC": cl_12,
Expand All @@ -175,6 +205,12 @@ def get_extra_lines(tup):
"Rx": cl_11,
"RGx": cl_11,
"RGBx": cl_11,

"sRGB": cl_20,
"sRGBx": cl_20,
"sRGBA": cl_20,
"sBGRA": cl_20,
"ABGR": cl_20,
},

cl.kernel_work_group_info: {
Expand All @@ -187,13 +223,21 @@ def get_extra_lines(tup):
"MIRRORED_REPEAT": cl_11,
},

cl.sampler_info: {
"MIP_FILTER_MODE": cl_20,
"LOD_MIN": cl_20,
"LOD_MAX": cl_20,
},

cl.event_info: {
"CONTEXT": cl_11,
},

cl.mem_info: {
"ASSOCIATED_MEMOBJECT": cl_11,
"OFFSET": cl_11,

"USES_SVM_POINTER": cl_20,
},

cl.image_info: {
Expand All @@ -214,6 +258,8 @@ def get_extra_lines(tup):

cl.program_build_info: {
"BINARY_TYPE": cl_12,

"GLOBAL_VARIABLE_TOTAL_SIZE": cl_20,
},

cl.program_binary_type: {
Expand All @@ -231,6 +277,7 @@ def get_extra_lines(tup):
"ADDRESS_QUALIFIER": cl_12,
"ACCESS_QUALIFIER": cl_12,
"TYPE_NAME": cl_12,
"TYPE_QUALIFIER": cl_12_2015,
"ARG_NAME": cl_12,
},

Expand All @@ -248,6 +295,15 @@ def get_extra_lines(tup):
"NONE": cl_12,
},

cl.kernel_arg_type_qualifier: {
"NONE": cl_12_2015,
"CONST": cl_12_2015,
"RESTRICT": cl_12_2015,
"VOLATILE": cl_12_2015,

"PIPE": cl_20,
},

cl.command_type: {
"READ_BUFFER_RECT": cl_11,
"WRITE_BUFFER_RECT": cl_11,
Expand All @@ -258,12 +314,43 @@ def get_extra_lines(tup):
"MIGRATE_MEM_OBJECTS": cl_12,
"FILL_BUFFER": cl_12,
"FILL_IMAGE": cl_12,

"SVM_FREE": cl_20,
"SVM_MEMCPY": cl_20,
"SVM_MEMFILL": cl_20,
"SVM_MAP": cl_20,
"SVM_UNMAP": cl_20,
},

cl.command_queue_info: {
"SIZE": cl_20,
},

cl.queue_properties: {
"PROPERTIES": cl_20,
"SIZE": cl_20,
},

cl.mem_flags: {
"USE_PERSISTENT_MEM_AMD":
("cl_amd_device_memory_flags", "2011.1"),
"HOST_WRITE_ONLY": cl_12,
"KERNEL_READ_AND_WRITE": cl_20,
},

cl.svm_mem_flags: {
"READ_WRITE": cl_20,
"WRITE_ONLY": cl_20,
"READ_ONLY": cl_20,
"SVM_FINE_GRAIN_BUFFER": cl_20,
"SVM_ATOMICS": cl_20,
},

cl.device_svm_capabilities: {
"COARSE_GRAIN_BUFFER": cl_20,
"FINE_GRAIN_BUFFER": cl_20,
"FINE_GRAIN_SYSTEM": cl_20,
"ATOMICS": cl_20,
},

cl.device_partition_property: {
Expand Down Expand Up @@ -305,6 +392,10 @@ def get_extra_lines(tup):
"NEXT_FISSIONABLE": fission,
},

cl.profiling_info: {
"COMPLETE": cl_20,
},

cl.mem_migration_flags: {
"HOST": cl_12,
"CONTENT_UNDEFINED": cl_12,
Expand Down Expand Up @@ -346,7 +437,7 @@ def doc_class(cls):

cls_const_ext = const_ext_lookup.get(cls, {})
for name in sorted(dir(cls)):
if not name.startswith("_") and not name in ["to_string", "names", "values"]:
if not name.startswith("_") and name not in ["to_string", "names", "values"]:
print(" .. attribute :: %s" % name)

if name in cls_const_ext:
Expand Down
16 changes: 16 additions & 0 deletions pyopencl/cffi_cl.py
Expand Up @@ -295,6 +295,10 @@ class device_exec_capabilities(_NoInit): # noqa
pass


class device_svm_capabilities(_NoInit): # noqa
pass


class command_queue_properties(_NoInit): # noqa
pass

Expand All @@ -315,6 +319,10 @@ class command_queue_info(_NoInit): # noqa
pass


class queue_properties(_NoInit): # noqa
pass


class mem_flags(_NoInit): # noqa
@classmethod
def _writable(cls, flags):
Expand All @@ -333,6 +341,10 @@ def _host_writable(cls, flags):
return cls._writable(flags) and cls._hold_host(flags)


class svm_mem_flags(_NoInit): # noqa
pass


class channel_order(_NoInit): # noqa
pass

Expand Down Expand Up @@ -397,6 +409,10 @@ class kernel_arg_access_qualifier(_NoInit): # noqa
pass


class kernel_arg_type_qualifier(_NoInit): # noqa
pass


class kernel_work_group_info(_NoInit): # noqa
pass

Expand Down
4 changes: 0 additions & 4 deletions setup.py
Expand Up @@ -72,8 +72,6 @@ def get_config_schema():
return ConfigSchema([
Switch("CL_TRACE", False, "Enable OpenCL API tracing"),
Switch("CL_ENABLE_GL", False, "Enable OpenCL<->OpenGL interoperability"),
Switch("CL_ENABLE_DEVICE_FISSION", True,
"Enable device fission extension, if present"),
Option("CL_PRETEND_VERSION", None,
"Dotted CL version (e.g. 1.2) which you'd like to use."),

Expand Down Expand Up @@ -109,8 +107,6 @@ def main():
if conf["CL_ENABLE_GL"]:
extra_defines["HAVE_GL"] = 1

if conf["CL_ENABLE_DEVICE_FISSION"]:
extra_defines["PYOPENCL_USE_DEVICE_FISSION"] = 1
if conf["CL_PRETEND_VERSION"]:
try:
major, minor = [int(x) for x in conf["CL_PRETEND_VERSION"].split(".")]
Expand Down

0 comments on commit d6652d1

Please sign in to comment.