KhronosGroup / KhronosGroup/OpenCL-Docs

Old-style atomics with generic address space

Open
#66 10 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

OpenCL C Spec themed-agenda
Dominant language
Python
Stars
421
Forks
132
Avg merge
5d 13h
Merged PRs (30d)
11

Description

Porting some of our OpenCL 1.2 code to OpenCL 2.0, I encountered some problems with atomic operations. After getting rid of the __global and __shared specifiers to pointers, the code fails to compile.

The reason is that the "old-style" atomics we are using, e.g. atomic_add, yield in clang:
address space mismatch in 1st argument ('__generic int *'), parameter type must be 'volatile __global int *'

Unfortunately, switching to the new atomics in C11/C++11 style is not straight forward.
In other parts of the code, where we exclude concurrent access to the integers, we use binary operators (&, |, ^), which are not available for the C11 atomics like atomic_uint.

Basically, we rely on the fact that the integers behave as normal integers when the pointers are dereferenced, but we need the atomic operations on them in addition (we make sure ourselves, that this will not collide). This is a feature available with the old OpenCL 1.2. atomics, but not with the new C11 atomics.

In my opinion, all operations of "normal" integers should be available also for atomic_uint, etc, or the old-style atomic operations like atomic_add should work with pointers to the generic address space in OpenCL 2.0.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source file or test is named. Start by reviewing the OpenCL 2.0 rules for generic address spaces, old-style atomics, and C11 atomic types, then determine which requested behavior the specification should define. Done means the behavior is resolved and the relevant OpenCL documentation is clarified.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
compilers, documentation
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.