cancel
Showing results for 
Search instead for 
Did you mean: 

OpenCL

pszilard
Adept I

Issues when switching to OpenCL 2.0

Jump to solution

I was going to try out some OpenCL 2.0 features an ran into two strange issues after adding the -cl-std=CL2.0 flag:

  • The preprocessing stage fails and the compiler complains about includes missing; the same code compiled just fine with CL1.2 did.
  • After copying the missing files to /tmp to satisfy the compiler, I got about 25-35% performance drop from just adding the flag not changing anything else. Is there something in the OpenCL 2.0 specs or is AMD implementation that (in)directly affects performance of 1.2 code? Or is this just a bug?
0 Likes
Reply
1 Solution

Accepted Solutions
rampitec
Staff
Staff

Re: Issues when switching to OpenCL 2.0

Jump to solution

Although OpenCL 1.2 and 2.0 syntax is very similar, there is a big internal difference for the compiler. The differences are both in language semantics and compiler internals. There are at least two big factors, which might affect kernel performance if 2.0 syntax is forced on an 1.2 source:

  1. Unqualified pointer passed to a function treated as generic vs private. That is a good idea to complete declarations of functions so that private pointer arguments are properly marked with __private attribute. That will make source compatible with both 1.2 and 2.0 syntax.
  2. OpenCL 2.0 supports non-uniform workgroups, so expansion of get_local_size() becomes substantially bigger than with 1.2. You can mitigate the impact by setting OpenCL 2.0 specific option -cl-uniform-work-group-size, although it will not remove all issues in the current release and will be improved in the future. Meanwhile you can achieve better results by using kernel attribute reqd_work_group_size if it is known.

Other than that compiler is really different internally for 1.2 and 2.0 now, so there can be differences if performance and behavior in both directions given a specific source.

View solution in original post

31 Replies

Re: Issues when switching to OpenCL 2.0

Jump to solution

I've added you to the developer forum white list and moved this message to the OpenCL forum.

0 Likes
Reply
nibal
Challenger

Re: Issues when switching to OpenCL 2.0

Jump to solution

Hi,

I imagine you have SDK-3.0 installed. What is the output of your clinfo, the version of your driver, your OS and your Makefile include flags?

TIA,

Nikos

0 Likes
Reply
pszilard
Adept I

Re: Issues when switching to OpenCL 2.0

Jump to solution

Yes, I have the SDK 3.0 installed*, the clinfo output is this: Paste: h444t

(One a related note, can anyone explain why does this version have nothing to do with the fglrx version which in turn has nothing to do with the year.month versioning of the releases?)

  • OS: Ubuntu 14.04.3, kernel 3.19

Which "makefile include flags" are you referring to?

*admittedly there are some funny issues with it, my application reports different driver version when using the APP SDK v2.9 and 3.0 (i.e. headers + linked against libOpenCL).

0 Likes
Reply
nibal
Challenger

Re: Issues when switching to OpenCL 2.0

Jump to solution

Well for your SDK header files you need to include in your CFLAGS: -I/opt/AMDAPPSDK-3.0/include. Have you done it?

BTW, driver version is different under SDK2.9 vs SDK3.0. This is an SDK2.9 known bug, but it is no longer supported

Which compiler do you mean, gcc or ocl? What preprocessor errors you get?

