Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to setup OpenCL on AMD videocard with opensource driver?

Tags:

opencl

mesa

I have read this link - https://wiki.debian.org/ru/AtiHowTo and decide to setup OpenCL.

the r600g driver still have to load proprietary microcode into the GPU to enable hardware acceleration. This firmware is usually included in the kernel, but is packaged separately in Debian.

So, I installed firmware:

# apt-show-versions firmware-linux-nonfree firmware-linux
firmware-linux-nonfree:all/sid 0.40 uptodate
firmware-linux:all/sid 0.40 uptodate

Then I upgrade kernel version:

uname -v
#1 SMP PREEMPT RT Debian 3.12.8-1 (2014-01-19)

and checked kernel flags:

grep DRM_RADEON /boot/config-$(uname -r)
CONFIG_DRM_RADEON=m
# CONFIG_DRM_RADEON_UMS is not set
grep AGP /boot/config-$(uname -r)
CONFIG_AGP=y
CONFIG_AGP_AMD64=y
CONFIG_AGP_INTEL=y
CONFIG_AGP_SIS=y
CONFIG_AGP_VIA=y

Also I setup xserver version recent enough:

# apt-show-versions xorg
xorg:amd64/sid 1:7.7+5 uptodate

I choose radeon as driver:

You most certainly are using wheezy's xserver-xorg-core which does not provide xorg-video-abi-6.0 any more, and radeonhd is not available for the newer xorg-video-abi because it has been removed from Debian

# apt-show-versions xserver-xorg-video-radeon
xserver-xorg-video-radeon:amd64/sid 1:7.3.0-1 uptodate

This gives me OpenGL working:

$ glxinfo | grep OpenGL
OpenGL vendor string: X.Org
OpenGL renderer string: Gallium 0.4 on AMD RV770
OpenGL core profile version string: 3.1 (Core Profile) Mesa 10.1.0-devel (git-81144c0 saucy-oibaf-ppa+curaga)
OpenGL core profile shading language version string: 1.40
OpenGL core profile context flags: (none)
OpenGL core profile extensions:
OpenGL version string: 3.0 Mesa 10.1.0-devel (git-81144c0 saucy-oibaf-ppa+curaga)
OpenGL shading language version string: 1.30
OpenGL context flags: (none)
OpenGL extensions:

I am trying to use application which works with OpenCL.

This programs works ok on CPU:

$ mono scallion/bin/Debug/scallion.exe parallax
Cooking up some delicions scallions...
Putting 1 patterns into 1 buckets.
Using kernel optimized from file kernel.cl (Optimized4)
Using work group size 1
Compiling kernel... done.
LoopIteration:10  HashCount:167.77MH  Speed:7.8MH/s  Runtime:00:00:21
Predicted:19:38:20
Stopping and shutting down...

LoopIteration:11  HashCount:184.55MH  Speed:7.8MH/s  Runtime:00:00:23
Predicted:19:36:58  init: 2687ms / 1 (2687ms, 0.37/s)
generate key: 153ms / 6 (25.5ms, 39.22/s)
cpu precompute: 7ms / 6 (1.17ms, 857.14/s)
total without init: 23706ms / 1 (23706ms, 0.04/s)
set buffers: 0ms / 11 (0ms, 0/s)
write buffers: 0ms / 11 (0ms, 0/s)
read results: 23699ms / 11 (2154.45ms, 0.46/s)
check results: 0ms / 11 (0ms, 0/s)

7.78 million hashes per second

Stopping and shutting down...

But I am unable to detect GPU:

$ mono scallion/bin/Debug/scallion.exe
Usage: scallion [OPTIONS]+ regex [regex]+
Options:
      -l, --listdevices          Lists the devices that can be used.
      -d, --device=VALUE         Specifies the opencl device that should be used.

There is no GPU in the list of devices:

$ mono scallion/bin/Debug/scallion.exe -l
Id:0 Name:Intel(R) Core(TM)2 Quad CPU    Q9650  @ 3.00GHz
    PreferredGroupSizeMultiple:1 ComputeUnits:4 ClockFrequency:2000
    MaxConstantBufferSize:65536 MaxConstantArgs:8 MaxMemAllocSize:2147483648

