2

So I downloaded OpenCL from Nvidia vendor, and I wrote a program. So I was wondering can my program still run on AMD GPU or I need to install AMD version of OpenCL?

ProjectPhysX
  • 4,535
  • 2
  • 14
  • 34
Peng Andy
  • 21
  • 3
  • Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. – Community Mar 14 '22 at 10:17

1 Answers1

3

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.


However there are some rare issues that you could encounter, based on differences in the hardware.

One example: Nvidia GPUs work with "warps" of 32 threads, so if you choose the workgroup size 32 or a multiple of 32, you will fully use the hardware. AMD GCN GPUs need at least workgroup size 64 or a multiple of 64 to fully use the hardware. With only workgroup size 32 you only get half the arithmetic performance.

Another example: For Nvidia GPUs, you can have quite large tables still in private memory, and if it is too much you get a spilling into global memory (makes it very slow, but still works without error). Some AMD GPUs can't fit so many private variables and will throw an error during compiling, so you'd have to move the table in constant memory (this then works with both AMD and Nvidia).

ProjectPhysX
  • 4,535
  • 2
  • 14
  • 34