The drop in performance is a known bug:(

BTW, b4 you get in too deep with ocl, be warned Memory corruption in latest crimson driver 15.302?

HTH

Nikos

0 Likes
Reply
pszilard
Adept I

Re: Issues when switching to OpenCL 2.0

Jump to solution

> Well for your SDK header files you need to include in your CFLAGS: -I/opt/AMDAPPSDK-3.0/include. Have you done it?

Sure, my code builds (http://www.gromacs.org/ ​), so yeah, includes should be fine.

> BTW, driver version is different under SDK2.9 vs SDK3.0. This is an SDK2.9 known bug,

You mean it's a known bug that the driver version reported via the OpenCL SDK when using v2.9 and v3.0 are different?

> but it is no longer supported

What is not supported?

> Which compiler do you mean, gcc or ocl? What preprocessor errors you get?

The OpenCL compiler. It seems like the include path where some headers used by the OpenCL kernel are located is simply ignored.

0 Likes
Reply
nibal
Challenger

Re: Issues when switching to OpenCL 2.0

Jump to solution

pszilard wrote:

> Well for your SDK header files you need to include in your CFLAGS: -I/opt/AMDAPPSDK-3.0/include. Have you done it?

Sure, my code builds (http://www.gromacs.org/ ), so yeah, includes should be fine.

So, no more /tmp/headers...

pszilard wrote:

> BTW, driver version is different under SDK2.9 vs SDK3.0. This is an SDK2.9 known bug,

You mean it's a known bug that the driver version reported via the OpenCL SDK when using v2.9 and v3.0 are different?    

Yes. You can double-check with clinfo. Version from-SDK 2.9.1 should be 700-1000 lower than SDK-3.0

pszilard wrote:

> but it is no longer supported

What is not supported?

SDK-2.9.1 ofc. I don't think that even SDK-3.0 is supported any more

pszilard wrote:

> Which compiler do you mean, gcc or ocl? What preprocessor errors you get?

The OpenCL compiler. It seems like the include path where some headers used by the OpenCL kernel are located is simply ignored.

Hmmm. Interesting. I can't use ocl2.0, so, i never tried compiling as 2.0. But never had a problem with ocl1.2 and my own headers.

Have you tried passing in your cflags string "-I."?

HTH,

Nikos

0 Likes
Reply
pszilard
Adept I

Re: Issues when switching to OpenCL 2.0

Jump to solution

> So, no more /tmp/headers...

False. The code builds with -cl-std=CL1.2. If I pass -cl-std=CL2.0, includes are not found. Not OpenCL includes, but my own includes that should be picked up from the path passed to the OpenCL compiler via "-I/path/to/my/source/tree"

Yes. You can double-check with clinfo. Version from-SDK 2.9.1 should be 700-1000 lower than SDK-3.0

Not really. With APP SDK 3.0 I get lower driver version reported, 1800.8 here:

$ ldd $gmx | grep OpenCL;

libOpenCL.so.1 => /opt/tcbsys/amd/appsdk/3.0/lib/x86_64/libOpenCL.so.1 (0x00007fd37562a000)

$ $gmx mdrun -nsteps 0 2>&1 | grep -A2 "GPUs detected"

    Number of GPUs detected: 2

    #0: name: Fiji, vendor: Advanced Micro Devices, Inc., device version: OpenCL 2.0 AMD-APP (1800.8), stat: compatible

    #1: name: Hawaii, vendor: Advanced Micro Devices, Inc., device version: OpenCL 2.0 AMD-APP (1800.8), stat: compatible

while with v2.9 I get 1912.5

$ ldd $gmx | grep OpenCL

  libOpenCL.so.1 => /opt/tcbsys/amd/appsdk/2.9/lib/x86_64/libOpenCL.so.1 (0x00007f43c7ce5000)

$ $gmx mdrun -nsteps 0 2>&1 | grep -A2 "GPUs detected"

    Number of GPUs detected: 2

    #0: name: Fiji, vendor: Advanced Micro Devices, Inc., device version: OpenCL 2.0 AMD-APP (1912.5), stat: compatible

    #1: name: Hawaii, vendor: Advanced Micro Devices, Inc., device version: OpenCL 2.0 AMD-APP (1912.5), stat: compatible

0 Likes
Reply
pszilard
Adept I

Re: Issues when switching to OpenCL 2.0

Jump to solution

PS: What do you mean by APP SDK 3.0 not being supported? Supported by what, the diver? Or by AMD?

0 Likes
Reply
nibal
Challenger

Re: Issues when switching to OpenCL 2.0

Jump to solution

pszilard wrote:

PS: What do you mean by APP SDK 3.0 not being supported? Supported by what, the diver? Or by AMD?

The driver always includes all ocl libraries. I doubt about AMD. Haven't seen *any* AMD employee or moderator since I came back.

I doubt that anyone from AMD is reading this forum:(

0 Likes
Reply