BenV's notes

Slackware, Wine and OpenCL (NVIDIA)

by on Jan.29, 2012, under Software

While updating wine-1.4-rc1 I thought it would be interesting to see if I could get their OpenCL stuff to work. The lack of information on how to do so is really annyoing, so here’s what I did to get it to compile.
Since I have an NVIDIA card I’ll work from there, if you have AMD/Intel I’m sure they can help with that.

My system runs Slackware64 current (but 13.37 should be almost the same atm), but since wine needs the 32 bits libraries to be useful I still have my 32 bits Slackware partition that I can chroot into which I use for wine. Alternatively I’m sure you can use the 32 bits alien libaries and mess up your 64 bit version taht way, but I like keeping them seperate.

First, we need the latest NVIDIA driver, right now this is version 290.10. After installing this on my (normal) Slackware64 (drop out of Xorg, bash, yes yes yes yes, start X again) I still needed to install it on my slackware32 partition, since the driver (or libraries to be more specific) need to be there as well. The installation through chroot is a bit more messy though, since the installer pays a bit too much attention to ‘uname -m’ and refuses to work properly. Therefore I always manually install the driver like this:

root@slack64:~# chroot /slackware32
root@slack64:/# cd /usr/src/nivida
root@slack64:/usr/src/nvidia# wget -q
root@slack64:/usr/src/nvidia# bash -x
Creating directory NVIDIA-Linux-x86-290.10
Verifying archive integrity... OK
Uncompressing NVIDIA Accelerated Graphics Driver for Linux-x86 290.10........................................................................................................................................
root@slack64:/usr/src/nvidia# cd NVIDIA-Linux-x86-290.10
# Remove old version first, in this case 290.06
root@slack64:/usr/src/nvidia/NVIDIA-Linux-x86-290.10# find /usr/lib -type f -name "lib*.so.290.06"
# Make sure these are only nvidia libs, should be ok
root@slack64:/usr/src/nvidia/NVIDIA-Linux-x86-290.10# find /usr/lib -type f -name "lib*.so.290.06" -delete
root@slack64:/usr/src/nvidia/NVIDIA-Linux-x86-290.10# for k in lib*.so.290.10 ; do
> ginstall -m755 "$k" /usr/lib
root@slack64:/usr/src/nvidia/NVIDIA-Linux-x86-290.10# for k in tls/*.so.290.10 ; do
> ginstall -m755 "$k" /usr/lib/tls
root@slack64:/usr/src/nvidia/NVIDIA-Linux-x86-290.10# for k in nvidia-{settings,xconfig,smi,installer} ; do
> ginstall -m755 "$k" /usr/bin
> ginstall -m644 "$k.1.gz" /usr/share/man/man1
# Make sure xorg ext makes sense:
root@slack64:/usr/src/nvidia/NVIDIA-Linux-x86-290.10# if [ ! -L /usr/lib/xorg/modules/extensions/ ]
> then
> mv /usr/lib/xorg/modules/extensions/ /usr/lib/xorg/modules/extensions/
> ln -s /usr/lib/ /usr/lib/xorg/modules/extensions/
root@slack64:/usr/src/nvidia/NVIDIA-Linux-x86-290.10# ldconfig

This driver includes libcuda and libOpenCL, which we want for messing around with GPU programming.
Cuda is NVIDIA’s own gpu programming stuff, getting information on the will make your head spin when you click from marketing spam to more spam in their maze of garbage that can be found here and further.

Anyhow, on to wine. For wine to be able to compile with OpenCL we need to make sure the OpenCL headers exist.
First I tried checking out the ‘development‘ drivers, but they don’t have the headers in them either. (so skip that)
Fortunately the guys at Khronos seem to have them lying around somewhere. If only they could make a nice installer …
So we’ll have to get these manually:

