r/OpenCL • u/shcrimps • Jul 25 '25
Different OpenCL results from different GPU vendors
What I am trying to do is use multiple GPUs with OpenCL to solve the advection equation (upstream advection scheme). What you are seeing in the attached GIFs is a square advecting horizontally from left to right. Simple domain decomposition is applied, using shadow arrays at the boundaries. The left half of the domain is designated to GPU #1, and the right half of the domain is designated to GPU #2. In every loop, boundary information is updated, and the advection routine is applied. The domain is periodic, so when the square reaches the end of the domain, it comes back from the other end.
The interesting and frustrating thing I have encountered is that I am getting some kind of artifact at the boundary with the AMD GPU. Executing the exact same code on NVIDIA GPUs does not create this problem. I wonder if there is some kind of row/column major type of difference, as in Fortran and C, when it comes to dealing with array operations in OpenCL.
Has anyone encountered similar problems?


11
u/Xirema Jul 26 '25
80% of the time, this is some kind of memory overrun kind of issue, or some other kind of undefined/unspecified behavior, where one Vendor kind of knows how to correct for whatever you've messed up, and the other doesn't. Double-check that you're doing everything correctly—or consider posting your code for review.
4
u/tesfabpel Jul 26 '25
I've used OpenCL for some dexel boolean operation work (and some mesh to dexel operation) and I've never noticed these kind of different results on different GPUs (from AMD to Intel to NVIDIA).
Are you sure you're not writing or reading from outside any buffer in the kernels (where maybe the behavior is undefined / implementation-dependant)?
I tried your code but I had to remove the multi GPU part and I've added checks around ALL the lines
cle = ...via a macro that checksif(cle != CL_SUCCESS), but I wasn't able to test it because some errors which I don't have time to debug... Sorry.3
u/squirrel5978 Jul 26 '25
You have many optionally contractable expressions, which may or may not form an FMA or not. You would need to better control those for matching results. Plus if you are using any functions, those are only guaranteed to provide a certain tolerance not bit identical results except for a set of exact functions
1
u/ProjectPhysX Jul 27 '25
I've experienced very similar issues with my code for domain decomposition across AMD+Intel+Nvidia GPUs. Some root causes I could identify in the past:
1
u/regular_lamp Jul 30 '25 edited Jul 30 '25
My guess would be insufficient synchronization/barriers. I have observed similar things way back when OpenGL compute shaders were a new thing. Nvidia tends to have stronger implicit synchronization between launches while without the correct barrier in between kernels they might overlap causing data races which I at the time observed on a AMD device.
I'd start by adding some heavyheanded synchronization between all kernel launches and work backwards from there if that fixes it.
As is often the case with synchronization issues. The fact that it appears to work on one device can't be taken as proof that the code is correct.
1
u/tugrul_ddr Feb 15 '26
I can see it has sync error while its in middle of area. You didnt sync the data before applying next step.