[Openmp-commits] [PATCH] D95062: [libomptarget][devicertl][nfc] Simplify target_atomic abstraction
Shilei Tian via Phabricator via Openmp-commits
openmp-commits at lists.llvm.org
Wed Jan 20 13:49:37 PST 2021
tianshilei1992 added a comment.
In D95062#2510863 <https://reviews.llvm.org/D95062#2510863>, @jdoerfert wrote:
> In D95062#2510856 <https://reviews.llvm.org/D95062#2510856>, @tianshilei1992 wrote:
>
>> None of the three atomic operations provided by OpenMP, `read`, `write`, and `update`, sound like similar semantics as the four operations here.
>
> Please finish reading the section about atomics (https://www.openmp.org/spec-html/5.1/openmpsu105.html#x138-1480002.19.7). All of the above operations are expressible, as far as I can tell.
> `add` and `inc` are `atomic update`, `exchange` is `atomic capture`, `max` and `cas` are `atomic compare`, all with appropriate expression statement following them.
All these operations should be `capture` because they're composite. For example, `atomicAdd` should be something like:
int atomicAdd(int *Addr, int Val) {
int Old;
#pragma omp atomic capture
{ Old = *Addr; *Addr += Val; }
return Old;
}
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D95062/new/
https://reviews.llvm.org/D95062
More information about the Openmp-commits
mailing list