root@slack64:~# chroot /slackware32
root@slack64:/# cd /usr/include/CL # create this if it doesn't exist, I had it from my NVIDIA driver installation
root@slack64:/usr/include/CL# for file in opencl.h cl_platform.h cl.h cl_ext.h cl_dx9_media_sharing.h cl_d3d10.h cl_d3d11.h cl_gl.h cl_gl_ext.h cl.hpp
> do wget -q$file
> done
root@slack64:/usr/include/CL# ln -sf /usr/include/CL /usr/include/OpenCL

There, now we have headers. Let’s see how far wine gets in the configuration with opencl now:

root@slack64:~# chroot /slackware32
root@slack64:/# cd /usr/src/wine-git/
root@slack64:/usr/src/wine-git# ./configure
# Loads of stuff, here's what I care about:
checking OpenCL/opencl.h usability... yes
checking OpenCL/opencl.h presence... yes
checking for OpenCL/opencl.h... yes
checking for clGetPlatformInfo in -lOpenCL... no
# at the bottom
configure: OpenCL 32-bit development files not found, OpenCL won't be supported.

Let’s see what that is all about. Apparently it find the header files now (those used to say ‘no’ before getting the headers from Khoros), but what’s the issue with the libOpenCL? Checking config.log shows:

configure:8986: checking for clGetPlatformInfo in -lOpenCL
configure:9011: gcc -m32 -o conftest -g -O2 conftest.c -lOpenCL >&5
/usr/lib/gcc/i486-slackware-linux/4.5.3/../../../../i486-slackware-linux/bin/ld: cannot find -lOpenCL
collect2: ld returned 1 exit status

That’s interesting, since the library is right there under our noses:

root@slack64:/usr/src/wine-git# ls -la /usr/lib/*OpenCL*
lrwxrwxrwx 1 root root 18 Dec 12 2009 /usr/lib/ ->
-rwxr-xr-x 1 root root 16632 Jan 29 16:34 /usr/lib/

But, there’s no … let’s fix that.

root@slack64:/usr/src/wine-git# ln -s /usr/lib/ /usr/lib/

Back to compiling wine! After a rerun of configure you should notice that wine now finds the libopencl and doesn’t complain anymore at the end.
Yay. Let’s run a test. For example smallptGPU uses it.
Before I had opencl support in wine it would refuse to run:

benv@slack64:/tmp/SmallptGPU-v1.6:0>wine SmallptGPU.exe
fixme:iphlpapi:NotifyAddrChange (Handle 0xdae8c8, overlapped 0xdae8ac): stub
wine: configuration in '/home/benv/.wine' has been updated.
err:module:import_dll Library OpenCL.dll (which is needed by L"Z:\\tmp\\SmallptGPU-v1.6\\SmallptGPU.exe") not found
err:module:LdrInitializeThunk Main exe initialization for L"Z:\\tmp\\SmallptGPU-v1.6\\SmallptGPU.exe" failed, status c0000135

With the new wine we get:

benv@slack64:/tmp/SmallptGPU-v1.6:0>wine SmallptGPU.exe
Usage: Z:\tmp\SmallptGPU-v1.6\SmallptGPU.exe
Usage: Z:\tmp\SmallptGPU-v1.6\SmallptGPU.exe 0 and power of 2)>
OpenCL Platform 0: NVIDIA Corporation
OpenCL Device 0: Type = TYPE_GPU
OpenCL Device 0: Name = GeForce GTX 470
OpenCL Device 0: Compute units = 14
OpenCL Device 0: Max. work group size = 1024
[SELECTED] OpenCL Device 0: Type = TYPE_GPU
[SELECTED] OpenCL Device 0: Name = GeForce GTX 470
[SELECTED] OpenCL Device 0: Compute units = 14
[SELECTED] OpenCL Device 0: Max. work group size = 1024
Reading file '' (size 3216 bytes)
OpenCL Device 0: kernel work group size = 768
Selected sphere 1 (-9901.000000 40.799999 81.599998)

smallPTCPU using OpenCL under Wine 1.4-rc1

smallPTCPU using OpenCL under Wine 1.4-rc1

Later I’ll get back on messing around with cuda 🙂

:, , , ,

Leave a Reply

You must be logged in to post a comment.