Legion Runtime
Loading...
Searching...
No Matches
values.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_DEFERRED_VALUES_H__
17#define __LEGION_DEFERRED_VALUES_H__
18
24#include "legion/api/types.h"
25#include "legion/api/geometry.h"
26
27namespace Legion {
28
34 public:
35 DeferredValueRequest(void) = default;
36 // Convenience constructors
38 Memory mem, size_t size, size_t align = alignof(std::max_align_t),
39 const void* initial = nullptr, bool escaping = true);
41 Memory::Kind kind, size_t size,
42 size_t align = alignof(std::max_align_t), const void* initial = nullptr,
43 bool escaping = true);
44 public:
45 size_t field_size = 0;
46 size_t alignment = alignof(std::max_align_t);
47 const void* initial_value = nullptr;
48 union {
49 Memory exact = Memory::NO_MEMORY;
50 Memory::Kind kind;
51 } memory;
52 bool is_exact = true;
53 bool can_fail = false;
54 bool escaping = true;
55 };
56
62 public:
65 size_t field_size, Memory target_memory,
66 const void* initial_value = nullptr, size_t alignment = 16,
67 bool escaping = true);
69 size_t field_size, Memory::Kind memory_kind = Memory::Z_COPY_MEM,
70 const void* initial_value = nullptr, size_t alignment = 16,
71 bool escaping = true);
73 public:
74 template<typename T>
75 inline operator DeferredValue<T>(void) const;
76 template<typename REDOP, bool EXCLUSIVE>
77 inline operator DeferredReduction<REDOP, EXCLUSIVE>(void) const;
78 inline size_t field_size(void) const;
79 public:
80 inline bool exists(void) const { return instance.exists(); }
81 void finalize(Context ctx) const;
82 Realm::RegionInstance get_instance(void) const;
83 static void report_incompatible_accessor(
84 const char* accessor_kind, bool buffer = false);
85 protected:
86 Realm::RegionInstance instance;
87 protected:
88 static Domain get_index_space_bounds(IndexSpace space);
89 friend class Runtime;
90 template<PrivilegeMode, typename, int, typename, typename, bool>
91 friend class FieldAccessor;
92 template<typename, bool, int, typename, typename, bool>
93 friend class ReductionAccessor;
94 };
95
109 template<typename T>
111 public:
113 T initial_value, size_t alignment = std::alignment_of<T>(),
114 Memory::Kind memory_kind = Memory::Z_COPY_MEM, bool escaping = true);
116 T initial_value, Memory target_memory,
117 size_t alignment = std::alignment_of<T>(), bool escaping = true);
118 public:
119 __LEGION_CUDA_HD__
120 inline T read(void) const;
121 __LEGION_CUDA_HD__
122 inline void write(T value) const;
123 __LEGION_CUDA_HD__
124 inline T* ptr(void) const;
125 __LEGION_CUDA_HD__
126 inline T& ref(void) const;
127 __LEGION_CUDA_HD__
128 inline operator T(void) const;
129 __LEGION_CUDA_HD__
130 inline DeferredValue<T>& operator=(T value);
131 public:
132 typedef T value_type;
133 typedef T& reference;
134 typedef const T& const_reference;
135 protected:
136 friend class UntypedDeferredValue;
137 DeferredValue(void);
138 Realm::AffineAccessor<T, 1, coord_t> accessor;
139 };
140
150 template<typename REDOP, bool EXCLUSIVE = false>
151 class DeferredReduction : public DeferredValue<typename REDOP::RHS> {
152 public:
154 size_t alignment = std::alignment_of<typename REDOP::RHS>(),
155 bool escaping = true);
156 public:
157 __LEGION_CUDA_HD__
158 inline void reduce(typename REDOP::RHS val) const;
159 __LEGION_CUDA_HD__
160 inline void operator<<=(typename REDOP::RHS val) const;
161 public:
162 typedef typename REDOP::RHS value_type;
163 typedef typename REDOP::RHS& reference;
164 typedef const typename REDOP::RHS& const_reference;
165 };
166
167} // namespace Legion
168
169#include "legion/api/values.inl"
170
171#endif // __LEGION_DEFERRED_VALUES_H__
Definition values.h:151
Definition values.h:110
Definition geometry.h:159
Definition accessors.h:76
Definition data.h:35
Definition accessors.h:384
Definition runtime.h:108
Definition values.h:61
Definition accessors.h:29
Definition values.h:33