Legion Runtime
Loading...
Searching...
No Matches
sync.h
1/* Copyright 2026 Stanford University, NVIDIA Corporation
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16#ifndef __LEGION_SYNCHRONIZATION_H__
17#define __LEGION_SYNCHRONIZATION_H__
18
19#include "legion/api/types.h"
20
21namespace Legion {
22
52 class Lock {
53 public:
54 Lock(void);
55 protected:
56 // Only the runtime is allowed to make non-empty locks
57 FRIEND_ALL_RUNTIME_CLASSES
58 Lock(Reservation r);
59 public:
60 bool operator<(const Lock& rhs) const;
61 bool operator==(const Lock& rhs) const;
62 public:
63 void acquire(unsigned mode = 0, bool exclusive = true);
64 void release(void);
65 private:
66 Reservation reservation_lock;
67 };
68
76 struct LockRequest {
77 public:
78 LockRequest(Lock l, unsigned mode = 0, bool exclusive = true);
79 public:
80 Lock lock;
81 unsigned mode;
82 bool exclusive;
83 };
84
97 class Grant {
98 public:
99 Grant(void);
100 Grant(const Grant& g);
101 ~Grant(void);
102 protected:
103 // Only the runtime is allowed to make non-empty grants
104 FRIEND_ALL_RUNTIME_CLASSES
105 explicit Grant(Internal::GrantImpl* impl);
106 public:
107 bool operator==(const Grant& g) const { return impl == g.impl; }
108 bool operator<(const Grant& g) const { return impl < g.impl; }
109 Grant& operator=(const Grant& g);
110 protected:
111 Internal::GrantImpl* impl;
112 };
113
143 public:
144 PhaseBarrier(void);
145 protected:
146 // Only the runtime is allowed to make non-empty phase barriers
147 FRIEND_ALL_RUNTIME_CLASSES
149 public:
150 bool operator<(const PhaseBarrier& rhs) const;
151 bool operator==(const PhaseBarrier& rhs) const;
152 bool operator!=(const PhaseBarrier& rhs) const;
153 public:
154 void arrive(unsigned count = 1);
155 void wait(void);
156 void alter_arrival_count(int delta);
157 Realm::Barrier get_barrier(void) const { return phase_barrier; }
158 bool exists(void) const;
159 protected:
160 Internal::ApBarrier phase_barrier;
161 friend std::ostream& operator<<(std::ostream& os, const PhaseBarrier& pb);
162 };
163
179 public:
180 DynamicCollective(void);
181 protected:
182 // Only the runtime is allowed to make non-empty dynamic collectives
183 FRIEND_ALL_RUNTIME_CLASSES
184 DynamicCollective(Internal::ApBarrier b, ReductionOpID redop);
185 public:
186 // All the same operations as a phase barrier
187 void arrive(const void* value, size_t size, unsigned count = 1);
188 protected:
189 ReductionOpID redop;
190 };
191
192} // namespace Legion
193
194#include "legion/api/sync.inl"
195
196#endif // __LEGION_SYNCHRONIZATION_H__
Definition sync.h:178
Definition sync.h:97
Definition types.h:898
Definition sync.h:52
Definition sync.h:142
Definition sync.h:76