1 //===- Synchronization.h - OpenMP synchronization utilities ------- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 //
10 //===----------------------------------------------------------------------===//
11 
12 #ifndef OMPTARGET_DEVICERTL_SYNCHRONIZATION_H
13 #define OMPTARGET_DEVICERTL_SYNCHRONIZATION_H
14 
15 #include "Types.h"
16 
17 namespace _OMP {
18 
19 namespace synchronize {
20 
21 /// Initialize the synchronization machinery. Must be called by all threads.
22 void init(bool IsSPMD);
23 
24 /// Synchronize all threads in a warp identified by \p Mask.
25 void warp(LaneMaskTy Mask);
26 
27 /// Synchronize all threads in a block.
28 void threads();
29 
30 } // namespace synchronize
31 
32 namespace fence {
33 
34 /// Memory fence with \p Ordering semantics for the team.
35 void team(int Ordering);
36 
37 /// Memory fence with \p Ordering semantics for the contention group.
38 void kernel(int Ordering);
39 
40 /// Memory fence with \p Ordering semantics for the system.
41 void system(int Ordering);
42 
43 } // namespace fence
44 
45 namespace atomic {
46 
47 /// Atomically load \p Addr with \p Ordering semantics.
48 uint32_t load(uint32_t *Addr, int Ordering);
49 
50 /// Atomically store \p V to \p Addr with \p Ordering semantics.
51 void store(uint32_t *Addr, uint32_t V, int Ordering);
52 
53 /// Atomically increment \p *Addr and wrap at \p V with \p Ordering semantics.
54 uint32_t inc(uint32_t *Addr, uint32_t V, int Ordering);
55 
56 /// Atomically add \p V to \p *Addr with \p Ordering semantics.
57 uint32_t add(uint32_t *Addr, uint32_t V, int Ordering);
58 
59 /// Atomically add \p V to \p *Addr with \p Ordering semantics.
60 uint64_t add(uint64_t *Addr, uint64_t V, int Ordering);
61 
62 } // namespace atomic
63 
64 } // namespace _OMP
65 
66 #endif
67