Legion Runtime
Loading...
Searching...
No Matches
legion_c_util.h
Go to the documentation of this file.
1/* Copyright 2024 Stanford University
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
17#ifndef __LEGION_C_UTIL_H__
18#define __LEGION_C_UTIL_H__
19
25#include "legion.h"
26#include "legion/legion_c.h"
27#include "legion/legion_mapping.h"
28#include "mappers/mapping_utilities.h"
29
30#include <stdlib.h>
31#include <string.h>
32#include <algorithm>
33
34static inline bool operator<(const legion_ptr_t &lhs, const legion_ptr_t &rhs)
35{ return lhs.value < rhs.value; }
36
37namespace Legion {
38
39 class CContext;
40 class TaskMut;
41
43 public:
44 std::set<legion_ptr_t> points;
45 std::set<std::pair<legion_ptr_t,legion_ptr_t> > ranges;
46 };
47 typedef std::map<Color,ColoredPoints> Coloring;
48 typedef std::map<Color,Domain> DomainColoring;
49 typedef std::map<DomainPoint,ColoredPoints> PointColoring;
50 typedef std::map<DomainPoint,Domain> DomainPointColoring;
51 typedef std::map<DomainPoint,std::set<Domain> > MultiDomainPointColoring;
52
54 public:
55#define ARRAY_ACCESSOR(DIM) \
56 typedef Legion::UnsafeFieldAccessor<char,DIM,coord_t, \
57 Realm::AffineAccessor<char,DIM,coord_t> > ArrayAccessor##DIM##D;
58 LEGION_FOREACH_N(ARRAY_ACCESSOR)
59#undef ARRAY_ACCESSOR
60
61#define RECT_ITERATOR(DIM) \
62 typedef RectInDomainIterator<DIM,coord_t> RectInDomainIterator##DIM##D;
63 LEGION_FOREACH_N(RECT_ITERATOR)
64#undef RECT_ITERATOR
65
66#define BUFFER_CHAR(DIM) \
67 typedef DeferredBuffer<char,DIM> DeferredBufferChar##DIM##D;
68 LEGION_FOREACH_N(BUFFER_CHAR)
69#undef BUFFER_CHAR
70
71#ifdef __ICC
72// icpc complains about "error #858: type qualifier on return type is meaningless"
73// but it's pretty annoying to get this macro to handle all the cases right
74#pragma warning (push)
75#pragma warning (disable: 858)
76#endif
77#ifdef __PGIC__
78#pragma warning (push)
79#pragma diag_suppress 191
80#pragma diag_suppress 816
81#endif
82#define NEW_OPAQUE_WRAPPER(T_, T) \
83 static T_ wrap(T t) { \
84 T_ t_; \
85 t_.impl = static_cast<void *>(t); \
86 return t_; \
87 } \
88 static const T_ wrap_const(const T t) { \
89 T_ t_; \
90 t_.impl = const_cast<void *>(static_cast<const void *>(t)); \
91 return t_; \
92 } \
93 static T unwrap(T_ t_) { \
94 return static_cast<T>(t_.impl); \
95 } \
96 static const T unwrap_const(const T_ t_) { \
97 return static_cast<const T>(t_.impl); \
98 }
99
100 NEW_OPAQUE_WRAPPER(legion_runtime_t, Runtime *);
101 NEW_OPAQUE_WRAPPER(legion_context_t, CContext *);
102 NEW_OPAQUE_WRAPPER(legion_domain_point_iterator_t, Domain::DomainPointIterator *);
103#define RECT_ITERATOR(DIM) \
104 NEW_OPAQUE_WRAPPER(legion_rect_in_domain_iterator_##DIM##d_t, RectInDomainIterator##DIM##D *);
105 LEGION_FOREACH_N(RECT_ITERATOR)
106#undef RECT_ITERATOR
107 NEW_OPAQUE_WRAPPER(legion_coloring_t, Coloring *);
108 NEW_OPAQUE_WRAPPER(legion_domain_coloring_t, DomainColoring *);
109 NEW_OPAQUE_WRAPPER(legion_point_coloring_t, PointColoring *);
110 NEW_OPAQUE_WRAPPER(legion_domain_point_coloring_t, DomainPointColoring *);
111 NEW_OPAQUE_WRAPPER(legion_multi_domain_point_coloring_t, MultiDomainPointColoring *);
112 NEW_OPAQUE_WRAPPER(legion_index_space_allocator_t, IndexSpaceAllocator *);
113 NEW_OPAQUE_WRAPPER(legion_field_allocator_t, FieldAllocator *);
114 NEW_OPAQUE_WRAPPER(legion_argument_map_t, ArgumentMap *);
115 NEW_OPAQUE_WRAPPER(legion_predicate_t, Predicate *);
116 NEW_OPAQUE_WRAPPER(legion_future_t, Future *);
117 NEW_OPAQUE_WRAPPER(legion_future_map_t, FutureMap *);
118#define BUFFER_CHAR(DIM) \
119 NEW_OPAQUE_WRAPPER(legion_deferred_buffer_char_##DIM##d_t, DeferredBufferChar##DIM##D *);
120 LEGION_FOREACH_N(BUFFER_CHAR)
121#undef BUFFER_CHAR
122 NEW_OPAQUE_WRAPPER(legion_task_launcher_t, TaskLauncher *);
123 NEW_OPAQUE_WRAPPER(legion_index_launcher_t, IndexTaskLauncher *);
124 NEW_OPAQUE_WRAPPER(legion_inline_launcher_t, InlineLauncher *);
125 NEW_OPAQUE_WRAPPER(legion_copy_launcher_t, CopyLauncher *);
126 NEW_OPAQUE_WRAPPER(legion_index_copy_launcher_t, IndexCopyLauncher *);
127 NEW_OPAQUE_WRAPPER(legion_fill_launcher_t, FillLauncher *);
128 NEW_OPAQUE_WRAPPER(legion_index_fill_launcher_t, IndexFillLauncher *);
129 NEW_OPAQUE_WRAPPER(legion_discard_launcher_t, DiscardLauncher *);
130 NEW_OPAQUE_WRAPPER(legion_acquire_launcher_t, AcquireLauncher *);
131 NEW_OPAQUE_WRAPPER(legion_release_launcher_t, ReleaseLauncher *);
132 NEW_OPAQUE_WRAPPER(legion_attach_launcher_t, AttachLauncher *);
133 NEW_OPAQUE_WRAPPER(legion_index_attach_launcher_t, IndexAttachLauncher *);
134 NEW_OPAQUE_WRAPPER(legion_must_epoch_launcher_t, MustEpochLauncher *);
135 NEW_OPAQUE_WRAPPER(legion_physical_region_t, PhysicalRegion *);
136 NEW_OPAQUE_WRAPPER(legion_external_resources_t, ExternalResources *);
137#define ACCESSOR_ARRAY(DIM) \
138 NEW_OPAQUE_WRAPPER(legion_accessor_array_##DIM##d_t, ArrayAccessor##DIM##D *);
139 LEGION_FOREACH_N(ACCESSOR_ARRAY)
140#undef ACCESSOR_ARRAY
141 NEW_OPAQUE_WRAPPER(legion_task_t, Task *);
142 NEW_OPAQUE_WRAPPER(legion_task_mut_t, TaskMut *);
143 NEW_OPAQUE_WRAPPER(legion_copy_t, Copy *);
144 NEW_OPAQUE_WRAPPER(legion_fill_t, Fill *);
145 NEW_OPAQUE_WRAPPER(legion_inline_t, InlineMapping *);
146 NEW_OPAQUE_WRAPPER(legion_mappable_t, Mappable *);
147 NEW_OPAQUE_WRAPPER(legion_region_requirement_t , RegionRequirement *);
148 NEW_OPAQUE_WRAPPER(legion_output_requirement_t , OutputRequirement *);
149 NEW_OPAQUE_WRAPPER(legion_machine_t, Machine *);
150 NEW_OPAQUE_WRAPPER(legion_logger_t, Realm::Logger *);
151 NEW_OPAQUE_WRAPPER(legion_mapper_t, Mapping::Mapper *);
152 NEW_OPAQUE_WRAPPER(legion_processor_query_t, Machine::ProcessorQuery *);
153 NEW_OPAQUE_WRAPPER(legion_memory_query_t, Machine::MemoryQuery *);
154 NEW_OPAQUE_WRAPPER(legion_machine_query_interface_t,
155 Mapping::Utilities::MachineQueryInterface *);
156 NEW_OPAQUE_WRAPPER(legion_default_mapper_t, Mapping::DefaultMapper *);
157 NEW_OPAQUE_WRAPPER(legion_execution_constraint_set_t, ExecutionConstraintSet *);
158 NEW_OPAQUE_WRAPPER(legion_layout_constraint_set_t, LayoutConstraintSet *);
159 NEW_OPAQUE_WRAPPER(legion_task_layout_constraint_set_t, TaskLayoutConstraintSet *);
160 NEW_OPAQUE_WRAPPER(legion_map_task_input_t, Mapping::Mapper::MapTaskInput *);
161 NEW_OPAQUE_WRAPPER(legion_map_task_output_t, Mapping::Mapper::MapTaskOutput *);
162 NEW_OPAQUE_WRAPPER(legion_slice_task_output_t, Mapping::Mapper::SliceTaskOutput *);
163 NEW_OPAQUE_WRAPPER(legion_physical_instance_t, Mapping::PhysicalInstance *);
164 NEW_OPAQUE_WRAPPER(legion_mapper_runtime_t, Mapping::MapperRuntime *);
165 // nvcc wrongly complains about a meaningless qualifer on the return type,
166 // probably due to it not chasing the typedefs when doing the check.
167 // here we inline the type alias to suppress the warning
168 NEW_OPAQUE_WRAPPER(legion_mapper_context_t, Internal::MappingCallInfo *);
169 typedef std::map<FieldID, const char *> FieldMap;
170 NEW_OPAQUE_WRAPPER(legion_field_map_t, FieldMap *);
171 NEW_OPAQUE_WRAPPER(legion_point_transform_functor_t, PointTransformFunctor *);
172 NEW_OPAQUE_WRAPPER(legion_task_variant_registrar_t, TaskVariantRegistrar *);
173#undef NEW_OPAQUE_WRAPPER
174#ifdef __ICC
175// icpc complains about "error #858: type qualifier on return type is meaningless"
176// but it's pretty annoying to get this macro to handle all the cases right
177#pragma warning (pop)
178#endif
179#ifdef __PGIC__
180#pragma warning (pop)
181#endif
182
183#define NEW_POINT_WRAPPER(DIM) \
184 typedef Point<DIM,coord_t> Point##DIM##D; \
185 static legion_point_##DIM##d_t wrap(Point##DIM##D t) { \
186 legion_point_##DIM##d_t t_; \
187 for (int i = 0; i < DIM; i++) \
188 t_.x[i] = t[i]; \
189 return t_; \
190 } \
191 static Point##DIM##D unwrap(legion_point_##DIM##d_t t_) { \
192 Point##DIM##D t; \
193 for (int i = 0; i < DIM; i++) \
194 t[i] = t_.x[i]; \
195 return t; \
196 }
197 LEGION_FOREACH_N(NEW_POINT_WRAPPER)
198#undef NEW_POINT_WRAPPER
199
200#define NEW_RECT_WRAPPER(DIM) \
201 typedef Rect<DIM,coord_t> Rect##DIM##D; \
202 static legion_rect_##DIM##d_t wrap(Rect##DIM##D t) { \
203 legion_rect_##DIM##d_t t_; \
204 t_.lo = wrap(Point##DIM##D(t.lo)); \
205 t_.hi = wrap(Point##DIM##D(t.hi)); \
206 return t_; \
207 } \
208 static Rect##DIM##D unwrap(legion_rect_##DIM##d_t t_) { \
209 Rect##DIM##D t(unwrap(t_.lo), unwrap(t_.hi)); \
210 return t; \
211 }
212 LEGION_FOREACH_N(NEW_RECT_WRAPPER)
213#undef NEW_RECT_WRAPPER
214
215#define NEW_BLOCKIFY_WRAPPER(DIM) \
216 static Blockify<DIM> unwrap(legion_blockify_##DIM##d_t t_) { \
217 Blockify<DIM> t(unwrap(t_.block_size), unwrap(t_.offset)); \
218 return t; \
219 }
220 template<int DIM>
221 struct Blockify {
222 public:
223 Blockify(Point<DIM,coord_t> b,
224 Point<DIM,coord_t> o)
225 : block_size(b), offset(o) { }
226 public:
227 Point<DIM,coord_t> block_size, offset;
228 };
229 LEGION_FOREACH_N(NEW_BLOCKIFY_WRAPPER)
230#undef NEW_BLOCKIFY_WRAPPER
231
232#define NEW_TRANSFORM_WRAPPER(D1,D2) \
233 typedef Transform<D1,D2,coord_t> Transform##D1##x##D2; \
234 static legion_transform_##D1##x##D2##_t wrap(Transform##D1##x##D2 t) { \
235 legion_transform_##D1##x##D2##_t t_; \
236 for (int i = 0; i < D1; i++) \
237 for (int j = 0; j < D2; j++) \
238 t_.trans[i][j] = t[i][j]; \
239 return t_; \
240 } \
241 static Transform##D1##x##D2 unwrap(legion_transform_##D1##x##D2##_t t_) { \
242 Transform##D1##x##D2 t; \
243 for (int i = 0; i < D1; i++) \
244 for (int j = 0; j < D2; j++) \
245 t[i][j] = t_.trans[i][j]; \
246 return t; \
247 }
248 LEGION_FOREACH_NN(NEW_TRANSFORM_WRAPPER)
249#undef NEW_TRANSFORM_WRAPPER
250
251#define NEW_AFFINE_TRANSFORM_WRAPPER(D1,D2) \
252 typedef AffineTransform<D1,D2,coord_t> AffineTransform##D1##x##D2; \
253 static legion_affine_transform_##D1##x##D2##_t wrap(AffineTransform##D1##x##D2 t) { \
254 legion_affine_transform_##D1##x##D2##_t t_; \
255 t_.transform = wrap(t.transform); \
256 t_.offset = wrap(t.offset); \
257 return t_; \
258 } \
259 static AffineTransform##D1##x##D2 unwrap(legion_affine_transform_##D1##x##D2##_t t_) { \
260 AffineTransform##D1##x##D2 t; \
261 t.transform = unwrap(t_.transform); \
262 t.offset = unwrap(t_.offset); \
263 return t; \
264 }
265 LEGION_FOREACH_NN(NEW_AFFINE_TRANSFORM_WRAPPER)
266#undef NEW_AFFINE_TRANSFORM_WRAPPER
267
268 static legion_domain_t
269 wrap(Domain domain) {
270 legion_domain_t domain_;
271 domain_.is_id = domain.is_id;
272 domain_.is_type = domain.is_type;
273 domain_.dim = domain.dim;
274 std::copy(domain.rect_data, domain.rect_data + 2 * LEGION_MAX_DIM, domain_.rect_data);
275 return domain_;
276 }
277
278 static Domain
279 unwrap(legion_domain_t domain_) {
280 Domain domain;
281 domain.is_id = domain_.is_id;
282 domain.is_type = domain_.is_type;
283 domain.dim = domain_.dim;
284 std::copy(domain_.rect_data, domain_.rect_data + 2 * LEGION_MAX_DIM, domain.rect_data);
285 return domain;
286 }
287
289 wrap(DomainPoint dp) {
291 dp_.dim = dp.dim;
292 std::copy(dp.point_data, dp.point_data + LEGION_MAX_DIM, dp_.point_data);
293 return dp_;
294 }
295
296 static DomainPoint
297 unwrap(legion_domain_point_t dp_) {
298 DomainPoint dp;
299 dp.dim = dp_.dim;
300 std::copy(dp_.point_data, dp_.point_data + LEGION_MAX_DIM, dp.point_data);
301 return dp;
302 }
303
305 wrap(DomainTransform transform) {
306 legion_domain_transform_t transform_;
307 transform_.m = transform.m;
308 transform_.n = transform.n;
309 std::copy(transform.matrix, transform.matrix + LEGION_MAX_DIM * LEGION_MAX_DIM, transform_.matrix);
310 return transform_;
311 }
312
313 static DomainTransform
314 unwrap(legion_domain_transform_t transform_) {
315 DomainTransform transform;
316 transform.m = transform_.m;
317 transform.n = transform_.n;
318 std::copy(transform_.matrix, transform_.matrix + LEGION_MAX_DIM * LEGION_MAX_DIM, transform.matrix);
319 return transform;
320 }
321
323 wrap(DomainAffineTransform transform) {
325 transform_.transform = wrap(transform.transform);
326 transform_.offset = wrap(transform.offset);
327 return transform_;
328 }
329
330 static DomainAffineTransform
331 unwrap(legion_domain_affine_transform_t transform_) {
332 DomainAffineTransform transform;
333 transform.transform = unwrap(transform_.transform);
334 transform.offset = unwrap(transform_.offset);
335 return transform;
336 }
337
339 wrap(IndexSpace is)
340 {
342 is_.id = is.id;
343 is_.tid = is.tid;
344 is_.type_tag = is.type_tag;
345 return is_;
346 }
347
348 static IndexSpace
349 unwrap(legion_index_space_t is_)
350 {
351 IndexSpace is;
352 is.id = is_.id;
353 is.tid = is_.tid;
354 is.type_tag = is_.type_tag;
355 return is;
356 }
357
359 wrap(IndexPartition ip)
360 {
362 ip_.id = ip.id;
363 ip_.tid = ip.tid;
364 ip_.type_tag = ip.type_tag;
365 return ip_;
366 }
367
368 static IndexPartition
369 unwrap(legion_index_partition_t ip_)
370 {
371 IndexPartition ip;
372 ip.id = ip_.id;
373 ip.tid = ip_.tid;
374 ip.type_tag = ip_.type_tag;
375 return ip;
376 }
377
379 wrap(FieldSpace fs)
380 {
382 fs_.id = fs.id;
383 return fs_;
384 }
385
386 static FieldSpace
387 unwrap(legion_field_space_t fs_)
388 {
389 FieldSpace fs(fs_.id);
390 return fs;
391 }
392
394 wrap(LogicalRegion r)
395 {
397 r_.tree_id = r.tree_id;
398 r_.index_space = wrap(r.index_space);
399 r_.field_space = wrap(r.field_space);
400 return r_;
401 }
402
403 static LogicalRegion
404 unwrap(legion_logical_region_t r_)
405 {
406 LogicalRegion r(r_.tree_id,
407 unwrap(r_.index_space),
408 unwrap(r_.field_space));
409 return r;
410 }
411
413 wrap(LogicalPartition r)
414 {
416 r_.tree_id = r.tree_id;
417 r_.index_partition = wrap(r.index_partition);
418 r_.field_space = wrap(r.field_space);
419 return r_;
420 }
421
422 static LogicalPartition
424 {
425 LogicalPartition r(r_.tree_id,
426 unwrap(r_.index_partition),
427 unwrap(r_.field_space));
428 return r;
429 }
430
432 wrap(UntypedBuffer arg)
433 {
435 arg_.args = arg.get_ptr();
436 arg_.arglen = arg.get_size();
437 return arg_;
438 }
439
440 static UntypedBuffer
441 unwrap(legion_untyped_buffer_t arg_)
442 {
443 return UntypedBuffer(arg_.args, arg_.arglen);
444 }
445
446 static const legion_byte_offset_t
447 wrap(const ptrdiff_t offset)
448 {
449 legion_byte_offset_t offset_;
450 offset_.offset = offset;
451 return offset_;
452 }
453
454 static ptrdiff_t
455 unwrap(const legion_byte_offset_t offset_)
456 {
457 return offset_.offset;
458 }
459
460 static const legion_input_args_t
461 wrap_const(const InputArgs arg)
462 {
464 arg_.argv = arg.argv;
465 arg_.argc = arg.argc;
466 return arg_;
467 }
468
469 static const InputArgs
470 unwrap_const(const legion_input_args_t args_)
471 {
472 InputArgs args;
473 args.argv = args_.argv;
474 args.argc = args_.argc;
475 return args;
476 }
477
479 wrap(TaskConfigOptions options)
480 {
482 options_.leaf = options.leaf;
483 options_.inner = options.inner;
484 options_.idempotent = options.idempotent;
485 return options_;
486 }
487
488 static TaskConfigOptions
489 unwrap(legion_task_config_options_t options_)
490 {
491 TaskConfigOptions options(options_.leaf,
492 options_.inner,
493 options_.idempotent);
494 return options;
495 }
496
497 static legion_processor_t
498 wrap(Processor proc)
499 {
500 legion_processor_t proc_;
501 proc_.id = proc.id;
502 return proc_;
503 }
504
505 static Processor
506 unwrap(legion_processor_t proc_)
507 {
508 Processor proc;
509 proc.id = proc_.id;
510 return proc;
511 }
512
513 static legion_processor_kind_t
514 wrap(Processor::Kind options)
515 {
516 return static_cast<legion_processor_kind_t>(options);
517 }
518
519 static Processor::Kind
520 unwrap(legion_processor_kind_t options_)
521 {
522 return static_cast<Processor::Kind>(options_);
523 }
524
525 static legion_memory_t
526 wrap(Memory mem)
527 {
528 legion_memory_t mem_;
529 mem_.id = mem.id;
530 return mem_;
531 }
532
533 static Memory
534 unwrap(legion_memory_t mem_)
535 {
536 Memory mem;
537 mem.id = mem_.id;
538 return mem;
539 }
540
541 static legion_memory_kind_t
542 wrap(Memory::Kind options)
543 {
544 return static_cast<legion_memory_kind_t>(options);
545 }
546
547 static Memory::Kind
548 unwrap(legion_memory_kind_t options_)
549 {
550 return static_cast<Memory::Kind>(options_);
551 }
552
554 wrap(Mapping::Mapper::TaskSlice task_slice) {
555 legion_task_slice_t task_slice_;
556 task_slice_.domain = wrap(task_slice.domain);
557 task_slice_.proc = wrap(task_slice.proc);
558 task_slice_.recurse = task_slice.recurse;
559 task_slice_.stealable = task_slice.stealable;
560 return task_slice_;
561 }
562
563 static Mapping::Mapper::TaskSlice
564 unwrap(legion_task_slice_t task_slice_) {
565 Mapping::Mapper::TaskSlice task_slice;
566 task_slice.domain = unwrap(task_slice_.domain);
567 task_slice.proc = unwrap(task_slice_.proc);
568 task_slice.recurse = task_slice_.recurse;
569 task_slice.stealable = task_slice_.stealable;
570 return task_slice;
571 }
572
574 wrap(PhaseBarrier barrier) {
575 legion_phase_barrier_t barrier_;
576 barrier_.id = barrier.get_barrier().id;
577 barrier_.timestamp = barrier.get_barrier().timestamp;
578 return barrier_;
579 }
580
581 static PhaseBarrier
582 unwrap(legion_phase_barrier_t barrier_) {
583 PhaseBarrier barrier;
584 barrier.phase_barrier.id = barrier_.id;
585 barrier.phase_barrier.timestamp = barrier_.timestamp;
586 return barrier;
587 }
588
590 wrap(DynamicCollective collective) {
591 legion_dynamic_collective_t collective_;
592 collective_.id = collective.get_barrier().id;
593 collective_.timestamp = collective.get_barrier().timestamp;
594 collective_.redop = collective.redop;
595 return collective_;
596 }
597
598 static DynamicCollective
599 unwrap(legion_dynamic_collective_t collective_) {
600 DynamicCollective collective;
601 collective.phase_barrier.id = collective_.id;
602 collective.phase_barrier.timestamp = collective_.timestamp;
603 collective.redop = collective_.redop;
604 return collective;
605 }
606
608 wrap(Mapping::Mapper::TaskOptions& options) {
609 legion_task_options_t options_;
610 options_.initial_proc = CObjectWrapper::wrap(options.initial_proc);
611 options_.inline_task = options.inline_task;
612 options_.stealable = options.stealable;
613 options_.map_locally = options.map_locally;
614 options_.valid_instances = options.valid_instances;
615 options_.memoize = options.memoize;
616 options_.replicate = options.replicate;
617 options_.parent_priority = options.parent_priority;
618 return options_;
619 }
620
621 static Mapping::Mapper::TaskOptions
622 unwrap(legion_task_options_t& options_) {
623 Mapping::Mapper::TaskOptions options;
624 options.initial_proc = CObjectWrapper::unwrap(options_.initial_proc);
625 options.inline_task = options_.inline_task;
626 options.stealable = options_.stealable;
627 options.map_locally = options_.map_locally;
628 options.valid_instances = options_.valid_instances;
629 options.memoize = options_.memoize;
630 options.replicate = options_.replicate;
631 options.parent_priority = options_.parent_priority;
632 return options;
633 }
634
636 wrap(Mapping::Mapper::SliceTaskInput& input) {
638 input_.domain = CObjectWrapper::wrap(input.domain);
639 return input_;
640 }
641
643 wrap_const(const Mapping::Mapper::SliceTaskInput& input) {
645 input_.domain = CObjectWrapper::wrap(input.domain);
646 return input_;
647 }
648
649 static Mapping::Mapper::SliceTaskInput
650 unwrap(legion_slice_task_input_t& input_) {
651 Mapping::Mapper::SliceTaskInput input;
652 input.domain = CObjectWrapper::unwrap(input_.domain);
653 return input;
654 }
655 };
656
657 class CContext {
658 public:
659 CContext(Context _ctx)
660 : ctx(_ctx)
661 {}
662
663 CContext(Context _ctx, const std::vector<PhysicalRegion>& _physical_regions)
664 : ctx(_ctx)
665 , physical_regions(_physical_regions.size())
666 {
667 for (size_t i = 0; i < _physical_regions.size(); i++) {
668 physical_regions[i] =
669 CObjectWrapper::wrap(new PhysicalRegion(_physical_regions[i]));
670 }
671 }
672
673 ~CContext(void)
674 {
675 for (size_t i = 0; i < physical_regions.size(); i++) {
676 delete CObjectWrapper::unwrap(physical_regions[i]);
677 }
678 }
679
680 Context context(void) const
681 {
682 return ctx;
683 }
684
685 const legion_physical_region_t *regions(void) const
686 {
687 if(physical_regions.empty())
688 return 0;
689 else
690 return &physical_regions[0];
691 }
692
693 size_t num_regions(void) const
694 {
695 return physical_regions.size();
696 }
697
698 protected:
699 Context ctx;
700 std::vector<legion_physical_region_t> physical_regions;
701 };
702
703 class TaskMut : public Task {
704 public:
705 virtual ~TaskMut() {}
706 virtual UniqueID get_unique_id(void) const {
707 assert(false);
708 return 0;
709 }
710 virtual uint64_t get_context_index(void) const {
711 assert(false);
712 return 0;
713 }
714 virtual int get_depth(void) const {
715 assert(false);
716 return 0;
717 }
718 virtual const Task* get_parent_task(void) const {
719 assert(false);
720 return NULL;
721 }
722 virtual const std::string_view& get_provenance_string(
723 bool human=true) const {
724 assert(false);
725 return (*new std::string_view());
726 }
727 virtual bool has_parent_task(void) const {
728 assert(false);
729 return false;
730 }
731 virtual const char* get_task_name(void) const {
732 assert(false);
733 return NULL;
734 }
735 virtual Domain get_slice_domain(void) const {
736 assert(false);
737 return Domain::NO_DOMAIN;
738 }
739 virtual ShardID get_shard_id(void) const {
740 assert(false);
741 return 0;
742 }
743 virtual size_t get_total_shards(void) const {
744 assert(false);
745 return 1;
746 };
747 virtual DomainPoint get_shard_point(void) const {
748 assert(false);
749 return DomainPoint();
750 };
751 virtual Domain get_shard_domain(void) const {
752 assert(false);
753 return Domain();
754 }
755 };
756};
757
758#endif // __LEGION_C_UTIL_H__
Definition legion.h:563
Definition legion_c_util.h:657
Definition legion_c_util.h:53
Definition legion.h:4470
Definition legion_domain.h:351
Definition legion_domain.h:253
Definition legion_domain.h:132
Definition legion.h:2738
Definition legion.h:378
Definition legion.h:4587
Definition legion.h:1183
Definition legion.h:1397
Definition legion.h:4499
Definition legion.h:4328
Definition legion.h:2591
Definition legion.h:5037
Definition legion.h:656
Definition legion.h:5077
Definition legion.h:4399
Definition legion_c_util.h:703
#define ACCESSOR_ARRAY(DIM)
Definition legion_c.h:5186
Definition legion.h:4068
Definition legion.h:2212
Definition legion_c_util.h:221
Definition legion_c_util.h:42
Definition legion.h:1835
Definition legion.h:2171
Definition legion.h:2004
Definition legion.h:2304
Definition legion.h:1916
Definition legion.h:2064
Definition legion.h:1650
Definition legion.h:1775
Definition legion.h:4175
Definition legion.h:1078
Definition legion.h:875
Definition legion.h:4116
Definition legion.h:1547
Definition legion.h:2521
Definition legion_c.h:300
Definition legion_c.h:241
Definition legion_c.h:196
Definition legion_c.h:157
Definition legion_c.h:204
Definition legion_c.h:359
Definition legion_c.h:267
Definition legion_c.h:258
Definition legion_c.h:249
Definition legion_c.h:307
Definition legion_c.h:283
Definition legion_c.h:274
Definition legion_c.h:332
Definition legion_c.h:349
Definition legion_c.h:325
Definition legion_c.h:123
Definition legion_c.h:383
Definition legion_c.h:315
Definition legion_c.h:372
Definition legion_c.h:339
Definition legion_c.h:292