From e3802bab8e162bc289e202dd379ec0640be31191 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Mon, 29 Jun 2015 00:23:58 -0500 Subject: [PATCH] Convert wrapper to ahead-of-time, verified build (some extensions missing so far) --- .gitignore | 2 + MANIFEST.in | 2 + cffi_build.py.in | 93 +++++++++++++ cl_gl_types.h | 12 ++ pyopencl/_cffi.py => cl_types.h | 127 +----------------- pyopencl/cffi_cl.py | 50 ++++++- pyopencl/tools.py | 2 +- setup.py | 122 +++++------------ src/c_wrapper/buffer.cpp | 6 - src/c_wrapper/buffer.h | 4 - src/c_wrapper/clhelper.h | 28 ++-- src/c_wrapper/clobj.h | 4 - src/c_wrapper/command_queue.cpp | 6 - src/c_wrapper/command_queue.h | 4 - src/c_wrapper/context.cpp | 6 - src/c_wrapper/context.h | 4 - src/c_wrapper/debug.cpp | 8 +- src/c_wrapper/debug.h | 4 - src/c_wrapper/device.cpp | 6 - src/c_wrapper/device.h | 4 - src/c_wrapper/error.h | 8 +- src/c_wrapper/event.cpp | 6 - src/c_wrapper/event.h | 4 - src/c_wrapper/function.h | 4 - src/c_wrapper/gl_obj.cpp | 6 - src/c_wrapper/gl_obj.h | 4 - src/c_wrapper/image.cpp | 6 - src/c_wrapper/image.h | 4 - src/c_wrapper/kernel.cpp | 6 - src/c_wrapper/kernel.h | 4 - src/c_wrapper/memory_map.cpp | 6 - src/c_wrapper/memory_map.h | 4 - src/c_wrapper/memory_object.cpp | 6 - src/c_wrapper/memory_object.h | 4 - src/c_wrapper/platform.cpp | 6 - src/c_wrapper/platform.h | 4 - src/c_wrapper/program.cpp | 6 - src/c_wrapper/program.h | 4 - src/c_wrapper/pyhelper.cpp | 12 +- src/c_wrapper/pyhelper.h | 4 - src/c_wrapper/sampler.cpp | 6 - src/c_wrapper/sampler.h | 4 - src/c_wrapper/utils.h | 4 - src/c_wrapper/wrap_cl.cpp | 5 - src/c_wrapper/wrap_cl.h | 4 +- {pyopencl => src}/c_wrapper/wrap_cl_core.h | 7 + {pyopencl => src}/c_wrapper/wrap_cl_gl_core.h | 0 src/c_wrapper/wrap_constants.cpp | 9 +- 48 files changed, 222 insertions(+), 419 deletions(-) create mode 100644 cffi_build.py.in create mode 100644 cl_gl_types.h rename pyopencl/_cffi.py => cl_types.h (58%) rename {pyopencl => src}/c_wrapper/wrap_cl_core.h (99%) rename {pyopencl => src}/c_wrapper/wrap_cl_gl_core.h (100%) diff --git a/.gitignore b/.gitignore index a520df17f..2a42bf4dd 100644 --- a/.gitignore +++ b/.gitignore @@ -60,3 +60,5 @@ virtualenv-[0-9]* pytest.xml setuptools*tar.gz build-and-test-py-project.sh + +cffi_build.py diff --git a/MANIFEST.in b/MANIFEST.in index e76d1dead..27620315d 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -4,6 +4,7 @@ include pyopencl/cl/*.cl include src/c_wrapper/*.hpp include src/c_wrapper/*.h include src/c_wrapper/*.cpp +include *.h include test/*.py include test/*.h include examples/*.py @@ -16,6 +17,7 @@ include doc/source/conf.py include doc/source/_static/*.css include doc/source/_templates/*.html +include *.py.in include configure.py include Makefile.in include aksetup_helper.py diff --git a/cffi_build.py.in b/cffi_build.py.in new file mode 100644 index 000000000..7d2b86782 --- /dev/null +++ b/cffi_build.py.in @@ -0,0 +1,93 @@ +from __future__ import absolute_import, print_function + +__copyright__ = """ +Copyright (C) 2009-15 Andreas Kloeckner +Copyright (C) 2013 Marko Bencun +Copyright (C) 2014 Yuyi Chao +""" + +__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. +""" + + +from cffi import FFI + +ffi = FFI() + + +with open("cl_types.h", "rt") as f: + ffi.cdef(f.read()) + +if {CL_ENABLE_GL}: + with open("cl_gl_types.h") as f: + ffi.cdef(f.read()) + +with open("src/c_wrapper/wrap_cl_core.h", "rt") as f: + ffi.cdef(f.read()) + +if {CL_ENABLE_GL}: + with open("wrap_cl_gl_core.h") as f: + ffi.cdef(f.read()) + +ffi.set_source("pyopencl._cffi", + """ + #include + + extern "C" {{ + #include + #ifdef HAVE_GL + #include + #endif + }} + """, + define_macros=list({EXTRA_DEFINES}.items()), + include_dirs=( + {CL_INC_DIR} + ["src/c_wrapper/"]), + library_dirs={CL_LIB_DIR}, + libraries={CL_LIBNAME}, + extra_compile_args=( + ['-std=c++0x'] + {CXXFLAGS}), + extra_link_args={LDFLAGS}, + source_extension=".cpp", + sources=[ + "src/c_wrapper/wrap_cl.cpp", + "src/c_wrapper/wrap_constants.cpp", + "src/c_wrapper/bitlog.cpp", + "src/c_wrapper/pyhelper.cpp", + "src/c_wrapper/platform.cpp", + "src/c_wrapper/device.cpp", + "src/c_wrapper/context.cpp", + "src/c_wrapper/command_queue.cpp", + "src/c_wrapper/event.cpp", + "src/c_wrapper/memory_object.cpp", + "src/c_wrapper/image.cpp", + "src/c_wrapper/gl_obj.cpp", + "src/c_wrapper/memory_map.cpp", + "src/c_wrapper/buffer.cpp", + "src/c_wrapper/sampler.cpp", + "src/c_wrapper/program.cpp", + "src/c_wrapper/kernel.cpp", + "src/c_wrapper/debug.cpp", + ] + ) + + +if __name__ == "__main__": + ffi.compile() diff --git a/cl_gl_types.h b/cl_gl_types.h new file mode 100644 index 000000000..ea0e7e4df --- /dev/null +++ b/cl_gl_types.h @@ -0,0 +1,12 @@ +/* cl_gl.h */ +typedef cl_uint cl_gl_object_type; +typedef cl_uint cl_gl_texture_info; +typedef cl_uint cl_gl_platform_info; +typedef struct __GLsync *cl_GLsync; +typedef cl_uint cl_gl_context_info; + +/* cl_egl.h */ +typedef void* CLeglImageKHR; +typedef void* CLeglDisplayKHR; +typedef void* CLeglSyncKHR; +typedef intptr_t cl_egl_image_properties_khr; diff --git a/pyopencl/_cffi.py b/cl_types.h similarity index 58% rename from pyopencl/_cffi.py rename to cl_types.h index 3944bbf10..2feb15c98 100644 --- a/pyopencl/_cffi.py +++ b/cl_types.h @@ -1,9 +1,3 @@ -from __future__ import absolute_import -from cffi import FFI - -_ffi = FFI() -_cl_header = """ - /* gl.h */ typedef unsigned int GLenum; typedef int GLint; /* 4-byte signed */ @@ -110,6 +104,8 @@ } cl_buffer_region; /* cl_ext.h */ + +/* typedef cl_ulong cl_device_partition_property_ext; typedef cl_uint cl_image_pitch_info_qcom; typedef struct _cl_mem_ext_host_ptr { @@ -123,121 +119,4 @@ } cl_mem_ion_host_ptr; typedef cl_bitfield cl_mem_migration_flags_ext; - -/* cl_gl.h */ -typedef cl_uint cl_gl_object_type; -typedef cl_uint cl_gl_texture_info; -typedef cl_uint cl_gl_platform_info; -typedef struct __GLsync *cl_GLsync; -typedef cl_uint cl_gl_context_info; - -/* cl_egl.h */ -typedef void* CLeglImageKHR; -typedef void* CLeglDisplayKHR; -typedef void* CLeglSyncKHR; -typedef intptr_t cl_egl_image_properties_khr; - -/* c++ class pointer */ -typedef struct clbase *clobj_t; -""" - - -def _get_wrap_header(filename): - from pkg_resources import Requirement, resource_filename - header_name = resource_filename( - Requirement.parse("pyopencl"), "pyopencl/c_wrapper/"+filename) - - with open(header_name, "rt") as f: - return f.read() - -_ffi.cdef(_cl_header) -_ffi.cdef(_get_wrap_header("wrap_cl_core.h")) - - -# Copied from pypy distutils/commands/build_ext.py -def _get_c_extension_suffix(): - import imp - for ext, mod, typ in imp.get_suffixes(): - if typ == imp.C_EXTENSION: - return ext - - -def _get_wrapcl_so_names(): - import os.path - current_directory = os.path.dirname(__file__) - - # TODO: windows debug_mode? - - # Copied from pypy's distutils that "should work for CPython too". - ext_suffix = _get_c_extension_suffix() - if ext_suffix is not None: - yield os.path.join(current_directory, "_wrapcl" + ext_suffix) - - # Oh god. Chop hyphen-separated bits off the end, in the hope that - # something matches... - - root, ext = os.path.splitext(ext_suffix) - while True: - last_hyphen = root.rfind("-") - if last_hyphen == -1: - break - root = root[:last_hyphen] - yield os.path.join(current_directory, "_wrapcl" + root + ext) - - yield os.path.join(current_directory, "_wrapcl" + ext) - - from distutils.sysconfig import get_config_var - # "SO" is apparently deprecated, but changing this to "EXT_SUFFIX" - # as recommended breaks Py2 and PyPy3, as reported by @yuyichao - # on 2014-07-20. - # - # You've been warned. Change "SO" with care. - yield os.path.join(current_directory, "_wrapcl" + get_config_var("SO")) - - -def _import_library(): - names = list(_get_wrapcl_so_names()) - for name in names: - try: - return _ffi.dlopen(name) - except OSError: - pass - - raise RuntimeError("could not find PyOpenCL wrapper library. (tried: %s)" - % ", ".join(names)) - -_lib = _import_library() - -if _lib.have_gl(): - _ffi.cdef(_get_wrap_header("wrap_cl_gl_core.h")) - -import gc -_py_gc = _ffi.callback('int(void)')(gc.collect) - -_pyrefs = {} - - -@_ffi.callback('void(void*)') -def _py_deref(handle): - try: - del _pyrefs[handle] - except: - pass - - -# return a new reference of the object pointed to by the handle. -# The return value might be different with the input (on PyPy). -# _py_deref should be called (once) when the object is not needed anymore. -@_ffi.callback('void*(void*)') -def _py_ref(handle): - obj = _ffi.from_handle(handle) - handle = _ffi.new_handle(obj) - _pyrefs[handle] = handle - return handle - - -@_ffi.callback('void(void*, cl_int)') -def _py_call(handle, status): - _ffi.from_handle(handle)(status) - -_lib.set_py_funcs(_py_gc, _py_ref, _py_deref, _py_call) +*/ diff --git a/pyopencl/cffi_cl.py b/pyopencl/cffi_cl.py index f238fccdc..353272013 100644 --- a/pyopencl/cffi_cl.py +++ b/pyopencl/cffi_cl.py @@ -1,8 +1,4 @@ -from __future__ import division -from __future__ import absolute_import -from six.moves import map -from six.moves import range -from six.moves import zip +from __future__ import division, absolute_import __copyright__ = """ Copyright (C) 2013 Marko Bencun @@ -30,14 +26,54 @@ THE SOFTWARE. """ +from six.moves import map, range, zip import warnings import numpy as np import sys -from pyopencl._cffi import _ffi, _lib +from pyopencl._cffi import ffi as _ffi from .compyte.array import f_contiguous_strides, c_contiguous_strides +_lib = _ffi.dlopen(None) + +# {{{ hook up connections between the wrapper and the interperter + +import gc +_py_gc = _ffi.callback('int(void)')(gc.collect) + +_pyrefs = {} + + +@_ffi.callback('void(void*)') +def _py_deref(handle): + try: + del _pyrefs[handle] + except: + pass + + +# return a new reference of the object pointed to by the handle. +# The return value might be different with the input (on PyPy). +# _py_deref should be called (once) when the object is not needed anymore. +@_ffi.callback('void*(void*)') +def _py_ref(handle): + obj = _ffi.from_handle(handle) + handle = _ffi.new_handle(obj) + _pyrefs[handle] = handle + return handle + + +@_ffi.callback('void(void*, cl_int)') +def _py_call(handle, status): + _ffi.from_handle(handle)(status) + + +_lib.set_py_funcs(_py_gc, _py_ref, _py_deref, _py_call) + +# }}} + + # {{{ compatibility shims # are we running on pypy? @@ -406,7 +442,7 @@ class migrate_mem_object_flags_ext(_NoInit): # noqa _locals = locals() -@_ffi.callback('void(const char*, const char* name, long value)') +@_ffi.callback('void (*)(const char*, const char* name, long value)') def _constant_callback(type_, name, value): setattr(_locals[_ffi_pystr(type_)], _ffi_pystr(name), value) # noqa diff --git a/pyopencl/tools.py b/pyopencl/tools.py index 258e8c225..015fd2714 100644 --- a/pyopencl/tools.py +++ b/pyopencl/tools.py @@ -35,7 +35,7 @@ from decorator import decorator import pyopencl as cl from pytools import memoize, memoize_method -from pyopencl._cffi import _lib +from pyopencl.cffi_cl import _lib import re diff --git a/setup.py b/setup.py index aaf12bf14..c7eb81264 100644 --- a/setup.py +++ b/setup.py @@ -1,10 +1,11 @@ -from __future__ import absolute_import -from __future__ import print_function #!/usr/bin/env python -# -*- coding: latin-1 -*- +# -*- coding: utf-8 -*- + +from __future__ import absolute_import, print_function __copyright__ = """ -Copyright (C) 2009-14 Andreas Kloeckner +Copyright (C) 2009-15 Andreas Kloeckner +Copyright (C) 2013 Marko Bencun Copyright (C) 2013 Marko Bencun """ @@ -84,37 +85,40 @@ def get_config_schema(): def main(): + from setuptools import find_packages from aksetup_helper import (hack_distutils, get_config, setup, check_git_submodules) - from setuptools import Extension check_git_submodules() hack_distutils() conf = get_config(get_config_schema(), warn_about_no_config=False) - EXTRA_DEFINES = {} - EXTRA_DEFINES["PYGPU_PACKAGE"] = "pyopencl" - EXTRA_DEFINES["PYGPU_PYOPENCL"] = "1" + extra_defines = {} + + extra_defines["PYGPU_PACKAGE"] = "pyopencl" + extra_defines["PYGPU_PYOPENCL"] = "1" if conf["CL_TRACE"]: - EXTRA_DEFINES["PYOPENCL_TRACE"] = 1 + extra_defines["PYOPENCL_TRACE"] = 1 if conf["CL_ENABLE_GL"]: - EXTRA_DEFINES["HAVE_GL"] = 1 + extra_defines["HAVE_GL"] = 1 if conf["CL_ENABLE_DEVICE_FISSION"]: - EXTRA_DEFINES["PYOPENCL_USE_DEVICE_FISSION"] = 1 + 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(".")] - EXTRA_DEFINES["PYOPENCL_PRETEND_CL_VERSION"] = \ + extra_defines["PYOPENCL_PRETEND_CL_VERSION"] = \ 0x1000*major + 0x10 * minor except: print("CL_PRETEND_VERSION must be of the form M.N, " "with two integers M and N") raise + conf["EXTRA_DEFINES"] = extra_defines + ver_dic = {} version_file = open("pyopencl/version.py") try: @@ -124,14 +128,14 @@ def main(): exec(compile(version_file_contents, "pyopencl/version.py", 'exec'), ver_dic) - SEPARATOR = "-"*75 + separator = "-"*75 try: import mako # noqa except ImportError: - print(SEPARATOR) + print(separator) print("Mako is not installed.") - print(SEPARATOR) + print(separator) print("That is not a problem, as most of PyOpenCL will be just fine ") print("without it.Some higher-level parts of pyopencl (such as ") print("pyopencl.reduction) will not function without the templating engine ") @@ -140,46 +144,26 @@ def main(): print("installing PyOpenCL.") print("") print("[1] http://www.makotemplates.org/") - print(SEPARATOR) + print(separator) print("Hit Ctrl-C now if you'd like to think about the situation.") - print(SEPARATOR) + print(separator) from aksetup_helper import count_down_delay count_down_delay(delay=5) - might_be_cuda = False - for inc_dir in conf["CL_INC_DIR"]: - inc_dir = inc_dir.lower() - if "nv" in inc_dir or "cuda" in inc_dir: - might_be_cuda = True - - if might_be_cuda and conf["CL_ENABLE_DEVICE_FISSION"]: - print(SEPARATOR) - print("You might be compiling against Nvidia CUDA with device " - "fission enabled.") - print(SEPARATOR) - print("That is not a problem on CUDA 4.0 and newer. If you are " - "using CUDA 3.2,") - print("your build will break, because Nvidia shipped a broken CL header in") - print("in your version. The fix is to set CL_ENABLE_DEVICE_FISSION to False") - print("in your PyOpenCL configuration.") - print(SEPARATOR) - print("Hit Ctrl-C now if you'd like to think about the situation.") - print(SEPARATOR) + # {{{ write cffi build script - from aksetup_helper import count_down_delay - count_down_delay(delay=5) + with open("cffi_build.py.in", "rt") as f: + build_script_template = f.read() + + format_args = dict((k, repr(v)) for k, v in conf.items()) - # from pyopencl._cffi import _get_verifier + build_script = build_script_template.format(**format_args) - # for development: clean cache such that the extension is rebuilt - if 0: - import os.path - current_directory = os.path.dirname(__file__) + with open("cffi_build.py", "wt") as f: + f.write(build_script) - import shutil - shutil.rmtree(os.path.join(current_directory, - 'pyopencl', '__pycache__/'), ignore_errors=True) + # }}} setup(name="pyopencl", # metadata @@ -212,10 +196,11 @@ def main(): ], # build info - packages=["pyopencl", "pyopencl.characterize", "pyopencl.compyte"], + packages=find_packages(), setup_requires=[ "numpy", + "cffi>=1.1.0", ], install_requires=[ @@ -223,53 +208,16 @@ def main(): "pytools>=2014.2", "pytest>=2", "decorator>=3.2.0", - "cffi>=0.7.2", + "cffi>=1.1.0", "appdirs>=1.4.0", # "Mako>=0.3.6", ], - ext_package="pyopencl", - ext_modules=[ - Extension("_wrapcl", - ["src/c_wrapper/wrap_cl.cpp", - "src/c_wrapper/wrap_constants.cpp", - "src/c_wrapper/bitlog.cpp", - "src/c_wrapper/pyhelper.cpp", - "src/c_wrapper/platform.cpp", - "src/c_wrapper/device.cpp", - "src/c_wrapper/context.cpp", - "src/c_wrapper/command_queue.cpp", - "src/c_wrapper/event.cpp", - "src/c_wrapper/memory_object.cpp", - "src/c_wrapper/image.cpp", - "src/c_wrapper/gl_obj.cpp", - "src/c_wrapper/memory_map.cpp", - "src/c_wrapper/buffer.cpp", - "src/c_wrapper/sampler.cpp", - "src/c_wrapper/program.cpp", - "src/c_wrapper/kernel.cpp", - "src/c_wrapper/debug.cpp", - ], - include_dirs=( - conf["CL_INC_DIR"] - + ["src/c_wrapper/", - "pyopencl/c_wrapper/"]), - library_dirs=conf["CL_LIB_DIR"], - libraries=conf["CL_LIBNAME"], - define_macros=list(EXTRA_DEFINES.items()), - extra_compile_args=(['-std=c++0x'] - + conf["CXXFLAGS"]), - extra_link_args=conf["LDFLAGS"]) - ], + cffi_modules=["cffi_build.py:ffi"], include_package_data=True, package_data={ - "pyopencl": [ - "cl/*.cl", - "cl/*.h", - "c_wrapper/wrap_cl_core.h", - ] + (["c_wrapper/wrap_cl_gl_core.h"] - if conf["CL_ENABLE_GL"] else []) + "pyopencl": ["cl/*.cl", "cl/*.h"] }, zip_safe=False) diff --git a/src/c_wrapper/buffer.cpp b/src/c_wrapper/buffer.cpp index da8fc68a9..bda4499d3 100644 --- a/src/c_wrapper/buffer.cpp +++ b/src/c_wrapper/buffer.cpp @@ -3,8 +3,6 @@ #include "command_queue.h" #include "event.h" -namespace pyopencl { - template void print_clobj(std::ostream&, const buffer*); PYOPENCL_USE_RESULT static PYOPENCL_INLINE buffer* @@ -54,11 +52,7 @@ buffer::getitem(ssize_t start, ssize_t end) const } #endif -} - // c wrapper -// Import all the names in pyopencl namespace for c wrappers. -using namespace pyopencl; // Buffer error* diff --git a/src/c_wrapper/buffer.h b/src/c_wrapper/buffer.h index 95feffb86..23b990084 100644 --- a/src/c_wrapper/buffer.h +++ b/src/c_wrapper/buffer.h @@ -4,8 +4,6 @@ #ifndef __PYOPENCL_BUFFER_H #define __PYOPENCL_BUFFER_H -namespace pyopencl { - // {{{ buffer class buffer : public memory_object { @@ -27,6 +25,4 @@ extern template void print_clobj(std::ostream&, const buffer*); // }}} -} - #endif diff --git a/src/c_wrapper/clhelper.h b/src/c_wrapper/clhelper.h index f95391e14..b66087f00 100644 --- a/src/c_wrapper/clhelper.h +++ b/src/c_wrapper/clhelper.h @@ -4,8 +4,6 @@ #ifndef __PYOPENCL_CLHELPER_H #define __PYOPENCL_CLHELPER_H -namespace pyopencl { - template class _CLObjOutArg : public OutArg { typedef typename CLObj::cl_type CLType; @@ -70,7 +68,7 @@ make_cloutarg(clobj_t *ret, cl_int (*release)(typename CLObj::cl_type), return _CLObjOutArg(ret, release, name, t1...); } #define pyopencl_outarg(type, ret, func, args...) \ - pyopencl::make_cloutarg(ret, func, #func, ##args) + make_cloutarg(ret, func, #func, ##args) // {{{ GetInfo helpers @@ -86,7 +84,7 @@ get_vec_info(cl_int (*func)(ArgTypes...), const char *name, return buf; } #define pyopencl_get_vec_info(type, what, args...) \ - pyopencl::get_vec_info(clGet##what##Info, "clGet" #what "Info", args) + get_vec_info(clGet##what##Info, "clGet" #what "Info", args) template PYOPENCL_USE_RESULT static PYOPENCL_INLINE generic_info @@ -110,7 +108,7 @@ convert_array_info(const char *tname, pyopencl_buf &&_buf) } #define pyopencl_convert_array_info(type, buf) \ - pyopencl::convert_array_info(#type, buf) + convert_array_info(#type, buf) #define pyopencl_get_array_info(type, what, args...) \ pyopencl_convert_array_info(type, pyopencl_get_vec_info(type, what, args)) @@ -126,7 +124,7 @@ convert_opaque_array_info(T &&buf) return info; } #define pyopencl_get_opaque_array_info(cls, what, args...) \ - pyopencl::convert_opaque_array_info( \ + convert_opaque_array_info( \ pyopencl_get_vec_info(cls::cl_type, what, args)) template @@ -148,7 +146,7 @@ get_opaque_info(cl_int (*func)(ArgTypes...), const char *name, return info; } #define pyopencl_get_opaque_info(clobj, what, args...) \ - pyopencl::get_opaque_info(clGet##what##Info, \ + get_opaque_info(clGet##what##Info, \ "clGet" #what "Info", args) template @@ -168,7 +166,7 @@ get_str_info(cl_int (*func)(ArgTypes...), const char *name, return info; } #define pyopencl_get_str_info(what, args...) \ - pyopencl::get_str_info(clGet##what##Info, "clGet" #what "Info", args) + get_str_info(clGet##what##Info, "clGet" #what "Info", args) template PYOPENCL_USE_RESULT static PYOPENCL_INLINE generic_info @@ -185,7 +183,7 @@ get_int_info(cl_int (*func)(ArgTypes...), const char *name, return info; } #define pyopencl_get_int_info(type, what, args...) \ - pyopencl::get_int_info(clGet##what##Info, "clGet" #what "Info", \ + get_int_info(clGet##what##Info, "clGet" #what "Info", \ #type "*", args) // }}} @@ -203,7 +201,7 @@ convert_obj(cl_int (*clRelease)(CLType), const char *name, CLType cl_obj, } } #define pyopencl_convert_obj(type, func, args...) \ - pyopencl::convert_obj(func, #func, args) + convert_obj(func, #func, args) // {{{ extension function pointers @@ -214,12 +212,12 @@ get_ext_fun(cl_platform_id plat, const char *name, const char *err) { T func = (T)clGetExtensionFunctionAddressForPlatform(plat, name); if (!func) { - throw pyopencl::clerror(name, CL_INVALID_VALUE, err); + throw clerror(name, CL_INVALID_VALUE, err); } return func; } #define pyopencl_get_ext_fun(plat, name) \ - pyopencl::get_ext_fun(plat, #name, #name " not available") + get_ext_fun(plat, #name, #name " not available") #else template PYOPENCL_USE_RESULT static PYOPENCL_INLINE T @@ -227,18 +225,16 @@ get_ext_fun(const char *name, const char *err) { T func = (T)clGetExtensionFunctionAddress(name); if (!func) { - throw pyopencl::clerror(name, CL_INVALID_VALUE, err); + throw clerror(name, CL_INVALID_VALUE, err); } return func; } #define pyopencl_get_ext_fun(plat, name) \ - pyopencl::get_ext_fun(#name, #name " not available") + get_ext_fun(#name, #name " not available") #endif // }}} -} - static PYOPENCL_INLINE std::ostream& operator<<(std::ostream &stm, const cl_image_format &fmt) { diff --git a/src/c_wrapper/clobj.h b/src/c_wrapper/clobj.h index 660dd3ba1..6d2982282 100644 --- a/src/c_wrapper/clobj.h +++ b/src/c_wrapper/clobj.h @@ -7,8 +7,6 @@ constexpr static class_t class_id = CLASS_##name; \ constexpr static const char *class_name = #name; -namespace pyopencl { - struct clbase { private: // non-copyable @@ -148,6 +146,4 @@ buf_to_base(T2 &&buf2, ArgTypes&&... args) std::forward(args)...); } -} - #endif diff --git a/src/c_wrapper/command_queue.cpp b/src/c_wrapper/command_queue.cpp index bede3cbf5..e56beea21 100644 --- a/src/c_wrapper/command_queue.cpp +++ b/src/c_wrapper/command_queue.cpp @@ -4,8 +4,6 @@ #include "event.h" #include "clhelper.h" -namespace pyopencl { - template class clobj; template void print_arg(std::ostream&, const cl_command_queue&, bool); @@ -38,11 +36,7 @@ command_queue::get_info(cl_uint param_name) const } } -} - // c wrapper -// Import all the names in pyopencl namespace for c wrappers. -using namespace pyopencl; // Command Queue error* diff --git a/src/c_wrapper/command_queue.h b/src/c_wrapper/command_queue.h index 7d4dcc7b9..378666fa0 100644 --- a/src/c_wrapper/command_queue.h +++ b/src/c_wrapper/command_queue.h @@ -3,8 +3,6 @@ #ifndef __PYOPENCL_COMMAND_QUEUE_H #define __PYOPENCL_COMMAND_QUEUE_H -namespace pyopencl { - // {{{ command_queue extern template class clobj; @@ -63,6 +61,4 @@ extern template void print_clobj(std::ostream&, // }}} -} - #endif diff --git a/src/c_wrapper/context.cpp b/src/c_wrapper/context.cpp index 6c5937ccc..11f683450 100644 --- a/src/c_wrapper/context.cpp +++ b/src/c_wrapper/context.cpp @@ -3,8 +3,6 @@ #include "platform.h" #include "clhelper.h" -namespace pyopencl { - template class clobj; template void print_arg(std::ostream&, const cl_context&, bool); template void print_clobj(std::ostream&, const context*); @@ -106,11 +104,7 @@ context::get_info(cl_uint param_name) const } } -} - // c wrapper -// Import all the names in pyopencl namespace for c wrappers. -using namespace pyopencl; // Context error* diff --git a/src/c_wrapper/context.h b/src/c_wrapper/context.h index 323381de9..ff94ecb18 100644 --- a/src/c_wrapper/context.h +++ b/src/c_wrapper/context.h @@ -3,8 +3,6 @@ #ifndef __PYOPENCL_CONTEXT_H #define __PYOPENCL_CONTEXT_H -namespace pyopencl { - // {{{ context extern template class clobj; @@ -33,6 +31,4 @@ extern template void print_clobj(std::ostream&, const context*); // }}} -} - #endif diff --git a/src/c_wrapper/debug.cpp b/src/c_wrapper/debug.cpp index 75d109fa4..a118b4687 100644 --- a/src/c_wrapper/debug.cpp +++ b/src/c_wrapper/debug.cpp @@ -4,8 +4,6 @@ #include #include -namespace pyopencl { - std::mutex dbg_lock; void @@ -73,16 +71,14 @@ _get_debug_env() bool debug_enabled = _get_debug_env(); -} - int get_debug() { - return (int)pyopencl::debug_enabled; + return (int) debug_enabled; } void set_debug(int debug) { - pyopencl::debug_enabled = (bool)debug; + debug_enabled = (bool)debug; } diff --git a/src/c_wrapper/debug.h b/src/c_wrapper/debug.h index 777dc6808..c56165870 100644 --- a/src/c_wrapper/debug.h +++ b/src/c_wrapper/debug.h @@ -6,8 +6,6 @@ #ifndef __PYOPENCL_DEBUG_H #define __PYOPENCL_DEBUG_H -namespace pyopencl { - extern bool debug_enabled; #ifdef PYOPENCL_TRACE #define DEFAULT_DEBUG true @@ -27,6 +25,4 @@ dbg_print_str(std::ostream &stm, const char *str) } void dbg_print_bytes(std::ostream &stm, const unsigned char *bytes, size_t len); -} - #endif diff --git a/src/c_wrapper/device.cpp b/src/c_wrapper/device.cpp index c395b62bd..488cc5a69 100644 --- a/src/c_wrapper/device.cpp +++ b/src/c_wrapper/device.cpp @@ -1,8 +1,6 @@ #include "device.h" #include "platform.h" -namespace pyopencl { - template class clobj; template void print_arg(std::ostream&, const cl_device_id&, bool); @@ -295,11 +293,7 @@ device::create_sub_devices_ext(const cl_device_partition_property_ext *props) } #endif -} - // c wrapper -// Import all the names in pyopencl namespace for c wrappers. -using namespace pyopencl; #if PYOPENCL_CL_VERSION >= 0x1020 error* diff --git a/src/c_wrapper/device.h b/src/c_wrapper/device.h index 970047d1c..061800077 100644 --- a/src/c_wrapper/device.h +++ b/src/c_wrapper/device.h @@ -3,8 +3,6 @@ #ifndef __PYOPENCL_DEVICE_H #define __PYOPENCL_DEVICE_H -namespace pyopencl { - // {{{ device extern template class clobj; @@ -78,6 +76,4 @@ extern template void print_clobj(std::ostream&, const device*); // }}} -} - #endif diff --git a/src/c_wrapper/error.h b/src/c_wrapper/error.h index 9efb7de32..5e483698f 100644 --- a/src/c_wrapper/error.h +++ b/src/c_wrapper/error.h @@ -12,8 +12,6 @@ #ifndef __PYOPENCL_ERROR_H #define __PYOPENCL_ERROR_H -namespace pyopencl { - // {{{ error class clerror : public std::runtime_error { @@ -239,7 +237,7 @@ call_guarded(T (*func)(ArgTypes...), const char *name, ArgTypes2&&... args) return res; } #define pyopencl_call_guarded(func, args...) \ - pyopencl::call_guarded(func, #func, args) + call_guarded(func, #func, args) static PYOPENCL_INLINE void cleanup_print_error(cl_int status_code, const char *name) noexcept @@ -263,7 +261,7 @@ call_guarded_cleanup(cl_int (*func)(ArgTypes...), const char *name, } } #define pyopencl_call_guarded_cleanup(func, args...) \ - pyopencl::call_guarded_cleanup(func, #func, args) + call_guarded_cleanup(func, #func, args) template PYOPENCL_USE_RESULT static PYOPENCL_INLINE error* @@ -311,6 +309,4 @@ c_handle_retry_mem_error(Func &&func) noexcept // }}} -} - #endif diff --git a/src/c_wrapper/event.cpp b/src/c_wrapper/event.cpp index facbab0be..63c6daa71 100644 --- a/src/c_wrapper/event.cpp +++ b/src/c_wrapper/event.cpp @@ -5,8 +5,6 @@ #include -namespace pyopencl { - template class clobj; template void print_arg(std::ostream&, const cl_event&, bool); template void print_clobj(std::ostream&, const event*); @@ -202,11 +200,7 @@ class user_event : public event { }; #endif -} - // c wrapper -// Import all the names in pyopencl namespace for c wrappers. -using namespace pyopencl; // Event error* diff --git a/src/c_wrapper/event.h b/src/c_wrapper/event.h index 6dde1a3ed..7c3b48528 100644 --- a/src/c_wrapper/event.h +++ b/src/c_wrapper/event.h @@ -4,8 +4,6 @@ #ifndef __PYOPENCL_EVENT_H #define __PYOPENCL_EVENT_H -namespace pyopencl { - // {{{ event extern template class clobj; @@ -79,6 +77,4 @@ nanny_event_out(clobj_t *ret, void *ward) // }}} -} - #endif diff --git a/src/c_wrapper/function.h b/src/c_wrapper/function.h index cbb62e353..89869918c 100644 --- a/src/c_wrapper/function.h +++ b/src/c_wrapper/function.h @@ -10,8 +10,6 @@ #define PYOPENCL_INLINE inline #endif -namespace pyopencl { - template using rm_ref_t = typename std::remove_reference::type; template @@ -118,6 +116,4 @@ make_argpack(Types&&... args) return ArgPack...>(std::forward(args)...); } -} - #endif diff --git a/src/c_wrapper/gl_obj.cpp b/src/c_wrapper/gl_obj.cpp index 036ebdc71..206d30b46 100644 --- a/src/c_wrapper/gl_obj.cpp +++ b/src/c_wrapper/gl_obj.cpp @@ -6,8 +6,6 @@ #ifdef HAVE_GL -namespace pyopencl { - template void print_clobj(std::ostream&, const gl_buffer*); template void print_clobj(std::ostream&, const gl_renderbuffer*); @@ -66,11 +64,7 @@ enqueue_gl_objects(clEnqueueGLObjectFunc func, const char *name, enqueue_gl_objects(clEnqueue##what##GLObjects, \ "clEnqueue" #what "GLObjects", args) -} - // c wrapper -// Import all the names in pyopencl namespace for c wrappers. -using namespace pyopencl; error* create_from_gl_buffer(clobj_t *ptr, clobj_t _ctx, diff --git a/src/c_wrapper/gl_obj.h b/src/c_wrapper/gl_obj.h index 17c3d73b1..9f47e19b2 100644 --- a/src/c_wrapper/gl_obj.h +++ b/src/c_wrapper/gl_obj.h @@ -3,8 +3,6 @@ #ifndef __PYOPENCL_GL_OBJ_H #define __PYOPENCL_GL_OBJ_H -namespace pyopencl { - #ifdef HAVE_GL // {{{ gl interop @@ -45,6 +43,4 @@ class gl_texture : public image { #endif -} - #endif diff --git a/src/c_wrapper/image.cpp b/src/c_wrapper/image.cpp index 2892e17c2..775528588 100644 --- a/src/c_wrapper/image.cpp +++ b/src/c_wrapper/image.cpp @@ -4,8 +4,6 @@ #include "event.h" #include "buffer.h" -namespace pyopencl { - template void print_clobj(std::ostream&, const image*); PYOPENCL_USE_RESULT static PYOPENCL_INLINE image* @@ -53,11 +51,7 @@ image::get_image_info(cl_image_info param) const } } -} - // c wrapper -// Import all the names in pyopencl namespace for c wrappers. -using namespace pyopencl; // Image error* diff --git a/src/c_wrapper/image.h b/src/c_wrapper/image.h index 85a95d338..55520f880 100644 --- a/src/c_wrapper/image.h +++ b/src/c_wrapper/image.h @@ -4,8 +4,6 @@ #ifndef __PYOPENCL_IMAGE_H #define __PYOPENCL_IMAGE_H -namespace pyopencl { - // {{{ image class image : public memory_object { @@ -49,6 +47,4 @@ extern template void print_clobj(std::ostream&, const image*); // }}} -} - #endif diff --git a/src/c_wrapper/kernel.cpp b/src/c_wrapper/kernel.cpp index 0d367a834..246376ab7 100644 --- a/src/c_wrapper/kernel.cpp +++ b/src/c_wrapper/kernel.cpp @@ -8,8 +8,6 @@ #include "event.h" #include "clhelper.h" -namespace pyopencl { - template class clobj; template void print_arg(std::ostream&, const cl_kernel&, bool); template void print_clobj(std::ostream&, const kernel*); @@ -87,11 +85,7 @@ kernel::get_arg_info(cl_uint idx, cl_kernel_arg_info param) const } #endif -} - // c wrapper -// Import all the names in pyopencl namespace for c wrappers. -using namespace pyopencl; // Kernel error* diff --git a/src/c_wrapper/kernel.h b/src/c_wrapper/kernel.h index c297dae69..4a1b332a2 100644 --- a/src/c_wrapper/kernel.h +++ b/src/c_wrapper/kernel.h @@ -3,8 +3,6 @@ #ifndef __PYOPENCL_KERNEL_H #define __PYOPENCL_KERNEL_H -namespace pyopencl { - class device; // {{{ kernel @@ -43,6 +41,4 @@ extern template void print_clobj(std::ostream&, const kernel*); // }}} -} - #endif diff --git a/src/c_wrapper/memory_map.cpp b/src/c_wrapper/memory_map.cpp index 176027a2f..f9014dcd7 100644 --- a/src/c_wrapper/memory_map.cpp +++ b/src/c_wrapper/memory_map.cpp @@ -4,8 +4,6 @@ #include "event.h" #include "clhelper.h" -namespace pyopencl { - template class clobj; template void print_arg(std::ostream&, void *const&, bool); template void print_buf(std::ostream&, void *const*, @@ -59,11 +57,7 @@ convert_memory_map(clobj_t evt, command_queue *queue, } } -} - // c wrapper -// Import all the names in pyopencl namespace for c wrappers. -using namespace pyopencl; // Memory Map error* diff --git a/src/c_wrapper/memory_map.h b/src/c_wrapper/memory_map.h index 8836b374d..65a988a9b 100644 --- a/src/c_wrapper/memory_map.h +++ b/src/c_wrapper/memory_map.h @@ -5,8 +5,6 @@ #ifndef __PYOPENCL_MEMORY_MAP_H #define __PYOPENCL_MEMORY_MAP_H -namespace pyopencl { - class event; // {{{ memory_map @@ -36,6 +34,4 @@ class memory_map : public clobj { // }}} -} - #endif diff --git a/src/c_wrapper/memory_object.cpp b/src/c_wrapper/memory_object.cpp index 72e442f46..bc178d5df 100644 --- a/src/c_wrapper/memory_object.cpp +++ b/src/c_wrapper/memory_object.cpp @@ -4,8 +4,6 @@ #include "command_queue.h" #include "clhelper.h" -namespace pyopencl { - template class clobj; template void print_arg(std::ostream&, const cl_mem&, bool); template void print_buf(std::ostream&, const cl_mem*, @@ -64,11 +62,7 @@ memory_object::~memory_object() pyopencl_call_guarded_cleanup(clReleaseMemObject, this); } -} - // c wrapper -// Import all the names in pyopencl namespace for c wrappers. -using namespace pyopencl; // Memory Object error* diff --git a/src/c_wrapper/memory_object.h b/src/c_wrapper/memory_object.h index 65228f9f6..a56972e15 100644 --- a/src/c_wrapper/memory_object.h +++ b/src/c_wrapper/memory_object.h @@ -4,8 +4,6 @@ #ifndef __PYOPENCL_MEMORY_OBJECT_H #define __PYOPENCL_MEMORY_OBJECT_H -namespace pyopencl { - // {{{ memory_object extern template class clobj; @@ -55,6 +53,4 @@ class memory_object : public clobj { // }}} -} - #endif diff --git a/src/c_wrapper/platform.cpp b/src/c_wrapper/platform.cpp index 1bf7e496c..b08e1b178 100644 --- a/src/c_wrapper/platform.cpp +++ b/src/c_wrapper/platform.cpp @@ -5,8 +5,6 @@ #include #include -namespace pyopencl { - template class clobj; template void print_arg(std::ostream&, const cl_platform_id&, bool); @@ -58,11 +56,7 @@ platform::get_version(cl_platform_id plat, int *major, int *minor) *minor = atoi(name + ver_match.position(2)); } -} - // c wrapper -// Import all the names in pyopencl namespace for c wrappers. -using namespace pyopencl; error* get_platforms(clobj_t **_platforms, uint32_t *num_platforms) diff --git a/src/c_wrapper/platform.h b/src/c_wrapper/platform.h index f399392a7..1bad5c298 100644 --- a/src/c_wrapper/platform.h +++ b/src/c_wrapper/platform.h @@ -3,8 +3,6 @@ #ifndef __PYOPENCL_PLATFORM_H #define __PYOPENCL_PLATFORM_H -namespace pyopencl { - // {{{ platform extern template class clobj; @@ -26,6 +24,4 @@ extern template void print_clobj(std::ostream&, const platform*); // }}} -} - #endif diff --git a/src/c_wrapper/program.cpp b/src/c_wrapper/program.cpp index 39f30b292..893d01f95 100644 --- a/src/c_wrapper/program.cpp +++ b/src/c_wrapper/program.cpp @@ -4,8 +4,6 @@ #include "clhelper.h" #include "kernel.h" -namespace pyopencl { - template class clobj; template void print_arg(std::ostream&, const cl_program&, bool); template void print_clobj(std::ostream&, const program*); @@ -121,11 +119,7 @@ program::all_kernels() return buf_to_base(knls, true); } -} - // c wrapper -// Import all the names in pyopencl namespace for c wrappers. -using namespace pyopencl; // Program error* diff --git a/src/c_wrapper/program.h b/src/c_wrapper/program.h index e0b6f640a..eef07c12b 100644 --- a/src/c_wrapper/program.h +++ b/src/c_wrapper/program.h @@ -3,8 +3,6 @@ #ifndef __PYOPENCL_PROGRAM_H #define __PYOPENCL_PROGRAM_H -namespace pyopencl { - class device; // {{{ program @@ -57,6 +55,4 @@ extern template void print_clobj(std::ostream&, const program*); // }}} -} - #endif diff --git a/src/c_wrapper/pyhelper.cpp b/src/c_wrapper/pyhelper.cpp index 0000728ec..7397d12b7 100644 --- a/src/c_wrapper/pyhelper.cpp +++ b/src/c_wrapper/pyhelper.cpp @@ -1,7 +1,5 @@ #include "pyhelper.h" -namespace pyopencl { - namespace py { WrapFunc gc; WrapFunc ref; @@ -9,14 +7,12 @@ WrapFunc deref; WrapFunc call; } -} - void set_py_funcs(int (*_gc)(), void *(*_ref)(void*), void (*_deref)(void*), void (*_call)(void*, cl_int)) { - pyopencl::py::gc = _gc; - pyopencl::py::ref = _ref; - pyopencl::py::deref = _deref; - pyopencl::py::call = _call; + py::gc = _gc; + py::ref = _ref; + py::deref = _deref; + py::call = _call; } diff --git a/src/c_wrapper/pyhelper.h b/src/c_wrapper/pyhelper.h index 15a72f473..50c084029 100644 --- a/src/c_wrapper/pyhelper.h +++ b/src/c_wrapper/pyhelper.h @@ -4,8 +4,6 @@ #include "wrap_cl.h" #include "function.h" -namespace pyopencl { - template class WrapFunc; @@ -42,6 +40,4 @@ extern WrapFunc deref; extern WrapFunc call; } -} - #endif diff --git a/src/c_wrapper/sampler.cpp b/src/c_wrapper/sampler.cpp index 1ade54fa5..3e260ef30 100644 --- a/src/c_wrapper/sampler.cpp +++ b/src/c_wrapper/sampler.cpp @@ -2,8 +2,6 @@ #include "context.h" #include "clhelper.h" -namespace pyopencl { - template class clobj; template void print_arg(std::ostream&, const cl_sampler&, bool); template void print_clobj(std::ostream&, const sampler*); @@ -36,11 +34,7 @@ sampler::get_info(cl_uint param_name) const } } -} - // c wrapper -// Import all the names in pyopencl namespace for c wrappers. -using namespace pyopencl; // Sampler error* diff --git a/src/c_wrapper/sampler.h b/src/c_wrapper/sampler.h index 8ac5db7d4..0f41eaac5 100644 --- a/src/c_wrapper/sampler.h +++ b/src/c_wrapper/sampler.h @@ -3,8 +3,6 @@ #ifndef __PYOPENCL_SAMPLER_H #define __PYOPENCL_SAMPLER_H -namespace pyopencl { - // {{{ sampler extern template class clobj; @@ -32,6 +30,4 @@ extern template void print_clobj(std::ostream&, const sampler*); // }}} -} - #endif diff --git a/src/c_wrapper/utils.h b/src/c_wrapper/utils.h index 6f4f27322..62fb359ca 100644 --- a/src/c_wrapper/utils.h +++ b/src/c_wrapper/utils.h @@ -28,8 +28,6 @@ tostring(const T& v) return ostr.str(); } -namespace pyopencl { - template struct CLGenericArgPrinter { static PYOPENCL_INLINE void @@ -552,6 +550,4 @@ _copy_str(const std::string& str) return strdup(str.c_str()); } -} - #endif diff --git a/src/c_wrapper/wrap_cl.cpp b/src/c_wrapper/wrap_cl.cpp index 338738a78..5a88c05ea 100644 --- a/src/c_wrapper/wrap_cl.cpp +++ b/src/c_wrapper/wrap_cl.cpp @@ -14,7 +14,6 @@ #include "program.h" #include "kernel.h" -namespace pyopencl { template void print_buf(std::ostream&, const char*, size_t, ArgType, bool, bool); template void print_buf(std::ostream&, const cl_int*, size_t, @@ -28,13 +27,9 @@ template void print_buf(std::ostream&, const cl_ulong*, size_t, template void print_buf(std::ostream&, const cl_image_format*, size_t, ArgType, bool, bool); -} // {{{ c wrapper -// Import all the names in pyopencl namespace for c wrappers. -using namespace pyopencl; - // Generic functions int get_cl_version() diff --git a/src/c_wrapper/wrap_cl.h b/src/c_wrapper/wrap_cl.h index 7ca450f84..58acc5057 100644 --- a/src/c_wrapper/wrap_cl.h +++ b/src/c_wrapper/wrap_cl.h @@ -91,10 +91,8 @@ typedef cl_bitfield cl_mem_migration_flags_ext; typedef cl_ulong cl_device_partition_property_ext; #endif -namespace pyopencl { struct clbase; -} -typedef pyopencl::clbase *clobj_t; +typedef clbase *clobj_t; #ifdef __cplusplus extern "C" { diff --git a/pyopencl/c_wrapper/wrap_cl_core.h b/src/c_wrapper/wrap_cl_core.h similarity index 99% rename from pyopencl/c_wrapper/wrap_cl_core.h rename to src/c_wrapper/wrap_cl_core.h index 20fa204d3..9f4c751fa 100644 --- a/pyopencl/c_wrapper/wrap_cl_core.h +++ b/src/c_wrapper/wrap_cl_core.h @@ -1,5 +1,8 @@ // Interface between C and Python +struct clbase; +typedef struct clbase *clobj_t; + // Types typedef enum { TYPE_FLOAT, @@ -66,9 +69,11 @@ error *platform__unload_compiler(clobj_t plat); error *device__create_sub_devices(clobj_t _dev, clobj_t **_devs, uint32_t *num_devices, const cl_device_partition_property *props); +/* FIXME reenable error *device__create_sub_devices_ext(clobj_t _dev, clobj_t **_devs, uint32_t *num_devices, const cl_device_partition_property_ext*); +*/ // Context error *create_context(clobj_t *ctx, const cl_context_properties *props, cl_uint num_devices, const clobj_t *ptr_devices); @@ -181,6 +186,7 @@ error *enqueue_wait_for_events(clobj_t _queue, const clobj_t *_wait_for, uint32_t num_wait_for); error *enqueue_marker(clobj_t *event, clobj_t queue); error *enqueue_barrier(clobj_t queue); +/* FIXME reenable error *enqueue_migrate_mem_objects(clobj_t *evt, clobj_t _queue, const clobj_t *_mem_obj, uint32_t, cl_mem_migration_flags flags, @@ -189,6 +195,7 @@ error *enqueue_migrate_mem_object_ext(clobj_t *evt, clobj_t _queue, const clobj_t *_mem_obj, uint32_t, cl_mem_migration_flags_ext flags, const clobj_t *_wait_for, uint32_t); +*/ // enqueue_*_buffer* error *enqueue_read_buffer(clobj_t *event, clobj_t queue, clobj_t mem, void *buffer, size_t size, size_t device_offset, diff --git a/pyopencl/c_wrapper/wrap_cl_gl_core.h b/src/c_wrapper/wrap_cl_gl_core.h similarity index 100% rename from pyopencl/c_wrapper/wrap_cl_gl_core.h rename to src/c_wrapper/wrap_cl_gl_core.h diff --git a/src/c_wrapper/wrap_constants.cpp b/src/c_wrapper/wrap_constants.cpp index 5d92d54c5..1ac31e15c 100644 --- a/src/c_wrapper/wrap_constants.cpp +++ b/src/c_wrapper/wrap_constants.cpp @@ -2,9 +2,8 @@ #include extern "C" -namespace pyopencl { - void populate_constants(void(*add)(const char*, const char*, long value)) { - +void populate_constants(void(*add)(const char*, const char*, long value)) +{ #define _ADD_ATTR(TYPE, PREFIX, NAME, SUFFIX, ...) \ add(TYPE, #NAME, CL_##PREFIX##NAME##SUFFIX) #define ADD_ATTR(TYPE, PREFIX, NAME, EXTRA...) \ @@ -703,6 +702,4 @@ namespace pyopencl { #ifdef cl_ext_migrate_memobject ADD_ATTR("migrate_mem_object_flags_ext", MIGRATE_MEM_OBJECT_, HOST, _EXT); #endif - } - -}; +}