I am unable to find instructions on how to setup OpenCL:

apt-get install libclc-r600

apt-show-versions libclc-r600 ocl-icd-libopencl1
libclc-r600:all/saucy 0~git20140101-1~gd~s uptodate
ocl-icd-libopencl1:amd64/sid 2.1.3-2 uptodate

and after starting application I receive an error:

~/github.com/lachesis/scallion$ mono ./scallion/bin/Debug/scallion.exe -l

Unhandled Exception:
System.InvalidOperationException: ErrorCode:'-1001'
at scallion.CLDeviceInfo.CheckError (Int32 err) [0x00000] in :0
at scallion.CLDeviceInfo.GetPlatformIds () [0x00000] in :0
at scallion.CLDeviceInfo.GetDeviceIds () [0x00000] in :0
at scallion.CLRuntime.GetDevices () [0x00000] in :0
at scallion.Program.ListDevices () [0x00000] in :0
at scallion.Program.Main (System.String[] args) [0x00000] in :0
[ERROR] FATAL UNHANDLED EXCEPTION: System.InvalidOperationException:
ErrorCode:'-1001'
at scallion.CLDeviceInfo.CheckError (Int32 err) [0x00000] in :0
at scallion.CLDeviceInfo.GetPlatformIds () [0x00000] in :0
at scallion.CLDeviceInfo.GetDeviceIds () [0x00000] in :0
at scallion.CLRuntime.GetDevices () [0x00000] in :0
at scallion.Program.ListDevices () [0x00000] in :0
at scallion.Program.Main (System.String[] args) [0x00000] in :0

The error code values are defined in opencl.h It look like your platform is not configured properly. CL_PLATFORM_NOT_FOUND_KHR (-1001) error from clGetPlatformIDs. That's because you do have the dispatcher, but no actual OpenCL drivers."

After

sudo apt-get install libopencl1-mesa

$ find / -iname «libMesaOpenCL.so*» 2>/dev/null
/usr/lib/x86_64-linux-gnu/libMesaOpenCL.so
/usr/lib/x86_64-linux-gnu/libMesaOpenCL.so.1.0.0
/usr/lib/x86_64-linux-gnu/libMesaOpenCL.so.1

In configuration file there should be

cat /etc/OpenCL/vendors/mesa.icd
libMesaOpenCL.so

The error is

fatal error: cannot open file '/usr/lib/clc/rv770-r600--.bc': No such file or directory

How to make this work?

like image 755
user2743980 Avatar asked Feb 03 '14 08:02

user2743980


People also ask

Does OpenCL support AMD?

In short: Yes, programs developed with the OpenCL headers from Nvidia toolkit will also work on AMD and Intel GPUs. Programs for Nvidia GPUs are always in OpenCL C 1.2, and AMD/Intel GPUs support OpenCL C 1.2/2.0/2.1/2.2, which always is backwards-compatible with OpenCL C 1.2.

Is AMDGPU driver open source?

Development. AMDgpu is AMD's fully open source unified kernel driver for its GPUs on Linux. It takes the form of an in-tree kernel module. As of 2022, AMD Kernel Fusion Driver (KFD) is now integrated in this one kernel module.


1 Answers

I eventually enabled the free OpenCL stack, and ran into very similar problems. I'll provide an abridged overview, of some of the relevant packages.

That libopencl1-mesa is just the ICD runtime, which is loaded into the generic ocl-icd-libopencl1. Then libclc is used by libopencl1-mesa to deal with the OpenCL Kernels. Using an LLVM chipset specific backend, libclc generates instructions. You're missing the GPU chipset specific glue, which is provided by the missing .bc. This is greatly simplified, but for this problem it should suffice, still a good diagram would help immensely.

In your particular example, the .bc's would be provided by libclc-r600 However I'm not seeing anything for your chipset 'DONE', on this Freedesktop.org GalliumCompute page. It appears the lowest supported chipset is the Evergreen (HD5000 Series).

* please recheck GalliumCompute if you read this after 02-04-2014.

like image 161
J. M. Becker Avatar answered Oct 13 '22 13:10

J. M. Becker