Dear developers,
I managed to compile PyOpenCL on my system (Windows 7 64bit, Python 2.6
64bit, AMD Radeon 5870, Visual Studio 2008 Prof., boost 1.43). Here I
want to share the procedure:
1) Compile boost libraries
took source distribution of boost 1.43; created bjam; created directory
'x64' in boost directory
bjam --toolset=msvc-9.0 address-model=64 --build-type=complete
--stagedir=x64
added x64 subdirectory to search path
2) Compile PyOpenCL. Took it from git trunk (0.92beta). Edited my
siteconf.py:
---------------
BOOST_LIB_DIR = [r'c:\users\i-med-thalhammer\boost\boost_1_43_0\x64\lib']
BOOST_INC_DIR = [r'c:\users\i-med-thalhammer\boost\boost_1_43_0']
BOOST_COMPILER = 'msvc'
BOOST_PYTHON_LIBNAME = ['boost_python-vc90-mt-1_43']
USE_SHIPPED_BOOST = False
CL_TRACE = False
CL_ENABLE_GL = True
CL_INC_DIR = [r'c:\Program Files (x86)\ATI Stream\include']
CL_LIB_DIR = [r'c:\Program Files (x86)\ATI Stream\lib\x86_64']
CL_LIBNAME = ['OpenCL']
CXXFLAGS = ['/EHsc', '/DBOOST_PYTHON_NO_PY_SIGNATURES']
LDFLAGS = ['/FORCE']
---------------
python setup.py install
To enable OpenGL interoperability I had to change wrap_cl.hpp:
---------------------------
diff --git a/src/wrapper/wrap_cl.hpp b/src/wrapper/wrap_cl.hpp
index b12286c..d9c46ff 100644
--- a/src/wrapper/wrap_cl.hpp
+++ b/src/wrapper/wrap_cl.hpp
@@ -20,6 +20,10 @@
// FIXME: Nvidia doesn't install cl_ext.h by default. Grr.
// #include <CL/cl_ext.h>
#ifdef HAVE_GL
+#ifdef _WIN32
+#define NOMINMAX
+#include <windows.h>
+#endif
#include <GL/gl.h>
#include <CL/cl_gl.h>
#endif
@@ -2874,8 +2878,8 @@ namespace pyopencl
std::vector<cl_context_properties> props
= parse_context_properties(py_properties);
- typedef CL_API_ENTRY cl_int CL_API_CALL
- (*func_ptr_type)(const cl_context_properties * /* properties */,
+ typedef CL_API_ENTRY cl_int (CL_API_CALL
+ *func_ptr_type)(const cl_context_properties * /* properties */,
cl_gl_context_info /* param_name */,
size_t /* param_value_size */,
void * /* param_value */,
---------------------------
Compiling gave a couple of warnings since size_t and int or cl_uint are
different.
3) To test OpenGL interoperability I changed examples/gl_interop_demo.py:
---------------
diff --git a/examples/gl_interop_demo.py b/examples/gl_interop_demo.py
index dd4bf3e..4495804 100644
--- a/examples/gl_interop_demo.py
+++ b/examples/gl_interop_demo.py
@@ -1,14 +1,15 @@
from OpenGL.GL import *
from OpenGL.GLUT import *
from OpenGL.raw.GL.VERSION.GL_1_5 import glBufferData as rawGlBufferData
-try:
- from OpenGL.WGL import wglGetCurrentDisplay as GetCurrentDisplay,
wglGetCurrentContext as GetCurrentContext
-except:
- pass
-try:
- from OpenGL.GLX import glXGetCurrentDisplay as GetCurrentDisplay,
glXGetCurrentContext as GetCurrentContext
-except:
- pass
+from OpenGL import platform
+# try:
+# from OpenGL.WGL import wglGetCurrentDisplay as GetCurrentDisplay,
wglGetCurrentContext as GetCurrentContext
+# except:
+# pass
+# try:
+# from OpenGL.GLX import glXGetCurrentDisplay as GetCurrentDisplay,
glXGetCurrentContext as GetCurrentContext
+# except:
+# pass
import pyopencl as cl
@@ -31,8 +32,10 @@ __kernel void generate_sin(__global float2* a)
def initialize():
plats = cl.get_platforms()
ctx_props = cl.context_properties
- props = [(ctx_props.PLATFORM, plats[0]), (ctx_props.GL_CONTEXT_KHR,
- GetCurrentContext()), (ctx_props.GLX_DISPLAY_KHR,
GetCurrentDisplay())]
+ props = [(ctx_props.PLATFORM, plats[0]),
+ (ctx_props.GL_CONTEXT_KHR, platform.GetCurrentContext()),
+ #(ctx_props.GLX_DISPLAY_KHR, platform.GetCurrentDisplay()),
+ ]
ctx = cl.Context(properties=props)
glClearColor(1, 1, 1, 1)
glColor(0, 0, 1)
--------------------------
I didn't know how to make these changes platform independent.
In a similar manner, I managed to compile PyOpenCL for 32bit Python,
using precompiled 32bit libraries for boost 1.42.
Thanks for providing PyOpenCL, it is a great package.
Gregor
_______________________________________________
PyOpenCL mailing list
PyOpenCL@tiker.net
http://lists.tiker.net/listinfo/pyopencl