diff --git a/pyopencl/array.py b/pyopencl/array.py index 9ee94a15ea8b4ca3458ab5499f6ba4c6b04eef95..08f7cc8b969c60b22df0565806d3db30f9126b4b 100644 --- a/pyopencl/array.py +++ b/pyopencl/array.py @@ -69,6 +69,12 @@ class VecLookupWarner(object): warn("pyopencl.array.vec is deprecated. " "Please use pyopencl.cltypes for OpenCL vector and scalar types", DeprecationWarning, 2) + + if name == "types": + name = "vec_types" + elif name == "type_to_scalar_and_count": + name = "vec_type_to_scalar_and_count" + return getattr(cltypes, name) diff --git a/pyopencl/cltypes.py b/pyopencl/cltypes.py index c8ff35c378bd1eb395e54dc0efa5ce6a21ff9b85..d1ba79f3f8e3905bdee8f119dca3e57a8dda6509 100644 --- a/pyopencl/cltypes.py +++ b/pyopencl/cltypes.py @@ -46,7 +46,6 @@ double = np.float64 # {{{ vector types - def _create_vector_types(): _mapping = [(k, globals()[k]) for k in ['char', 'uchar', 'short', 'ushort', 'int', @@ -55,10 +54,10 @@ def _create_vector_types(): def set_global(key, val): globals()[key] = val - field_names = ["x", "y", "z", "w"] + vec_types = {} + vec_type_to_scalar_and_count = {} - set_global('types', {}) - set_global('type_to_scalar_and_count', {}) + field_names = ["x", "y", "z", "w"] counts = [2, 3, 4, 8, 16] @@ -119,9 +118,14 @@ def _create_vector_types(): set_global("zeros_" + name, eval("lambda: filled_%s(0)" % (name))) set_global("ones_" + name, eval("lambda: filled_%s(1)" % (name))) - globals()['types'][np.dtype(base_type), count] = dtype - globals()['type_to_scalar_and_count'][dtype] = np.dtype(base_type), count + vec_types[np.dtype(base_type), count] = dtype + vec_type_to_scalar_and_count[dtype] = np.dtype(base_type), count + return vec_types, vec_type_to_scalar_and_count + + +vec_types, vec_type_to_scalar_and_count = _create_vector_types() -_create_vector_types() # }}} + +# vim: foldmethod=marker