I am using the AMD APP SDK v3.0,
A Radeon RX460 (4GB) Graphics Card with Driver versions 17.4.4 and 17.10.2711.1021 (tried both),
and Visual Studio 2015.
For my program i need to use OpenCL 2.0 functionality, which should be possible with this setup, right?
Problem:
appsdk::SDKDeviceInfo devInfo; | |
devInfo.setDeviceInfo(device_id); |
tells me
deviceVersion: Open CL 1.2 AMD-APP(2348.3)
openclCVersion: Open CL C 1.2
So when i try to use OCL 2.0 functionality in my kernel code, it returns with errors. How can i switch to version 2.0?
Is this a problem with my Hardware or Software?
Solved! Go to Solution.
Hi Florian,
First of all, you've been whitelisted now, so in future, you will be able to create a topic directly on any forum of your choice and move the thread to other place if required.
Now, coming to your issue related to OpenCL2.0. Your RX 460 card supports OpenCL 2.0, so, I don't think it's a hardware limitation. I've following suggestions:
Regards,
(A suggestion: move this question to the OpenCL forum: OpenCL )
OpenCL 2.0 Drivers for Windows and Linux are available: AMD OpenCL™ 2.0 Driver
Thanks. I am using these drivers.
Will move the post now
It seems that i have no rights to move it to OpenCL the forum.
Hi Florian,
First of all, you've been whitelisted now, so in future, you will be able to create a topic directly on any forum of your choice and move the thread to other place if required.
Now, coming to your issue related to OpenCL2.0. Your RX 460 card supports OpenCL 2.0, so, I don't think it's a hardware limitation. I've following suggestions:
Regards,
Thank you,
the problem was the 64-bit mode. The Device Info says 2.0 now.
Atomic Float operations (Atomic Functions ) still don't seem to work tho.
This is the error i keep getting:
C:\..\\OCL6268T3.cl:1507:3: error: no matching function for call to 'atomic_add'
atomic_add(bufOut, f0);
^~~~~~~~~~
c:\constructicon\builds\gfx\two\17.10\stream\opencl\compiler\clc2\ocl-headers\build\wNow64a\B_rel\opencl12_builtins.h:4256:35: note: candidate function not viable: no known conversion from '__global float *' to 'volatile __global int *' for 1st argument
int __attribute__((overloadable)) atomic_add(volatile __global int *p, int val);
...
bufOut is a __global float *
f0 is a local float value
I tried different versions of the
#pragma OPENCL EXTENSION cl_khr_int64_extended_atomics : enable
with no effect so far.
Does anyone know a solution to this?`It should be possible to use those with float values right?
I found some workarounds for atomic float operations using cmpxchg and (slow) loops. But they don't provide the performance of native atomic functions and are therefore not really usable for me.
[edit: this is wrong, my mistake. atomic_fetch_add doesn't exist for floats, as florian_a and dipak found below.]
Have you tried using atomic_float rather than float* ?
And atomic_fetch_add rather than atomic_add?
atomic_fetch_add((atomic_float)bufOut, f0);
http://developer.amd.com/wordpress/media/2013/12/AMD_OpenCL_Programming_User_Guide2.pdf#page=107
https://www.khronos.org/registry/OpenCL/sdk/2.0/docs/man/xhtml/atomicFunctions.html
https://www.khronos.org/registry/OpenCL/sdk/2.0/docs/man/xhtml/atomic_fetch_key.html
(atomic_add was deprecated)
http://developer.amd.com/wordpress/media/2013/12/AMD_OpenCL_Programming_User_Guide2.pdf#page=161
i tried atomic_float, but with the same result.
atomic_fetch_add is new to me. Sadly it doesn't work for me:
error: implicit declaration of function 'atomic_fetch_add' is invalid in C99
i can't find a required include here: atomic_fetch_key
It only mentions C11. So i will try to change the version in my compiler. I will post the results afterwards.
Please use build option "-cl-std=CL2.0" (clBuildProgram ) to build the kernel for OpenCL 2.0.
Regards,
i did that:
clBuildProgram(program, 0, NULL, "-cl-std=CL2.0", NULL, NULL);
with OCL-Code:
atomic_fetch_add((atomic_float*)(bufOut), f0);
and
#pragma OPENCL EXTENSION cl_khr_int64_extended_atomics : enable
#pragma OPENCL EXTENSION cl_khr_int64_base_atomics : enable
but i still get:
error: no matching function for call to 'atomic_fetch_add'
atomic_fetch_add((atomic_float*)(bufOut), f0);
...
c:\constructicon\builds\gfx\two\17.10\stream\opencl\compiler\clc2\ocl-headers\build\wNow64a\B_rel\opencl20_builtins.h:13745:1: note: candidate function not viable: no known conversion from '__generic atomic_float *' to 'volatile __generic atomic_int *' for 1st argument
it seems that also the atomic_fetch_key functions cannot handle float values. Or am i still doing something wrong?
As per the spec, atomic_fetch_key supports integer type only.
"These operations perform arithmetic and bitwise computations. All of these operations are applicable to an object of any atomic integer type."
atomic_add function expects an integer whereas you're passing a floating value to it. In fact, most of these atomic functions (from OpenCL 1.2 ) expect an integer only. On the other hand, atomic_xchg does support floating value as argument.
Regards,
thank you, but as i mentioned before i want to use 2.0 not 1.2 because of the float operations promised in the doc.
The atomic_xchg variant is simply to slow because it requires multiple tries per operation.