Legion Runtime
Loading...
Searching...
No Matches
sync.h
Go to the documentation of this file.
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
24
#include "
legion/api/types.h
"
25
26
namespace
Legion
{
27
57
class
Lock
{
58
public
:
59
Lock
(
void
);
60
protected
:
61
// Only the runtime is allowed to make non-empty locks
62
FRIEND_ALL_RUNTIME_CLASSES
63
Lock
(Reservation r);
64
public
:
65
bool
operator<(
const
Lock
& rhs)
const
;
66
bool
operator==(
const
Lock
& rhs)
const
;
67
public
:
68
void
acquire(
unsigned
mode = 0,
bool
exclusive =
true
);
69
void
release(
void
);
70
private
:
71
Reservation reservation_lock;
72
};
73
81
struct
LockRequest
{
82
public
:
83
LockRequest
(
Lock
l,
unsigned
mode = 0,
bool
exclusive =
true
);
84
public
:
85
Lock
lock;
86
unsigned
mode;
87
bool
exclusive;
88
};
89
102
class
Grant
{
103
public
:
104
Grant
(
void
);
105
Grant
(
const
Grant
& g);
106
~Grant
(
void
);
107
protected
:
108
// Only the runtime is allowed to make non-empty grants
109
FRIEND_ALL_RUNTIME_CLASSES
110
explicit
Grant
(Internal::GrantImpl* impl);
111
public
:
112
bool
operator==(
const
Grant
& g)
const
{
return
impl == g.impl; }
113
bool
operator<(
const
Grant
& g)
const
{
return
impl < g.impl; }
114
Grant
& operator=(
const
Grant
& g);
115
protected
:
116
Internal::GrantImpl* impl;
117
};
118
147
class
PhaseBarrier
{
148
public
:
149
PhaseBarrier
(
void
);
150
protected
:
151
// Only the runtime is allowed to make non-empty phase barriers
152
FRIEND_ALL_RUNTIME_CLASSES
153
PhaseBarrier
(
Internal::ApBarrier
b);
154
public
:
155
bool
operator<(
const
PhaseBarrier
& rhs)
const
;
156
bool
operator==(
const
PhaseBarrier
& rhs)
const
;
157
bool
operator!=(
const
PhaseBarrier
& rhs)
const
;
158
public
:
159
void
arrive(
unsigned
count = 1);
160
void
wait(
void
);
161
void
alter_arrival_count(
int
delta);
162
Realm::Barrier get_barrier(
void
)
const
{
return
phase_barrier; }
163
bool
exists(
void
)
const
;
164
protected
:
165
Internal::ApBarrier
phase_barrier;
166
friend
std::ostream& operator<<(std::ostream& os,
const
PhaseBarrier
& pb);
167
};
168
183
class
DynamicCollective
:
public
PhaseBarrier
{
184
public
:
185
DynamicCollective
(
void
);
186
protected
:
187
// Only the runtime is allowed to make non-empty dynamic collectives
188
FRIEND_ALL_RUNTIME_CLASSES
189
DynamicCollective
(
Internal::ApBarrier
b, ReductionOpID redop);
190
public
:
191
// All the same operations as a phase barrier
192
void
arrive(
const
void
* value,
size_t
size,
unsigned
count = 1);
193
protected
:
194
ReductionOpID redop;
195
};
196
197
}
// namespace Legion
198
199
#include "legion/api/sync.inl"
200
201
#endif
// __LEGION_SYNCHRONIZATION_H__
Legion::DynamicCollective
Definition
sync.h:183
Legion::Grant
Definition
sync.h:102
Legion::Internal::ApBarrier
Definition
types.h:907
Legion::Lock
Definition
sync.h:57
Legion::PhaseBarrier
Definition
sync.h:147
Legion
Definition
accessors.h:29
Legion::LockRequest
Definition
sync.h:81
types.h
legion
api
sync.h
Generated on Sat Oct 3 2026 02:56:22 for Legion Runtime by
1.9.8