diff --git a/examples/dump-properties.py b/examples/dump-properties.py index 92ce7dcbfa541ba7df65ce12a37f7e44c1fd34c7..8732c4cc96eb6500170b8704a41f73b53c4e1282 100644 --- a/examples/dump-properties.py +++ b/examples/dump-properties.py @@ -11,7 +11,6 @@ def print_info(obj, info_cls): if (info_cls == cl.device_info and info_name == "PARTITION_TYPES_EXT" and isinstance(info_value, list)): - print info_value print("%s: %s" % (info_name, [ cl.device_partition_property_ext.to_string(v) for v in info_value])) else: @@ -28,3 +27,35 @@ for platform in cl.get_platforms(): print(device) print(75*"-") print_info(device, cl.device_info) + ctx = cl.Context([device]) + #for mf in [cl.mem_flags.READ_ONLY, cl.mem_flags.READ_WRITE, cl.mem_flags.WRITE_ONLY]: + for mf in [cl.mem_flags.READ_ONLY]: + for itype in [cl.mem_object_type.IMAGE2D, cl.mem_object_type.IMAGE3D]: + try: + formats = cl.get_supported_image_formats(ctx, mf, itype) + except: + formats = "<error>" + else: + def str_chd_type(chdtype): + result = cl.channel_type.to_string(chdtype, + "<unknown channel data type %d>") + + result = result.replace("_INT", "") + result = result.replace("UNSIGNED", "U") + result = result.replace("SIGNED", "S") + result = result.replace("NORM", "N") + result = result.replace("FLOAT", "F") + return result + + formats = ", ".join( + "%s-%s" % ( + cl.channel_order.to_string(iform.channel_order, + "<unknown channel order 0x%x>"), + str_chd_type(iform.channel_data_type)) + for iform in formats) + + print "%s %s FORMATS: %s\n" % ( + cl.mem_object_type.to_string(itype), + cl.mem_flags.to_string(mf), + formats) + del ctx diff --git a/pyopencl/__init__.py b/pyopencl/__init__.py index 8c12e36b4d1bd4a91bcfe89603f4e30069a91936..4b329c49a9e1a4f7526bc2f5ec649081e75d99d2 100644 --- a/pyopencl/__init__.py +++ b/pyopencl/__init__.py @@ -275,9 +275,9 @@ def _add_functionality(): def image_format_repr(self): return "ImageFormat(%s, %s)" % ( channel_order.to_string(self.channel_order, - "<unknown channel order %d>"), + "<unknown channel order 0x%x>"), channel_type.to_string(self.channel_data_type, - "<unknown channel data type %d>")) + "<unknown channel data type 0x%x>")) ImageFormat.__repr__ = image_format_repr