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