Skip to content

Commit

Permalink
data/kernels: switch atomics to OpenCL 1.1+
Browse files Browse the repository at this point in the history
The cl_khr_global_int32_base_atomics extension became a core feature in
OpenCL 1.1, update the code accordingly.

https://www.khronos.org/registry/OpenCL/specs/3.0-unified/html/OpenCL_Ext.html#cl_khr_int32_atomics
  • Loading branch information
sharkcz authored and TurboGit committed Jan 9, 2022
1 parent f17933b commit ff44aa8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
6 changes: 2 additions & 4 deletions data/kernels/bilateral.cl
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
along with darktable. If not, see <http://www.gnu.org/licenses/>.
*/

#pragma OPENCL EXTENSION cl_khr_global_int32_base_atomics : enable

#include "common.h"

float4
Expand Down Expand Up @@ -64,10 +62,10 @@ atomic_add_f(
// the following is equivalent to old_val.f = *val. however, as according to the opencl standard
// we can not rely on global buffer val to be consistently cached (relaxed memory consistency) we
// access it via a slower but consistent atomic operation.
old_val.i = atom_add(ival, 0);
old_val.i = atomic_add(ival, 0);
new_val.f = old_val.f + delta;
}
while (atom_cmpxchg (ival, old_val.i, new_val.i) != old_val.i);
while (atomic_cmpxchg (ival, old_val.i, new_val.i) != old_val.i);
#endif
}

Expand Down
6 changes: 2 additions & 4 deletions data/kernels/colorreconstruction.cl
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
along with darktable. If not, see <http://www.gnu.org/licenses/>.
*/

#pragma OPENCL EXTENSION cl_khr_global_int32_base_atomics : enable

#include "common.h"

typedef enum dt_iop_colorreconstruct_precedence_t
Expand Down Expand Up @@ -83,10 +81,10 @@ atomic_add_f(
// the following is equivalent to old_val.f = *val. however, as according to the opencl standard
// we can not rely on global buffer val to be consistently cached (relaxed memory consistency) we
// access it via a slower but consistent atomic operation.
old_val.i = atom_add(ival, 0);
old_val.i = atomic_add(ival, 0);
new_val.f = old_val.f + delta;
}
while (atom_cmpxchg (ival, old_val.i, new_val.i) != old_val.i);
while (atomic_cmpxchg (ival, old_val.i, new_val.i) != old_val.i);
#endif
}

Expand Down

0 comments on commit ff44aa8

Please sign in to comment.