From 27381fe4a50fb2ea5b8f1c9d9983c1c4565e97dc Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner <inform@tiker.net> Date: Sun, 5 Jul 2015 00:28:21 -0500 Subject: [PATCH] Restructure pyopencl.__init__ imports --- pyopencl/__init__.py | 129 +++++++++++++++++++++++++++++++++++++--- pyopencl/_pvt_struct.py | 71 ---------------------- 2 files changed, 121 insertions(+), 79 deletions(-) delete mode 100644 pyopencl/_pvt_struct.py diff --git a/pyopencl/__init__.py b/pyopencl/__init__.py index ca6f1b3b..aa8abdd7 100644 --- a/pyopencl/__init__.py +++ b/pyopencl/__init__.py @@ -1,13 +1,8 @@ # -*- coding: utf-8 -*- -from __future__ import division -from __future__ import absolute_import -from __future__ import print_function -import six -from six.moves import zip -from six.moves import input +from __future__ import division, absolute_import, print_function -__copyright__ = "Copyright (C) 2009 Andreas Kloeckner" +__copyright__ = "Copyright (C) 2009-15 Andreas Kloeckner" __license__ = """ Permission is hereby granted, free of charge, to any person obtaining a copy @@ -29,6 +24,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ +import six +import sys +from six.moves import input, range + from pyopencl.version import VERSION, VERSION_STATUS, VERSION_TEXT # noqa from pytools import Record as _Record @@ -45,7 +44,121 @@ except ImportError: import numpy as np -from pyopencl.cffi_cl import * # noqa + +from pyopencl.cffi_cl import ( # noqa + get_cl_header_version, + program_kind, + status_code, + platform_info, + device_type, + device_info, + device_fp_config, + device_mem_cache_type, + device_local_mem_type, + device_exec_capabilities, + command_queue_properties, + context_info, + gl_context_info, + context_properties, + command_queue_info, + mem_flags, + channel_order, + channel_type, + mem_object_type, + mem_info, + image_info, + addressing_mode, + filter_mode, + sampler_info, + map_flags, + program_info, + program_build_info, + program_binary_type, + kernel_info, + kernel_arg_info, + kernel_arg_address_qualifier, + kernel_arg_access_qualifier, + kernel_work_group_info, + event_info, + command_type, + command_execution_status, + profiling_info, + mem_migration_flags, + mem_migration_flags_ext, + device_partition_property_ext, + affinity_domain_ext, + device_partition_property, + device_affinity_domain, + gl_object_type, + gl_texture_info, + migrate_mem_object_flags_ext, + + Error, MemoryError, LogicError, RuntimeError, + + Platform, + get_platforms, + unload_platform_compiler, + + Device, + Context, + CommandQueue, + LocalMemory, + MemoryObjectHolder, + MemoryObject, + MemoryMap, + Buffer, + _Program, + Kernel, + + Event, + wait_for_events, + NannyEvent, + UserEvent, + + enqueue_nd_range_kernel, + enqueue_task, + + _enqueue_marker_with_wait_list, + _enqueue_marker, + _enqueue_barrier_with_wait_list, + + enqueue_migrate_mem_objects, + enqueue_migrate_mem_object_ext, + + _enqueue_barrier_with_wait_list, + _enqueue_read_buffer, + _enqueue_write_buffer, + _enqueue_copy_buffer, + _enqueue_read_buffer_rect, + _enqueue_write_buffer_rect, + _enqueue_copy_buffer_rect, + + enqueue_map_buffer, + _enqueue_fill_buffer, + _enqueue_read_image, + _enqueue_copy_image, + _enqueue_write_image, + enqueue_map_image, + enqueue_fill_image, + _enqueue_copy_image_to_buffer, + _enqueue_copy_buffer_to_image, + + have_gl, + _GLObject, + GLBuffer, + GLRenderBuffer, + _create_gl_enqueue, + + ImageFormat, + get_supported_image_formats, + + ImageDescriptor, + Image, + Sampler, + GLTexture, + ) + + import inspect as _inspect CONSTANT_CLASSES = [ diff --git a/pyopencl/_pvt_struct.py b/pyopencl/_pvt_struct.py deleted file mode 100644 index 90ed4a4a..00000000 --- a/pyopencl/_pvt_struct.py +++ /dev/null @@ -1,71 +0,0 @@ -from __future__ import division -from __future__ import absolute_import - -__copyright__ = """ -Copyright (C) 2013 Marko Bencun -Copyright (C) 2014 Andreas Kloeckner -Copyright (C) 2014 Yichao Yu -""" - -__license__ = """ -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -""" - -#import pyopencl._cl as _cl -import pyopencl.cffi_cl as _cl -import sys -from struct import pack as _pack - -_size_t_char = ({ - 8: 'Q', - 4: 'L', - 2: 'H', - 1: 'B', -})[_cl._ffi.sizeof('size_t')] -_type_char_map = { - 'n': _size_t_char.lower(), - 'N': _size_t_char -} -del _size_t_char - - -def pack_normal(type_char, obj): - if type_char == 'F': - return _pack('f', obj.real) + _pack('f', obj.imag) - elif type_char == "D": - return _pack('d', obj.real) + _pack('d', obj.imag) - else: - return _pack(_type_char_map.get(type_char, type_char), obj) - - -def pack_py26(type_char, obj): - if type_char == 'F': - return _pack('f', obj.real) + _pack('f', obj.imag) - elif type_char == "D": - return _pack('d', obj.real) + _pack('d', obj.imag) - elif type_char in "IL": - return _pack(type_char, long(obj)) - else: - return _pack(_type_char_map.get(type_char, type_char), obj) - - -if (2, 6) <= sys.version_info < (2, 7): - pack = pack_py26 -else: - pack = pack_normal -- GitLab