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