Legion Runtime
 All Classes Namespaces Files Functions Variables Typedefs Macros Pages
legion.h
Go to the documentation of this file.
1 /* Copyright 2023 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 // decide whether we want C and/or C++ bindings (default matches host language)
17 //
18 // each set of bindings has its own include-once ifdef armor, allowing the
19 // second set of bindings to be loaded even if the first already has been
20 #if !defined(LEGION_ENABLE_C_BINDINGS) && !defined(LEGION_DISABLE_C_BINDINGS)
21  #ifndef __cplusplus
22  #define LEGION_ENABLE_C_BINDINGS
23  #endif
24 #endif
25 #if !defined(LEGION_ENABLE_CXX_BINDINGS) && !defined(LEGION_DISABLE_CXX_BINDINGS)
26  #ifdef __cplusplus
27  #define LEGION_ENABLE_CXX_BINDINGS
28  #endif
29 #endif
30 
31 #ifdef LEGION_ENABLE_C_BINDINGS
32 #include "legion/legion_c.h"
33 #endif
34 
35 #ifdef LEGION_ENABLE_CXX_BINDINGS
36 #ifndef __LEGION_RUNTIME_H__
37 #define __LEGION_RUNTIME_H__
38 
52 #if __cplusplus < 201103L
53 #error "Legion requires C++11 as the minimum standard version"
54 #endif
55 
56 #include "legion/legion_types.h"
57 #include "legion/legion_domain.h"
58 #include "legion/legion_constraint.h"
59 #include "legion/legion_redop.h"
60 
61 #define LEGION_PRINT_ONCE(runtime, ctx, file, fmt, ...) \
62 { \
63  char message[4096]; \
64  snprintf(message, 4096, fmt, ##__VA_ARGS__); \
65  runtime->print_once(ctx, file, message); \
66 }
67 
68 // A guard macro that will exist until control replication is available
69 #define NO_LEGION_CONTROL_REPLICATION
70 
75 namespace Legion {
76 
77  //==========================================================================
78  // Data Description Classes
79  //==========================================================================
80 
88  class IndexSpace {
89  public:
90  static const IndexSpace NO_SPACE;
91  protected:
92  // Only the runtime should be allowed to make these
93  FRIEND_ALL_RUNTIME_CLASSES
94  IndexSpace(IndexSpaceID id, IndexTreeID tid, TypeTag tag);
95  public:
96  IndexSpace(void);
97  public:
98  inline bool operator==(const IndexSpace &rhs) const;
99  inline bool operator!=(const IndexSpace &rhs) const;
100  inline bool operator<(const IndexSpace &rhs) const;
101  inline bool operator>(const IndexSpace &rhs) const;
102  inline IndexSpaceID get_id(void) const { return id; }
103  inline IndexTreeID get_tree_id(void) const { return tid; }
104  inline bool exists(void) const { return (id != 0); }
105  inline TypeTag get_type_tag(void) const { return type_tag; }
106  inline int get_dim(void) const;
107  protected:
108  friend std::ostream& operator<<(std::ostream& os,
109  const IndexSpace& is);
110  IndexSpaceID id;
111  IndexTreeID tid;
112  TypeTag type_tag;
113  };
114 
121  template<int DIM, typename COORD_T = coord_t>
122  class IndexSpaceT : public IndexSpace {
123  private:
124  static_assert(DIM > 0, "DIM must be positive");
125  static_assert(std::is_integral<COORD_T>::value, "must be integral type");
126  protected:
127  // Only the runtime should be allowed to make these
128  FRIEND_ALL_RUNTIME_CLASSES
129  IndexSpaceT(IndexSpaceID id, IndexTreeID tid);
130  public:
131  IndexSpaceT(void);
132  explicit IndexSpaceT(const IndexSpace &rhs);
133  public:
134  inline IndexSpaceT& operator=(const IndexSpace &rhs);
135  };
136 
144  public:
145  static const IndexPartition NO_PART;
146  protected:
147  // Only the runtime should be allowed to make these
148  FRIEND_ALL_RUNTIME_CLASSES
149  IndexPartition(IndexPartitionID id, IndexTreeID tid, TypeTag tag);
150  public:
151  IndexPartition(void);
152  public:
153  inline bool operator==(const IndexPartition &rhs) const;
154  inline bool operator!=(const IndexPartition &rhs) const;
155  inline bool operator<(const IndexPartition &rhs) const;
156  inline bool operator>(const IndexPartition &rhs) const;
157  inline IndexPartitionID get_id(void) const { return id; }
158  inline IndexTreeID get_tree_id(void) const { return tid; }
159  inline bool exists(void) const { return (id != 0); }
160  inline TypeTag get_type_tag(void) const { return type_tag; }
161  inline int get_dim(void) const;
162  protected:
163  friend std::ostream& operator<<(std::ostream& os,
164  const IndexPartition& ip);
165  IndexPartitionID id;
166  IndexTreeID tid;
167  TypeTag type_tag;
168  };
169 
176  template<int DIM, typename COORD_T = coord_t>
178  private:
179  static_assert(DIM > 0, "DIM must be positive");
180  static_assert(std::is_integral<COORD_T>::value, "must be integral type");
181  protected:
182  // Only the runtime should be allowed to make these
183  FRIEND_ALL_RUNTIME_CLASSES
184  IndexPartitionT(IndexPartitionID id, IndexTreeID tid);
185  public:
186  IndexPartitionT(void);
187  explicit IndexPartitionT(const IndexPartition &rhs);
188  public:
189  inline IndexPartitionT& operator=(const IndexPartition &rhs);
190  };
191 
201  class FieldSpace {
202  public:
203  static const FieldSpace NO_SPACE;
204  protected:
205  // Only the runtime should be allowed to make these
206  FRIEND_ALL_RUNTIME_CLASSES
207  FieldSpace(FieldSpaceID id);
208  public:
209  FieldSpace(void);
210  public:
211  inline bool operator==(const FieldSpace &rhs) const;
212  inline bool operator!=(const FieldSpace &rhs) const;
213  inline bool operator<(const FieldSpace &rhs) const;
214  inline bool operator>(const FieldSpace &rhs) const;
215  inline FieldSpaceID get_id(void) const { return id; }
216  inline bool exists(void) const { return (id != 0); }
217  private:
218  friend std::ostream& operator<<(std::ostream& os, const FieldSpace& fs);
219  FieldSpaceID id;
220  };
221 
237  public:
238  static const LogicalRegion NO_REGION;
239  protected:
240  // Only the runtime should be allowed to make these
241  FRIEND_ALL_RUNTIME_CLASSES
242  LogicalRegion(RegionTreeID tid, IndexSpace index, FieldSpace field);
243  public:
244  LogicalRegion(void);
245  public:
246  inline bool operator==(const LogicalRegion &rhs) const;
247  inline bool operator!=(const LogicalRegion &rhs) const;
248  inline bool operator<(const LogicalRegion &rhs) const;
249  public:
250  inline IndexSpace get_index_space(void) const { return index_space; }
251  inline FieldSpace get_field_space(void) const { return field_space; }
252  inline RegionTreeID get_tree_id(void) const { return tree_id; }
253  inline bool exists(void) const { return (tree_id != 0); }
254  inline TypeTag get_type_tag(void) const
255  { return index_space.get_type_tag(); }
256  inline int get_dim(void) const { return index_space.get_dim(); }
257  protected:
258  friend std::ostream& operator<<(std::ostream& os,
259  const LogicalRegion& lr);
260  // These are private so the user can't just arbitrarily change them
261  RegionTreeID tree_id;
262  IndexSpace index_space;
263  FieldSpace field_space;
264  };
265 
272  template<int DIM, typename COORD_T = coord_t>
273  class LogicalRegionT : public LogicalRegion {
274  private:
275  static_assert(DIM > 0, "DIM must be positive");
276  static_assert(std::is_integral<COORD_T>::value, "must be integral type");
277  protected:
278  // Only the runtime should be allowed to make these
279  FRIEND_ALL_RUNTIME_CLASSES
280  LogicalRegionT(RegionTreeID tid, IndexSpace index, FieldSpace field);
281  public:
282  LogicalRegionT(void);
283  explicit LogicalRegionT(const LogicalRegion &rhs);
284  public:
285  inline LogicalRegionT& operator=(const LogicalRegion &rhs);
286  };
287 
304  public:
305  static const LogicalPartition NO_PART;
306  protected:
307  // Only the runtime should be allowed to make these
308  FRIEND_ALL_RUNTIME_CLASSES
309  LogicalPartition(RegionTreeID tid, IndexPartition pid, FieldSpace field);
310  public:
311  LogicalPartition(void);
312  public:
313  inline bool operator==(const LogicalPartition &rhs) const;
314  inline bool operator!=(const LogicalPartition &rhs) const;
315  inline bool operator<(const LogicalPartition &rhs) const;
316  public:
317  inline IndexPartition get_index_partition(void) const
318  { return index_partition; }
319  inline FieldSpace get_field_space(void) const { return field_space; }
320  inline RegionTreeID get_tree_id(void) const { return tree_id; }
321  inline bool exists(void) const { return (tree_id != 0); }
322  inline TypeTag get_type_tag(void) const
323  { return index_partition.get_type_tag(); }
324  inline int get_dim(void) const { return index_partition.get_dim(); }
325  protected:
326  friend std::ostream& operator<<(std::ostream& os,
327  const LogicalPartition& lp);
328  // These are private so the user can't just arbitrary change them
329  RegionTreeID tree_id;
330  IndexPartition index_partition;
331  FieldSpace field_space;
332  };
333 
340  template<int DIM, typename COORD_T = coord_t>
342  private:
343  static_assert(DIM > 0, "DIM must be positive");
344  static_assert(std::is_integral<COORD_T>::value, "must be integral type");
345  protected:
346  // Only the runtime should be allowed to make these
347  FRIEND_ALL_RUNTIME_CLASSES
348  LogicalPartitionT(RegionTreeID tid, IndexPartition pid, FieldSpace field);
349  public:
350  LogicalPartitionT(void);
351  explicit LogicalPartitionT(const LogicalPartition &rhs);
352  public:
353  inline LogicalPartitionT& operator=(const LogicalPartition &rhs);
354  };
355 
356  //==========================================================================
357  // Data Allocation Classes
358  //==========================================================================
359 
360 #ifdef __GNUC__
361 #pragma GCC diagnostic push
362 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
363 #endif
364 #ifdef __clang__
365 #pragma clang diagnostic push
366 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
367 #endif
368 
376  class LEGION_DEPRECATED("Use DomainPointIterator instead") IndexIterator {
377  public:
378  IndexIterator(void);
379  IndexIterator(const Domain &dom, ptr_t start = ptr_t());
380  IndexIterator(Runtime *rt, Context ctx,
381  IndexSpace space, ptr_t start = ptr_t());
382  IndexIterator(Runtime *rt, Context ctx,
383  LogicalRegion lr, ptr_t start = ptr_t());
385  IndexSpace space, ptr_t start = ptr_t());
386  IndexIterator(const IndexIterator &rhs);
387  ~IndexIterator(void);
388  public:
392  inline bool has_next(void) const;
397  inline ptr_t next(void);
403  inline ptr_t next_span(size_t& act_count,
404  size_t req_count = (size_t)-1LL);
405  public:
406  IndexIterator& operator=(const IndexIterator &rhs);
407  private:
408  Realm::IndexSpaceIterator<1,coord_t> is_iterator;
409  Realm::PointInRectIterator<1,coord_t> rect_iterator;
410  };
411 
429  class LEGION_DEPRECATED("Dynamic IndexAllocators are no longer supported")
430  IndexAllocator : public Unserializable<IndexAllocator> {
431  public:
432  IndexAllocator(void);
433  IndexAllocator(const IndexAllocator &allocator);
434  ~IndexAllocator(void);
435  protected:
436  FRIEND_ALL_RUNTIME_CLASSES
437  // Only the Runtime should be able to make these
438  IndexAllocator(IndexSpace space, IndexIterator iterator);
439  public:
440  IndexAllocator& operator=(const IndexAllocator &allocator);
441  inline bool operator<(const IndexAllocator &rhs) const;
442  inline bool operator==(const IndexAllocator &rhs) const;
443  public:
449  LEGION_DEPRECATED("Dynamic allocation is no longer supported")
450  ptr_t alloc(unsigned num_elements = 1);
456  LEGION_DEPRECATED("Dynamic allocation is no longer supported")
457  void free(ptr_t ptr, unsigned num_elements = 1);
462  inline IndexSpace get_index_space(void) const { return index_space; }
463  private:
464  IndexSpace index_space;
465  IndexIterator iterator;
466  };
467 #ifdef __GNUC__
468 #pragma GCC diagnostic pop
469 #endif
470 #ifdef __clang__
471 #pragma clang diagnostic pop
472 #endif
473 
490  class FieldAllocator : public Unserializable<FieldAllocator> {
491  public:
492  FieldAllocator(void);
493  FieldAllocator(const FieldAllocator &allocator);
494  FieldAllocator(FieldAllocator &&allocator);
495  ~FieldAllocator(void);
496  protected:
497  FRIEND_ALL_RUNTIME_CLASSES
498  // Only the Runtime should be able to make these
499  FieldAllocator(Internal::FieldAllocatorImpl *impl);
500  public:
501  FieldAllocator& operator=(const FieldAllocator &allocator);
502  FieldAllocator& operator=(FieldAllocator &&allocator);
503  inline bool operator<(const FieldAllocator &rhs) const;
504  inline bool operator==(const FieldAllocator &rhs) const;
505  public:
507 
526  FieldID allocate_field(size_t field_size,
527  FieldID desired_fieldid = LEGION_AUTO_GENERATE_ID,
528  CustomSerdezID serdez_id = 0,
529  bool local_field = false,
530  const char *provenance = NULL);
531  FieldID allocate_field(const Future &field_size,
532  FieldID desired_fieldid = LEGION_AUTO_GENERATE_ID,
533  CustomSerdezID serdez_id = 0,
534  bool local_field = false,
535  const char *provenance = NULL);
537 
545  void free_field(FieldID fid, const bool unordered = false,
546  const char *provenance = NULL);
547 
555  FieldID allocate_local_field(size_t field_size,
556  FieldID desired_fieldid = LEGION_AUTO_GENERATE_ID,
557  CustomSerdezID serdez_id = 0, const char *provenance = NULL);
559 
576  void allocate_fields(const std::vector<size_t> &field_sizes,
577  std::vector<FieldID> &resulting_fields,
578  CustomSerdezID serdez_id = 0,
579  bool local_fields = false,
580  const char *provenance = NULL);
581  void allocate_fields(const std::vector<Future> &field_sizes,
582  std::vector<FieldID> &resulting_fields,
583  CustomSerdezID serdez_id = 0,
584  bool local_fields = false,
585  const char *provenance = NULL);
587 
595  void free_fields(const std::set<FieldID> &to_free,
596  const bool unordered = false,
597  const char *provenance = NULL);
605  void allocate_local_fields(const std::vector<size_t> &field_sizes,
606  std::vector<FieldID> &resulting_fields,
607  CustomSerdezID serdez_id = 0,
608  const char *provenance = NULL);
612  FieldSpace get_field_space(void) const;
613  private:
614  Internal::FieldAllocatorImpl *impl;
615  };
616 
617  //==========================================================================
618  // Pass-By-Value Argument Classes
619  //==========================================================================
620 
629  class UntypedBuffer : public Unserializable<UntypedBuffer> {
630  public:
631  UntypedBuffer(void) : args(NULL), arglen(0) { }
632  UntypedBuffer(const void *arg, size_t argsize)
633  : args(const_cast<void*>(arg)), arglen(argsize) { }
634  UntypedBuffer(const UntypedBuffer &rhs)
635  : args(rhs.args), arglen(rhs.arglen) { }
636  public:
637  inline size_t get_size(void) const { return arglen; }
638  inline void* get_ptr(void) const { return args; }
639  public:
640  inline bool operator==(const UntypedBuffer &arg) const
641  { return (args == arg.args) && (arglen == arg.arglen); }
642  inline bool operator<(const UntypedBuffer &arg) const
643  { return (args < arg.args) && (arglen < arg.arglen); }
644  inline UntypedBuffer& operator=(const UntypedBuffer &rhs)
645  { args = rhs.args; arglen = rhs.arglen; return *this; }
646  private:
647  void *args;
648  size_t arglen;
649  };
650  // This typedef is here for backwards compatibility since we
651  // used to call an UntypedBuffer a TaskArgument
652  typedef UntypedBuffer TaskArgument;
653 
664  class ArgumentMap : public Unserializable<ArgumentMap> {
665  public:
666  ArgumentMap(void);
667  ArgumentMap(const FutureMap &rhs);
668  ArgumentMap(const ArgumentMap &rhs);
669  ArgumentMap(ArgumentMap &&rhs);
670  ~ArgumentMap(void);
671  public:
672  ArgumentMap& operator=(const FutureMap &rhs);
673  ArgumentMap& operator=(const ArgumentMap &rhs);
674  ArgumentMap& operator=(ArgumentMap &&rhs);
675  inline bool operator==(const ArgumentMap &rhs) const
676  { return (impl == rhs.impl); }
677  inline bool operator<(const ArgumentMap &rhs) const
678  { return (impl < rhs.impl); }
679  public:
685  bool has_point(const DomainPoint &point);
692  void set_point(const DomainPoint &point, const UntypedBuffer &arg,
693  bool replace = true);
700  void set_point(const DomainPoint &point, const Future &f,
701  bool replace = true);
707  bool remove_point(const DomainPoint &point);
715  UntypedBuffer get_point(const DomainPoint &point) const;
716  public:
725  template<typename PT, unsigned DIM>
726  inline void set_point_arg(const PT point[DIM], const UntypedBuffer &arg,
727  bool replace = false);
733  template<typename PT, unsigned DIM>
734  inline bool remove_point(const PT point[DIM]);
735  private:
736  FRIEND_ALL_RUNTIME_CLASSES
737  Internal::ArgumentMapImpl *impl;
738  private:
739  explicit ArgumentMap(Internal::ArgumentMapImpl *i);
740  };
741 
742  //==========================================================================
743  // Predicate Classes
744  //==========================================================================
745 
756  class Predicate : public Unserializable<Predicate> {
757  public:
758  static const Predicate TRUE_PRED;
759  static const Predicate FALSE_PRED;
760  public:
761  Predicate(void);
762  Predicate(const Predicate &p);
763  Predicate(Predicate &&p);
764  explicit Predicate(bool value);
765  ~Predicate(void);
766  protected:
767  FRIEND_ALL_RUNTIME_CLASSES
768  Internal::PredicateImpl *impl;
769  // Only the runtime should be allowed to make these
770  explicit Predicate(Internal::PredicateImpl *impl);
771  public:
772  Predicate& operator=(const Predicate &p);
773  Predicate& operator=(Predicate &&p);
774  inline bool operator==(const Predicate &p) const;
775  inline bool operator<(const Predicate &p) const;
776  inline bool operator!=(const Predicate &p) const;
777  private:
778  bool const_value;
779  };
780 
781  //==========================================================================
782  // Simultaneous Coherence Synchronization Classes
783  //==========================================================================
784 
814  class Lock {
815  public:
816  Lock(void);
817  protected:
818  // Only the runtime is allowed to make non-empty locks
819  FRIEND_ALL_RUNTIME_CLASSES
820  Lock(Reservation r);
821  public:
822  bool operator<(const Lock &rhs) const;
823  bool operator==(const Lock &rhs) const;
824  public:
825  void acquire(unsigned mode = 0, bool exclusive = true);
826  void release(void);
827  private:
828  Reservation reservation_lock;
829  };
830 
838  struct LockRequest {
839  public:
840  LockRequest(Lock l, unsigned mode = 0, bool exclusive = true);
841  public:
842  Lock lock;
843  unsigned mode;
844  bool exclusive;
845  };
846 
859  class Grant {
860  public:
861  Grant(void);
862  Grant(const Grant &g);
863  ~Grant(void);
864  protected:
865  // Only the runtime is allowed to make non-empty grants
866  FRIEND_ALL_RUNTIME_CLASSES
867  explicit Grant(Internal::GrantImpl *impl);
868  public:
869  bool operator==(const Grant &g) const
870  { return impl == g.impl; }
871  bool operator<(const Grant &g) const
872  { return impl < g.impl; }
873  Grant& operator=(const Grant &g);
874  protected:
875  Internal::GrantImpl *impl;
876  };
877 
906  class PhaseBarrier {
907  public:
908  PhaseBarrier(void);
909  protected:
910  // Only the runtime is allowed to make non-empty phase barriers
911  FRIEND_ALL_RUNTIME_CLASSES
913  public:
914  bool operator<(const PhaseBarrier &rhs) const;
915  bool operator==(const PhaseBarrier &rhs) const;
916  bool operator!=(const PhaseBarrier &rhs) const;
917  public:
918  void arrive(unsigned count = 1);
919  void wait(void);
920  void alter_arrival_count(int delta);
921  Realm::Barrier get_barrier(void) const { return phase_barrier; }
922  bool exists(void) const;
923  protected:
924  Internal::ApBarrier phase_barrier;
925  friend std::ostream& operator<<(std::ostream& os, const PhaseBarrier& pb);
926  };
927 
943  public:
944  DynamicCollective(void);
945  protected:
946  // Only the runtime is allowed to make non-empty dynamic collectives
947  FRIEND_ALL_RUNTIME_CLASSES
948  DynamicCollective(Internal::ApBarrier b, ReductionOpID redop);
949  public:
950  // All the same operations as a phase barrier
951  void arrive(const void *value, size_t size, unsigned count = 1);
952  protected:
953  ReductionOpID redop;
954  };
955 
956  //==========================================================================
957  // Operation Requirement Classes
958  //==========================================================================
959 
975  public:
976  RegionRequirement(void);
981  const std::set<FieldID> &privilege_fields,
982  const std::vector<FieldID> &instance_fields,
983  PrivilegeMode _priv, CoherenceProperty _prop,
984  LogicalRegion _parent, MappingTagID _tag = 0,
985  bool _verified = false);
989  RegionRequirement(LogicalPartition pid, ProjectionID _proj,
990  const std::set<FieldID> &privilege_fields,
991  const std::vector<FieldID> &instance_fields,
992  PrivilegeMode _priv, CoherenceProperty _prop,
993  LogicalRegion _parent, MappingTagID _tag = 0,
994  bool _verified = false);
998  RegionRequirement(LogicalRegion _handle, ProjectionID _proj,
999  const std::set<FieldID> &privilege_fields,
1000  const std::vector<FieldID> &instance_fields,
1001  PrivilegeMode _priv, CoherenceProperty _prop,
1002  LogicalRegion _parent, MappingTagID _tag = 0,
1003  bool _verified = false);
1009  const std::set<FieldID> &privilege_fields,
1010  const std::vector<FieldID> &instance_fields,
1011  ReductionOpID op, CoherenceProperty _prop,
1012  LogicalRegion _parent, MappingTagID _tag = 0,
1013  bool _verified = false);
1017  RegionRequirement(LogicalPartition pid, ProjectionID _proj,
1018  const std::set<FieldID> &privilege_fields,
1019  const std::vector<FieldID> &instance_fields,
1020  ReductionOpID op, CoherenceProperty _prop,
1021  LogicalRegion _parent, MappingTagID _tag = 0,
1022  bool _verified = false);
1026  RegionRequirement(LogicalRegion _handle, ProjectionID _proj,
1027  const std::set<FieldID> &privilege_fields,
1028  const std::vector<FieldID> &instance_fields,
1029  ReductionOpID op, CoherenceProperty _prop,
1030  LogicalRegion _parent, MappingTagID _tag = 0,
1031  bool _verified = false);
1032  public:
1033  // Analogous constructors without the privilege and instance fields
1034  RegionRequirement(LogicalRegion _handle, PrivilegeMode _priv,
1035  CoherenceProperty _prop, LogicalRegion _parent,
1036  MappingTagID _tag = 0, bool _verified = false);
1037  RegionRequirement(LogicalPartition pid, ProjectionID _proj,
1038  PrivilegeMode _priv, CoherenceProperty _prop,
1039  LogicalRegion _parent, MappingTagID _tag = 0,
1040  bool _verified = false);
1041  RegionRequirement(LogicalRegion _handle, ProjectionID _proj,
1042  PrivilegeMode _priv, CoherenceProperty _prop,
1043  LogicalRegion _parent, MappingTagID _tag = 0,
1044  bool _verified = false);
1045  RegionRequirement(LogicalRegion _handle, ReductionOpID op,
1046  CoherenceProperty _prop, LogicalRegion _parent,
1047  MappingTagID _tag = 0, bool _verified = false);
1048  RegionRequirement(LogicalPartition pid, ProjectionID _proj,
1049  ReductionOpID op, CoherenceProperty _prop,
1050  LogicalRegion _parent, MappingTagID _tag = 0,
1051  bool _verified = false);
1052  RegionRequirement(LogicalRegion _handle, ProjectionID _proj,
1053  ReductionOpID op, CoherenceProperty _prop,
1054  LogicalRegion _parent, MappingTagID _tag = 0,
1055  bool _verified = false);
1056  public:
1058  ~RegionRequirement(void);
1059  RegionRequirement& operator=(const RegionRequirement &req);
1060  public:
1061  bool operator==(const RegionRequirement &req) const;
1062  bool operator<(const RegionRequirement &req) const;
1063  public:
1069  inline RegionRequirement& add_field(FieldID fid, bool instance = true);
1070  inline RegionRequirement& add_fields(const std::vector<FieldID>& fids,
1071  bool instance = true);
1072 
1073  inline RegionRequirement& add_flags(RegionFlags new_flags);
1074  public:
1075  inline bool is_verified(void) const
1076  { return (flags & LEGION_VERIFIED_FLAG); }
1077  inline bool is_no_access(void) const
1078  { return (flags & LEGION_NO_ACCESS_FLAG); }
1079  inline bool is_restricted(void) const
1080  { return (flags & LEGION_RESTRICTED_FLAG); }
1081  inline bool must_premap(void) const
1082  { return (flags & LEGION_MUST_PREMAP_FLAG); }
1083  public:
1084  const void* get_projection_args(size_t *size) const;
1085  void set_projection_args(const void *args, size_t size, bool own = false);
1086  public:
1087 #ifdef LEGION_PRIVILEGE_CHECKS
1088  unsigned get_accessor_privilege(void) const;
1089 #endif
1090  bool has_field_privilege(FieldID fid) const;
1091  public:
1092  // Fields used for controlling task launches
1095  std::set<FieldID> privilege_fields;
1096  std::vector<FieldID> instance_fields;
1097  PrivilegeMode privilege;
1098  CoherenceProperty prop;
1100  ReductionOpID redop;
1101  MappingTagID tag;
1102  RegionFlags flags;
1103  public:
1104  ProjectionType handle_type;
1105  ProjectionID projection;
1106  protected:
1109  };
1110 
1119  public:
1120  IndexSpace handle;
1121  AllocateMode privilege;
1122  IndexSpace parent;
1123  bool verified;
1124  public:
1125  IndexSpaceRequirement(void);
1127  AllocateMode _priv,
1128  IndexSpace _parent,
1129  bool _verified = false);
1130  public:
1131  bool operator<(const IndexSpaceRequirement &req) const;
1132  bool operator==(const IndexSpaceRequirement &req) const;
1133  };
1134 
1147  public:
1148  FieldSpace handle;
1149  AllocateMode privilege;
1150  bool verified;
1151  public:
1152  FieldSpaceRequirement(void);
1154  AllocateMode _priv,
1155  bool _verified = false);
1156  public:
1157  bool operator<(const FieldSpaceRequirement &req) const;
1158  bool operator==(const FieldSpaceRequirement &req) const;
1159  };
1160 
1161  //==========================================================================
1162  // Future Value Classes
1163  //==========================================================================
1164 
1183  class Future : public Unserializable<Future> {
1184  public:
1185  Future(void);
1186  Future(const Future &f);
1187  Future(Future &&f);
1188  ~Future(void);
1189  private:
1190  Internal::FutureImpl *impl;
1191  protected:
1192  // Only the runtime should be allowed to make these
1193  FRIEND_ALL_RUNTIME_CLASSES
1194  explicit Future(Internal::FutureImpl *impl,
1195  bool need_reference = true);
1196  public:
1197  bool operator==(const Future &f) const
1198  { return impl == f.impl; }
1199  bool operator<(const Future &f) const
1200  { return impl < f.impl; }
1201  Future& operator=(const Future &f);
1202  Future& operator=(Future &&f);
1203  public:
1212  template<typename T>
1213  inline T get_result(bool silence_warnings = false,
1214  const char *warning_string = NULL) const;
1220  void get_void_result(bool silence_warnings = false,
1221  const char *warning_string = NULL) const;
1233  bool is_empty(bool block = false, bool silence_warnings = false,
1234  const char *warning_string = NULL) const;
1242  bool is_ready(bool subscribe = false) const;
1243  public:
1257  template<typename T>
1258  inline const T& get_reference(bool silence_warnings = false,
1259  const char *warning_string = NULL) const;
1270  inline const void* get_untyped_pointer(bool silence_warnings = false,
1271  const char *warning_string = NULL) const;
1275  size_t get_untyped_size(void) const;
1276  public:
1277  // These methods provide partial support the C++ future interface
1278  template<typename T>
1279  inline T get(void);
1280 
1281  inline bool valid(void) const;
1282 
1283  inline void wait(void) const;
1284  public:
1290  template<typename T>
1291  static inline Future from_value(Runtime *rt, const T &value);
1292 
1297  static inline Future from_untyped_pointer(Runtime *rt,
1298  const void *buffer,
1299  size_t bytes);
1300  private:
1301  void* get_untyped_result(bool silence_warnings,
1302  const char *warning_string,
1303  bool check_size, size_t future_size = 0) const;
1304  };
1305 
1319  class FutureMap : public Unserializable<FutureMap> {
1320  public:
1321  FutureMap(void);
1322  FutureMap(const FutureMap &map);
1323  FutureMap(FutureMap &&map);
1324  ~FutureMap(void);
1325  private:
1326  Internal::FutureMapImpl *impl;
1327  protected:
1328  // Only the runtime should be allowed to make these
1329  FRIEND_ALL_RUNTIME_CLASSES
1330  explicit FutureMap(Internal::FutureMapImpl *impl,
1331  bool need_reference = true);
1332  public:
1333  inline bool operator==(const FutureMap &f) const
1334  { return impl == f.impl; }
1335  inline bool operator<(const FutureMap &f) const
1336  { return impl < f.impl; }
1337  inline Future operator[](const DomainPoint &point) const
1338  { return get_future(point); }
1339  FutureMap& operator=(const FutureMap &f);
1340  FutureMap& operator=(FutureMap &&f);
1341  public:
1350  template<typename T>
1351  inline T get_result(const DomainPoint &point,
1352  bool silence_warnings = false,
1353  const char *warning_string = NULL) const;
1361  Future get_future(const DomainPoint &point) const;
1369  void get_void_result(const DomainPoint &point,
1370  bool silence_warnings = false,
1371  const char *warning_string = NULL) const;
1372  public:
1380  template<typename RT, typename PT, unsigned DIM>
1381  inline RT get_result(const PT point[DIM]) const;
1390  template<typename PT, unsigned DIM>
1391  inline Future get_future(const PT point[DIM]) const;
1397  template<typename PT, unsigned DIM>
1398  inline void get_void_result(const PT point[DIM]) const;
1399  public:
1406  void wait_all_results(bool silence_warnings = false,
1407  const char *warning_string = NULL) const;
1408  };
1409 
1410 
1411  //==========================================================================
1412  // Operation Launcher Classes
1413  //==========================================================================
1414 
1423  struct StaticDependence : public Unserializable<StaticDependence> {
1424  public:
1425  StaticDependence(void);
1426  StaticDependence(unsigned previous_offset,
1427  unsigned previous_req_index,
1428  unsigned current_req_index,
1429  DependenceType dtype,
1430  bool validates = false,
1431  bool shard_only = false);
1432  public:
1433  inline void add_field(FieldID fid);
1434  public:
1435  // The relative offset from this operation to
1436  // previous operation in the stream of operations
1437  // (e.g. 1 is the operation launched immediately before)
1438  unsigned previous_offset;
1439  // Region requirement of the previous operation for the dependence
1440  unsigned previous_req_index;
1441  // Region requirement of the current operation for the dependence
1442  unsigned current_req_index;
1443  // The type of the dependence
1444  DependenceType dependence_type;
1445  // Whether this requirement validates the previous writer
1446  bool validates;
1447  // Whether this dependence is a shard-only dependence for
1448  // control replication or it depends on all other copies
1449  bool shard_only;
1450  // Fields that have the dependence
1451  std::set<FieldID> dependent_fields;
1452  };
1453 
1461  struct TaskLauncher {
1462  public:
1463  TaskLauncher(void);
1464  TaskLauncher(TaskID tid,
1465  UntypedBuffer arg,
1466  Predicate pred = Predicate::TRUE_PRED,
1467  MapperID id = 0,
1468  MappingTagID tag = 0,
1469  UntypedBuffer map_arg = UntypedBuffer(),
1470  const char *provenance = "");
1471  public:
1472  inline IndexSpaceRequirement&
1473  add_index_requirement(const IndexSpaceRequirement &req);
1474  inline RegionRequirement&
1475  add_region_requirement(const RegionRequirement &req);
1476  inline void add_field(unsigned idx, FieldID fid, bool inst = true);
1477  public:
1478  inline void add_future(Future f);
1479  inline void add_grant(Grant g);
1480  inline void add_wait_barrier(PhaseBarrier bar);
1481  inline void add_arrival_barrier(PhaseBarrier bar);
1482  inline void add_wait_handshake(LegionHandshake handshake);
1483  inline void add_arrival_handshake(LegionHandshake handshake);
1484  public:
1485  inline void set_predicate_false_future(Future f);
1486  inline void set_predicate_false_result(UntypedBuffer arg);
1487  public:
1488  inline void set_independent_requirements(bool independent);
1489  public:
1490  TaskID task_id;
1491  std::vector<IndexSpaceRequirement> index_requirements;
1492  std::vector<RegionRequirement> region_requirements;
1493  std::vector<Future> futures;
1494  std::vector<Grant> grants;
1495  std::vector<PhaseBarrier> wait_barriers;
1496  std::vector<PhaseBarrier> arrive_barriers;
1497  UntypedBuffer argument;
1498  Predicate predicate;
1499  MapperID map_id;
1500  MappingTagID tag;
1501  UntypedBuffer map_arg;
1502  DomainPoint point;
1503  // Only used in control replication contexts for
1504  // doing sharding. If left unspecified the runtime
1505  // will use an index space of size 1 containing 'point'
1506  IndexSpace sharding_space;
1507  public:
1508  // If the predicate is set to anything other than
1509  // Predicate::TRUE_PRED, then the application must
1510  // specify a value for the future in the case that
1511  // the predicate resolves to false. UntypedBuffer(NULL,0)
1512  // can be used if the task's return type is void.
1513  Future predicate_false_future;
1514  UntypedBuffer predicate_false_result;
1515  public:
1516  // Provenance string for the runtime and tools to use
1517  std::string provenance;
1518  public:
1519  // Inform the runtime about any static dependences
1520  // These will be ignored outside of static traces
1521  const std::vector<StaticDependence> *static_dependences;
1522  public:
1523  // Users can tell the runtime this task is eligible
1524  // for inlining by the mapper. This will invoke the
1525  // select_task_options call inline as part of the launch
1526  // logic for this task to allow the mapper to decide
1527  // whether to inline the task or not. Note that if the
1528  // mapper pre-empts during execution then resuming it
1529  // may take a long time if another long running task
1530  // gets scheduled on the processor that launched this task.
1531  bool enable_inlining;
1532  public:
1533  // In some cases users (most likely compilers) will want
1534  // to run a light-weight function (e.g. a continuation)
1535  // as a task that just depends on futures once those futures
1536  // are ready on a local processor where the parent task
1537  // is executing. We call this a local function task and it
1538  // must not have any region requirements. It must als be a
1539  // pure function with no side effects. This task will
1540  // not have the option of being distributed to remote nodes.
1541  bool local_function_task;
1542  public:
1543  // Users can inform the runtime that all region requirements
1544  // are independent of each other in this task. Independent
1545  // means that either field sets are independent or region
1546  // requirements are disjoint based on the region tree.
1547  bool independent_requirements;
1548  public:
1549  // Instruct the runtime that it does not need to produce
1550  // a future or future map result for this index task
1551  bool elide_future_return;
1552  public:
1553  bool silence_warnings;
1554  };
1555 
1565  public:
1566  IndexTaskLauncher(void);
1567  IndexTaskLauncher(TaskID tid,
1568  Domain domain,
1569  UntypedBuffer global_arg,
1570  ArgumentMap map,
1571  Predicate pred = Predicate::TRUE_PRED,
1572  bool must = false,
1573  MapperID id = 0,
1574  MappingTagID tag = 0,
1575  UntypedBuffer map_arg = UntypedBuffer(),
1576  const char *provenance = "");
1577  IndexTaskLauncher(TaskID tid,
1578  IndexSpace launch_space,
1579  UntypedBuffer global_arg,
1580  ArgumentMap map,
1581  Predicate pred = Predicate::TRUE_PRED,
1582  bool must = false,
1583  MapperID id = 0,
1584  MappingTagID tag = 0,
1585  UntypedBuffer map_arg = UntypedBuffer(),
1586  const char *provenance = "");
1587  public:
1588  inline IndexSpaceRequirement&
1589  add_index_requirement(const IndexSpaceRequirement &req);
1590  inline RegionRequirement&
1591  add_region_requirement(const RegionRequirement &req);
1592  inline void add_field(unsigned idx, FieldID fid, bool inst = true);
1593  public:
1594  inline void add_future(Future f);
1595  inline void add_grant(Grant g);
1596  inline void add_wait_barrier(PhaseBarrier bar);
1597  inline void add_arrival_barrier(PhaseBarrier bar);
1598  inline void add_wait_handshake(LegionHandshake handshake);
1599  inline void add_arrival_handshake(LegionHandshake handshake);
1600  public:
1601  inline void set_predicate_false_future(Future f);
1602  inline void set_predicate_false_result(UntypedBuffer arg);
1603  public:
1604  inline void set_independent_requirements(bool independent);
1605  public:
1606  TaskID task_id;
1607  Domain launch_domain;
1608  IndexSpace launch_space;
1609  // Will only be used in control replication context. If left
1610  // unset the runtime will use launch_domain/launch_space
1611  IndexSpace sharding_space;
1612  std::vector<IndexSpaceRequirement> index_requirements;
1613  std::vector<RegionRequirement> region_requirements;
1614  std::vector<Future> futures;
1615  // These are appended to the futures for the point
1616  // task after the futures sent to all points above
1617  std::vector<ArgumentMap> point_futures;
1618  std::vector<Grant> grants;
1619  std::vector<PhaseBarrier> wait_barriers;
1620  std::vector<PhaseBarrier> arrive_barriers;
1621  UntypedBuffer global_arg;
1622  ArgumentMap argument_map;
1623  Predicate predicate;
1624  bool must_parallelism;
1625  MapperID map_id;
1626  MappingTagID tag;
1627  UntypedBuffer map_arg;
1628  public:
1629  // If the predicate is set to anything other than
1630  // Predicate::TRUE_PRED, then the application must
1631  // specify a value for the future in the case that
1632  // the predicate resolves to false. UntypedBuffer(NULL,0)
1633  // can be used if the task's return type is void.
1634  Future predicate_false_future;
1635  UntypedBuffer predicate_false_result;
1636  public:
1637  // Provenance string for the runtime and tools to use
1638  std::string provenance;
1639  public:
1640  // Inform the runtime about any static dependences
1641  // These will be ignored outside of static traces
1642  const std::vector<StaticDependence> *static_dependences;
1643  public:
1644  // Users can tell the runtime this task is eligible
1645  // for inlining by the mapper. This will invoke the
1646  // select_task_options call inline as part of the launch
1647  // logic for this task to allow the mapper to decide
1648  // whether to inline the task or not. Note that if the
1649  // mapper pre-empts during execution then resuming it
1650  // may take a long time if another long running task
1651  // gets scheduled on the processor that launched this task.
1652  bool enable_inlining;
1653  public:
1654  // Users can inform the runtime that all region requirements
1655  // are independent of each other in this task. Independent
1656  // means that either field sets are independent or region
1657  // requirements are disjoint based on the region tree.
1658  bool independent_requirements;
1659  public:
1660  // Instruct the runtime that it does not need to produce
1661  // a future or future map result for this index task
1662  bool elide_future_return;
1663  public:
1664  bool silence_warnings;
1665  };
1666 
1676  public:
1677  InlineLauncher(void);
1678  InlineLauncher(const RegionRequirement &req,
1679  MapperID id = 0,
1680  MappingTagID tag = 0,
1681  LayoutConstraintID layout_id = 0,
1682  UntypedBuffer map_arg = UntypedBuffer(),
1683  const char *provenance = "");
1684  public:
1685  inline void add_field(FieldID fid, bool inst = true);
1686  public:
1687  inline void add_grant(Grant g);
1688  inline void add_wait_barrier(PhaseBarrier bar);
1689  inline void add_arrival_barrier(PhaseBarrier bar);
1690  inline void add_wait_handshake(LegionHandshake handshake);
1691  inline void add_arrival_handshake(LegionHandshake handshake);
1692  public:
1693  RegionRequirement requirement;
1694  std::vector<Grant> grants;
1695  std::vector<PhaseBarrier> wait_barriers;
1696  std::vector<PhaseBarrier> arrive_barriers;
1697  MapperID map_id;
1698  MappingTagID tag;
1699  UntypedBuffer map_arg;
1700  public:
1701  LayoutConstraintID layout_constraint_id;
1702  public:
1703  // Provenance string for the runtime and tools to use
1704  std::string provenance;
1705  public:
1706  // Inform the runtime about any static dependences
1707  // These will be ignored outside of static traces
1708  const std::vector<StaticDependence> *static_dependences;
1709  };
1710 
1735  struct CopyLauncher {
1736  public:
1737  CopyLauncher(Predicate pred = Predicate::TRUE_PRED,
1738  MapperID id = 0, MappingTagID tag = 0,
1739  UntypedBuffer map_arg = UntypedBuffer(),
1740  const char *provenance = "");
1741  public:
1742  inline unsigned add_copy_requirements(const RegionRequirement &src,
1743  const RegionRequirement &dst);
1744  inline void add_src_field(unsigned idx, FieldID fid, bool inst = true);
1745  inline void add_dst_field(unsigned idx, FieldID fid, bool inst = true);
1746  public:
1747  // Specify src/dst indirect requirements (must have exactly 1 field)
1748  inline void add_src_indirect_field(FieldID src_idx_fid,
1749  const RegionRequirement &src_idx_req,
1750  bool is_range_indirection = false,
1751  bool inst = true);
1752  inline void add_dst_indirect_field(FieldID dst_idx_fid,
1753  const RegionRequirement &dst_idx_req,
1754  bool is_range_indirection = false,
1755  bool inst = true);
1756  inline RegionRequirement& add_src_indirect_field(
1757  const RegionRequirement &src_idx_req,
1758  bool is_range_indirection = false);
1759  inline RegionRequirement& add_dst_indirect_field(
1760  const RegionRequirement &dst_idx_req,
1761  bool is_range_indirection = false);
1762  public:
1763  inline void add_grant(Grant g);
1764  inline void add_wait_barrier(PhaseBarrier bar);
1765  inline void add_arrival_barrier(PhaseBarrier bar);
1766  inline void add_wait_handshake(LegionHandshake handshake);
1767  inline void add_arrival_handshake(LegionHandshake handshake);
1768  public:
1769  std::vector<RegionRequirement> src_requirements;
1770  std::vector<RegionRequirement> dst_requirements;
1771  std::vector<RegionRequirement> src_indirect_requirements;
1772  std::vector<RegionRequirement> dst_indirect_requirements;
1773  std::vector<bool> src_indirect_is_range;
1774  std::vector<bool> dst_indirect_is_range;
1775  std::vector<Grant> grants;
1776  std::vector<PhaseBarrier> wait_barriers;
1777  std::vector<PhaseBarrier> arrive_barriers;
1778  Predicate predicate;
1779  MapperID map_id;
1780  MappingTagID tag;
1781  UntypedBuffer map_arg;
1782  DomainPoint point;
1783  // Only used in control replication contexts for
1784  // doing sharding. If left unspecified the runtime
1785  // will use an index space of size 1 containing 'point'
1786  IndexSpace sharding_space;
1787  public:
1788  // Provenance string for the runtime and tools to use
1789  std::string provenance;
1790  public:
1791  // Inform the runtime about any static dependences
1792  // These will be ignored outside of static traces
1793  const std::vector<StaticDependence> *static_dependences;
1794  public:
1795  // Whether the source and destination indirections can lead
1796  // to out-of-range access into the instances to skip
1797  bool possible_src_indirect_out_of_range;
1798  bool possible_dst_indirect_out_of_range;
1799  // Whether the destination indirection can lead to aliasing
1800  // in the destination instances requiring synchronization
1801  bool possible_dst_indirect_aliasing;
1802  public:
1803  bool silence_warnings;
1804  };
1805 
1817  public:
1818  IndexCopyLauncher(void);
1819  IndexCopyLauncher(Domain domain, Predicate pred = Predicate::TRUE_PRED,
1820  MapperID id = 0, MappingTagID tag = 0,
1821  UntypedBuffer map_arg = UntypedBuffer(),
1822  const char *provenance = "");
1823  IndexCopyLauncher(IndexSpace space, Predicate pred = Predicate::TRUE_PRED,
1824  MapperID id = 0, MappingTagID tag = 0,
1825  UntypedBuffer map_arg = UntypedBuffer(),
1826  const char *provenance = "");
1827  public:
1828  inline unsigned add_copy_requirements(const RegionRequirement &src,
1829  const RegionRequirement &dst);
1830  inline void add_src_field(unsigned idx, FieldID fid, bool inst = true);
1831  inline void add_dst_field(unsigned idx, FieldID fid, bool inst = true);
1832  public:
1833  // Specify src/dst indirect requirements (must have exactly 1 field)
1834  inline void add_src_indirect_field(FieldID src_idx_fid,
1835  const RegionRequirement &src_idx_req,
1836  bool is_range_indirection = false,
1837  bool inst = true);
1838  inline void add_dst_indirect_field(FieldID dst_idx_fid,
1839  const RegionRequirement &dst_idx_req,
1840  bool is_range_indirection = false,
1841  bool inst = true);
1842  inline RegionRequirement& add_src_indirect_field(
1843  const RegionRequirement &src_idx_req,
1844  bool is_range_indirection = false);
1845  inline RegionRequirement& add_dst_indirect_field(
1846  const RegionRequirement &dst_idx_req,
1847  bool is_range_indirection = false);
1848  public:
1849  inline void add_grant(Grant g);
1850  inline void add_wait_barrier(PhaseBarrier bar);
1851  inline void add_arrival_barrier(PhaseBarrier bar);
1852  inline void add_wait_handshake(LegionHandshake handshake);
1853  inline void add_arrival_handshake(LegionHandshake handshake);
1854  public:
1855  std::vector<RegionRequirement> src_requirements;
1856  std::vector<RegionRequirement> dst_requirements;
1857  std::vector<RegionRequirement> src_indirect_requirements;
1858  std::vector<RegionRequirement> dst_indirect_requirements;
1859  std::vector<bool> src_indirect_is_range;
1860  std::vector<bool> dst_indirect_is_range;
1861  std::vector<Grant> grants;
1862  std::vector<PhaseBarrier> wait_barriers;
1863  std::vector<PhaseBarrier> arrive_barriers;
1864  Domain launch_domain;
1865  IndexSpace launch_space;
1866  // Will only be used in control replication context. If left
1867  // unset the runtime will use launch_domain/launch_space
1868  IndexSpace sharding_space;
1869  Predicate predicate;
1870  MapperID map_id;
1871  MappingTagID tag;
1872  UntypedBuffer map_arg;
1873  public:
1874  // Provenance string for the runtime and tools to use
1875  std::string provenance;
1876  public:
1877  // Inform the runtime about any static dependences
1878  // These will be ignored outside of static traces
1879  const std::vector<StaticDependence> *static_dependences;
1880  public:
1881  // Whether the source and destination indirections can lead
1882  // to out-of-range access into the instances to skip
1883  bool possible_src_indirect_out_of_range;
1884  bool possible_dst_indirect_out_of_range;
1885  // Whether the destination indirection can lead to aliasing
1886  // in the destination instances requiring synchronization
1887  bool possible_dst_indirect_aliasing;
1888  // Whether the individual point copies should operate collectively
1889  // together in the case of indirect copies (e.g. allow indirections
1890  // to refer to instances from other points). These settings have
1891  // no effect in the case of copies without indirections.
1892  bool collective_src_indirect_points;
1893  bool collective_dst_indirect_points;
1894  public:
1895  bool silence_warnings;
1896  };
1897 
1904  struct FillLauncher {
1905  public:
1906  FillLauncher(void);
1907  FillLauncher(LogicalRegion handle, LogicalRegion parent,
1908  UntypedBuffer arg, Predicate pred = Predicate::TRUE_PRED,
1909  MapperID id = 0, MappingTagID tag = 0,
1910  UntypedBuffer map_arg = UntypedBuffer(),
1911  const char *provenance = "");
1912  FillLauncher(LogicalRegion handle, LogicalRegion parent,
1913  Future f, Predicate pred = Predicate::TRUE_PRED,
1914  MapperID id = 0, MappingTagID tag = 0,
1915  UntypedBuffer map_arg = UntypedBuffer(),
1916  const char *provenance = "");
1917  public:
1918  inline void set_argument(UntypedBuffer arg);
1919  inline void set_future(Future f);
1920  inline void add_field(FieldID fid);
1921  inline void add_grant(Grant g);
1922  inline void add_wait_barrier(PhaseBarrier bar);
1923  inline void add_arrival_barrier(PhaseBarrier bar);
1924  inline void add_wait_handshake(LegionHandshake handshake);
1925  inline void add_arrival_handshake(LegionHandshake handshake);
1926  public:
1927  LogicalRegion handle;
1928  LogicalRegion parent;
1929  UntypedBuffer argument;
1930  Future future;
1931  Predicate predicate;
1932  std::set<FieldID> fields;
1933  std::vector<Grant> grants;
1934  std::vector<PhaseBarrier> wait_barriers;
1935  std::vector<PhaseBarrier> arrive_barriers;
1936  MapperID map_id;
1937  MappingTagID tag;
1938  UntypedBuffer map_arg;
1939  DomainPoint point;
1940  // Only used in control replication contexts for
1941  // doing sharding. If left unspecified the runtime
1942  // will use an index space of size 1 containing 'point'
1943  IndexSpace sharding_space;
1944  public:
1945  // Provenance string for the runtime and tools to use
1946  std::string provenance;
1947  public:
1948  // Inform the runtime about any static dependences
1949  // These will be ignored outside of static traces
1950  const std::vector<StaticDependence> *static_dependences;
1951  public:
1952  bool silence_warnings;
1953  };
1954 
1965  public:
1966  IndexFillLauncher(void);
1967  // Region projection
1968  IndexFillLauncher(Domain domain, LogicalRegion handle,
1969  LogicalRegion parent, UntypedBuffer arg,
1970  ProjectionID projection = 0,
1971  Predicate pred = Predicate::TRUE_PRED,
1972  MapperID id = 0, MappingTagID tag = 0,
1973  UntypedBuffer map_arg = UntypedBuffer(),
1974  const char *provenance = "");
1975  IndexFillLauncher(Domain domain, LogicalRegion handle,
1976  LogicalRegion parent, Future f,
1977  ProjectionID projection = 0,
1978  Predicate pred = Predicate::TRUE_PRED,
1979  MapperID id = 0, MappingTagID tag = 0,
1980  UntypedBuffer map_arg = UntypedBuffer(),
1981  const char *provenance = "");
1983  LogicalRegion parent, UntypedBuffer arg,
1984  ProjectionID projection = 0,
1985  Predicate pred = Predicate::TRUE_PRED,
1986  MapperID id = 0, MappingTagID tag = 0,
1987  UntypedBuffer map_arg = UntypedBuffer(),
1988  const char *provenance = "");
1990  LogicalRegion parent, Future f,
1991  ProjectionID projection = 0,
1992  Predicate pred = Predicate::TRUE_PRED,
1993  MapperID id = 0, MappingTagID tag = 0,
1994  UntypedBuffer map_arg = UntypedBuffer(),
1995  const char *provenance = "");
1996  // Partition projection
1997  IndexFillLauncher(Domain domain, LogicalPartition handle,
1998  LogicalRegion parent, UntypedBuffer arg,
1999  ProjectionID projection = 0,
2000  Predicate pred = Predicate::TRUE_PRED,
2001  MapperID id = 0, MappingTagID tag = 0,
2002  UntypedBuffer map_arg = UntypedBuffer(),
2003  const char *provenance = "");
2004  IndexFillLauncher(Domain domain, LogicalPartition handle,
2005  LogicalRegion parent, Future f,
2006  ProjectionID projection = 0,
2007  Predicate pred = Predicate::TRUE_PRED,
2008  MapperID id = 0, MappingTagID tag = 0,
2009  UntypedBuffer map_arg = UntypedBuffer(),
2010  const char *provenance = "");
2012  LogicalRegion parent, UntypedBuffer arg,
2013  ProjectionID projection = 0,
2014  Predicate pred = Predicate::TRUE_PRED,
2015  MapperID id = 0, MappingTagID tag = 0,
2016  UntypedBuffer map_arg = UntypedBuffer(),
2017  const char *provenance = "");
2019  LogicalRegion parent, Future f,
2020  ProjectionID projection = 0,
2021  Predicate pred = Predicate::TRUE_PRED,
2022  MapperID id = 0, MappingTagID tag = 0,
2023  UntypedBuffer map_arg = UntypedBuffer(),
2024  const char *provenance = "");
2025  public:
2026  inline void set_argument(UntypedBuffer arg);
2027  inline void set_future(Future f);
2028  inline void add_field(FieldID fid);
2029  inline void add_grant(Grant g);
2030  inline void add_wait_barrier(PhaseBarrier bar);
2031  inline void add_arrival_barrier(PhaseBarrier bar);
2032  inline void add_wait_handshake(LegionHandshake handshake);
2033  inline void add_arrival_handshake(LegionHandshake handshake);
2034  public:
2035  Domain launch_domain;
2036  IndexSpace launch_space;
2037  // Will only be used in control replication context. If left
2038  // unset the runtime will use launch_domain/launch_space
2039  IndexSpace sharding_space;
2040  LogicalRegion region;
2041  LogicalPartition partition;
2042  LogicalRegion parent;
2043  ProjectionID projection;
2044  UntypedBuffer argument;
2045  Future future;
2046  Predicate predicate;
2047  std::set<FieldID> fields;
2048  std::vector<Grant> grants;
2049  std::vector<PhaseBarrier> wait_barriers;
2050  std::vector<PhaseBarrier> arrive_barriers;
2051  MapperID map_id;
2052  MappingTagID tag;
2053  UntypedBuffer map_arg;
2054  public:
2055  // Provenance string for the runtime and tools to use
2056  std::string provenance;
2057  public:
2058  // Inform the runtime about any static dependences
2059  // These will be ignored outside of static traces
2060  const std::vector<StaticDependence> *static_dependences;
2061  public:
2062  bool silence_warnings;
2063  };
2064 
2076  public:
2077  AttachLauncher(ExternalResource resource,
2078  LogicalRegion handle, LogicalRegion parent,
2079  const bool restricted = true,
2080  const bool mapped = true);
2081  public:
2082  inline void attach_file(const char *file_name,
2083  const std::vector<FieldID> &fields,
2084  LegionFileMode mode);
2085  inline void attach_hdf5(const char *file_name,
2086  const std::map<FieldID,const char*> &field_map,
2087  LegionFileMode mode);
2088  // Helper methods for AOS and SOA arrays, but it is totally
2089  // acceptable to fill in the layout constraint set manually
2090  inline void attach_array_aos(void *base, bool column_major,
2091  const std::vector<FieldID> &fields,
2092  Memory memory = Memory::NO_MEMORY,
2093  const std::map<FieldID,size_t> *alignments = NULL);
2094  inline void attach_array_soa(void *base, bool column_major,
2095  const std::vector<FieldID> &fields,
2096  Memory memory = Memory::NO_MEMORY,
2097  const std::map<FieldID,size_t> *alignments = NULL);
2098  public:
2099  ExternalResource resource;
2100  LogicalRegion handle;
2101  LogicalRegion parent;
2102  // Whether this instance will be restricted when attached
2103  bool restricted /*= true*/;
2104  // Whether this region should be mapped by the calling task
2105  bool mapped; /*= true*/
2106  public:
2107  // Provenance string for the runtime and tools to use
2108  std::string provenance;
2109  public:
2110  // Data for files
2111  const char *file_name;
2112  LegionFileMode mode;
2113  std::vector<FieldID> file_fields; // normal files
2114  std::map<FieldID,/*file name*/const char*> field_files; // hdf5 files
2115  public:
2116  // Data for external instances
2117  LayoutConstraintSet constraints;
2118  std::set<FieldID> privilege_fields;
2119  public:
2120  // Optional footprint of the instance in memory in bytes
2121  size_t footprint;
2122  public:
2123  // Inform the runtime about any static dependences
2124  // These will be ignored outside of static traces
2125  const std::vector<StaticDependence> *static_dependences;
2126  };
2127 
2135  public:
2136  IndexAttachLauncher(ExternalResource resource,
2137  LogicalRegion parent,
2138  const bool restricted = true);
2139  public:
2140  inline void attach_file(LogicalRegion handle,
2141  const char *file_name,
2142  const std::vector<FieldID> &fields,
2143  LegionFileMode mode);
2144  inline void attach_hdf5(LogicalRegion handle,
2145  const char *file_name,
2146  const std::map<FieldID,const char*> &field_map,
2147  LegionFileMode mode);
2148  // Helper methods for AOS and SOA arrays, but it is totally
2149  // acceptable to fill in the layout constraint set manually
2150  inline void attach_array_aos(LogicalRegion handle,
2151  void *base, bool column_major,
2152  const std::vector<FieldID> &fields,
2153  Memory memory = Memory::NO_MEMORY,
2154  const std::map<FieldID,size_t> *alignments = NULL);
2155  inline void attach_array_soa(LogicalRegion handle,
2156  void *base, bool column_major,
2157  const std::vector<FieldID> &fields,
2158  Memory memory = Memory::NO_MEMORY,
2159  const std::map<FieldID,size_t> *alignments = NULL);
2160  public:
2161  ExternalResource resource;
2162  std::vector<LogicalRegion> handles;
2163  LogicalRegion parent;
2164  // Whether these instances will be restricted when attached
2165  bool restricted /*= true*/;
2166  // Whether the runtime should check for duplicate resources across the
2167  // shards in a control replicated context, it is illegal to pass in the
2168  // same resource to different shards if this is set to false
2169  bool deduplicate_across_shards;
2170  public:
2171  // Provenance string for the runtime and tools to use
2172  std::string provenance;
2173  public:
2174  // Data for files
2175  LegionFileMode mode;
2176  std::vector<const char*> file_names;
2177  std::vector<FieldID> file_fields; // normal files
2178  std::map<FieldID,
2179  std::vector</*file name*/const char*> > field_files; // hdf5 files
2180  public:
2181  // Data for external instances
2182  LayoutConstraintSet constraints;
2183  std::vector<PointerConstraint> pointers;
2184  std::set<FieldID> privilege_fields;
2185  public:
2186  // Optional footprint of the instance in memory in bytes
2187  std::vector<size_t> footprint;
2188  public:
2189  // Inform the runtime about any static dependences
2190  // These will be ignored outside of static traces
2191  const std::vector<StaticDependence> *static_dependences;
2192  };
2193 
2201  public:
2202  explicit PredicateLauncher(bool and_op = true);
2203  public:
2204  inline void add_predicate(const Predicate &pred);
2205  public:
2206  bool and_op; // if not 'and' then 'or'
2207  std::vector<Predicate> predicates;
2208  std::string provenance;
2209  };
2210 
2217  public:
2218  TimingLauncher(TimingMeasurement measurement);
2219  public:
2220  inline void add_precondition(const Future &f);
2221  public:
2222  TimingMeasurement measurement;
2223  std::set<Future> preconditions;
2224  public:
2225  // Provenance string for the runtime and tools to use
2226  std::string provenance;
2227  };
2228 
2235  public:
2236  TunableLauncher(TunableID tid,
2237  MapperID mapper = 0,
2238  MappingTagID tag = 0);
2239  public:
2240  TunableID tunable;
2241  MapperID mapper;
2242  MappingTagID tag;
2243  UntypedBuffer arg;
2244  std::vector<Future> futures;
2245  public:
2246  // Provenance string for the runtime and tools to use
2247  std::string provenance;
2248  };
2249 
2250  //==========================================================================
2251  // Task Variant Registrars
2252  //==========================================================================
2253 
2265  public:
2268  const char *layout_name = NULL);
2269  public:
2271  add_constraint(const SpecializedConstraint &constraint);
2273  add_constraint(const MemoryConstraint &constraint);
2275  add_constraint(const OrderingConstraint &constraint);
2277  add_constraint(const SplittingConstraint &constraint);
2279  add_constraint(const FieldConstraint &constraint);
2281  add_constraint(const DimensionConstraint &constraint);
2283  add_constraint(const AlignmentConstraint &constraint);
2285  add_constraint(const OffsetConstraint &constraint);
2287  add_constraint(const PointerConstraint &constraint);
2288  public:
2289  FieldSpace handle;
2290  LayoutConstraintSet layout_constraints;
2291  const char* layout_name;
2292  };
2293 
2303  public:
2304  TaskVariantRegistrar(void);
2305  TaskVariantRegistrar(TaskID task_id, bool global = true,
2306  const char *variant_name = NULL);
2307  TaskVariantRegistrar(TaskID task_id, const char *variant_name,
2308  bool global = true);
2309  public: // Add execution constraints
2310  inline TaskVariantRegistrar&
2311  add_constraint(const ISAConstraint &constraint);
2312  inline TaskVariantRegistrar&
2313  add_constraint(const ProcessorConstraint &constraint);
2314  inline TaskVariantRegistrar&
2315  add_constraint(const ResourceConstraint &constraint);
2316  inline TaskVariantRegistrar&
2317  add_constraint(const LaunchConstraint &constraint);
2318  inline TaskVariantRegistrar&
2319  add_constraint(const ColocationConstraint &constraint);
2320  public: // Add layout constraint sets
2321  inline TaskVariantRegistrar&
2322  add_layout_constraint_set(unsigned index, LayoutConstraintID desc);
2323  public: // Set properties
2324  inline void set_leaf(bool is_leaf = true);
2325  inline void set_inner(bool is_inner = true);
2326  inline void set_idempotent(bool is_idempotent = true);
2327  inline void set_replicable(bool is_replicable = true);
2328  public: // Generator Task IDs
2329  inline void add_generator_task(TaskID tid);
2330  public:
2331  TaskID task_id;
2332  bool global_registration;
2333  const char* task_variant_name;
2334  public: // constraints
2335  ExecutionConstraintSet execution_constraints;
2336  TaskLayoutConstraintSet layout_constraints;
2337  public:
2338  // TaskIDs for which this variant can serve as a generator
2339  std::set<TaskID> generator_tasks;
2340  public: // properties
2341  bool leaf_variant;
2342  bool inner_variant;
2343  bool idempotent_variant;
2344  bool replicable_variant;
2345  };
2346 
2347  //==========================================================================
2348  // Physical Data Classes
2349  //==========================================================================
2350 
2359  class PhysicalRegion : public Unserializable<PhysicalRegion> {
2360  public:
2361  PhysicalRegion(void);
2362  PhysicalRegion(const PhysicalRegion &rhs);
2364  ~PhysicalRegion(void);
2365  private:
2366  Internal::PhysicalRegionImpl *impl;
2367  protected:
2368  FRIEND_ALL_RUNTIME_CLASSES
2369  explicit PhysicalRegion(Internal::PhysicalRegionImpl *impl);
2370  public:
2371  PhysicalRegion& operator=(const PhysicalRegion &rhs);
2372  PhysicalRegion& operator=(PhysicalRegion &&rhs);
2373  inline bool operator==(const PhysicalRegion &reg) const
2374  { return (impl == reg.impl); }
2375  inline bool operator<(const PhysicalRegion &reg) const
2376  { return (impl < reg.impl); }
2377  public:
2381  bool is_mapped(void) const;
2389  void wait_until_valid(bool silence_warnings = false,
2390  const char *warning_string = NULL);
2397  bool is_valid(void) const;
2401  LogicalRegion get_logical_region(void) const;
2405  PrivilegeMode get_privilege(void) const;
2413  LEGION_DEPRECATED("All accessors in the LegionRuntime::Accessor "
2414  "namespace are now deprecated. FieldAccessor "
2415  "from the Legion namespace should be used now.")
2416  LegionRuntime::Accessor::RegionAccessor<
2417  LegionRuntime::Accessor::AccessorType::Generic>
2418  get_accessor(bool silence_warnings = false) const;
2427  LEGION_DEPRECATED("All accessors in the LegionRuntime::Accessor "
2428  "namespace are now deprecated. FieldAccessor "
2429  "from the Legion namespace should be used now.")
2430  LegionRuntime::Accessor::RegionAccessor<
2431  LegionRuntime::Accessor::AccessorType::Generic>
2432  get_field_accessor(FieldID field,
2433  bool silence_warnings = false) const;
2437  void get_memories(std::set<Memory>& memories,
2438  bool silence_warnings = false,
2439  const char *warning_string = NULL) const;
2443  void get_fields(std::vector<FieldID>& fields) const;
2444  public:
2445  template<int DIM, typename COORD_T>
2446  DomainT<DIM,COORD_T> get_bounds(void) const;
2447  // We'll also allow this to implicitly cast to a realm index space
2448  // so that users can easily iterate over the points
2449  template<int DIM, typename COORD_T>
2450  operator DomainT<DIM,COORD_T>(void) const;
2451  // They can implicitly cast to a rectangle if there is no
2452  // sparsity map, runtime will check for this
2453  template<int DIM, typename COORD_T>
2454  operator Rect<DIM,COORD_T>(void) const;
2455  protected:
2456  // These methods can only be accessed by accessor classes
2457  template<PrivilegeMode, typename, int, typename, typename, bool>
2458  friend class FieldAccessor;
2459  template<typename, bool, int, typename, typename, bool>
2460  friend class ReductionAccessor;
2461  template<typename, int, typename, typename, bool, bool, int>
2462  friend class MultiRegionAccessor;
2463  template<typename, int, typename, typename>
2464  friend class UnsafeFieldAccessor;
2465  template<typename, PrivilegeMode>
2466  friend class ArraySyntax::AccessorRefHelper;
2467  template<typename>
2468  friend class ArraySyntax::AffineRefHelper;
2469  friend class PieceIterator;
2470  template<PrivilegeMode, typename, int, typename>
2471  friend class SpanIterator;
2472  template<typename, int, typename>
2473  friend class UnsafeSpanIterator;
2474  Realm::RegionInstance get_instance_info(PrivilegeMode mode,
2475  FieldID fid, size_t field_size,
2476  void *realm_is, TypeTag type_tag,
2477  const char *warning_string,
2478  bool silence_warnings,
2479  bool generic_accessor,
2480  bool check_field_size,
2481  ReductionOpID redop = 0) const;
2482  Realm::RegionInstance get_instance_info(PrivilegeMode mode,
2483  const std::vector<PhysicalRegion> &other_regions,
2484  FieldID fid, size_t field_size,
2485  void *realm_is, TypeTag type_tag,
2486  const char *warning_string,
2487  bool silence_warnings,
2488  bool generic_accessor,
2489  bool check_field_size,
2490  bool need_bounds,
2491  ReductionOpID redop = 0) const;
2492  void report_incompatible_accessor(const char *accessor_kind,
2493  Realm::RegionInstance instance, FieldID fid) const;
2494  void report_incompatible_multi_accessor(unsigned index, FieldID fid,
2495  Realm::RegionInstance inst1,
2496  Realm::RegionInstance inst2) const;
2497  void report_colocation_violation(const char *accessor_kind, FieldID fid,
2498  Realm::RegionInstance inst1,
2499  Realm::RegionInstance inst2,
2500  const PhysicalRegion &other,
2501  bool reduction = false) const;
2502  static void empty_colocation_regions(const char *accessor_kind,
2503  FieldID fid, bool reduction = false);
2504  static void fail_bounds_check(DomainPoint p, FieldID fid,
2505  PrivilegeMode mode, bool multi = false);
2506  static void fail_bounds_check(Domain d, FieldID fid,
2507  PrivilegeMode mode, bool multi = false);
2508  static void fail_privilege_check(DomainPoint p, FieldID fid,
2509  PrivilegeMode mode);
2510  static void fail_privilege_check(Domain d, FieldID fid,
2511  PrivilegeMode mode);
2512  protected:
2513  void get_bounds(void *realm_is, TypeTag type_tag) const;
2514  };
2515 
2523  class ExternalResources : public Unserializable<ExternalResources> {
2524  public:
2525  ExternalResources(void);
2528  ~ExternalResources(void);
2529  private:
2530  Internal::ExternalResourcesImpl *impl;
2531  protected:
2532  FRIEND_ALL_RUNTIME_CLASSES
2533  explicit ExternalResources(Internal::ExternalResourcesImpl *impl);
2534  public:
2535  ExternalResources& operator=(const ExternalResources &rhs);
2536  ExternalResources& operator=(ExternalResources &&rhs);
2537  inline bool operator==(const ExternalResources &reg) const
2538  { return (impl == reg.impl); }
2539  inline bool operator<(const ExternalResources &reg) const
2540  { return (impl < reg.impl); }
2541  public:
2542  size_t size(void) const;
2543  PhysicalRegion operator[](unsigned index) const;
2544  };
2545 
2583  template<PrivilegeMode MODE, typename FT, int N, typename COORD_T = coord_t,
2584  typename A = Realm::GenericAccessor<FT,N,COORD_T>,
2585 #ifdef LEGION_BOUNDS_CHECKS
2586  bool CHECK_BOUNDS = true>
2587 #else
2588  bool CHECK_BOUNDS = false>
2589 #endif
2591  private:
2592  static_assert(N > 0, "N must be positive");
2593  static_assert(std::is_integral<COORD_T>::value, "must be integral type");
2594  public:
2595  FieldAccessor(void) { }
2596  FieldAccessor(const PhysicalRegion &region, FieldID fid,
2597  // The actual field size in case it is different from the
2598  // one being used in FT and we still want to check it
2599  size_t actual_field_size = sizeof(FT),
2600 #ifdef DEBUG_LEGION
2601  bool check_field_size = true,
2602 #else
2603  bool check_field_size = false,
2604 #endif
2605  bool silence_warnings = false,
2606  const char *warning_string = NULL,
2607  size_t subfield_offset = 0) { }
2608  // For Realm::AffineAccessor specializations there are additional
2609  // methods for creating accessors with limited bounding boxes and
2610  // affine transformations for using alternative coordinates spaces
2611  // Specify a specific bounds rectangle to use for the accessor
2612  FieldAccessor(const PhysicalRegion &region, FieldID fid,
2613  const Rect<N,COORD_T> bounds,
2614  // The actual field size in case it is different from the
2615  // one being used in FT and we still want to check it
2616  size_t actual_field_size = sizeof(FT),
2617 #ifdef DEBUG_LEGION
2618  bool check_field_size = true,
2619 #else
2620  bool check_field_size = false,
2621 #endif
2622  bool silence_warnings = false,
2623  const char *warning_string = NULL,
2624  size_t subfield_offset = 0) { }
2625  // Specify a specific Affine transform to use for interpreting points
2626  // Not avalable for Realm::MultiAffineAccessor specializations
2627  template<int M>
2628  FieldAccessor(const PhysicalRegion &region, FieldID fid,
2629  const AffineTransform<M,N,COORD_T> transform,
2630  // The actual field size in case it is different from the
2631  // one being used in FT and we still want to check it
2632  size_t actual_field_size = sizeof(FT),
2633 #ifdef DEBUG_LEGION
2634  bool check_field_size = true,
2635 #else
2636  bool check_field_size = false,
2637 #endif
2638  bool silence_warnings = false,
2639  const char *warning_string = NULL,
2640  size_t subfield_offset = 0) { }
2641  // Specify both a transform and a bounds to use
2642  // Not avalable for Realm::MultiAffineAccessor specializations
2643  template<int M>
2644  FieldAccessor(const PhysicalRegion &region, FieldID fid,
2645  const AffineTransform<M,N,COORD_T> transform,
2646  const Rect<N,COORD_T> bounds,
2647  // The actual field size in case it is different from the
2648  // one being used in FT and we still want to check it
2649  size_t actual_field_size = sizeof(FT),
2650 #ifdef DEBUG_LEGION
2651  bool check_field_size = true,
2652 #else
2653  bool check_field_size = false,
2654 #endif
2655  bool silence_warnings = false,
2656  const char *warning_string = NULL,
2657  size_t subfield_offset = 0) { }
2658  public:
2659  // Variations of the above four methods but with multiple physical
2660  // regions specified using input iterators for colocation regions
2661  // Colocation regions from [start, stop)
2662  template<typename InputIterator>
2663  FieldAccessor(InputIterator start_region,
2664  InputIterator stop_region, FieldID fid,
2665  // The actual field size in case it is different from the
2666  // one being used in FT and we still want to check it
2667  size_t actual_field_size = sizeof(FT),
2668 #ifdef DEBUG_LEGION
2669  bool check_field_size = true,
2670 #else
2671  bool check_field_size = false,
2672 #endif
2673  bool silence_warnings = false,
2674  const char *warning_string = NULL,
2675  size_t subfield_offset = 0) { }
2676  // For Realm::AffineAccessor specializations there are additional
2677  // methods for creating accessors with limited bounding boxes and
2678  // affine transformations for using alternative coordinates spaces
2679  // Specify a specific bounds rectangle to use for the accessor
2680  // Colocation regions from [start, stop)
2681  template<typename InputIterator>
2682  FieldAccessor(InputIterator start_region,
2683  InputIterator stop_region, FieldID fid,
2684  const Rect<N,COORD_T> bounds,
2685  // The actual field size in case it is different from the
2686  // one being used in FT and we still want to check it
2687  size_t actual_field_size = sizeof(FT),
2688 #ifdef DEBUG_LEGION
2689  bool check_field_size = true,
2690 #else
2691  bool check_field_size = false,
2692 #endif
2693  bool silence_warnings = false,
2694  const char *warning_string = NULL,
2695  size_t subfield_offset = 0) { }
2696  // Specify a specific Affine transform to use for interpreting points
2697  // Not avalable for Realm::MultiAffineAccessor specializations
2698  // Colocation regions from [start, stop)
2699  template<typename InputIterator, int M>
2700  FieldAccessor(InputIterator start_region,
2701  InputIterator stop_region, FieldID fid,
2702  const AffineTransform<M,N,COORD_T> transform,
2703  // The actual field size in case it is different from the
2704  // one being used in FT and we still want to check it
2705  size_t actual_field_size = sizeof(FT),
2706 #ifdef DEBUG_LEGION
2707  bool check_field_size = true,
2708 #else
2709  bool check_field_size = false,
2710 #endif
2711  bool silence_warnings = false,
2712  const char *warning_string = NULL,
2713  size_t subfield_offset = 0) { }
2714  // Specify both a transform and a bounds to use
2715  // Not avalable for Realm::MultiAffineAccessor specializations
2716  // Colocation regions from [start, stop)
2717  template<typename InputIterator, int M>
2718  FieldAccessor(InputIterator start_region,
2719  InputIterator stop_region, FieldID fid,
2720  const AffineTransform<M,N,COORD_T> transform,
2721  const Rect<N,COORD_T> bounds,
2722  // The actual field size in case it is different from the
2723  // one being used in FT and we still want to check it
2724  size_t actual_field_size = sizeof(FT),
2725 #ifdef DEBUG_LEGION
2726  bool check_field_size = true,
2727 #else
2728  bool check_field_size = false,
2729 #endif
2730  bool silence_warnings = false,
2731  const char *warning_string = NULL,
2732  size_t subfield_offset = 0) { }
2733  public:
2734  // Create a FieldAccessor for an UntypedDeferredValue
2735  // (only with AffineAccessors)
2736  FieldAccessor(const UntypedDeferredValue &value,
2737  // The actual field size in case it is different from the
2738  // one being used in FT and we still want to check it
2739  size_t actual_field_size = sizeof(FT),
2740 #ifdef DEBUG_LEGION
2741  bool check_field_size = true,
2742 #else
2743  bool check_field_size = false,
2744 #endif
2745  bool silence_warnings = false,
2746  const char *warning_string = NULL,
2747  size_t subfield_offset = 0) { }
2748  // Create a FieldAccessor for an UntypedDeferredValue
2749  // Specify a specific bounds rectangle to use for the accessor
2750  // (only with AffineAccessors)
2751  FieldAccessor(const UntypedDeferredValue &value,
2752  const Rect<N,COORD_T> &bounds,
2753  // The actual field size in case it is different from the
2754  // one being used in FT and we still want to check it
2755  size_t actual_field_size = sizeof(FT),
2756 #ifdef DEBUG_LEGION
2757  bool check_field_size = true,
2758 #else
2759  bool check_field_size = false,
2760 #endif
2761  bool silence_warnings = false,
2762  const char *warning_string = NULL,
2763  size_t subfield_offset = 0) { }
2764  public:
2765  // Create a FieldAccessor for UntypedDeferredBuffer
2766  // (only with AffineAccessors)
2768  // The actual field size in case it is different from the
2769  // one being used in FT and we still want to check it
2770  size_t actual_field_size = sizeof(FT),
2771 #ifdef DEBUG_LEGION
2772  bool check_field_size = true,
2773 #else
2774  bool check_field_size = false,
2775 #endif
2776  bool silence_warnings = false,
2777  const char *warning_string = NULL,
2778  size_t subfield_offset = 0) { }
2779  // Create a FieldAccessor for UntypedDeferredBuffer
2780  // Specify a specific bounds rectangle to use for the accessor
2781  // (only with AffineAccessors)
2783  const Rect<N,COORD_T> &bounds,
2784  // The actual field size in case it is different from the
2785  // one being used in FT and we still want to check it
2786  size_t actual_field_size = sizeof(FT),
2787 #ifdef DEBUG_LEGION
2788  bool check_field_size = true,
2789 #else
2790  bool check_field_size = false,
2791 #endif
2792  bool silence_warnings = false,
2793  const char *warning_string = NULL,
2794  size_t subfield_offset = 0) { }
2795  // Create a FieldAccessor for UntypedDeferredBuffer
2796  // Specify a specific Affine transform to use for interpreting points
2797  // (only with AffineAccessors)
2798  template<int M>
2800  const AffineTransform<M,N,COORD_T> &transform,
2801  // The actual field size in case it is different from the
2802  // one being used in FT and we still want to check it
2803  size_t actual_field_size = sizeof(FT),
2804 #ifdef DEBUG_LEGION
2805  bool check_field_size = true,
2806 #else
2807  bool check_field_size = false,
2808 #endif
2809  bool silence_warnings = false,
2810  const char *warning_string = NULL,
2811  size_t subfield_offset = 0) { }
2812  // Create a FieldAccessor for UntypedDeferredBuffer
2813  // Specify both a transform and a bounds to use
2814  // (only with AffineAccessors)
2815  template<int M>
2817  const AffineTransform<M,N,COORD_T> &transform,
2818  const Rect<N,COORD_T> &bounds,
2819  // The actual field size in case it is different from the
2820  // one being used in FT and we still want to check it
2821  size_t actual_field_size = sizeof(FT),
2822 #ifdef DEBUG_LEGION
2823  bool check_field_size = true,
2824 #else
2825  bool check_field_size = false,
2826 #endif
2827  bool silence_warnings = false,
2828  const char *warning_string = NULL,
2829  size_t subfield_offset = 0) { }
2830  public:
2831  typedef FT value_type;
2832  typedef FT& reference;
2833  typedef const FT& const_reference;
2834  static const int dim = N;
2835  };
2836 
2849  template<typename REDOP, bool EXCLUSIVE, int N, typename COORD_T = coord_t,
2850  typename A = Realm::GenericAccessor<typename REDOP::RHS,N,COORD_T>,
2851 #ifdef LEGION_BOUNDS_CHECKS
2852  bool CHECK_BOUNDS = true>
2853 #else
2854  bool CHECK_BOUNDS = false>
2855 #endif
2857  private:
2858  static_assert(N > 0, "N must be positive");
2859  static_assert(std::is_integral<COORD_T>::value, "must be integral type");
2860  public:
2861  ReductionAccessor(void) { }
2862  ReductionAccessor(const PhysicalRegion &region, FieldID fid,
2863  ReductionOpID redop, bool silence_warnings = false,
2864  const char *warning_string = NULL,
2865  size_t subfield_offset = 0,
2866  size_t actual_field_size = sizeof(typename REDOP::RHS),
2867 #ifdef DEBUG_LEGION
2868  bool check_field_size = true
2869 #else
2870  bool check_field_size = false
2871 #endif
2872  ) { }
2873  // For Realm::AffineAccessor specializations there are additional
2874  // methods for creating accessors with limited bounding boxes and
2875  // affine transformations for using alternative coordinates spaces
2876  // Specify a specific bounds rectangle to use for the accessor
2877  ReductionAccessor(const PhysicalRegion &region, FieldID fid,
2878  ReductionOpID redop,
2879  const Rect<N,COORD_T> bounds,
2880  bool silence_warnings = false,
2881  const char *warning_string = NULL,
2882  size_t subfield_offset = 0,
2883  size_t actual_field_size = sizeof(typename REDOP::RHS),
2884 #ifdef DEBUG_LEGION
2885  bool check_field_size = true
2886 #else
2887  bool check_field_size = false
2888 #endif
2889  ) { }
2890  // Specify a specific Affine transform to use for interpreting points
2891  // Not available for Realm::MultiAffineAccessor specializations
2892  template<int M>
2893  ReductionAccessor(const PhysicalRegion &region, FieldID fid,
2894  ReductionOpID redop,
2895  const AffineTransform<M,N,COORD_T> transform,
2896  bool silence_warnings = false,
2897  const char *warning_string = NULL,
2898  size_t subfield_offset = 0,
2899  size_t actual_field_size = sizeof(typename REDOP::RHS),
2900 #ifdef DEBUG_LEGION
2901  bool check_field_size = true
2902 #else
2903  bool check_field_size = false
2904 #endif
2905  ) { }
2906  // Specify both a transform and a bounds to use
2907  // Not available for Realm::MultiAffineAccessor specializations
2908  template<int M>
2909  ReductionAccessor(const PhysicalRegion &region, FieldID fid,
2910  ReductionOpID redop,
2911  const AffineTransform<M,N,COORD_T> transform,
2912  const Rect<N,COORD_T> bounds,
2913  bool silence_warnings = false,
2914  const char *warning_string = NULL,
2915  size_t subfield_offset = 0,
2916  size_t actual_field_size = sizeof(typename REDOP::RHS),
2917 #ifdef DEBUG_LEGION
2918  bool check_field_size = true
2919 #else
2920  bool check_field_size = false
2921 #endif
2922  ) { }
2923  public:
2924  // Variations of the same four methods above but with multiple
2925  // physical regions specified using input iterators for colocation regions
2926  // Colocation regions from [start, stop)
2927  template<typename InputIterator>
2928  ReductionAccessor(InputIterator start_region,
2929  InputIterator stop_region, FieldID fid,
2930  ReductionOpID redop, bool silence_warnings = false,
2931  const char *warning_string = NULL,
2932  size_t subfield_offset = 0,
2933  size_t actual_field_size = sizeof(typename REDOP::RHS),
2934 #ifdef DEBUG_LEGION
2935  bool check_field_size = true
2936 #else
2937  bool check_field_size = false
2938 #endif
2939  ) { }
2940  // For Realm::AffineAccessor specializations there are additional
2941  // methods for creating accessors with limited bounding boxes and
2942  // affine transformations for using alternative coordinates spaces
2943  // Specify a specific bounds rectangle to use for the accessor
2944  // Colocation regions from [start, stop)
2945  template<typename InputIterator>
2946  ReductionAccessor(InputIterator start_region,
2947  InputIterator stop_region, FieldID fid,
2948  ReductionOpID redop,
2949  const Rect<N,COORD_T> bounds,
2950  bool silence_warnings = false,
2951  const char *warning_string = NULL,
2952  size_t subfield_offset = 0,
2953  size_t actual_field_size = sizeof(typename REDOP::RHS),
2954 #ifdef DEBUG_LEGION
2955  bool check_field_size = true
2956 #else
2957  bool check_field_size = false
2958 #endif
2959  ) { }
2960  // Specify a specific Affine transform to use for interpreting points
2961  // Not available for Realm::MultiAffineAccessor specializations
2962  // Colocation regions from [start, stop)
2963  template<typename InputIterator, int M>
2964  ReductionAccessor(InputIterator start_region,
2965  InputIterator stop_region, FieldID fid,
2966  ReductionOpID redop,
2967  const AffineTransform<M,N,COORD_T> transform,
2968  bool silence_warnings = false,
2969  const char *warning_string = NULL,
2970  size_t subfield_offset = 0,
2971  size_t actual_field_size = sizeof(typename REDOP::RHS),
2972 #ifdef DEBUG_LEGION
2973  bool check_field_size = true
2974 #else
2975  bool check_field_size = false
2976 #endif
2977  ) { }
2978  // Specify both a transform and a bounds to use
2979  // Not available for Realm::MultiAffineAccessor specializations
2980  // Colocation regions from [start, stop)
2981  template<typename InputIterator, int M>
2982  ReductionAccessor(InputIterator start_region,
2983  InputIterator stop_region, FieldID fid,
2984  ReductionOpID redop,
2985  const AffineTransform<M,N,COORD_T> transform,
2986  const Rect<N,COORD_T> bounds,
2987  bool silence_warnings = false,
2988  const char *warning_string = NULL,
2989  size_t subfield_offset = 0,
2990  size_t actual_field_size = sizeof(typename REDOP::RHS),
2991 #ifdef DEBUG_LEGION
2992  bool check_field_size = true
2993 #else
2994  bool check_field_size = false
2995 #endif
2996  ) { }
2997  public:
2998  // Create a ReductionAccessor for an UntypedDeferredValue
2999  // (only with AffineAccessors)
3001  bool silence_warnings = false,
3002  const char *warning_string = NULL,
3003  size_t subfield_offset = 0,
3004  size_t actual_field_size = sizeof(typename REDOP::RHS),
3005 #ifdef DEBUG_LEGION
3006  bool check_field_size = true
3007 #else
3008  bool check_field_size = false
3009 #endif
3010  ) { }
3011  // Create a ReductionAccessor for an UntypedDeferredValue
3012  // Specify a specific bounds rectangle to use for the accessor
3013  // (only with AffineAccessors)
3015  const Rect<N,COORD_T> &bounds,
3016  bool silence_warnings = false,
3017  const char *warning_string = NULL,
3018  size_t subfield_offset = 0,
3019  size_t actual_field_size = sizeof(typename REDOP::RHS),
3020 #ifdef DEBUG_LEGION
3021  bool check_field_size = true
3022 #else
3023  bool check_field_size = false
3024 #endif
3025  ) { }
3026  public:
3027  // Create a ReductionAccessor for an UntypedDeferredBuffer
3028  // (only with AffineAccessors)
3030  bool silence_warnings = false,
3031  const char *warning_string = NULL,
3032  size_t subfield_offset = 0,
3033  size_t actual_field_size = sizeof(typename REDOP::RHS),
3034 #ifdef DEBUG_LEGION
3035  bool check_field_size = true
3036 #else
3037  bool check_field_size = false
3038 #endif
3039  ) { }
3040  // Create a ReductionAccessor for an UntypedDeferredBuffer
3041  // Specify a specific bounds rectangle to use for the accessor
3042  // (only with AffineAccessors)
3044  const Rect<N,COORD_T> &bounds,
3045  bool silence_warnings = false,
3046  const char *warning_string = NULL,
3047  size_t subfield_offset = 0,
3048  size_t actual_field_size = sizeof(typename REDOP::RHS),
3049 #ifdef DEBUG_LEGION
3050  bool check_field_size = true
3051 #else
3052  bool check_field_size = false
3053 #endif
3054  ) { }
3055  // Create a ReductionAccessor for an UntypedDeferredBuffer
3056  // Specify a specific Affine transform to use for interpreting points
3057  // (only with AffineAccessors)
3058  template<int M>
3060  const AffineTransform<M,N,COORD_T> &transform,
3061  bool silence_warnings = false,
3062  const char *warning_string = NULL,
3063  size_t subfield_offset = 0,
3064  size_t actual_field_size = sizeof(typename REDOP::RHS),
3065 #ifdef DEBUG_LEGION
3066  bool check_field_size = true
3067 #else
3068  bool check_field_size = false
3069 #endif
3070  ) { }
3071  // Create a ReductionAccessor for an UntypedDeferredBuffer
3072  // Specify both a transform and a bounds to use
3073  // (only with AffineAccessors)
3074  template<int M>
3076  const AffineTransform<M,N,COORD_T> &transform,
3077  const Rect<N,COORD_T> &bounds,
3078  bool silence_warnings = false,
3079  const char *warning_string = NULL,
3080  size_t subfield_offset = 0,
3081  size_t actual_field_size = sizeof(typename REDOP::RHS),
3082 #ifdef DEBUG_LEGION
3083  bool check_field_size = true
3084 #else
3085  bool check_field_size = false
3086 #endif
3087  ) { }
3088  public:
3089  typedef typename REDOP::RHS value_type;
3090  typedef typename REDOP::RHS& reference;
3091  typedef const typename REDOP::RHS& const_reference;
3092  static const int dim = N;
3093  };
3094 
3095 #ifdef LEGION_MULTI_REGION_ACCESSOR
3096  // Multi-Region Accessors are a provisional feature now and are likely
3097  // to be deprecated and removed in the near future. Instead of multi-region
3098  // accessors you should be able to use the new colocation constructors
3099  // on the traditional Field Accessors.
3129  template<typename FT, int N, typename COORD_T = coord_t,
3130  typename A = Realm::GenericAccessor<FT,N,COORD_T>,
3131 #ifdef LEGION_BOUNDS_CHECKS
3132  bool CHECK_BOUNDS = true,
3133 #else
3134  bool CHECK_BOUNDS = false,
3135 #endif
3136 #ifdef LEGION_PRIVILEGE_CHECKS
3137  bool CHECK_PRIVILEGES = true,
3138 #else
3139  bool CHECK_PRIVILEGES = false,
3140 #endif
3141  // Only used if bounds/privilege checks enabled
3142  // Can safely over-approximate, but may cost space
3143  // Especially GPU parameter space
3144  int MAX_REGIONS = 4>
3145  class MultiRegionAccessor {
3146  private:
3147  static_assert(N > 0, "N must be positive");
3148  static_assert(std::is_integral<COORD_T>::value, "must be integral type");
3149  public:
3150  MultiRegionAccessor(void) { }
3151  public: // iterator based construction of the multi-region accessors
3152  template<typename InputIterator>
3153  MultiRegionAccessor(InputIterator start, InputIterator stop,
3154  // The actual field size in case it is different from
3155  // the one being used in FT and we still want to check
3156  FieldID fid, size_t actual_field_size = sizeof(FT),
3157 #ifdef DEBUG_LEGION
3158  bool check_field_size = true,
3159 #else
3160  bool check_field_size = false,
3161 #endif
3162  bool silence_warnings = false,
3163  const char *warning_string = NULL,
3164  size_t subfield_offset = 0) { }
3165  // Specify a specific bounds rectangle to use for the accessor
3166  template<typename InputIterator>
3167  MultiRegionAccessor(InputIterator start, InputIterator stop,
3168  const Rect<N,COORD_T> bounds, FieldID fid,
3169  // The actual field size in case it is different from
3170  // the one being used in FT and we still want to check
3171  size_t actual_field_size = sizeof(FT),
3172 #ifdef DEBUG_LEGION
3173  bool check_field_size = true,
3174 #else
3175  bool check_field_size = false,
3176 #endif
3177  bool silence_warnings = false,
3178  const char *warning_string = NULL,
3179  size_t subfield_offset = 0) { }
3180  // Specify a specific Affine transform to use for interpreting points
3181  template<int M, typename InputIterator>
3182  MultiRegionAccessor(InputIterator start, InputIterator stop,
3183  const AffineTransform<M,N,COORD_T> transform,
3184  // The actual field size in case it is different from
3185  // the one being used in FT and we still want to check
3186  FieldID fid, size_t actual_field_size = sizeof(FT),
3187 #ifdef DEBUG_LEGION
3188  bool check_field_size = true,
3189 #else
3190  bool check_field_size = false,
3191 #endif
3192  bool silence_warnings = false,
3193  const char *warning_string = NULL,
3194  size_t subfield_offset = 0) { }
3195  // Specify both a transform and a bounds to use
3196  template<int M, typename InputIterator>
3197  MultiRegionAccessor(InputIterator start, InputIterator stop,
3198  const AffineTransform<M,N,COORD_T> transform,
3199  const Rect<N,COORD_T> bounds, FieldID fid,
3200  // The actual field size in case it is different from the
3201  // one being used in FT and we still want to check it
3202  size_t actual_field_size = sizeof(FT),
3203 #ifdef DEBUG_LEGION
3204  bool check_field_size = true,
3205 #else
3206  bool check_field_size = false,
3207 #endif
3208  bool silence_warnings = false,
3209  const char *warning_string = NULL,
3210  size_t subfield_offset = 0) { }
3211  public: // explicit data structure versions of the implicit iterators above
3212  MultiRegionAccessor(const std::vector<PhysicalRegion> &regions,
3213  // The actual field size in case it is different from
3214  // the one being used in FT and we still want to check
3215  FieldID fid, size_t actual_field_size = sizeof(FT),
3216 #ifdef DEBUG_LEGION
3217  bool check_field_size = true,
3218 #else
3219  bool check_field_size = false,
3220 #endif
3221  bool silence_warnings = false,
3222  const char *warning_string = NULL,
3223  size_t subfield_offset = 0) { }
3224  // Specify a specific bounds rectangle to use for the accessor
3225  MultiRegionAccessor(const std::vector<PhysicalRegion> &regions,
3226  const Rect<N,COORD_T> bounds, FieldID fid,
3227  // The actual field size in case it is different from
3228  // the one being used in FT and we still want to check
3229  size_t actual_field_size = sizeof(FT),
3230 #ifdef DEBUG_LEGION
3231  bool check_field_size = true,
3232 #else
3233  bool check_field_size = false,
3234 #endif
3235  bool silence_warnings = false,
3236  const char *warning_string = NULL,
3237  size_t subfield_offset = 0) { }
3238  // Specify a specific Affine transform to use for interpreting points
3239  template<int M>
3240  MultiRegionAccessor(const std::vector<PhysicalRegion> &regions,
3241  const AffineTransform<M,N,COORD_T> transform,
3242  // The actual field size in case it is different from
3243  // the one being used in FT and we still want to check
3244  FieldID fid, size_t actual_field_size = sizeof(FT),
3245 #ifdef DEBUG_LEGION
3246  bool check_field_size = true,
3247 #else
3248  bool check_field_size = false,
3249 #endif
3250  bool silence_warnings = false,
3251  const char *warning_string = NULL,
3252  size_t subfield_offset = 0) { }
3253  // Specify both a transform and a bounds to use
3254  template<int M>
3255  MultiRegionAccessor(const std::vector<PhysicalRegion> &regions,
3256  const AffineTransform<M,N,COORD_T> transform,
3257  const Rect<N,COORD_T> bounds, FieldID fid,
3258  // The actual field size in case it is different from the
3259  // one being used in FT and we still want to check it
3260  size_t actual_field_size = sizeof(FT),
3261 #ifdef DEBUG_LEGION
3262  bool check_field_size = true,
3263 #else
3264  bool check_field_size = false,
3265 #endif
3266  bool silence_warnings = false,
3267  const char *warning_string = NULL,
3268  size_t subfield_offset = 0) { }
3269  public:
3270  typedef FT value_type;
3271  typedef FT& reference;
3272  typedef const FT& const_reference;
3273  static const int dim = N;
3274  };
3275 #endif // LEGION_MULTI_REGION_ACCESSOR
3276 
3301  public:
3302  PieceIterator(void);
3303  PieceIterator(const PieceIterator &rhs);
3305  PieceIterator(const PhysicalRegion &region, FieldID fid,
3306  bool privilege_only,
3307  bool silence_warnings = false,
3308  const char *warning_string = NULL);
3309  ~PieceIterator(void);
3310  public:
3311  PieceIterator& operator=(const PieceIterator &rhs);
3312  PieceIterator& operator=(PieceIterator &&rhs);
3313  public:
3314  inline bool valid(void) const;
3315  bool step(void);
3316  public:
3317  inline operator bool(void) const;
3318  inline bool operator()(void) const;
3319  inline const Domain& operator*(void) const;
3320  inline const Domain* operator->(void) const;
3321  inline PieceIterator& operator++(void);
3322  inline PieceIterator operator++(int/*postfix*/);
3323  public:
3324  bool operator<(const PieceIterator &rhs) const;
3325  bool operator==(const PieceIterator &rhs) const;
3326  bool operator!=(const PieceIterator &rhs) const;
3327  private:
3328  Internal::PieceIteratorImpl *impl;
3329  int index;
3330  protected:
3331  Domain current_piece;
3332  };
3333 
3339  template<int DIM, typename COORD_T = coord_t>
3341  private:
3342  static_assert(DIM > 0, "DIM must be positive");
3343  static_assert(std::is_integral<COORD_T>::value, "must be integral type");
3344  public:
3345  PieceIteratorT(void);
3346  PieceIteratorT(const PieceIteratorT &rhs);
3348  PieceIteratorT(const PhysicalRegion &region, FieldID fid,
3349  bool privilege_only,
3350  bool silence_warnings = false,
3351  const char *warning_string = NULL);
3352  public:
3353  PieceIteratorT<DIM,COORD_T>& operator=(const PieceIteratorT &rhs);
3354  PieceIteratorT<DIM,COORD_T>& operator=(PieceIteratorT &&rhs);
3355  public:
3356  inline bool step(void);
3357  inline const Rect<DIM,COORD_T>& operator*(void) const;
3358  inline const Rect<DIM,COORD_T>* operator->(void) const;
3359  inline PieceIteratorT<DIM,COORD_T>& operator++(void);
3360  inline PieceIteratorT<DIM,COORD_T> operator++(int/*postfix*/);
3361  protected:
3362  Rect<DIM,COORD_T> current_rect;
3363  };
3364 
3374  template<PrivilegeMode PM, typename FT, int DIM, typename COORD_T = coord_t>
3376  private:
3377  static_assert(DIM > 0, "DIM must be positive");
3378  static_assert(std::is_integral<COORD_T>::value, "must be integral type");
3379  public:
3380  SpanIterator(void) { }
3381  SpanIterator(const PhysicalRegion &region, FieldID fid,
3382  // The actual field size in case it is different from the
3383  // one being used in FT and we still want to check it
3384  size_t actual_field_size = sizeof(FT),
3385 #ifdef DEBUG_LEGION
3386  bool check_field_size = true,
3387 #else
3388  bool check_field_size = false,
3389 #endif
3390  // Iterate only the spans that we have privileges on
3391  bool privileges_only = true,
3392  bool silence_warnings = false,
3393  const char *warning_string = NULL);
3394  public:
3395  inline bool valid(void) const;
3396  inline bool step(void);
3397  public:
3398  inline operator bool(void) const;
3399  inline bool operator()(void) const;
3400  inline const Span<FT,PM>& operator*(void) const;
3401  inline const Span<FT,PM>* operator->(void) const;
3402  inline SpanIterator<PM,FT,DIM,COORD_T>& operator++(void);
3403  inline SpanIterator<PM,FT,DIM,COORD_T> operator++(int);
3404  private:
3405  PieceIteratorT<DIM,COORD_T> piece_iterator;
3406  Realm::MultiAffineAccessor<FT,DIM,COORD_T> accessor;
3407  Span<FT,PM> current;
3408  Point<DIM,COORD_T> partial_step_point;
3409  int dim_order[DIM];
3410  int partial_step_dim;
3411  bool partial_piece;
3412  };
3413 
3427  template<typename T>
3429  public:
3430  DeferredValue(T initial_value,
3431  size_t alignment = 16);
3432  public:
3433  __CUDA_HD__
3434  inline T read(void) const;
3435  __CUDA_HD__
3436  inline void write(T value) const;
3437  __CUDA_HD__
3438  inline T* ptr(void) const;
3439  __CUDA_HD__
3440  inline T& ref(void) const;
3441  __CUDA_HD__
3442  inline operator T(void) const;
3443  __CUDA_HD__
3444  inline DeferredValue<T>& operator=(T value);
3445  public:
3446  inline void finalize(Runtime *runtime, Context ctx) const;
3447  protected:
3448  friend class UntypedDeferredValue;
3449  DeferredValue(void);
3450  Realm::RegionInstance instance;
3451  Realm::AffineAccessor<T,1,coord_t> accessor;
3452  };
3453 
3463  template<typename REDOP, bool EXCLUSIVE=false>
3464  class DeferredReduction: public DeferredValue<typename REDOP::RHS> {
3465  public:
3466  DeferredReduction(size_t alignment = 16);
3467  public:
3468  __CUDA_HD__
3469  inline void reduce(typename REDOP::RHS val) const;
3470  __CUDA_HD__
3471  inline void operator<<=(typename REDOP::RHS val) const;
3472  };
3473 
3479  public:
3480  UntypedDeferredValue(void);
3481  UntypedDeferredValue(size_t field_size, Memory target_memory,
3482  const void *initial_value = NULL,
3483  size_t alignment = 16);
3484  UntypedDeferredValue(size_t field_size,
3485  Memory::Kind memory_kind = Memory::Z_COPY_MEM,
3486  const void *initial_value = NULL,
3487  size_t alignment = 16);
3488  template<typename T>
3490  template<typename REDOP, bool EXCLUSIVE>
3492  public:
3493  template<typename T>
3494  inline operator DeferredValue<T>(void) const;
3495  template<typename REDOP, bool EXCLUSIVE>
3496  inline operator DeferredReduction<REDOP,EXCLUSIVE>(void) const;
3497  public:
3498  void finalize(Runtime *runtime, Context ctx) const;
3499  Realm::RegionInstance get_instance() const;
3500  private:
3501  template<PrivilegeMode,typename,int,typename,typename,bool>
3502  friend class FieldAccessor;
3503  template<typename,bool,int,typename,typename,bool>
3504  friend class ReductionAccessor;
3505  Realm::RegionInstance instance;
3506  size_t field_size;
3507  };
3508 
3526  template<typename T, int DIM, typename COORD_T = coord_t,
3527 #ifdef LEGION_BOUNDS_CHECKS
3528  bool CHECK_BOUNDS = true>
3529 #else
3530  bool CHECK_BOUNDS = false>
3531 #endif
3533  private:
3534  static_assert(DIM > 0, "DIM must be positive");
3535  static_assert(std::is_integral<COORD_T>::value, "must be integral type");
3536  public:
3537  DeferredBuffer(void);
3538  public: // Constructors specifying a generic memory kind
3539  DeferredBuffer(Memory::Kind kind,
3540  const Domain &bounds,
3541  const T *initial_value = NULL,
3542  size_t alignment = 16,
3543  bool fortran_order_dims = false);
3544  DeferredBuffer(const Rect<DIM,COORD_T> &bounds,
3545  Memory::Kind kind,
3546  const T *initial_value = NULL,
3547  size_t alignment = 16,
3548  bool fortran_order_dims = false);
3549  public: // Constructors specifying a specific memory
3550  DeferredBuffer(Memory memory,
3551  const Domain &bounds,
3552  const T *initial_value = NULL,
3553  size_t alignment = 16,
3554  bool fortran_order_dims = false);
3555  DeferredBuffer(const Rect<DIM,COORD_T> &bounds,
3556  Memory memory,
3557  const T *initial_value = NULL,
3558  size_t alignment = 16,
3559  bool fortran_order_dims = false);
3560  public: // Constructors specifying a specific ordering
3561  DeferredBuffer(Memory::Kind kind,
3562  const Domain &bounds,
3563  std::array<DimensionKind,DIM> ordering,
3564  const T *initial_value = NULL,
3565  size_t alignment = 16);
3566  DeferredBuffer(const Rect<DIM,COORD_T> &bounds,
3567  Memory::Kind kind,
3568  std::array<DimensionKind,DIM> ordering,
3569  const T *initial_value = NULL,
3570  size_t alignment = 16);
3571  DeferredBuffer(Memory memory,
3572  const Domain &bounds,
3573  std::array<DimensionKind,DIM> ordering,
3574  const T *initial_value = NULL,
3575  size_t alignment = 16);
3576  DeferredBuffer(const Rect<DIM,COORD_T> &bounds,
3577  Memory memory,
3578  std::array<DimensionKind,DIM> ordering,
3579  const T *initial_value = NULL,
3580  size_t alignment = 16);
3581  protected:
3582  Memory get_memory_from_kind(Memory::Kind kind);
3583  void initialize_layout(size_t alignment, bool fortran_order_dims);
3584  void initialize(Memory memory,
3585  DomainT<DIM,COORD_T> bounds,
3586  const T *initial_value);
3587  public:
3588  __CUDA_HD__
3589  inline T read(const Point<DIM,COORD_T> &p) const;
3590  __CUDA_HD__
3591  inline void write(const Point<DIM,COORD_T> &p, T value) const;
3592  __CUDA_HD__
3593  inline T* ptr(const Point<DIM,COORD_T> &p) const;
3594  __CUDA_HD__
3595  inline T* ptr(const Rect<DIM,COORD_T> &r) const; // must be dense
3596  __CUDA_HD__
3597  inline T* ptr(const Rect<DIM,COORD_T> &r, size_t strides[DIM]) const;
3598  __CUDA_HD__
3599  inline T& operator[](const Point<DIM,COORD_T> &p) const;
3600  protected:
3601  friend class UntypedDeferredBuffer<COORD_T>;
3602  Realm::RegionInstance instance;
3603  Realm::AffineAccessor<T,DIM,COORD_T> accessor;
3604  std::array<DimensionKind,DIM> ordering;
3605  size_t alignment;
3606 #ifdef LEGION_BOUNDS_CHECKS
3607  DomainT<DIM,COORD_T> bounds;
3608 #endif
3609  };
3610 
3617  template<typename COORD_T = coord_t>
3619  private:
3620  static_assert(std::is_integral<COORD_T>::value, "must be integral type");
3621  public:
3622  UntypedDeferredBuffer(void);
3623  public: // Constructors specifying a generic memory kind
3624  UntypedDeferredBuffer(size_t field_size, int dims,
3625  Memory::Kind kind,
3626  const Domain &bounds,
3627  const void *initial_value = NULL,
3628  size_t alignment = 16,
3629  bool fortran_order_dims = false);
3630  UntypedDeferredBuffer(size_t field_size, int dims,
3631  Memory::Kind kind,
3632  IndexSpace bounds,
3633  const void *initial_value = NULL,
3634  size_t alignment = 16,
3635  bool fortran_order_dims = false);
3636  public: // Constructors specifying a specific memory
3637  UntypedDeferredBuffer(size_t field_size, int dims,
3638  Memory memory,
3639  const Domain &bounds,
3640  const void *initial_value = NULL,
3641  size_t alignment = 16,
3642  bool fortran_order_dims = false);
3643  UntypedDeferredBuffer(size_t field_size, int dims,
3644  Memory memory,
3645  IndexSpace bounds,
3646  const void *initial_value = NULL,
3647  size_t alignment = 16,
3648  bool fortran_order_dims = false);
3649  public:
3650  template<typename T, int DIM>
3652  public:
3653  template<typename T, int DIM, bool BC>
3654  inline operator DeferredBuffer<T,DIM,COORD_T,BC>(void) const;
3655  public:
3656  inline void destroy(void);
3657  inline Realm::RegionInstance get_instance(void) const { return instance; }
3658  private:
3659  template<PrivilegeMode,typename,int,typename,typename,bool>
3660  friend class FieldAccessor;
3661  template<typename,bool,int,typename,typename,bool>
3662  friend class ReductionAccessor;
3663  Realm::RegionInstance instance;
3664  size_t field_size;
3665  int dims;
3666  };
3667 
3668  //==========================================================================
3669  // Software Coherence Classes
3670  //==========================================================================
3671 
3684  public:
3685  AcquireLauncher(LogicalRegion logical_region,
3686  LogicalRegion parent_region,
3687  PhysicalRegion physical_region = PhysicalRegion(),
3688  Predicate pred = Predicate::TRUE_PRED,
3689  MapperID id = 0, MappingTagID tag = 0,
3690  UntypedBuffer map_arg = UntypedBuffer(),
3691  const char *provenance = "");
3692  public:
3693  inline void add_field(FieldID f);
3694  inline void add_grant(Grant g);
3695  inline void add_wait_barrier(PhaseBarrier pb);
3696  inline void add_arrival_barrier(PhaseBarrier pb);
3697  inline void add_wait_handshake(LegionHandshake handshake);
3698  inline void add_arrival_handshake(LegionHandshake handshake);
3699  public:
3700  LogicalRegion logical_region;
3701  LogicalRegion parent_region;
3702  std::set<FieldID> fields;
3703  public:
3704  // This field is now optional
3705  PhysicalRegion physical_region;
3706  public:
3707  std::vector<Grant> grants;
3708  std::vector<PhaseBarrier> wait_barriers;
3709  std::vector<PhaseBarrier> arrive_barriers;
3710  Predicate predicate;
3711  MapperID map_id;
3712  MappingTagID tag;
3713  UntypedBuffer map_arg;
3714  public:
3715  // Provenance string for the runtime and tools to use
3716  std::string provenance;
3717  public:
3718  // Inform the runtime about any static dependences
3719  // These will be ignored outside of static traces
3720  const std::vector<StaticDependence> *static_dependences;
3721  public:
3722  bool silence_warnings;
3723  };
3724 
3732  public:
3733  ReleaseLauncher(LogicalRegion logical_region,
3734  LogicalRegion parent_region,
3735  PhysicalRegion physical_region = PhysicalRegion(),
3736  Predicate pred = Predicate::TRUE_PRED,
3737  MapperID id = 0, MappingTagID tag = 0,
3738  UntypedBuffer map_arg = UntypedBuffer(),
3739  const char *provenance = "");
3740  public:
3741  inline void add_field(FieldID f);
3742  inline void add_grant(Grant g);
3743  inline void add_wait_barrier(PhaseBarrier pb);
3744  inline void add_arrival_barrier(PhaseBarrier pb);
3745  inline void add_wait_handshake(LegionHandshake handshake);
3746  inline void add_arrival_handshake(LegionHandshake handshake);
3747  public:
3748  LogicalRegion logical_region;
3749  LogicalRegion parent_region;
3750  std::set<FieldID> fields;
3751  public:
3752  // This field is now optional
3753  PhysicalRegion physical_region;
3754  public:
3755  std::vector<Grant> grants;
3756  std::vector<PhaseBarrier> wait_barriers;
3757  std::vector<PhaseBarrier> arrive_barriers;
3758  Predicate predicate;
3759  MapperID map_id;
3760  MappingTagID tag;
3761  UntypedBuffer map_arg;
3762  public:
3763  // Provenance string for the runtime and tools to use
3764  std::string provenance;
3765  public:
3766  // Inform the runtime about any static dependences
3767  // These will be ignored outside of static traces
3768  const std::vector<StaticDependence> *static_dependences;
3769  public:
3770  bool silence_warnings;
3771  };
3772 
3773  //==========================================================================
3774  // Must Parallelism Classes
3775  //==========================================================================
3776 
3791  public:
3792  MustEpochLauncher(MapperID id = 0, MappingTagID tag = 0);
3793  public:
3794  inline void add_single_task(const DomainPoint &point,
3795  const TaskLauncher &launcher);
3796  inline void add_index_task(const IndexTaskLauncher &launcher);
3797  public:
3798  MapperID map_id;
3799  MappingTagID mapping_tag;
3800  std::vector<TaskLauncher> single_tasks;
3801  std::vector<IndexTaskLauncher> index_tasks;
3802  public:
3803  Domain launch_domain;
3804  IndexSpace launch_space;
3805  // Will only be used in control replication context. If left
3806  // unset the runtime will use launch_space/launch_domain
3807  IndexSpace sharding_space;
3808  public:
3809  // Provenance string for the runtime and tools to use
3810  std::string provenance;
3811  public:
3812  bool silence_warnings;
3813  };
3814 
3815  //==========================================================================
3816  // Interoperability Classes
3817  //==========================================================================
3818 
3829  class LegionHandshake : public Unserializable<LegionHandshake> {
3830  public:
3831  LegionHandshake(void);
3832  LegionHandshake(const LegionHandshake &rhs);
3833  ~LegionHandshake(void);
3834  protected:
3835  Internal::LegionHandshakeImpl *impl;
3836  protected:
3837  // Only the runtime should be able to make these
3838  FRIEND_ALL_RUNTIME_CLASSES
3839  explicit LegionHandshake(Internal::LegionHandshakeImpl *impl);
3840  public:
3841  bool operator==(const LegionHandshake &h) const
3842  { return impl == h.impl; }
3843  bool operator<(const LegionHandshake &h) const
3844  { return impl < h.impl; }
3845  LegionHandshake& operator=(const LegionHandshake &rhs);
3846  public:
3851  void ext_handoff_to_legion(void) const;
3857  void ext_wait_on_legion(void) const;
3858  public:
3863  void legion_handoff_to_ext(void) const;
3868  void legion_wait_on_ext(void) const;
3869  public:
3870  /*
3871  * For asynchronous Legion execution, you can use these
3872  * methods to get a phase barrier associated with the
3873  * handshake object instead of blocking on the legion side
3874  */
3886  void advance_legion_handshake(void) const;
3887  };
3888 
3895  public:
3896  MPILegionHandshake(void);
3898  ~MPILegionHandshake(void);
3899  protected:
3900  // Only the runtime should be able to make these
3901  FRIEND_ALL_RUNTIME_CLASSES
3902  explicit MPILegionHandshake(Internal::LegionHandshakeImpl *impl);
3903  public:
3904  bool operator==(const MPILegionHandshake &h) const
3905  { return impl == h.impl; }
3906  bool operator<(const MPILegionHandshake &h) const
3907  { return impl < h.impl; }
3908  MPILegionHandshake& operator=(const MPILegionHandshake &rhs);
3909  public:
3914  inline void mpi_handoff_to_legion(void) const { ext_handoff_to_legion(); }
3919  inline void mpi_wait_on_legion(void) const { ext_wait_on_legion(); }
3920  public:
3925  inline void legion_handoff_to_mpi(void) const { legion_handoff_to_ext(); }
3930  inline void legion_wait_on_mpi(void) const { legion_wait_on_ext(); }
3931  };
3932 
3933  //==========================================================================
3934  // Operation Classes
3935  //==========================================================================
3936 
3943  class Mappable {
3944  public:
3945  Mappable(void);
3946  public:
3947  // Return a globally unique ID for this operation
3948  virtual UniqueID get_unique_id(void) const = 0;
3949  // Return the number of operations that came before
3950  // this operation in the same context (close operations
3951  // return number of previous close operations)
3952  virtual size_t get_context_index(void) const = 0;
3953  // Return the depth of this operation in the task tree
3954  virtual int get_depth(void) const = 0;
3955  // Get the parent task associated with this mappable
3956  virtual const Task* get_parent_task(void) const = 0;
3957  // Get the provenance string for this mappable
3958  // By default we return the human readable component but
3959  // you can also get the machine component as well
3960  virtual const std::string& get_provenance_string(
3961  bool human = true) const = 0;
3962  public:
3963  virtual MappableType get_mappable_type(void) const = 0;
3964  virtual const Task* as_task(void) const { return NULL; }
3965  virtual const Copy* as_copy(void) const { return NULL; }
3966  virtual const InlineMapping* as_inline(void) const { return NULL; }
3967  virtual const Acquire* as_acquire(void) const { return NULL; }
3968  virtual const Release* as_release(void) const { return NULL; }
3969  virtual const Close* as_close(void) const { return NULL; }
3970  virtual const Fill* as_fill(void) const { return NULL; }
3971  virtual const Partition* as_partition(void) const { return NULL; }
3972  virtual const MustEpoch* as_must_epoch(void) const { return NULL; }
3973  public:
3974  MapperID map_id;
3975  MappingTagID tag;
3976  public:
3977  // The 'parent_task' member is here for backwards compatibility
3978  // It's better to use the 'get_parent_task' method
3979  // as this may be NULL until that method is called
3980  mutable const Task* parent_task;
3981  public:
3982  // Mapper annotated data
3983  void* mapper_data;
3984  size_t mapper_data_size;
3985  public:
3986  // These are here for backwards compatibility from a time when
3987  // the MappableType enum was inside of this class
3988 #ifndef __GNUC__
3989  // GCC doesn't like this line even though it's just creating a
3990  // type alias, who knows what their problem is
3991  typedef Legion::MappableType MappableType;
3992 #endif
3993  static const MappableType TASK_MAPPABLE = ::LEGION_TASK_MAPPABLE;
3994  static const MappableType COPY_MAPPABLE = ::LEGION_COPY_MAPPABLE;
3995  static const MappableType INLINE_MAPPABLE = ::LEGION_INLINE_MAPPABLE;
3996  static const MappableType ACQUIRE_MAPPABLE = ::LEGION_ACQUIRE_MAPPABLE;
3997  static const MappableType RELEASE_MAPPABLE = ::LEGION_RELEASE_MAPPABLE;
3998  static const MappableType CLOSE_MAPPABLE = ::LEGION_CLOSE_MAPPABLE;
3999  static const MappableType FILL_MAPPABLE = ::LEGION_FILL_MAPPABLE;
4000  static const MappableType PARTITION_MAPPABLE =
4001  ::LEGION_PARTITION_MAPPABLE;
4002  static const MappableType MUST_EPOCH_MAPPABLE =
4003  ::LEGION_MUST_EPOCH_MAPPABLE;
4004  };
4005 
4014  class Task : public Mappable {
4015  public:
4016  Task(void);
4017  public:
4018  // Check whether this task has a parent task.
4019  virtual bool has_parent_task(void) const = 0;
4020  // Return the name of the task.
4021  virtual const char* get_task_name(void) const = 0;
4022  // Returns the current slice of the index domain that this
4023  // task is operating over. This method will only return a
4024  // valid domain if this is part of an index space task.
4025  virtual Domain get_slice_domain(void) const = 0;
4026  public:
4027  virtual MappableType get_mappable_type(void) const
4028  { return LEGION_TASK_MAPPABLE; }
4029  virtual const Task* as_task(void) const { return this; }
4030  public:
4031  // Task argument information
4032  TaskID task_id;
4033  std::vector<IndexSpaceRequirement> indexes;
4034  std::vector<RegionRequirement> regions;
4035  std::vector<Future> futures;
4036  std::vector<Grant> grants;
4037  std::vector<PhaseBarrier> wait_barriers;
4038  std::vector<PhaseBarrier> arrive_barriers;
4039  void* args;
4040  size_t arglen;
4041  public:
4042  // Index task argument information
4043  bool is_index_space;
4044  bool must_epoch_task;
4045  Domain index_domain;
4046  DomainPoint index_point;
4047  IndexSpace sharding_space;
4048  void* local_args;
4049  size_t local_arglen;
4050  public:
4051  // Meta data information from the runtime
4052  Processor orig_proc;
4053  Processor current_proc;
4054  Processor target_proc;
4055  unsigned steal_count;
4056  bool stealable;
4057  bool speculated;
4058  bool local_function;
4059  };
4060 
4066  class Copy : public Mappable {
4067  public:
4068  Copy(void);
4069  public:
4070  virtual MappableType get_mappable_type(void) const
4071  { return LEGION_COPY_MAPPABLE; }
4072  virtual const Copy* as_copy(void) const { return this; }
4073  public:
4074  // Copy Launcher arguments
4075  std::vector<RegionRequirement> src_requirements;
4076  std::vector<RegionRequirement> dst_requirements;
4077  std::vector<RegionRequirement> src_indirect_requirements;
4078  std::vector<RegionRequirement> dst_indirect_requirements;
4079  std::vector<Grant> grants;
4080  std::vector<PhaseBarrier> wait_barriers;
4081  std::vector<PhaseBarrier> arrive_barriers;
4082  public:
4083  // Index copy argument information
4084  bool is_index_space;
4085  Domain index_domain;
4086  DomainPoint index_point;
4087  };
4088 
4094  class InlineMapping : public Mappable {
4095  public:
4096  InlineMapping(void);
4097  public:
4098  virtual MappableType get_mappable_type(void) const
4099  { return LEGION_INLINE_MAPPABLE; }
4100  virtual const InlineMapping* as_inline(void) const { return this; }
4101  public:
4102  // Inline Launcher arguments
4103  RegionRequirement requirement;
4104  std::vector<Grant> grants;
4105  std::vector<PhaseBarrier> wait_barriers;
4106  std::vector<PhaseBarrier> arrive_barriers;
4107  LayoutConstraintID layout_constraint_id;
4108  };
4109 
4115  class Acquire : public Mappable {
4116  public:
4117  Acquire(void);
4118  public:
4119  virtual MappableType get_mappable_type(void) const
4120  { return LEGION_ACQUIRE_MAPPABLE; }
4121  virtual const Acquire* as_acquire(void) const { return this; }
4122  public:
4123  // Acquire Launcher arguments
4124  LogicalRegion logical_region;
4125  LogicalRegion parent_region;
4126  std::set<FieldID> fields;
4127  std::vector<Grant> grants;
4128  std::vector<PhaseBarrier> wait_barriers;
4129  std::vector<PhaseBarrier> arrive_barriers;
4130  };
4131 
4137  class Release : public Mappable {
4138  public:
4139  Release(void);
4140  public:
4141  virtual MappableType get_mappable_type(void) const
4142  { return LEGION_RELEASE_MAPPABLE; }
4143  virtual const Release* as_release(void) const { return this; }
4144  public:
4145  // Release Launcher arguments
4146  LogicalRegion logical_region;
4147  LogicalRegion parent_region;
4148  std::set<FieldID> fields;
4149  std::vector<Grant> grants;
4150  std::vector<PhaseBarrier> wait_barriers;
4151  std::vector<PhaseBarrier> arrive_barriers;
4152  };
4153 
4163  class Close : public Mappable {
4164  public:
4165  Close(void);
4166  public:
4167  virtual MappableType get_mappable_type(void) const
4168  { return LEGION_CLOSE_MAPPABLE; }
4169  virtual const Close* as_close(void) const { return this; }
4170  public:
4171  // Synthesized region requirement
4172  RegionRequirement requirement;
4173  };
4174 
4181  class Fill : public Mappable {
4182  public:
4183  Fill(void);
4184  public:
4185  virtual MappableType get_mappable_type(void) const
4186  { return LEGION_FILL_MAPPABLE; }
4187  virtual const Fill* as_fill(void) const { return this; }
4188  public:
4189  // Synthesized region requirement
4190  RegionRequirement requirement;
4191  std::vector<Grant> grants;
4192  std::vector<PhaseBarrier> wait_barriers;
4193  std::vector<PhaseBarrier> arrive_barriers;
4194  public:
4195  // Index fill argument information
4196  bool is_index_space;
4197  Domain index_domain;
4198  DomainPoint index_point;
4199  };
4200 
4208  class Partition : public Mappable {
4209  public:
4210  Partition(void);
4211  public:
4212  virtual MappableType get_mappable_type(void) const
4213  { return LEGION_PARTITION_MAPPABLE; }
4214  virtual const Partition* as_partition(void) const { return this; }
4215  public:
4216  enum PartitionKind {
4217  BY_FIELD, // create partition by field
4218  BY_IMAGE, // create partition by image
4219  BY_IMAGE_RANGE, // create partition by image range
4220  BY_PREIMAGE, // create partition by preimage
4221  BY_PREIMAGE_RANGE, // create partition by preimage range
4222  BY_ASSOCIATION, // create partition by association
4223  };
4224  virtual PartitionKind get_partition_kind(void) const = 0;
4225  public:
4226  // Synthesized region requirement
4227  RegionRequirement requirement;
4228  public:
4229  // Index partition argument information
4230  bool is_index_space;
4231  Domain index_domain;
4232  DomainPoint index_point;
4233  };
4234 
4241  class MustEpoch : public Mappable {
4242  public:
4243  MustEpoch(void);
4244  public:
4245  virtual MappableType get_mappable_type(void) const
4246  { return LEGION_MUST_EPOCH_MAPPABLE; }
4247  virtual const MustEpoch* as_must_epoch(void) const { return this; }
4248  public:
4249  std::vector<const Task*> individual_tasks;
4250  std::vector<const Task*> index_space_tasks;
4251  public:
4252  // Index space of points for the must epoch operation
4253  Domain launch_domain;
4254  IndexSpace sharding_space;
4255  };
4256 
4257  //==========================================================================
4258  // Runtime Classes
4259  //==========================================================================
4260 
4266  template<typename T>
4267  struct ColoredPoints {
4268  public:
4269  std::set<T> points;
4270  std::set<std::pair<T,T> > ranges;
4271  };
4272 
4278  struct InputArgs {
4279  public:
4280  char **argv;
4281  int argc;
4282  };
4283 
4289  Machine machine;
4290  Runtime *runtime;
4291  std::set<Processor> local_procs;
4292  UntypedBuffer buffer;
4293  };
4294 
4308  public:
4309  TaskConfigOptions(bool leaf = false,
4310  bool inner = false,
4311  bool idempotent = false);
4312  public:
4313  bool leaf;
4314  bool inner;
4315  bool idempotent;
4316  };
4317 
4336  public:
4337  ProjectionFunctor(void);
4339  virtual ~ProjectionFunctor(void);
4340  public:
4357  virtual LogicalRegion project(const Mappable *mappable, unsigned index,
4358  LogicalRegion upper_bound,
4359  const DomainPoint &point);
4368  virtual LogicalRegion project(const Mappable *mappable, unsigned index,
4369  LogicalPartition upper_bound,
4370  const DomainPoint &point);
4371 
4382  virtual LogicalRegion project(LogicalRegion upper_bound,
4383  const DomainPoint &point,
4384  const Domain &launch_domain);
4385 
4396  virtual LogicalRegion project(LogicalPartition upper_bound,
4397  const DomainPoint &point,
4398  const Domain &launch_domain);
4399 
4411  LEGION_DEPRECATED("The interface for projection functors has been "
4412  "updated. Please use the new 'project' methods.")
4413  virtual LogicalRegion project(Context ctx, Task *task,
4414  unsigned index,
4415  LogicalRegion upper_bound,
4416  const DomainPoint &point);
4428  LEGION_DEPRECATED("The interface for projection functors has been "
4429  "updated. Please use the new 'project' methods.")
4430  virtual LogicalRegion project(Context ctx, Task *task,
4431  unsigned index,
4432  LogicalPartition upper_bound,
4433  const DomainPoint &point);
4435 
4443  virtual void invert(LogicalRegion region, LogicalRegion upper_bound,
4444  const Domain &launch_domain,
4445  std::vector<DomainPoint> &ordered_points);
4446  virtual void invert(LogicalRegion region, LogicalPartition upper_bound,
4447  const Domain &launch_domain,
4448  std::vector<DomainPoint> &ordered_points);
4450 
4457  virtual bool is_exclusive(void) const { return false; }
4458 
4459  /*
4460  * Indicate whether this is a functional projection
4461  * functor or whether it depends on the operation being
4462  * launched. This will determine which project method
4463  * is invoked by the runtime.
4464  */
4465  virtual bool is_functional(void) const { return false; }
4466 
4472  virtual bool is_invertible(void) const { return false; }
4473 
4485  virtual unsigned get_depth(void) const = 0;
4486  private:
4487  friend class Internal::Runtime;
4488  // For pre-registered projection functors the runtime will
4489  // use this to initialize the runtime pointer
4490  inline void set_runtime(Runtime *rt) { runtime = rt; }
4491  protected:
4492  Runtime *runtime;
4493  };
4494 
4509  public:
4510  ShardingFunctor(void) { }
4511  virtual ~ShardingFunctor(void) { }
4512  public:
4513  virtual ShardID shard(const DomainPoint &point,
4514  const Domain &full_space,
4515  const size_t total_shards) = 0;
4516  public:
4517  virtual bool is_invertible(void) const { return false; }
4518  virtual void invert(ShardID shard,
4519  const Domain &shard_domain,
4520  const Domain &full_domain,
4521  const size_t total_shards,
4522  std::vector<DomainPoint> &points) { }
4523  };
4524 
4541  public:
4542  virtual ~FutureFunctor(void) { }
4543  public:
4544  virtual size_t callback_get_future_size(void) = 0;
4545  virtual void callback_pack_future(void *buffer, size_t size) = 0;
4546  virtual void callback_release_future(void) = 0;
4547  };
4548 
4572  class Runtime {
4573  protected:
4574  // The Runtime bootstraps itself and should
4575  // never need to be explicitly created.
4576  friend class Internal::Runtime;
4577  friend class Future;
4578  Runtime(Internal::Runtime *rt);
4579  public:
4580  //------------------------------------------------------------------------
4581  // Index Space Operations
4582  //------------------------------------------------------------------------
4584 
4595  IndexSpace create_index_space(Context ctx, const Domain &bounds,
4596  TypeTag type_tag = 0,
4597  const char *provenance = NULL);
4598  // Template version
4599  template<int DIM, typename COORD_T>
4601  const Rect<DIM,COORD_T> &bounds,
4602  const char *provenance = NULL);
4603  template<int DIM, typename COORD_T>
4605  const DomainT<DIM,COORD_T> &bounds,
4606  const char *provenance = NULL);
4609 
4622  IndexSpace create_index_space(Context ctx, size_t dimensions,
4623  const Future &f, TypeTag type_tag = 0,
4624  const char *provenance = NULL);
4625  template<int DIM, typename COORD_T>
4626  IndexSpaceT<DIM,COORD_T> create_index_space(Context ctx, const Future &f,
4627  const char *provenance = NULL);
4630 
4638  IndexSpace create_index_space(Context ctx,
4639  const std::vector<DomainPoint> &points,
4640  const char *provenance = NULL);
4641  // Template version
4642  template<int DIM, typename COORD_T>
4644  const std::vector<Point<DIM,COORD_T> > &points,
4645  const char *provenance = NULL);
4648 
4656  IndexSpace create_index_space(Context ctx,
4657  const std::vector<Domain> &rects,
4658  const char *provenance = NULL);
4659  // Template version
4660  template<int DIM, typename COORD_T>
4662  const std::vector<Rect<DIM,COORD_T> > &rects,
4663  const char *provenance = NULL);
4666 
4675  IndexSpace union_index_spaces(Context ctx,
4676  const std::vector<IndexSpace> &spaces,
4677  const char *provenance = NULL);
4678  // Template version
4679  template<int DIM, typename COORD_T>
4681  const std::vector<IndexSpaceT<DIM,COORD_T> > &spaces,
4682  const char *provenance = NULL);
4685 
4694  IndexSpace intersect_index_spaces(Context ctx,
4695  const std::vector<IndexSpace> &spaces,
4696  const char *provenance = NULL);
4697  // Template version
4698  template<int DIM, typename COORD_T>
4700  const std::vector<IndexSpaceT<DIM,COORD_T> > &spaces,
4701  const char *provenance = NULL);
4704 
4710  IndexSpace subtract_index_spaces(Context ctx,
4711  IndexSpace left, IndexSpace right,
4712  const char *provenance = NULL);
4713  // Template version
4714  template<int DIM, typename COORD_T>
4717  const char *provenance = NULL);
4719 
4726  LEGION_DEPRECATED("Use the new index space creation routines with a "
4727  "single domain or rectangle.")
4728  IndexSpace create_index_space(Context ctx, size_t max_num_elmts);
4736  LEGION_DEPRECATED("Use the new index space creation routines with a "
4737  "single domain or rectangle.")
4738  IndexSpace create_index_space(Context ctx,
4739  const std::set<Domain> &domains);
4750  void create_shared_ownership(Context ctx, IndexSpace handle);
4761  void destroy_index_space(Context ctx, IndexSpace handle,
4762  const bool unordered = false,
4763  const bool recurse = true,
4764  const char *provenance = NULL);
4765  public:
4766  //------------------------------------------------------------------------
4767  // Index Partition Operations Based on Coloring
4768  // (These are deprecated, use the dependent partitioning calls instead)
4769  //------------------------------------------------------------------------
4782  LEGION_DEPRECATED("Use the new dependent partitioning API calls instead.")
4783  IndexPartition create_index_partition(Context ctx, IndexSpace parent,
4784  const Domain &color_space,
4785  const PointColoring &coloring,
4786  PartitionKind part_kind = LEGION_COMPUTE_KIND,
4787  Color color = LEGION_AUTO_GENERATE_ID,
4788  bool allocable = false);
4800  LEGION_DEPRECATED("Use the new dependent partitioning API calls instead.")
4801  IndexPartition create_index_partition(Context ctx, IndexSpace parent,
4802  const Coloring &coloring, bool disjoint,
4803  Color color = LEGION_AUTO_GENERATE_ID);
4804 
4816  LEGION_DEPRECATED("Use the new dependent partitioning API calls instead.")
4817  IndexPartition create_index_partition(Context ctx, IndexSpace parent,
4818  const Domain &color_space,
4819  const DomainPointColoring &coloring,
4820  PartitionKind part_kind = LEGION_COMPUTE_KIND,
4821  Color color = LEGION_AUTO_GENERATE_ID);
4834  LEGION_DEPRECATED("Use the new dependent partitioning API calls instead.")
4835  IndexPartition create_index_partition(Context ctx, IndexSpace parent,
4836  Domain color_space,
4837  const DomainColoring &coloring,
4838  bool disjoint,
4839  Color color =
4840  LEGION_AUTO_GENERATE_ID);
4841 
4853  LEGION_DEPRECATED("Use the new dependent partitioning API calls instead.")
4854  IndexPartition create_index_partition(Context ctx, IndexSpace parent,
4855  const Domain &color_space,
4856  const MultiDomainPointColoring &coloring,
4857  PartitionKind part_kind = LEGION_COMPUTE_KIND,
4858  Color color = LEGION_AUTO_GENERATE_ID);
4873  LEGION_DEPRECATED("Use the new dependent partitioning API calls instead.")
4874  IndexPartition create_index_partition(Context ctx, IndexSpace parent,
4875  Domain color_space,
4876  const MultiDomainColoring &coloring,
4877  bool disjoint,
4878  Color color =
4879  LEGION_AUTO_GENERATE_ID);
4889  template <typename T>
4890  LEGION_DEPRECATED("Use the new dependent partitioning API calls instead.")
4891  IndexPartition create_index_partition(Context ctx, IndexSpace parent,
4892  const T& mapping,
4893  Color color =
4894  LEGION_AUTO_GENERATE_ID);
4895 
4914  LEGION_DEPRECATED("Use the new dependent partitioning API calls instead.")
4915  IndexPartition create_index_partition(Context ctx, IndexSpace parent,
4916  LegionRuntime::Accessor::RegionAccessor<
4917  LegionRuntime::Accessor::AccessorType::Generic> field_accessor,
4918  Color color = LEGION_AUTO_GENERATE_ID);
4929  void create_shared_ownership(Context ctx, IndexPartition handle);
4940  void destroy_index_partition(Context ctx, IndexPartition handle,
4941  const bool unordered = false,
4942  const bool recurse = true,
4943  const char *provenance = NULL);
4944  public:
4945  //------------------------------------------------------------------------
4946  // Dependent Partitioning Operations
4947  //------------------------------------------------------------------------
4949 
4969  IndexPartition create_equal_partition(Context ctx, IndexSpace parent,
4970  IndexSpace color_space,
4971  size_t granularity = 1,
4972  Color color =
4973  LEGION_AUTO_GENERATE_ID,
4974  const char *provenance = NULL);
4975  template<int DIM, typename COORD_T,
4976  int COLOR_DIM, typename COLOR_COORD_T>
4978  IndexSpaceT<DIM,COORD_T> parent,
4980  size_t granularity = 1,
4981  Color color = LEGION_AUTO_GENERATE_ID,
4982  const char *provenance = NULL);
4985 
5003  const std::map<DomainPoint,int> &weights,
5004  IndexSpace color_space,
5005  size_t granularity = 1,
5006  Color color = LEGION_AUTO_GENERATE_ID,
5007  const char *provenance = NULL);
5008  template<int DIM, typename COORD_T, int COLOR_DIM, typename COLOR_COORD_T>
5010  IndexSpaceT<DIM,COORD_T> parent,
5011  const std::map<Point<COLOR_DIM,COLOR_COORD_T>,int> &weights,
5013  size_t granularity = 1,
5014  Color color = LEGION_AUTO_GENERATE_ID,
5015  const char *provenance = NULL);
5016  // 64-bit versions
5018  const std::map<DomainPoint,size_t> &weights,
5019  IndexSpace color_space,
5020  size_t granularity = 1,
5021  Color color = LEGION_AUTO_GENERATE_ID,
5022  const char *provenance = NULL);
5023  template<int DIM, typename COORD_T, int COLOR_DIM, typename COLOR_COORD_T>
5025  IndexSpaceT<DIM,COORD_T> parent,
5026  const std::map<Point<COLOR_DIM,COLOR_COORD_T>,size_t> &weights,
5028  size_t granularity = 1, Color color = LEGION_AUTO_GENERATE_ID,
5029  const char *provenance = NULL);
5030  // Alternate versions of the above method that take a future map where
5031  // the values in the future map will be interpretted as integer weights
5032  // You can use this method with both 32 and 64 bit weights
5034  const FutureMap &weights,
5035  IndexSpace color_space,
5036  size_t granularity = 1,
5037  Color color =
5038  LEGION_AUTO_GENERATE_ID,
5039  const char *provenance = NULL);
5040  template<int DIM, typename COORD_T, int COLOR_DIM, typename COLOR_COORD_T>
5042  IndexSpaceT<DIM,COORD_T> parent,
5043  const FutureMap &weights,
5045  size_t granularity = 1,
5046  Color color = LEGION_AUTO_GENERATE_ID,
5047  const char *provenance = NULL);
5050 
5075  IndexSpace parent,
5076  IndexPartition handle1,
5077  IndexPartition handle2,
5078  IndexSpace color_space,
5079  PartitionKind part_kind = LEGION_COMPUTE_KIND,
5080  Color color = LEGION_AUTO_GENERATE_ID,
5081  const char *provenance = NULL);
5082  template<int DIM, typename COORD_T,
5083  int COLOR_DIM, typename COLOR_COORD_T>
5085  IndexSpaceT<DIM,COORD_T> parent,
5089  PartitionKind part_kind = LEGION_COMPUTE_KIND,
5090  Color color = LEGION_AUTO_GENERATE_ID,
5091  const char *provenance = NULL);
5094 
5120  IndexSpace parent,
5121  IndexPartition handle1,
5122  IndexPartition handle2,
5123  IndexSpace color_space,
5124  PartitionKind part_kind = LEGION_COMPUTE_KIND,
5125  Color color = LEGION_AUTO_GENERATE_ID,
5126  const char *provenance = NULL);
5127  template<int DIM, typename COORD_T,
5128  int COLOR_DIM, typename COLOR_COORD_T>
5130  Context ctx,
5131  IndexSpaceT<DIM,COORD_T> parent,
5135  PartitionKind part_kind = LEGION_COMPUTE_KIND,
5136  Color color = LEGION_AUTO_GENERATE_ID,
5137  const char *provenance = NULL);
5140 
5161  IndexSpace parent,
5162  IndexPartition partition,
5163  PartitionKind part_kind = LEGION_COMPUTE_KIND,
5164  Color color = LEGION_AUTO_GENERATE_ID,
5165  bool dominates = false,
5166  const char *provenance = NULL);
5167  template<int DIM, typename COORD_T>
5169  IndexSpaceT<DIM,COORD_T> parent,
5170  IndexPartitionT<DIM,COORD_T> partition,
5171  PartitionKind part_kind = LEGION_COMPUTE_KIND,
5172  Color color = LEGION_AUTO_GENERATE_ID,
5173  bool dominates = false,
5174  const char *provenance = NULL);
5177 
5203  IndexSpace parent,
5204  IndexPartition handle1,
5205  IndexPartition handle2,
5206  IndexSpace color_space,
5207  PartitionKind part_kind = LEGION_COMPUTE_KIND,
5208  Color color = LEGION_AUTO_GENERATE_ID,
5209  const char *provenance = NULL);
5210  template<int DIM, typename COORD_T,
5211  int COLOR_DIM, typename COLOR_COORD_T>
5213  IndexSpaceT<DIM,COORD_T> parent,
5217  PartitionKind part_kind = LEGION_COMPUTE_KIND,
5218  Color color = LEGION_AUTO_GENERATE_ID,
5219  const char *provenance = NULL);
5222 
5247  Color create_cross_product_partitions(Context ctx,
5248  IndexPartition handle1,
5249  IndexPartition handle2,
5250  std::map<IndexSpace,IndexPartition> &handles,
5251  PartitionKind part_kind = LEGION_COMPUTE_KIND,
5252  Color color = LEGION_AUTO_GENERATE_ID,
5253  const char *provenance = NULL);
5254  template<int DIM, typename COORD_T,
5255  int COLOR_DIM, typename COLOR_COORD_T>
5256  Color create_cross_product_partitions(Context ctx,
5259  typename std::map<
5261  IndexPartitionT<DIM,COORD_T> > &handles,
5262  PartitionKind part_kind = LEGION_COMPUTE_KIND,
5263  Color color = LEGION_AUTO_GENERATE_ID,
5264  const char *provenance = NULL);
5267 
5291  void create_association(Context ctx,
5292  LogicalRegion domain,
5293  LogicalRegion domain_parent,
5294  FieldID domain_fid,
5295  IndexSpace range,
5296  MapperID id = 0,
5297  MappingTagID tag = 0,
5298  UntypedBuffer map_arg = UntypedBuffer(),
5299  const char *provenance = NULL);
5300  void create_bidirectional_association(Context ctx,
5301  LogicalRegion domain,
5302  LogicalRegion domain_parent,
5303  FieldID domain_fid,
5304  LogicalRegion range,
5305  LogicalRegion range_parent,
5306  FieldID range_fid,
5307  MapperID id = 0,
5308  MappingTagID tag = 0,
5309  UntypedBuffer map_arg =
5310  UntypedBuffer(),
5311  const char *provenance = NULL);
5312  // Template versions
5313  template<int DIM1, typename COORD_T1, int DIM2, typename COORD_T2>
5314  void create_association(Context ctx,
5316  LogicalRegionT<DIM1,COORD_T1> domain_parent,
5317  FieldID domain_fid, // type: Point<DIM2,COORD_T2>
5319  MapperID id = 0,
5320  MappingTagID tag = 0,
5321  UntypedBuffer map_arg = UntypedBuffer(),
5322  const char *provenance = NULL);
5323  template<int DIM1, typename COORD_T1, int DIM2, typename COORD_T2>
5324  void create_bidirectional_association(Context ctx,
5326  LogicalRegionT<DIM1,COORD_T1> domain_parent,
5327  FieldID domain_fid, // type: Point<DIM2,COORD_T2>
5329  LogicalRegionT<DIM2,COORD_T2> range_parent,
5330  FieldID range_fid, // type: Point<DIM1,COORD_T1>
5331  MapperID id = 0,
5332  MappingTagID tag = 0,
5333  UntypedBuffer map_arg = UntypedBuffer(),
5334  const char *provenance = NULL);
5337 
5363  IndexSpace parent,
5364  IndexSpace color_space,
5365  DomainTransform transform,
5366  Domain extent,
5367  PartitionKind part_kind = LEGION_COMPUTE_KIND,
5368  Color color = LEGION_AUTO_GENERATE_ID,
5369  const char *provenance = NULL);
5370  // Template version
5371  template<int DIM, int COLOR_DIM, typename COORD_T>
5373  IndexSpaceT<DIM,COORD_T> parent,
5374  IndexSpaceT<COLOR_DIM,COORD_T> color_space,
5375  Transform<DIM,COLOR_DIM,COORD_T> transform,
5376  Rect<DIM,COORD_T> extent,
5377  PartitionKind part_kind = LEGION_COMPUTE_KIND,
5378  Color color = LEGION_AUTO_GENERATE_ID,
5379  const char *provenance = NULL);
5382 
5398  IndexSpace parent,
5399  DomainPoint blocking_factor,
5400  Color color = LEGION_AUTO_GENERATE_ID,
5401  const char *provenance = NULL);
5402  // Template version
5403  template<int DIM, typename COORD_T>
5405  IndexSpaceT<DIM,COORD_T> parent,
5406  Point<DIM,COORD_T> blocking_factor,
5407  Color color = LEGION_AUTO_GENERATE_ID,
5408  const char *provenance = NULL);
5422  IndexSpace parent,
5423  DomainPoint blockify_factor,
5424  DomainPoint origin,
5425  Color color = LEGION_AUTO_GENERATE_ID,
5426  const char *provenance = NULL);
5427  // Template version
5428  template<int DIM, typename COORD_T>
5430  IndexSpaceT<DIM,COORD_T> parent,
5431  Point<DIM,COORD_T> blocking_factor,
5432  Point<DIM,COORD_T> origin,
5433  Color color = LEGION_AUTO_GENERATE_ID,
5434  const char *provenance = NULL);
5437 
5458  IndexSpace parent,
5459  const std::map<DomainPoint,Domain> &domains,
5460  IndexSpace color_space,
5461  bool perform_intersections = true,
5462  PartitionKind part_kind = LEGION_COMPUTE_KIND,
5463  Color color = LEGION_AUTO_GENERATE_ID,
5464  const char *provenance = NULL);
5465  template<int DIM, typename COORD_T, int COLOR_DIM, typename COLOR_COORD_T>
5467  IndexSpaceT<DIM,COORD_T> parent,
5468  const std::map<
5469  Point<COLOR_DIM,COLOR_COORD_T>,
5470  DomainT<DIM,COORD_T> > &domains,
5471  IndexSpaceT<COLOR_DIM,
5472  COLOR_COORD_T> color_space,
5473  bool perform_intersections = true,
5474  PartitionKind part_kind = LEGION_COMPUTE_KIND,
5475  Color color = LEGION_AUTO_GENERATE_ID,
5476  const char *provenance = NULL);
5495  IndexSpace parent,
5496  const FutureMap &domain_future_map,
5497  IndexSpace color_space,
5498  bool perform_intersections = true,
5499  PartitionKind part_kind = LEGION_COMPUTE_KIND,
5500  Color color = LEGION_AUTO_GENERATE_ID,
5501  const char *provenance = NULL);
5502  template<int DIM, typename COORD_T, int COLOR_DIM, typename COLOR_COORD_T>
5504  IndexSpaceT<DIM,COORD_T> parent,
5505  const FutureMap &domain_future_map,
5506  IndexSpaceT<COLOR_DIM,
5507  COLOR_COORD_T> color_space,
5508  bool perform_intersections = true,
5509  PartitionKind part_kind = LEGION_COMPUTE_KIND,
5510  Color color = LEGION_AUTO_GENERATE_ID,
5511  const char *provenance = NULL);
5514 
5543  LogicalRegion handle,
5544  LogicalRegion parent,
5545  FieldID fid,
5546  IndexSpace color_space,
5547  Color color =
5548  LEGION_AUTO_GENERATE_ID,
5549  MapperID id = 0,
5550  MappingTagID tag = 0,
5551  PartitionKind part_kind =
5552  LEGION_DISJOINT_KIND,
5553  UntypedBuffer map_arg =
5554  UntypedBuffer(),
5555  const char *provenance = NULL);
5556  template<int DIM, typename COORD_T,
5557  int COLOR_DIM, typename COLOR_COORD_T>
5561  FieldID fid, // type: Point<COLOR_DIM,COLOR_COORD_T>
5563  Color color = LEGION_AUTO_GENERATE_ID,
5564  MapperID id = 0, MappingTagID tag = 0,
5565  PartitionKind part_kind = LEGION_DISJOINT_KIND,
5566  UntypedBuffer map_arg = UntypedBuffer(),
5567  const char *provenance = NULL);
5570 
5604  IndexSpace handle,
5605  LogicalPartition projection,
5606  LogicalRegion parent,
5607  FieldID fid,
5608  IndexSpace color_space,
5609  PartitionKind part_kind = LEGION_COMPUTE_KIND,
5610  Color color = LEGION_AUTO_GENERATE_ID,
5611  MapperID id = 0, MappingTagID tag = 0,
5612  UntypedBuffer map_arg = UntypedBuffer(),
5613  const char *provenance = NULL);
5614  template<int DIM1, typename COORD_T1,
5615  int DIM2, typename COORD_T2,
5616  int COLOR_DIM, typename COLOR_COORD_T>
5621  FieldID fid, // type: Point<DIM2,COORD_T2>
5623  PartitionKind part_kind = LEGION_COMPUTE_KIND,
5624  Color color = LEGION_AUTO_GENERATE_ID,
5625  MapperID id = 0, MappingTagID tag = 0,
5626  UntypedBuffer map_arg = UntypedBuffer(),
5627  const char *provenance = NULL);
5628  // Range versions of image
5629  IndexPartition create_partition_by_image_range(Context ctx,
5630  IndexSpace handle,
5631  LogicalPartition projection,
5632  LogicalRegion parent,
5633  FieldID fid,
5634  IndexSpace color_space,
5635  PartitionKind part_kind = LEGION_COMPUTE_KIND,
5636  Color color = LEGION_AUTO_GENERATE_ID,
5637  MapperID id = 0, MappingTagID tag = 0,
5638  UntypedBuffer map_arg = UntypedBuffer(),
5639  const char *provenance = NULL);
5640  template<int DIM1, typename COORD_T1,
5641  int DIM2, typename COORD_T2,
5642  int COLOR_DIM, typename COLOR_COORD_T>
5643  IndexPartitionT<DIM2,COORD_T2> create_partition_by_image_range(
5644  Context ctx,
5648  FieldID fid, // type: Rect<DIM2,COORD_T2>
5650  PartitionKind part_kind = LEGION_COMPUTE_KIND,
5651  Color color = LEGION_AUTO_GENERATE_ID,
5652  MapperID id = 0, MappingTagID tag = 0,
5653  UntypedBuffer map_arg = UntypedBuffer(),
5654  const char *provenance = NULL);
5657 
5688  IndexPartition projection,
5689  LogicalRegion handle,
5690  LogicalRegion parent,
5691  FieldID fid,
5692  IndexSpace color_space,
5693  PartitionKind part_kind = LEGION_COMPUTE_KIND,
5694  Color color = LEGION_AUTO_GENERATE_ID,
5695  MapperID id = 0, MappingTagID tag = 0,
5696  UntypedBuffer map_arg = UntypedBuffer(),
5697  const char *provenance = NULL);
5698  template<int DIM1, typename COORD_T1,
5699  int DIM2, typename COORD_T2,
5700  int COLOR_DIM, typename COLOR_COORD_T>
5702  IndexPartitionT<DIM2,COORD_T2> projection,
5705  FieldID fid, // type: Point<DIM2,COORD_T2>
5707  PartitionKind part_kind = LEGION_COMPUTE_KIND,
5708  Color color = LEGION_AUTO_GENERATE_ID,
5709  MapperID id = 0, MappingTagID tag = 0,
5710  UntypedBuffer map_arg = UntypedBuffer(),
5711  const char *provenance = NULL);
5712  // Range versions of preimage
5713  IndexPartition create_partition_by_preimage_range(Context ctx,
5714  IndexPartition projection,
5715  LogicalRegion handle,
5716  LogicalRegion parent,
5717  FieldID fid,
5718  IndexSpace color_space,
5719  PartitionKind part_kind = LEGION_COMPUTE_KIND,
5720  Color color = LEGION_AUTO_GENERATE_ID,
5721  MapperID id = 0, MappingTagID tag = 0,
5722  UntypedBuffer map_arg = UntypedBuffer(),
5723  const char *provenance = NULL);
5724  template<int DIM1, typename COORD_T1,
5725  int DIM2, typename COORD_T2,
5726  int COLOR_DIM, typename COLOR_COORD_T>
5727  IndexPartitionT<DIM1,COORD_T1> create_partition_by_preimage_range(
5728  Context ctx,
5729  IndexPartitionT<DIM2,COORD_T2> projection,
5732  FieldID fid, // type: Rect<DIM2,COORD_T2>
5734  PartitionKind part_kind = LEGION_COMPUTE_KIND,
5735  Color color = LEGION_AUTO_GENERATE_ID,
5736  MapperID id = 0, MappingTagID tag = 0,
5737  UntypedBuffer map_arg = UntypedBuffer(),
5738  const char *provenance = NULL);
5740  public:
5741  //------------------------------------------------------------------------
5742  // Computed Index Spaces and Partitions
5743  //------------------------------------------------------------------------
5745 
5772  IndexSpace parent,
5773  IndexSpace color_space,
5774  PartitionKind part_kind = LEGION_COMPUTE_KIND,
5775  Color color = LEGION_AUTO_GENERATE_ID,
5776  const char *provenance = NULL);
5777  template<int DIM, typename COORD_T,
5778  int COLOR_DIM, typename COLOR_COORD_T>
5780  IndexSpaceT<DIM,COORD_T> parent,
5782  PartitionKind part_kind = LEGION_COMPUTE_KIND,
5783  Color color = LEGION_AUTO_GENERATE_ID,
5784  const char *provenance = NULL);
5787 
5803  IndexSpace create_index_space_union(Context ctx, IndexPartition parent,
5804  const DomainPoint &color,
5805  const std::vector<IndexSpace> &handles,
5806  const char *provenance = NULL);
5807  template<int DIM, typename COORD_T,
5808  int COLOR_DIM, typename COLOR_COORD_T>
5811  Point<COLOR_DIM,COLOR_COORD_T> color,
5812  const typename std::vector<
5813  IndexSpaceT<DIM,COORD_T> > &handles,
5814  const char *provenance = NULL);
5817 
5831  const DomainPoint &color,
5832  IndexPartition handle,
5833  const char *provenance = NULL);
5834  template<int DIM, typename COORD_T,
5835  int COLOR_DIM, typename COLOR_COORD_T>
5838  Point<COLOR_DIM,COLOR_COORD_T> color,
5840  const char *provenance = NULL);
5843 
5860  IndexPartition parent,
5861  const DomainPoint &color,
5862  const std::vector<IndexSpace> &handles,
5863  const char *provenance = NULL);
5864  template<int DIM, typename COORD_T,
5865  int COLOR_DIM, typename COLOR_COORD_T>
5868  Point<COLOR_DIM,COLOR_COORD_T> color,
5869  const typename std::vector<
5870  IndexSpaceT<DIM,COORD_T> > &handles,
5871  const char *provenance = NULL);
5874 
5888  IndexPartition parent,
5889  const DomainPoint &color,
5890  IndexPartition handle,
5891  const char *provenannce=NULL);
5892  template<int DIM, typename COORD_T,
5893  int COLOR_DIM, typename COLOR_COORD_T>
5896  Point<COLOR_DIM,COLOR_COORD_T> color,
5898  const char *provenance = NULL);
5901 
5923  IndexPartition parent,
5924  const DomainPoint &color,
5925  IndexSpace initial,
5926  const std::vector<IndexSpace> &handles,
5927  const char *provenancne = NULL);
5928  template<int DIM, typename COORD_T,
5929  int COLOR_DIM, typename COLOR_COORD_T>
5932  Point<COLOR_DIM,COLOR_COORD_T> color,
5933  IndexSpaceT<DIM,COORD_T> initial,
5934  const typename std::vector<
5935  IndexSpaceT<DIM,COORD_T> > &handles,
5936  const char *provenance = NULL);
5938  public:
5939  //------------------------------------------------------------------------
5940  // Index Tree Traversal Operations
5941  //------------------------------------------------------------------------
5943 
5951  IndexPartition get_index_partition(Context ctx, IndexSpace parent,
5952  Color color);
5953  IndexPartition get_index_partition(Context ctx, IndexSpace parent,
5954  const DomainPoint &color);
5955  // Context free versions
5956  IndexPartition get_index_partition(IndexSpace parent, Color color);
5958  const DomainPoint &color);
5959  // Template version
5960  template<int DIM, typename COORD_T>
5962  IndexSpaceT<DIM,COORD_T> parent, Color color);
5963 
5965 
5967 
5975  bool has_index_partition(Context ctx, IndexSpace parent, Color color);
5976  bool has_index_partition(Context ctx, IndexSpace parent,
5977  const DomainPoint &color);
5978  // Context free
5979  bool has_index_partition(IndexSpace parent, Color color);
5980  bool has_index_partition(IndexSpace parent,
5981  const DomainPoint &color);
5982  // Template version
5983  template<int DIM, typename COORD_T>
5984  bool has_index_partition(IndexSpaceT<DIM,COORD_T> parent, Color color);
5986 
5988 
5997  Color color);
5999  const DomainPoint &color);
6000  // Context free versions
6003  const DomainPoint &color);
6004  // Template version
6005  template<int DIM, typename COORD_T,
6006  int COLOR_DIM, typename COLOR_COORD_T>
6009  Point<COLOR_DIM,COLOR_COORD_T> color);
6011 
6013 
6021  bool has_index_subspace(Context ctx, IndexPartition p,
6022  const DomainPoint &color);
6023  // Context free
6025  const DomainPoint &color);
6026  // Template version
6027  template<int DIM, typename COORD_T,
6028  int COLOR_DIM, typename COLOR_COORD_T>
6030  Point<COLOR_DIM,COLOR_COORD_T> color);
6032 
6034 
6044  LEGION_DEPRECATED("Multiple domains are no longer supported.")
6045  bool has_multiple_domains(Context ctx, IndexSpace handle);
6046  // Context free
6047  LEGION_DEPRECATED("Multiple domains are no longer supported.")
6048  bool has_multiple_domains(IndexSpace handle);
6050 
6052 
6059  Domain get_index_space_domain(Context ctx, IndexSpace handle);
6060  // Context free
6062  // Template version
6063  template<int DIM, typename COORD_T>
6064  DomainT<DIM,COORD_T> get_index_space_domain(
6065  IndexSpaceT<DIM,COORD_T> handle);
6067 
6069 
6079  LEGION_DEPRECATED("Multiple domains are no longer supported.")
6080  void get_index_space_domains(Context ctx, IndexSpace handle,
6081  std::vector<Domain> &domains);
6082  // Context free
6083  LEGION_DEPRECATED("Multiple domains are no longer supported.")
6084  void get_index_space_domains(IndexSpace handle,
6085  std::vector<Domain> &domains);
6087 
6089 
6097  // Context free
6099  // Template version
6100  template<int DIM, typename COORD_T,
6101  int COLOR_DIM, typename COLOR_COORD_T>
6102  DomainT<COLOR_DIM,COLOR_COORD_T>
6105 
6107 
6114  IndexPartition p);
6115  // Context free
6117  // Template version
6118  template<int DIM, typename COORD_T,
6119  int COLOR_DIM, typename COLOR_COORD_T>
6123 
6125 
6134  void get_index_space_partition_colors(Context ctx, IndexSpace sp,
6135  std::set<Color> &colors);
6136  void get_index_space_partition_colors(Context ctx, IndexSpace sp,
6137  std::set<DomainPoint> &colors);
6138  // Context free versions
6140  std::set<Color> &colors);
6142  std::set<DomainPoint> &colors);
6144 
6146 
6152  bool is_index_partition_disjoint(Context ctx, IndexPartition p);
6153  // Context free
6156 
6158 
6164  bool is_index_partition_complete(Context ctx, IndexPartition p);
6165  // Context free
6168 
6177  template <unsigned DIM>
6178  LEGION_DEPRECATED("Use the new templated methods for geting a subspace.")
6180  LegionRuntime::Arrays::Point<DIM> color_point);
6181 
6183 
6191  Color get_index_space_color(Context ctx, IndexSpace handle);
6192  DomainPoint get_index_space_color_point(Context ctx, IndexSpace handle);
6193  // Context free
6194  Color get_index_space_color(IndexSpace handle);
6195  DomainPoint get_index_space_color_point(IndexSpace handle);
6196  // Template version
6197  template<int DIM, typename COORD_T,
6198  int COLOR_DIM, typename COLOR_COORD_T>
6199  Point<COLOR_DIM,COLOR_COORD_T>
6202 
6204 
6211  Color get_index_partition_color(Context ctx, IndexPartition handle);
6212  DomainPoint get_index_partition_color_point(Context ctx,
6213  IndexPartition handle);
6214  // Context free
6216  DomainPoint get_index_partition_color_point(IndexPartition handle);
6218 
6220 
6226  IndexSpace get_parent_index_space(Context ctx, IndexPartition handle);
6227  // Context free
6229  // Template version
6230  template<int DIM, typename COORD_T>
6234 
6236 
6242  bool has_parent_index_partition(Context ctx, IndexSpace handle);
6243  // Context free
6246 
6248 
6256  // Context free
6258  // Template version
6259  template<int DIM, typename COORD_T>
6261  IndexSpaceT<DIM,COORD_T> handle);
6263 
6265 
6271  unsigned get_index_space_depth(Context ctx, IndexSpace handle);
6272  // Context free
6273  unsigned get_index_space_depth(IndexSpace handle);
6275 
6277 
6283  unsigned get_index_partition_depth(Context ctx, IndexPartition handle);
6284  // Context free
6285  unsigned get_index_partition_depth(IndexPartition handle);
6287  public:
6288  //------------------------------------------------------------------------
6289  // Safe Cast Operations
6290  //------------------------------------------------------------------------
6299  ptr_t safe_cast(Context ctx, ptr_t pointer, LogicalRegion region);
6300 
6310  DomainPoint safe_cast(Context ctx, DomainPoint point,
6311  LogicalRegion region);
6312 
6321  template<int DIM, typename COORD_T>
6322  bool safe_cast(Context ctx,
6323  Point<DIM,COORD_T> point,
6325  public:
6326  //------------------------------------------------------------------------
6327  // Field Space Operations
6328  //------------------------------------------------------------------------
6336  FieldSpace create_field_space(Context ctx, const char *provenance = NULL);
6348  FieldSpace create_field_space(Context ctx,
6349  const std::vector<size_t> &field_sizes,
6350  std::vector<FieldID> &resulting_fields,
6351  CustomSerdezID serdez_id = 0,
6352  const char *provenance = NULL);
6364  FieldSpace create_field_space(Context ctx,
6365  const std::vector<Future> &field_sizes,
6366  std::vector<FieldID> &resulting_fields,
6367  CustomSerdezID serdez_id = 0,
6368  const char *provenance = NULL);
6379  void create_shared_ownership(Context ctx, FieldSpace handle);
6389  void destroy_field_space(Context ctx, FieldSpace handle,
6390  const bool unordered = false,
6391  const char *provenance = NULL);
6392 
6394 
6401  size_t get_field_size(Context ctx, FieldSpace handle, FieldID fid);
6402  // Context free
6403  size_t get_field_size(FieldSpace handle, FieldID fid);
6405 
6407 
6413  void get_field_space_fields(Context ctx, FieldSpace handle,
6414  std::vector<FieldID> &fields);
6415  // Context free
6416  void get_field_space_fields(FieldSpace handle,
6417  std::vector<FieldID> &fields);
6419 
6421 
6427  void get_field_space_fields(Context ctx, FieldSpace handle,
6428  std::set<FieldID> &fields);
6429  // Context free
6430  void get_field_space_fields(FieldSpace handle,
6431  std::set<FieldID> &fields);
6433  public:
6434  //------------------------------------------------------------------------
6435  // Logical Region Operations
6436  //------------------------------------------------------------------------
6450  LogicalRegion create_logical_region(Context ctx, IndexSpace index,
6451  FieldSpace fields,
6452  bool task_local = false,
6453  const char *provenance = NULL);
6454  // Template version
6455  template<int DIM, typename COORD_T>
6458  FieldSpace fields,
6459  bool task_local = false,
6460  const char *provenance = NULL);
6471  void create_shared_ownership(Context ctx, LogicalRegion handle);
6481  void destroy_logical_region(Context ctx, LogicalRegion handle,
6482  const bool unordered = false,
6483  const char *provenance = NULL);
6484 
6492  LEGION_DEPRECATED("Destruction of logical partitions are no-ops now."
6493  "Logical partitions are automatically destroyed when their root "
6494  "logical region or their index spartition are destroyed.")
6495  void destroy_logical_partition(Context ctx, LogicalPartition handle,
6496  const bool unordered = false);
6497  public:
6498  //------------------------------------------------------------------------
6499  // Logical Region Tree Traversal Operations
6500  //------------------------------------------------------------------------
6502 
6512  IndexPartition handle);
6513  // Context free
6515  IndexPartition handle);
6516  // Template version
6517  template<int DIM, typename COORD_T>
6522 
6524 
6533  LogicalRegion parent,
6534  Color c);
6536  LogicalRegion parent,
6537  const DomainPoint &c);
6538  // Context free
6540  Color c);
6542  const DomainPoint &c);
6543  // Template version
6544  template<int DIM, typename COORD_T>
6547  Color c);
6549 
6551 
6559  bool has_logical_partition_by_color(Context ctx,
6560  LogicalRegion parent,
6561  const DomainPoint &c);
6562  // Context free
6564  const DomainPoint &c);
6566 
6568 
6578  IndexPartition handle,
6579  FieldSpace fspace,
6580  RegionTreeID tid);
6581  // Context free
6583  FieldSpace fspace,
6584  RegionTreeID tid);
6585  // Template version
6586  template<int DIM, typename COORD_T>
6589  FieldSpace fspace, RegionTreeID tid);
6591 
6593 
6603  IndexSpace handle);
6604  // Context free
6606  IndexSpace handle);
6607  // Template version
6608  template<int DIM, typename COORD_T>
6611  IndexSpaceT<DIM,COORD_T> handle);
6613 
6615 
6624  LogicalPartition parent,
6625  Color c);
6627  LogicalPartition parent,
6628  const DomainPoint &c);
6629  // Context free
6631  Color c);
6633  const DomainPoint &c);
6634  // Template version
6635  template<int DIM, typename COORD_T,
6636  int COLOR_DIM, typename COLOR_COORD_T>
6639  Point<COLOR_DIM,COLOR_COORD_T> color);
6641 
6643 
6651  bool has_logical_subregion_by_color(Context ctx,
6652  LogicalPartition parent,
6653  const DomainPoint &c);
6654  // Context free
6656  const DomainPoint &c);
6657  // Template version
6658  template<int DIM, typename COORD_T,
6659  int COLOR_DIM, typename COLOR_COORD_T>
6661  Point<COLOR_DIM,COLOR_COORD_T> color);
6663 
6665 
6675  IndexSpace handle,
6676  FieldSpace fspace,
6677  RegionTreeID tid);
6678  // Context free
6680  FieldSpace fspace,
6681  RegionTreeID tid);
6682  // Template version
6683  template<int DIM, typename COORD_T>
6685  IndexSpaceT<DIM,COORD_T> handle,
6686  FieldSpace space, RegionTreeID tid);
6688 
6690 
6698  Color get_logical_region_color(Context ctx, LogicalRegion handle);
6699  DomainPoint get_logical_region_color_point(Context ctx,
6700  LogicalRegion handle);
6701  // Context free versions
6703  DomainPoint get_logical_region_color_point(LogicalRegion handle);
6704  // Template version
6705  template<int DIM, typename COORD_T,
6706  int COLOR_DIM, typename COLOR_COORD_T>
6707  Point<COLOR_DIM,COLOR_COORD_T>
6708  get_logical_region_color_point(LogicalRegionT<DIM,COORD_T> handle);
6710 
6712 
6719  Color get_logical_partition_color(Context ctx, LogicalPartition handle);
6720  DomainPoint get_logical_partition_color_point(Context ctx,
6721  LogicalPartition handle);
6722  // Context free versions
6724  DomainPoint get_logical_partition_color_point(LogicalPartition handle);
6726 
6728 
6735  LogicalPartition handle);
6736  // Context free
6738  // Template version
6739  template<int DIM, typename COORD_T>
6743 
6745 
6751  bool has_parent_logical_partition(Context ctx, LogicalRegion handle);
6752  // Context free
6755 
6757 
6764  LogicalRegion handle);
6765  // Context free
6767  // Template version
6768  template<int DIM, typename COORD_T>
6772  public:
6773  //------------------------------------------------------------------------
6774  // Allocator and Argument Map Operations
6775  //------------------------------------------------------------------------
6776 #ifdef __GNUC__
6777 #pragma GCC diagnostic push
6778 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
6779 #endif
6780 #ifdef __clang__
6781 #pragma clang diagnostic push
6782 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
6783 #endif
6784 
6795  LEGION_DEPRECATED("Dynamic index allocation is no longer supported.")
6796  IndexAllocator create_index_allocator(Context ctx, IndexSpace handle);
6797 #ifdef __GNUC__
6798 #pragma GCC diagnostic pop
6799 #endif
6800 #ifdef __clang__
6801 #pragma clang diagnostic pop
6802 #endif
6803 
6810  FieldAllocator create_field_allocator(Context ctx, FieldSpace handle);
6811 
6820  LEGION_DEPRECATED("ArgumentMap can be constructed directly.")
6821  ArgumentMap create_argument_map(Context ctx);
6822  public:
6823  //------------------------------------------------------------------------
6824  // Task Launch Operations
6825  //------------------------------------------------------------------------
6834  Future execute_task(Context ctx, const TaskLauncher &launcher);
6835 
6845  FutureMap execute_index_space(Context ctx,
6846  const IndexTaskLauncher &launcher);
6847 
6863  Future execute_index_space(Context ctx, const IndexTaskLauncher &launcher,
6864  ReductionOpID redop, bool deterministic = false);
6865 
6881  Future reduce_future_map(Context ctx, const FutureMap &future_map,
6882  ReductionOpID redop, bool deterministic = false,
6883  const char *provenance = NULL);
6884 
6910  FutureMap construct_future_map(Context ctx, IndexSpace domain,
6911  const std::map<DomainPoint,UntypedBuffer> &data,
6912  bool collective = false, ShardingID sid = 0,
6913  bool implicit_sharding = false);
6914  LEGION_DEPRECATED("Use the version that takes an IndexSpace instead")
6915  FutureMap construct_future_map(Context ctx, const Domain &domain,
6916  const std::map<DomainPoint,UntypedBuffer> &data,
6917  bool collective = false, ShardingID sid = 0,
6918  bool implicit_sharding = false);
6919 
6943  FutureMap construct_future_map(Context ctx, IndexSpace domain,
6944  const std::map<DomainPoint,Future> &futures,
6945  bool collective = false, ShardingID sid = 0,
6946  bool implicit_sharding = false,
6947  const char *provenance = NULL);
6948  LEGION_DEPRECATED("Use the version that takes an IndexSpace instead")
6949  FutureMap construct_future_map(Context ctx, const Domain &domain,
6950  const std::map<DomainPoint,Future> &futures,
6951  bool collective = false, ShardingID sid = 0,
6952  bool implicit_sharding = false);
6953 
6969  LEGION_DEPRECATED("Launching tasks should be done with the new task "
6970  "launcher interface.")
6971  Future execute_task(Context ctx, TaskID task_id,
6972  const std::vector<IndexSpaceRequirement> &indexes,
6973  const std::vector<FieldSpaceRequirement> &fields,
6974  const std::vector<RegionRequirement> &regions,
6975  const UntypedBuffer &arg,
6976  const Predicate &predicate = Predicate::TRUE_PRED,
6977  MapperID id = 0,
6978  MappingTagID tag = 0);
6979 
6998  LEGION_DEPRECATED("Launching tasks should be done with the new task "
6999  "launcher interface.")
7000  FutureMap execute_index_space(Context ctx, TaskID task_id,
7001  const Domain domain,
7002  const std::vector<IndexSpaceRequirement> &indexes,
7003  const std::vector<FieldSpaceRequirement> &fields,
7004  const std::vector<RegionRequirement> &regions,
7005  const UntypedBuffer &global_arg,
7006  const ArgumentMap &arg_map,
7007  const Predicate &predicate = Predicate::TRUE_PRED,
7008  bool must_paralleism = false,
7009  MapperID id = 0,
7010  MappingTagID tag = 0);
7011 
7033  LEGION_DEPRECATED("Launching tasks should be done with the new task "
7034  "launcher interface.")
7035  Future execute_index_space(Context ctx, TaskID task_id,
7036  const Domain domain,
7037  const std::vector<IndexSpaceRequirement> &indexes,
7038  const std::vector<FieldSpaceRequirement> &fields,
7039  const std::vector<RegionRequirement> &regions,
7040  const UntypedBuffer &global_arg,
7041  const ArgumentMap &arg_map,
7042  ReductionOpID reduction,
7043  const UntypedBuffer &initial_value,
7044  const Predicate &predicate = Predicate::TRUE_PRED,
7045  bool must_parallelism = false,
7046  MapperID id = 0,
7047  MappingTagID tag = 0);
7048  public:
7049  //------------------------------------------------------------------------
7050  // Inline Mapping Operations
7051  //------------------------------------------------------------------------
7061  PhysicalRegion map_region(Context ctx, const InlineLauncher &launcher);
7062 
7076  PhysicalRegion map_region(Context ctx, const RegionRequirement &req,
7077  MapperID id = 0, MappingTagID tag = 0,
7078  const char *provenance = NULL);
7079 
7091  PhysicalRegion map_region(Context ctx, unsigned idx,
7092  MapperID id = 0, MappingTagID tag = 0,
7093  const char *provenance = NULL);
7094 
7104  void remap_region(Context ctx, PhysicalRegion region,
7105  const char *provenance = NULL);
7106 
7114  void unmap_region(Context ctx, PhysicalRegion region);
7115 
7123  void unmap_all_regions(Context ctx);
7124  public:
7125  //------------------------------------------------------------------------
7126  // Fill Field Operations
7127  //------------------------------------------------------------------------
7142  template<typename T>
7143  void fill_field(Context ctx, LogicalRegion handle, LogicalRegion parent,
7144  FieldID fid, const T &value,
7145  Predicate pred = Predicate::TRUE_PRED);
7146 
7160  void fill_field(Context ctx, LogicalRegion handle, LogicalRegion parent,
7161  FieldID fid, const void *value, size_t value_size,
7162  Predicate pred = Predicate::TRUE_PRED);
7163 
7176  void fill_field(Context ctx, LogicalRegion handle, LogicalRegion parent,
7177  FieldID fid, Future f,
7178  Predicate pred = Predicate::TRUE_PRED);
7179 
7190  template<typename T>
7191  void fill_fields(Context ctx, LogicalRegion handle, LogicalRegion parent,
7192  const std::set<FieldID> &fields, const T &value,
7193  Predicate pred = Predicate::TRUE_PRED);
7194 
7207  void fill_fields(Context ctx, LogicalRegion handle, LogicalRegion parent,
7208  const std::set<FieldID> &fields,
7209  const void *value, size_t value_size,
7210  Predicate pred = Predicate::TRUE_PRED);
7211 
7222  void fill_fields(Context ctx, LogicalRegion handle, LogicalRegion parent,
7223  const std::set<FieldID> &fields,
7224  Future f, Predicate pred = Predicate::TRUE_PRED);
7225 
7232  void fill_fields(Context ctx, const FillLauncher &launcher);
7233 
7240  void fill_fields(Context ctx, const IndexFillLauncher &launcher);
7241  public:
7242  //------------------------------------------------------------------------
7243  // Attach Operations
7244  //------------------------------------------------------------------------
7245 
7253  const AttachLauncher &launcher);
7254 
7266  Future detach_external_resource(Context ctx, PhysicalRegion region,
7267  const bool flush = true,
7268  const bool unordered = false,
7269  const char *provenance = NULL);
7270 
7289  const IndexAttachLauncher &launcher);
7290 
7303  Future detach_external_resources(Context ctx, ExternalResources external,
7304  const bool flush = true,
7305  const bool unordered = false,
7306  const char *provenance = NULL);
7307 
7314  void progress_unordered_operations(Context ctx);
7315 
7346  LEGION_DEPRECATED("Attaching specific HDF5 file type is deprecated "
7347  "in favor of generic attach launcher interface.")
7348  PhysicalRegion attach_hdf5(Context ctx, const char *file_name,
7349  LogicalRegion handle, LogicalRegion parent,
7350  const std::map<FieldID,const char*> &field_map,
7351  LegionFileMode mode);
7352 
7369  LEGION_DEPRECATED("Detaching specific HDF5 file type is deprecated "
7370  "in favor of generic detach interface.")
7371  void detach_hdf5(Context ctx, PhysicalRegion region);
7372 
7379  LEGION_DEPRECATED("Attaching generic file type is deprecated "
7380  "in favor of generic attach launcher interface.")
7381  PhysicalRegion attach_file(Context ctx, const char *file_name,
7382  LogicalRegion handle, LogicalRegion parent,
7383  const std::vector<FieldID> &field_vec,
7384  LegionFileMode mode);
7385 
7391  LEGION_DEPRECATED("Detaching generic file type is deprecated "
7392  "in favor of generic detach interface.")
7393  void detach_file(Context ctx, PhysicalRegion region);
7394  public:
7395  //------------------------------------------------------------------------
7396  // Copy Operations
7397  //------------------------------------------------------------------------
7405  void issue_copy_operation(Context ctx, const CopyLauncher &launcher);
7406 
7414  void issue_copy_operation(Context ctx, const IndexCopyLauncher &launcher);
7415  public:
7416  //------------------------------------------------------------------------
7417  // Predicate Operations
7418  //------------------------------------------------------------------------
7428  Predicate create_predicate(Context ctx, const Future &f,
7429  const char *provenance = NULL);
7430 
7440  Predicate predicate_not(Context ctx, const Predicate &p,
7441  const char *provenance = NULL);
7442 
7453  Predicate predicate_and(Context ctx,
7454  const Predicate &p1, const Predicate &p2,
7455  const char *provenance = NULL);
7456 
7467  Predicate predicate_or(Context ctx,
7468  const Predicate &p1, const Predicate &p2,
7469  const char *provenance = NULL);
7470 
7477  Predicate create_predicate(Context ctx,const PredicateLauncher &launcher);
7478 
7485  Future get_predicate_future(Context ctx, const Predicate &p);
7486  public:
7487  //------------------------------------------------------------------------
7488  // Lock Operations
7489  //------------------------------------------------------------------------
7495  Lock create_lock(Context ctx);
7496 
7507  void destroy_lock(Context ctx, Lock l);
7508 
7521  Grant acquire_grant(Context ctx,
7522  const std::vector<LockRequest> &requests);
7523 
7533  void release_grant(Context ctx, Grant grant);
7534  public:
7535  //------------------------------------------------------------------------
7536  // Phase Barrier operations
7537  //------------------------------------------------------------------------
7547  PhaseBarrier create_phase_barrier(Context ctx, unsigned arrivals);
7548 
7559  void destroy_phase_barrier(Context ctx, PhaseBarrier pb);
7560 
7577  public:
7578  //------------------------------------------------------------------------
7579  // Dynamic Collective operations
7580  //------------------------------------------------------------------------
7596  unsigned arrivals,
7597  ReductionOpID redop,
7598  const void *init_value,
7599  size_t init_size);
7600 
7607  void destroy_dynamic_collective(Context ctx, DynamicCollective dc);
7608 
7618  void arrive_dynamic_collective(Context ctx,
7619  DynamicCollective dc,
7620  const void *buffer,
7621  size_t size, unsigned count = 1);
7622 
7632  void defer_dynamic_collective_arrival(Context ctx,
7633  DynamicCollective dc,
7634  const Future &f,
7635  unsigned count = 1);
7636 
7648  const char *provenance = NULL);
7649 
7659  DynamicCollective dc);
7660  public:
7661  //------------------------------------------------------------------------
7662  // User-Managed Software Coherence
7663  //------------------------------------------------------------------------
7670  void issue_acquire(Context ctx, const AcquireLauncher &launcher);
7671 
7678  void issue_release(Context ctx, const ReleaseLauncher &launcher);
7679  public:
7680  //------------------------------------------------------------------------
7681  // Fence Operations
7682  //------------------------------------------------------------------------
7691  Future issue_mapping_fence(Context ctx, const char *provenance = NULL);
7692 
7702  Future issue_execution_fence(Context ctx, const char *provenance = NULL);
7703  public:
7704  //------------------------------------------------------------------------
7705  // Tracing Operations
7706  //------------------------------------------------------------------------
7736  void begin_trace(Context ctx, TraceID tid, bool logical_only = false,
7737  bool static_trace = false, const std::set<RegionTreeID> *managed = NULL,
7738  const char *provenance = NULL);
7742  void end_trace(Context ctx, TraceID tid, const char *provenance = NULL);
7757  LEGION_DEPRECATED("Use begin_trace with static_trace=true")
7758  void begin_static_trace(Context ctx,
7759  const std::set<RegionTreeID> *managed = NULL);
7764  LEGION_DEPRECATED("Use end_trace")
7765  void end_static_trace(Context ctx);
7766 
7771  TraceID generate_dynamic_trace_id(void);
7772 
7783  TraceID generate_library_trace_ids(const char *name, size_t count);
7784 
7792  static TraceID generate_static_trace_id(void);
7793  public:
7794  //------------------------------------------------------------------------
7795  // Frame Operations
7796  //------------------------------------------------------------------------
7810  void complete_frame(Context ctx, const char *provenance = NULL);
7811  public:
7812  //------------------------------------------------------------------------
7813  // Must Parallelism
7814  //------------------------------------------------------------------------
7822  FutureMap execute_must_epoch(Context ctx,
7823  const MustEpochLauncher &launcher);
7824  public:
7825  //------------------------------------------------------------------------
7826  // Tunable Variables
7827  //------------------------------------------------------------------------
7828 
7842  Future select_tunable_value(Context ctx, TunableID tid,
7843  MapperID mapper = 0, MappingTagID tag = 0,
7844  const void *args = NULL, size_t argsize = 0);
7845  Future select_tunable_value(Context ctx, const TunableLauncher &launcher);
7846 
7853  LEGION_DEPRECATED("Tunable values should now be obtained via the "
7854  "generic interface that returns a future result.")
7855  int get_tunable_value(Context ctx, TunableID tid,
7856  MapperID mapper = 0, MappingTagID tag = 0);
7857  public:
7858  //------------------------------------------------------------------------
7859  // Task Local Interface
7860  //------------------------------------------------------------------------
7866  const Task* get_local_task(Context ctx);
7867 
7875  void* get_local_task_variable_untyped(Context ctx, LocalVariableID id);
7876  template<typename T>
7877  T* get_local_task_variable(Context ctx, LocalVariableID id);
7878 
7889  void set_local_task_variable_untyped(Context ctx, LocalVariableID id,
7890  const void *value, void (*destructor)(void*) = NULL);
7891  template<typename T>
7892  void set_local_task_variable(Context ctx, LocalVariableID id,
7893  const T* value, void (*destructor)(void*) = NULL);
7894  public:
7895  //------------------------------------------------------------------------
7896  // Timing Operations
7897  //------------------------------------------------------------------------
7906  Future get_current_time(Context ctx, Future precondition = Future());
7907 
7917  Future precondition = Future());
7918 
7928  Future precondition = Future());
7929 
7936  Future issue_timing_measurement(Context ctx,
7937  const TimingLauncher &launcher);
7938 
7945  static long long get_zero_time(void);
7946  public:
7947  //------------------------------------------------------------------------
7948  // Miscellaneous Operations
7949  //------------------------------------------------------------------------
7964  Mapping::Mapper* get_mapper(Context ctx, MapperID id,
7965  Processor target = Processor::NO_PROC);
7966 
7980  Mapping::MapperContext begin_mapper_call(Context ctx, MapperID id,
7981  Processor target = Processor::NO_PROC);
7982 
7988  void end_mapper_call(Mapping::MapperContext ctx);
7989 
7996  Processor get_executing_processor(Context ctx);
7997 
8004  const Task* get_current_task(Context ctx);
8005 
8022  void raise_region_exception(Context ctx, PhysicalRegion region,
8023  bool nuclear);
8024 
8035  void yield(Context ctx);
8036  public:
8037  //------------------------------------------------------------------------
8038  // Control Replication
8039  // In general SPMD-style programming in Legion is wrong. If you find
8040  // yourself writing SPMD-style code for large fractions of your program
8041  // then you're probably doing something wrong. There are a few exceptions:
8042  // 1. index attach/detach operations are collective and may need
8043  // to do per-shard work
8044  // 2. I/O in general often needs to do per-shard work
8045  // 3. interaction with collective frameworks like MPI and NCCL
8046  // 4. others?
8047  // For these reasons we allow users to get access to their shard ID and
8048  // the total number of shards and to make a future map collectively
8049  // Please, please, please be careful with how you use them
8050  //------------------------------------------------------------------------
8058  ShardID local_shard(Context ctx);
8059 
8067  size_t total_shards(Context ctx);
8068  public:
8069  //------------------------------------------------------------------------
8070  // MPI Interoperability
8071  //------------------------------------------------------------------------
8079  const std::map<int/*rank*/,AddressSpace>& find_forward_MPI_mapping(void);
8080 
8088  const std::map<AddressSpace,int/*rank*/>& find_reverse_MPI_mapping(void);
8089 
8093  int find_local_MPI_rank(void);
8094 
8098  bool is_MPI_interop_configured(void);
8099  public:
8100  //------------------------------------------------------------------------
8101  // Semantic Information
8102  //------------------------------------------------------------------------
8112  void attach_semantic_information(TaskID task_id, SemanticTag tag,
8113  const void *buffer, size_t size,
8114  bool is_mutable = false, bool local_only = false);
8115 
8124  void attach_semantic_information(IndexSpace handle, SemanticTag tag,
8125  const void *buffer, size_t size, bool is_mutable = false);
8126 
8135  void attach_semantic_information(IndexPartition handle, SemanticTag tag,
8136  const void *buffer, size_t size, bool is_mutable = false);
8137 
8146  void attach_semantic_information(FieldSpace handle, SemanticTag tag,
8147  const void *buffer, size_t size, bool is_mutable = false);
8148 
8158  void attach_semantic_information(FieldSpace handle, FieldID fid,
8159  SemanticTag tag, const void *buffer,
8160  size_t size, bool is_mutable = false);
8161 
8170  void attach_semantic_information(LogicalRegion handle, SemanticTag tag,
8171  const void *buffer, size_t size, bool is_mutable = false);
8172 
8182  SemanticTag tag, const void *buffer,
8183  size_t size, bool is_mutable = false);
8184 
8192  void attach_name(TaskID task_id, const char *name,
8193  bool is_mutable = false,
8194  bool local_only = false);
8195 
8202  void attach_name(IndexSpace handle, const char *name,
8203  bool is_mutable = false);
8204 
8211  void attach_name(IndexPartition handle, const char *name,
8212  bool is_mutable = false);
8213 
8220  void attach_name(FieldSpace handle, const char *name,
8221  bool is_mutable = false);
8222 
8230  void attach_name(FieldSpace handle, FieldID fid,
8231  const char *name, bool is_mutable = false);
8232 
8239  void attach_name(LogicalRegion handle, const char *name,
8240  bool is_mutable = false);
8241 
8248  void attach_name(LogicalPartition handle, const char *name,
8249  bool is_mutable = false);
8250 
8261  bool retrieve_semantic_information(TaskID task_id, SemanticTag tag,
8262  const void *&result, size_t &size,
8263  bool can_fail = false,
8264  bool wait_until_ready = false);
8265 
8276  bool retrieve_semantic_information(IndexSpace handle, SemanticTag tag,
8277  const void *&result, size_t &size,
8278  bool can_fail = false,
8279  bool wait_until_ready = false);
8280 
8291  bool retrieve_semantic_information(IndexPartition handle, SemanticTag tag,
8292  const void *&result, size_t &size,
8293  bool can_fail = false,
8294  bool wait_until_ready = false);
8295 
8306  bool retrieve_semantic_information(FieldSpace handle, SemanticTag tag,
8307  const void *&result, size_t &size,
8308  bool can_fail = false,
8309  bool wait_until_ready = false);
8310 
8322  bool retrieve_semantic_information(FieldSpace handle, FieldID fid,
8323  SemanticTag tag,
8324  const void *&result, size_t &size,
8325  bool can_fail = false,
8326  bool wait_until_ready = false);
8327 
8338  bool retrieve_semantic_information(LogicalRegion handle, SemanticTag tag,
8339  const void *&result, size_t &size,
8340  bool can_fail = false,
8341  bool wait_until_ready = false);
8342 
8354  SemanticTag tag,
8355  const void *&result, size_t &size,
8356  bool can_fail = false,
8357  bool wait_until_ready = false);
8358 
8364  void retrieve_name(TaskID task_id, const char *&result);
8365 
8371  void retrieve_name(IndexSpace handle, const char *&result);
8372 
8378  void retrieve_name(IndexPartition handle, const char *&result);
8379 
8385  void retrieve_name(FieldSpace handle, const char *&result);
8386 
8393  void retrieve_name(FieldSpace handle, FieldID fid, const char *&result);
8394 
8400  void retrieve_name(LogicalRegion handle, const char *&result);
8401 
8407  void retrieve_name(LogicalPartition handle, const char *&result);
8408 
8409  public:
8410  //------------------------------------------------------------------------
8411  // Printing operations, these are useful for only generating output
8412  // from a single task if the task has been replicated (either directly
8413  // or as part of control replication).
8414  //------------------------------------------------------------------------
8422  void print_once(Context ctx, FILE *f, const char *message);
8423 
8430  void log_once(Context ctx, Realm::LoggerMessage &message);
8431  public:
8432  //------------------------------------------------------------------------
8433  // Registration Callback Operations
8434  // All of these calls must be made while in the registration
8435  // function called before start-up. This function is specified
8436  // by calling the 'set_registration_callback' static method.
8437  //------------------------------------------------------------------------
8438 
8443  Mapping::MapperRuntime* get_mapper_runtime(void);
8444 
8449  MapperID generate_dynamic_mapper_id(void);
8450 
8461  MapperID generate_library_mapper_ids(const char *name, size_t count);
8462 
8470  static MapperID generate_static_mapper_id(void);
8471 
8483  void add_mapper(MapperID map_id, Mapping::Mapper *mapper,
8484  Processor proc = Processor::NO_PROC);
8485 
8497  void replace_default_mapper(Mapping::Mapper *mapper,
8498  Processor proc = Processor::NO_PROC);
8499 
8500  public:
8505  ProjectionID generate_dynamic_projection_id(void);
8506 
8517  ProjectionID generate_library_projection_ids(const char *name,
8518  size_t count);
8519 
8527  static ProjectionID generate_static_projection_id(void);
8528 
8542  void register_projection_functor(ProjectionID pid,
8543  ProjectionFunctor *functor,
8544  bool silence_warnings = false,
8545  const char *warning_string = NULL);
8546 
8556  static void preregister_projection_functor(ProjectionID pid,
8557  ProjectionFunctor *functor);
8558 
8565  static ProjectionFunctor* get_projection_functor(ProjectionID pid);
8566 
8571  ShardingID generate_dynamic_sharding_id(void);
8572 
8583  ShardingID generate_library_sharding_ids(const char *name, size_t count);
8584 
8592  static ShardingID generate_static_sharding_id(void);
8593 
8599  void register_sharding_functor(ShardingID sid,
8600  ShardingFunctor *functor,
8601  bool silence_warnings = false,
8602  const char *warning_string = NULL);
8603 
8610  static void preregister_sharding_functor(ShardingID sid,
8611  ShardingFunctor *functor);
8612  public:
8617  ReductionOpID generate_dynamic_reduction_id(void);
8618 
8629  ReductionOpID generate_library_reduction_ids(const char *name,
8630  size_t count);
8631 
8639  static ReductionOpID generate_static_reduction_id(void);
8640 
8655  template<typename REDOP>
8656  static void register_reduction_op(ReductionOpID redop_id,
8657  bool permit_duplicates = false);
8658 
8679  static void register_reduction_op(ReductionOpID redop_id,
8680  ReductionOp *op,
8681  SerdezInitFnptr init_fnptr = NULL,
8682  SerdezFoldFnptr fold_fnptr = NULL,
8683  bool permit_duplicates = false);
8684 
8690  static const ReductionOp* get_reduction_op(ReductionOpID redop_id);
8691 
8692 #ifdef LEGION_GPU_REDUCTIONS
8693  template<typename REDOP>
8694  LEGION_DEPRECATED("Use register_reduction_op instead")
8695  static void preregister_gpu_reduction_op(ReductionOpID redop_id);
8696 #endif
8697  public:
8702  CustomSerdezID generate_dynamic_serdez_id(void);
8703 
8714  CustomSerdezID generate_library_serdez_ids(const char *name,
8715  size_t count);
8716 
8724  static CustomSerdezID generate_static_serdez_id(void);
8725 
8739  template<typename SERDEZ>
8740  static void register_custom_serdez_op(CustomSerdezID serdez_id,
8741  bool permit_duplicates = false);
8742 
8755  static void register_custom_serdez_op(CustomSerdezID serdez_id,
8756  SerdezOp *serdez_op,
8757  bool permit_duplicates = false);
8758 
8764  static const SerdezOp* get_serdez_op(CustomSerdezID serdez_id);
8765  public:
8766  //------------------------------------------------------------------------
8767  // Start-up Operations
8768  // Everything below here is a static function that is used to configure
8769  // the runtime prior to calling the start method to begin execution.
8770  //------------------------------------------------------------------------
8771  public:
8777  static const char* get_legion_version(void);
8778 
8941  static int start(int argc, char **argv, bool background = false,
8942  bool supply_default_mapper = true);
8943 
8957  static void initialize(int *argc, char ***argv, bool filter = false);
8958 
8964  static int wait_for_shutdown(void);
8965 
8973  static void set_return_code(int return_code);
8974 
8982  static void set_top_level_task_id(TaskID top_id);
8983 
8990  static void set_top_level_task_mapper_id(MapperID mapper_id);
8991 
8998  Future launch_top_level_task(const TaskLauncher &launcher);
8999 
9018  Context begin_implicit_task(TaskID top_task_id,
9019  MapperID mapper_id,
9020  Processor::Kind proc_kind,
9021  const char *task_name = NULL,
9022  bool control_replicable = false,
9023  unsigned shard_per_address_space = 1,
9024  int shard_id = -1);
9025 
9034 
9041  void bind_implicit_task_to_external_thread(Context ctx);
9042 
9050  void finish_implicit_task(Context ctx);
9051 
9057  static size_t get_maximum_dimension(void);
9058 
9068  static void configure_MPI_interoperability(int rank);
9069 
9083  static LegionHandshake create_external_handshake(bool init_in_ext = true,
9084  int ext_participants = 1,
9085  int legion_participants = 1);
9086 
9098  static MPILegionHandshake create_handshake(bool init_in_MPI = true,
9099  int mpi_participants = 1,
9100  int legion_participants = 1);
9101 
9112  template<LogicalRegion (*PROJ_PTR)(LogicalRegion, const DomainPoint&,
9113  Runtime*)>
9114  LEGION_DEPRECATED("Projection functions should now be specified "
9115  "using projection functor objects")
9116  static ProjectionID register_region_function(ProjectionID handle);
9117 
9127  template<LogicalRegion (*PROJ_PTR)(LogicalPartition, const DomainPoint&,
9128  Runtime*)>
9129  LEGION_DEPRECATED("Projection functions should now be specified "
9130  "using projection functor objects")
9131  static ProjectionID register_partition_function(ProjectionID handle);
9132  public:
9149  static void add_registration_callback(RegistrationCallbackFnptr callback,
9150  bool dedup = true, size_t dedup_tag = 0);
9151  static void add_registration_callback(
9152  RegistrationWithArgsCallbackFnptr callback, const UntypedBuffer &buffer,
9153  bool dedup = true, size_t dedup_tag = 0);
9154 
9179  static void perform_registration_callback(
9180  RegistrationCallbackFnptr callback, bool global,
9181  bool deduplicate = true, size_t dedup_tag = 0);
9182  static void perform_registration_callback(
9183  RegistrationWithArgsCallbackFnptr callback,
9184  const UntypedBuffer &buffer, bool global,
9185  bool deduplicate = true , size_t dedup_tag = 0);
9186 
9198  LEGION_DEPRECATED("Legion now supports multiple registration callbacks "
9199  "added via the add_registration_callback method.")
9200  static void set_registration_callback(RegistrationCallbackFnptr callback);
9201 
9207  static const InputArgs& get_input_args(void);
9208  public:
9212  static void enable_profiling(void);
9216  static void disable_profiling(void);
9220  static void dump_profiling(void);
9221  public:
9222  //------------------------------------------------------------------------
9223  // Layout Registration Operations
9224  //------------------------------------------------------------------------
9233  LayoutConstraintID register_layout(
9234  const LayoutConstraintRegistrar &registrar);
9235 
9241  void release_layout(LayoutConstraintID layout_id);
9242 
9254  static LayoutConstraintID preregister_layout(
9255  const LayoutConstraintRegistrar &registrar,
9256  LayoutConstraintID layout_id =
9257  LEGION_AUTO_GENERATE_ID);
9258 
9265  LayoutConstraintID layout_id);
9266 
9272  void get_layout_constraints(LayoutConstraintID layout_id,
9273  LayoutConstraintSet &layout_constraints);
9274 
9280  const char* get_layout_constraints_name(LayoutConstraintID layout_id);
9281  public:
9282  //------------------------------------------------------------------------
9283  // Task Registration Operations
9284  //------------------------------------------------------------------------
9285 
9290  TaskID generate_dynamic_task_id(void);
9291 
9302  TaskID generate_library_task_ids(const char *name, size_t count);
9303 
9311  static TaskID generate_static_task_id(void);
9312 
9320  template<typename T,
9321  T (*TASK_PTR)(const Task*, const std::vector<PhysicalRegion>&,
9322  Context, Runtime*)>
9323  VariantID register_task_variant(const TaskVariantRegistrar &registrar,
9324  VariantID vid = LEGION_AUTO_GENERATE_ID);
9325 
9334  template<typename T, typename UDT,
9335  T (*TASK_PTR)(const Task*, const std::vector<PhysicalRegion>&,
9336  Context, Runtime*, const UDT&)>
9337  VariantID register_task_variant(const TaskVariantRegistrar &registrar,
9338  const UDT &user_data,
9339  VariantID vid = LEGION_AUTO_GENERATE_ID);
9340 
9348  template<
9349  void (*TASK_PTR)(const Task*, const std::vector<PhysicalRegion>&,
9350  Context, Runtime*)>
9351  VariantID register_task_variant(const TaskVariantRegistrar &registrar,
9352  VariantID vid = LEGION_AUTO_GENERATE_ID);
9353 
9362  template<typename UDT,
9363  void (*TASK_PTR)(const Task*, const std::vector<PhysicalRegion>&,
9364  Context, Runtime*, const UDT&)>
9365  VariantID register_task_variant(const TaskVariantRegistrar &registrar,
9366  const UDT &user_data,
9367  VariantID vid = LEGION_AUTO_GENERATE_ID);
9368 
9382  VariantID register_task_variant(const TaskVariantRegistrar &registrar,
9383  const CodeDescriptor &codedesc,
9384  const void *user_data = NULL,
9385  size_t user_len = 0,
9386  size_t return_type_size =
9387  LEGION_MAX_RETURN_SIZE,
9388  VariantID vid = LEGION_AUTO_GENERATE_ID);
9389 
9400  template<typename T,
9401  T (*TASK_PTR)(const Task*, const std::vector<PhysicalRegion>&,
9402  Context, Runtime*)>
9403  static VariantID preregister_task_variant(
9404  const TaskVariantRegistrar &registrar,
9405  const char *task_name = NULL,
9406  VariantID vid = LEGION_AUTO_GENERATE_ID);
9407 
9419  template<typename T, typename UDT,
9420  T (*TASK_PTR)(const Task*, const std::vector<PhysicalRegion>&,
9421  Context, Runtime*, const UDT&)>
9422  static VariantID preregister_task_variant(
9423  const TaskVariantRegistrar &registrar,
9424  const UDT &user_data,
9425  const char *task_name = NULL,
9426  VariantID vid = LEGION_AUTO_GENERATE_ID);
9427 
9438  template<
9439  void (*TASK_PTR)(const Task*, const std::vector<PhysicalRegion>&,
9440  Context, Runtime*)>
9441  static VariantID preregister_task_variant(
9442  const TaskVariantRegistrar &registrar,
9443  const char *task_name = NULL,
9444  VariantID vid = LEGION_AUTO_GENERATE_ID);
9445 
9457  template<typename UDT,
9458  void (*TASK_PTR)(const Task*, const std::vector<PhysicalRegion>&,
9459  Context, Runtime*, const UDT&)>
9460  static VariantID preregister_task_variant(
9461  const TaskVariantRegistrar &registrar, const UDT &user_data,
9462  const char *task_name = NULL,
9463  VariantID vid = LEGION_AUTO_GENERATE_ID);
9464 
9480  static VariantID preregister_task_variant(
9481  const TaskVariantRegistrar &registrar,
9482  const CodeDescriptor &codedesc,
9483  const void *user_data = NULL,
9484  size_t user_len = 0,
9485  const char *task_name = NULL,
9486  VariantID vid = LEGION_AUTO_GENERATE_ID,
9487  size_t return_type_size = LEGION_MAX_RETURN_SIZE,
9488  bool check_task_id = true);
9489 
9503  static void legion_task_preamble(const void *data, size_t datalen,
9504  Processor p, const Task *& task,
9505  const std::vector<PhysicalRegion> *& reg,
9506  Context& ctx, Runtime *& runtime);
9507 
9521  static void legion_task_postamble(Runtime *runtime, Context ctx,
9522  const void *retvalptr = NULL,
9523  size_t retvalsize = 0,
9524  bool owned = false,
9525  Realm::RegionInstance inst =
9526  Realm::RegionInstance::NO_INST);
9527 
9538  static void legion_task_postamble(Runtime *runtime, Context ctx,
9539  FutureFunctor *callback_functor,
9540  bool owned = false);
9541  public:
9542  // ------------------ Deprecated task registration -----------------------
9556  template<typename T,
9557  T (*TASK_PTR)(const Task*, const std::vector<PhysicalRegion>&,
9558  Context, Runtime*)>
9559  LEGION_DEPRECATED("Task registration should be done with "
9560  "a TaskVariantRegistrar")
9561  static TaskID register_legion_task(TaskID id, Processor::Kind proc_kind,
9562  bool single, bool index,
9563  VariantID vid =LEGION_AUTO_GENERATE_ID,
9565  const char *task_name = NULL);
9579  template<
9580  void (*TASK_PTR)(const Task*, const std::vector<PhysicalRegion>&,
9581  Context, Runtime*)>
9582  LEGION_DEPRECATED("Task registration should be done with "
9583  "a TaskVariantRegistrar")
9584  static TaskID register_legion_task(TaskID id, Processor::Kind proc_kind,
9585  bool single, bool index,
9586  VariantID vid =LEGION_AUTO_GENERATE_ID,
9588  const char *task_name = NULL);
9604  template<typename T, typename UDT,
9605  T (*TASK_PTR)(const Task*, const std::vector<PhysicalRegion>&,
9606  Context, Runtime*, const UDT&)>
9607  LEGION_DEPRECATED("Task registration should be done with "
9608  "a TaskVariantRegistrar")
9609  static TaskID register_legion_task(TaskID id, Processor::Kind proc_kind,
9610  bool single, bool index,
9611  const UDT &user_data,
9612  VariantID vid =LEGION_AUTO_GENERATE_ID,
9614  const char *task_name = NULL);
9630  template<typename UDT,
9631  void (*TASK_PTR)(const Task*,const std::vector<PhysicalRegion>&,
9632  Context, Runtime*, const UDT&)>
9633  LEGION_DEPRECATED("Task registration should be done with "
9634  "a TaskVariantRegistrar")
9635  static TaskID register_legion_task(TaskID id, Processor::Kind proc_kind,
9636  bool single, bool index,
9637  const UDT &user_data,
9638  VariantID vid =LEGION_AUTO_GENERATE_ID,
9640  const char *task_name = NULL);
9641  public:
9648  static bool has_runtime(void);
9649 
9657  static Runtime* get_runtime(Processor p = Processor::NO_PROC);
9658 
9665  static bool has_context(void);
9666 
9673  static Context get_context(void);
9674 
9680  static const Task* get_context_task(Context ctx);
9681  private:
9682  IndexPartition create_restricted_partition(Context ctx,
9683  IndexSpace parent,
9684  IndexSpace color_space,
9685  const void *transform,
9686  size_t transform_size,
9687  const void *extent,
9688  size_t extent_size,
9689  PartitionKind part_kind, Color color,
9690  const char *provenance);
9691  IndexSpace create_index_space_union_internal(Context ctx,
9692  IndexPartition parent,
9693  const void *realm_color, TypeTag type_tag,
9694  const std::vector<IndexSpace> &handles,
9695  const char *provenance);
9696  IndexSpace create_index_space_union_internal(Context ctx,
9697  IndexPartition parent,
9698  const void *realm_color, TypeTag type_tag,
9699  IndexPartition handle,
9700  const char *provenance);
9701  IndexSpace create_index_space_intersection_internal(Context ctx,
9702  IndexPartition parent,
9703  const void *realm_color, TypeTag type_tag,
9704  const std::vector<IndexSpace> &handles,
9705  const char *provenance);
9706  IndexSpace create_index_space_intersection_internal(Context ctx,
9707  IndexPartition parent,
9708  const void *realm_color, TypeTag type_tag,
9709  IndexPartition handle,
9710  const char *provenance);
9711  IndexSpace create_index_space_difference_internal(Context ctx,
9712  IndexPartition paretn,
9713  const void *realm_color, TypeTag type_tag,
9714  IndexSpace initial,
9715  const std::vector<IndexSpace> &handles,
9716  const char *provenance);
9717  IndexSpace get_index_subspace_internal(IndexPartition handle,
9718  const void *realm_color,TypeTag type_tag);
9719  bool has_index_subspace_internal(IndexPartition handle,
9720  const void *realm_color,TypeTag type_tag);
9721  void get_index_partition_color_space_internal(IndexPartition handle,
9722  void *realm_is, TypeTag type_tag);
9723  void get_index_space_domain_internal(IndexSpace handle,
9724  void *realm_is, TypeTag type_tag);
9725  void get_index_space_color_internal(IndexSpace handle,
9726  void *realm_color, TypeTag type_tag);
9727  bool safe_cast_internal(Context ctx, LogicalRegion region,
9728  const void *realm_point,TypeTag type_tag);
9729  LogicalRegion get_logical_subregion_by_color_internal(
9730  LogicalPartition parent,
9731  const void *realm_color,TypeTag type_tag);
9732  bool has_logical_subregion_by_color_internal(
9733  LogicalPartition parent,
9734  const void *realm_color,TypeTag type_tag);
9735  private:
9736  // Methods for the wrapper functions to get information from the runtime
9737  friend class LegionTaskWrapper;
9738  friend class LegionSerialization;
9739  Future from_value(const void *value, size_t value_size, bool owned);
9740  private:
9741  template<typename T>
9742  friend class DeferredValue;
9743  template<typename T, int DIM, typename COORD_T, bool CHECK_BOUNDS>
9744  friend class DeferredBuffer;
9745  friend class UntypedDeferredValue;
9746  template<typename>
9747  friend class UntypedDeferredBuffer;
9748  Realm::RegionInstance create_task_local_instance(Memory memory,
9749  Realm::InstanceLayoutGeneric *layout);
9750  public:
9751  // This method is hidden down here and not publicly documented because
9752  // users shouldn't really need it for anything, however there are some
9753  // reasonable cases where it might be utilitized for things like doing
9754  // file I/O or printf that people might want it for so we've got it
9755  ShardID get_shard_id(Context ctx, bool I_know_what_I_am_doing = false);
9756  // We'll also allow users to get the total number of shards in the context
9757  // if they also ar willing to attest they know what they are doing
9758  size_t get_num_shards(Context ctx, bool I_know_what_I_am_doing = false);
9759  private:
9760  friend class Mapper;
9761  Internal::Runtime *runtime;
9762  };
9763 
9764  //==========================================================================
9765  // Compiler Helper Classes
9766  //==========================================================================
9767 
9774  public:
9775  ColoringSerializer(void) { }
9776  ColoringSerializer(const Coloring &c);
9777  public:
9778  size_t legion_buffer_size(void) const;
9779  size_t legion_serialize(void *buffer) const;
9780  size_t legion_deserialize(const void *buffer);
9781  public:
9782  inline Coloring& ref(void) { return coloring; }
9783  private:
9784  Coloring coloring;
9785  };
9786 
9793  public:
9794  DomainColoringSerializer(void) { }
9795  DomainColoringSerializer(const DomainColoring &c);
9796  public:
9797  size_t legion_buffer_size(void) const;
9798  size_t legion_serialize(void *buffer) const;
9799  size_t legion_deserialize(const void *buffer);
9800  public:
9801  inline DomainColoring& ref(void) { return coloring; }
9802  private:
9803  DomainColoring coloring;
9804  };
9805 
9806 }; // namespace Legion
9807 
9808 #include "legion/legion.inl"
9809 // Include this here so we get the mapper interface in the header file
9810 // We have to put it here though since the mapper interface depends
9811 // on the rest of the legion interface
9812 #include "legion/legion_mapping.h"
9813 
9814 #endif // __LEGION_RUNTIME_H__
9815 #endif // defined LEGION_ENABLE_CXX_BINDINGS
9816 
9817 // EOF
9818 
void create_association(Context ctx, LogicalRegion domain, LogicalRegion domain_parent, FieldID domain_fid, IndexSpace range, MapperID id=0, MappingTagID tag=0, UntypedBuffer map_arg=UntypedBuffer(), const char *provenance=NULL)
Definition: legion.h:376
void detach_hdf5(Context ctx, PhysicalRegion region)
Color get_logical_region_color(Context ctx, LogicalRegion handle)
void allocate_local_fields(const std::vector< size_t > &field_sizes, std::vector< FieldID > &resulting_fields, CustomSerdezID serdez_id=0, const char *provenance=NULL)
Future get_current_time_in_nanoseconds(Context ctx, Future precondition=Future())
size_t total_shards(Context ctx)
static void legion_task_preamble(const void *data, size_t datalen, Processor p, const Task *&task, const std::vector< PhysicalRegion > *&reg, Context &ctx, Runtime *&runtime)
Definition: legion_types.h:167
Definition: legion.h:429
IndexPartition get_parent_index_partition(Context ctx, IndexSpace handle)
LogicalRegion get_logical_region(void) const
Definition: legion.h:3894
void legion_handoff_to_mpi(void) const
Definition: legion.h:3925
FutureMap execute_index_space(Context ctx, const IndexTaskLauncher &launcher)
FieldID allocate_local_field(size_t field_size, FieldID desired_fieldid=LEGION_AUTO_GENERATE_ID, CustomSerdezID serdez_id=0, const char *provenance=NULL)
ReductionOpID generate_library_reduction_ids(const char *name, size_t count)
static ProjectionFunctor * get_projection_functor(ProjectionID pid)
IndexPartition create_partition_by_intersection(Context ctx, IndexSpace parent, IndexPartition handle1, IndexPartition handle2, IndexSpace color_space, PartitionKind part_kind=LEGION_COMPUTE_KIND, Color color=LEGION_AUTO_GENERATE_ID, const char *provenance=NULL)
void free_fields(const std::set< FieldID > &to_free, const bool unordered=false, const char *provenance=NULL)
RegionRequirement & add_field(FieldID fid, bool instance=true)
static ReductionOpID generate_static_reduction_id(void)
bool is_mapped(void) const
Definition: legion.h:1816
void replace_default_mapper(Mapping::Mapper *mapper, Processor proc=Processor::NO_PROC)
LogicalPartition get_parent_logical_partition(Context ctx, LogicalRegion handle)
static const LogicalPartition NO_PART
Definition: legion.h:305
bool has_index_subspace(Context ctx, IndexPartition p, const DomainPoint &color)
TraceID generate_dynamic_trace_id(void)
Definition: legion.h:2590
IndexPartition create_partition_by_domain(Context ctx, IndexSpace parent, const std::map< DomainPoint, Domain > &domains, IndexSpace color_space, bool perform_intersections=true, PartitionKind part_kind=LEGION_COMPUTE_KIND, Color color=LEGION_AUTO_GENERATE_ID, const char *provenance=NULL)
IndexPartition create_partition_by_image(Context ctx, IndexSpace handle, LogicalPartition projection, LogicalRegion parent, FieldID fid, IndexSpace color_space, PartitionKind part_kind=LEGION_COMPUTE_KIND, Color color=LEGION_AUTO_GENERATE_ID, MapperID id=0, MappingTagID tag=0, UntypedBuffer map_arg=UntypedBuffer(), const char *provenance=NULL)
IndexPartition create_partition_by_preimage(Context ctx, IndexPartition projection, LogicalRegion handle, LogicalRegion parent, FieldID fid, IndexSpace color_space, PartitionKind part_kind=LEGION_COMPUTE_KIND, Color color=LEGION_AUTO_GENERATE_ID, MapperID id=0, MappingTagID tag=0, UntypedBuffer map_arg=UntypedBuffer(), const char *provenance=NULL)
LogicalRegion parent
Definition: legion.h:1099
Future detach_external_resource(Context ctx, PhysicalRegion region, const bool flush=true, const bool unordered=false, const char *provenance=NULL)
void ext_handoff_to_legion(void) const
Color get_index_space_color(Context ctx, IndexSpace handle)
void progress_unordered_operations(Context ctx)
T get_result(bool silence_warnings=false, const char *warning_string=NULL) const
static void enable_profiling(void)
Definition: legion.h:906
Definition: legion.h:3790
static void configure_MPI_interoperability(int rank)
void mpi_wait_on_legion(void) const
Definition: legion.h:3919
void set_point_arg(const PT point[DIM], const UntypedBuffer &arg, bool replace=false)
void get_layout_constraints(LayoutConstraintID layout_id, LayoutConstraintSet &layout_constraints)
Definition: legion.h:3375
LegionRuntime::Accessor::RegionAccessor< LegionRuntime::Accessor::AccessorType::Generic > get_accessor(bool silence_warnings=false) const
void fill_field(Context ctx, LogicalRegion handle, LogicalRegion parent, FieldID fid, const T &value, Predicate pred=Predicate::TRUE_PRED)
static void set_registration_callback(RegistrationCallbackFnptr callback)
const Task * get_local_task(Context ctx)
PhysicalRegion attach_hdf5(Context ctx, const char *file_name, LogicalRegion handle, LogicalRegion parent, const std::map< FieldID, const char * > &field_map, LegionFileMode mode)
PhysicalRegion attach_external_resource(Context ctx, const AttachLauncher &launcher)
Future select_tunable_value(Context ctx, TunableID tid, MapperID mapper=0, MappingTagID tag=0, const void *args=NULL, size_t argsize=0)
void release_layout(LayoutConstraintID layout_id)
Future issue_execution_fence(Context ctx, const char *provenance=NULL)
void print_once(Context ctx, FILE *f, const char *message)
Definition: legion.h:2359
void attach_semantic_information(TaskID task_id, SemanticTag tag, const void *buffer, size_t size, bool is_mutable=false, bool local_only=false)
Processor get_executing_processor(Context ctx)
IndexSpace get_index_partition_color_space_name(Context ctx, IndexPartition p)
LogicalPartition get_logical_partition_by_tree(Context ctx, IndexPartition handle, FieldSpace fspace, RegionTreeID tid)
Definition: legion.h:303
Future detach_external_resources(Context ctx, ExternalResources external, const bool flush=true, const bool unordered=false, const char *provenance=NULL)
MapperID generate_dynamic_mapper_id(void)
void unmap_all_regions(Context ctx)
std::set< FieldID > privilege_fields
Definition: legion.h:1095
Definition: legion_domain.h:629
Definition: legion.h:273
void destroy_logical_region(Context ctx, LogicalRegion handle, const bool unordered=false, const char *provenance=NULL)
Definition: legion.h:3464
static void register_reduction_op(ReductionOpID redop_id, bool permit_duplicates=false)
void register_sharding_functor(ShardingID sid, ShardingFunctor *functor, bool silence_warnings=false, const char *warning_string=NULL)
Definition: legion_domain.h:260
Future execute_task(Context ctx, const TaskLauncher &launcher)
FutureMap execute_must_epoch(Context ctx, const MustEpochLauncher &launcher)
Definition: legion_domain.h:46
ptr_t safe_cast(Context ctx, ptr_t pointer, LogicalRegion region)
void destroy_logical_partition(Context ctx, LogicalPartition handle, const bool unordered=false)
Color get_logical_partition_color(Context ctx, LogicalPartition handle)
TaskID generate_library_task_ids(const char *name, size_t count)
static void preregister_sharding_functor(ShardingID sid, ShardingFunctor *functor)
void get_memories(std::set< Memory > &memories, bool silence_warnings=false, const char *warning_string=NULL) const
Definition: legion.h:9792
Predicate create_predicate(Context ctx, const Future &f, const char *provenance=NULL)
IndexSpace create_index_space_difference(Context ctx, IndexPartition parent, const DomainPoint &color, IndexSpace initial, const std::vector< IndexSpace > &handles, const char *provenancne=NULL)
static MPILegionHandshake create_handshake(bool init_in_MPI=true, int mpi_participants=1, int legion_participants=1)
Definition: legion.h:1319
void end_mapper_call(Mapping::MapperContext ctx)
const std::map< AddressSpace, int > & find_reverse_MPI_mapping(void)
static bool has_runtime(void)
Definition: legion.h:942
IndexPartition create_index_partition(Context ctx, IndexSpace parent, const Domain &color_space, const PointColoring &coloring, PartitionKind part_kind=LEGION_COMPUTE_KIND, Color color=LEGION_AUTO_GENERATE_ID, bool allocable=false)
Definition: legion.h:177
const T & get_reference(bool silence_warnings=false, const char *warning_string=NULL) const
static const char * get_legion_version(void)
void legion_wait_on_mpi(void) const
Definition: legion.h:3930
Definition: legion.h:859
ProjectionType handle_type
Definition: legion.h:1104
size_t get_untyped_size(void) const
static TraceID generate_static_trace_id(void)
Definition: legion.h:3428
void log_once(Context ctx, Realm::LoggerMessage &message)
TraceID generate_library_trace_ids(const char *name, size_t count)
PhaseBarrier get_legion_wait_phase_barrier(void) const
void allocate_fields(const std::vector< size_t > &field_sizes, std::vector< FieldID > &resulting_fields, CustomSerdezID serdez_id=0, bool local_fields=false, const char *provenance=NULL)
FieldSpace get_field_space(void) const
Definition: legion.h:1904
LogicalRegion get_logical_subregion_by_tree(Context ctx, IndexSpace handle, FieldSpace fspace, RegionTreeID tid)
static Future from_untyped_pointer(Runtime *rt, const void *buffer, size_t bytes)
Lock create_lock(Context ctx)
void end_static_trace(Context ctx)
void get_field_space_fields(Context ctx, FieldSpace handle, std::vector< FieldID > &fields)
void issue_acquire(Context ctx, const AcquireLauncher &launcher)
Definition: legion.h:4572
Future get_current_time(Context ctx, Future precondition=Future())
int get_tunable_value(Context ctx, TunableID tid, MapperID mapper=0, MappingTagID tag=0)
void create_shared_ownership(Context ctx, IndexSpace handle)
void get_fields(std::vector< FieldID > &fields) const
Definition: legion.h:3478
void defer_dynamic_collective_arrival(Context ctx, DynamicCollective dc, const Future &f, unsigned count=1)
void attach_name(TaskID task_id, const char *name, bool is_mutable=false, bool local_only=false)
void set_local_task_variable_untyped(Context ctx, LocalVariableID id, const void *value, void(*destructor)(void *)=NULL)
IndexSpace intersect_index_spaces(Context ctx, const std::vector< IndexSpace > &spaces, const char *provenance=NULL)
void destroy_index_partition(Context ctx, IndexPartition handle, const bool unordered=false, const bool recurse=true, const char *provenance=NULL)
const Task * get_current_task(Context ctx)
FieldID allocate_field(size_t field_size, FieldID desired_fieldid=LEGION_AUTO_GENERATE_ID, CustomSerdezID serdez_id=0, bool local_field=false, const char *provenance=NULL)
static ProjectionID register_partition_function(ProjectionID handle)
bool has_multiple_domains(Context ctx, IndexSpace handle)
virtual void invert(LogicalRegion region, LogicalRegion upper_bound, const Domain &launch_domain, std::vector< DomainPoint > &ordered_points)
static void add_registration_callback(RegistrationCallbackFnptr callback, bool dedup=true, size_t dedup_tag=0)
FieldSpace get_layout_constraint_field_space(LayoutConstraintID layout_id)
static LegionHandshake create_external_handshake(bool init_in_ext=true, int ext_participants=1, int legion_participants=1)
void wait_until_valid(bool silence_warnings=false, const char *warning_string=NULL)
bool is_MPI_interop_configured(void)
void destroy_field_space(Context ctx, FieldSpace handle, const bool unordered=false, const char *provenance=NULL)
FutureMap construct_future_map(Context ctx, IndexSpace domain, const std::map< DomainPoint, UntypedBuffer > &data, bool collective=false, ShardingID sid=0, bool implicit_sharding=false)
Definition: legion.h:2234
bool retrieve_semantic_information(TaskID task_id, SemanticTag tag, const void *&result, size_t &size, bool can_fail=false, bool wait_until_ready=false)
void bind_implicit_task_to_external_thread(Context ctx)
Definition: legion.h:4267
Definition: legion_domain.h:753
Definition: legion.h:1423
void wait_all_results(bool silence_warnings=false, const char *warning_string=NULL) const
Definition: legion.h:3300
Definition: legion.h:4094
static const FieldSpace NO_SPACE
Definition: legion.h:203
IndexSpace union_index_spaces(Context ctx, const std::vector< IndexSpace > &spaces, const char *provenance=NULL)
Definition: legion.h:201
static const LogicalRegion NO_REGION
Definition: legion.h:238
ShardingID generate_library_sharding_ids(const char *name, size_t count)
static bool has_context(void)
static TaskID generate_static_task_id(void)
virtual unsigned get_depth(void) const =0
void detach_file(Context ctx, PhysicalRegion region)
void mpi_handoff_to_legion(void) const
Definition: legion.h:3914
Definition: legion.h:3340
void destroy_phase_barrier(Context ctx, PhaseBarrier pb)
PhaseBarrier create_phase_barrier(Context ctx, unsigned arrivals)
void destroy_dynamic_collective(Context ctx, DynamicCollective dc)
void end_trace(Context ctx, TraceID tid, const char *provenance=NULL)
LogicalRegion create_logical_region(Context ctx, IndexSpace index, FieldSpace fields, bool task_local=false, const char *provenance=NULL)
static Context get_context(void)
Definition: legion.h:2200
IndexPartition create_pending_partition(Context ctx, IndexSpace parent, IndexSpace color_space, PartitionKind part_kind=LEGION_COMPUTE_KIND, Color color=LEGION_AUTO_GENERATE_ID, const char *provenance=NULL)
Definition: legion.h:1146
static long long get_zero_time(void)
void destroy_index_space(Context ctx, IndexSpace handle, const bool unordered=false, const bool recurse=true, const char *provenance=NULL)
static const SerdezOp * get_serdez_op(CustomSerdezID serdez_id)
Definition: legion.h:4137
Definition: legion.h:3829
static MapperID generate_static_mapper_id(void)
Future launch_top_level_task(const TaskLauncher &launcher)
Definition: legion.h:122
Definition: legion.h:1564
static ProjectionID register_region_function(ProjectionID handle)
Definition: legion.h:1118
Definition: legion.h:2264
IndexSpace subtract_index_spaces(Context ctx, IndexSpace left, IndexSpace right, const char *provenance=NULL)
void issue_release(Context ctx, const ReleaseLauncher &launcher)
static TaskID register_legion_task(TaskID id, Processor::Kind proc_kind, bool single, bool index, VariantID vid=LEGION_AUTO_GENERATE_ID, TaskConfigOptions options=TaskConfigOptions(), const char *task_name=NULL)
IndexSpace create_index_space_intersection(Context ctx, IndexPartition parent, const DomainPoint &color, const std::vector< IndexSpace > &handles, const char *provenance=NULL)
Definition: legion.h:4278
Definition: legion.h:143
const void * get_untyped_pointer(bool silence_warnings=false, const char *warning_string=NULL) const
Definition: legion.h:814
IndexSpace create_index_space_union(Context ctx, IndexPartition parent, const DomainPoint &color, const std::vector< IndexSpace > &handles, const char *provenance=NULL)
Definition: legion.h:1461
Predicate predicate_or(Context ctx, const Predicate &p1, const Predicate &p2, const char *provenance=NULL)
Predicate predicate_and(Context ctx, const Predicate &p1, const Predicate &p2, const char *provenance=NULL)
static size_t get_maximum_dimension(void)
ArgumentMap create_argument_map(Context ctx)
Definition: legion_types.h:168
Definition: legion.h:2523
bool is_ready(bool subscribe=false) const
Definition: legion.h:756
Definition: legion.h:4208
LogicalRegion get_logical_subregion(Context ctx, LogicalPartition parent, IndexSpace handle)
PhysicalRegion map_region(Context ctx, const InlineLauncher &launcher)
int find_local_MPI_rank(void)
Definition: legion.h:2856
Mapping::MapperRuntime * get_mapper_runtime(void)
Definition: legion.h:4163
void remap_region(Context ctx, PhysicalRegion region, const char *provenance=NULL)
Definition: legion_types.h:2541
static const Task * get_context_task(Context ctx)
static const IndexSpace NO_SPACE
Definition: legion.h:90
LogicalRegion get_parent_logical_region(Context ctx, LogicalPartition handle)
Definition: legion.h:4181
static void set_top_level_task_mapper_id(MapperID mapper_id)
bool has_parent_logical_partition(Context ctx, LogicalRegion handle)
void get_index_space_domains(Context ctx, IndexSpace handle, std::vector< Domain > &domains)
Definition: legion.h:629
Definition: legion_domain.h:132
void register_projection_functor(ProjectionID pid, ProjectionFunctor *functor, bool silence_warnings=false, const char *warning_string=NULL)
IndexSpace get_index_subspace(Context ctx, IndexPartition p, Color color)
void add_mapper(MapperID map_id, Mapping::Mapper *mapper, Processor proc=Processor::NO_PROC)
void raise_region_exception(Context ctx, PhysicalRegion region, bool nuclear)
bool has_logical_partition_by_color(Context ctx, LogicalRegion parent, const DomainPoint &c)
void begin_trace(Context ctx, TraceID tid, bool logical_only=false, bool static_trace=false, const std::set< RegionTreeID > *managed=NULL, const char *provenance=NULL)
IndexSpace get_index_space(void) const
Definition: legion.h:462
static void perform_registration_callback(RegistrationCallbackFnptr callback, bool global, bool deduplicate=true, size_t dedup_tag=0)
CustomSerdezID generate_library_serdez_ids(const char *name, size_t count)
Future get_dynamic_collective_result(Context ctx, DynamicCollective dc, const char *provenance=NULL)
Definition: legion.h:341
bool has_parent_index_partition(Context ctx, IndexSpace handle)
Definition: legion.h:1183
Definition: legion.h:974
Definition: legion.h:1675
T get_result(const DomainPoint &point, bool silence_warnings=false, const char *warning_string=NULL) const
static void dump_profiling(void)
void ext_wait_on_legion(void) const
Future issue_timing_measurement(Context ctx, const TimingLauncher &launcher)
IndexPartition create_equal_partition(Context ctx, IndexSpace parent, IndexSpace color_space, size_t granularity=1, Color color=LEGION_AUTO_GENERATE_ID, const char *provenance=NULL)
static void set_return_code(int return_code)
static Future from_value(Runtime *rt, const T &value)
const char * get_layout_constraints_name(LayoutConstraintID layout_id)
std::vector< FieldID > instance_fields
Definition: legion.h:1096
RegionFlags flags
Definition: legion.h:1102
ExternalResources attach_external_resources(Context ctx, const IndexAttachLauncher &launcher)
LegionRuntime::Accessor::RegionAccessor< LegionRuntime::Accessor::AccessorType::Generic > get_field_accessor(FieldID field, bool silence_warnings=false) const
IndexPartition create_partition_by_difference(Context ctx, IndexSpace parent, IndexPartition handle1, IndexPartition handle2, IndexSpace color_space, PartitionKind part_kind=LEGION_COMPUTE_KIND, Color color=LEGION_AUTO_GENERATE_ID, const char *provenance=NULL)
static const ReductionOp * get_reduction_op(ReductionOpID redop_id)
void retrieve_name(TaskID task_id, const char *&result)
virtual LogicalRegion project(const Mappable *mappable, unsigned index, LogicalRegion upper_bound, const DomainPoint &point)
IndexSpace get_parent_index_space(Context ctx, IndexPartition handle)
bool has_index_partition(Context ctx, IndexSpace parent, Color color)
IndexAllocator create_index_allocator(Context ctx, IndexSpace handle)
IndexPartition create_partition_by_weights(Context ctx, IndexSpace parent, const std::map< DomainPoint, int > &weights, IndexSpace color_space, size_t granularity=1, Color color=LEGION_AUTO_GENERATE_ID, const char *provenance=NULL)
void unbind_implicit_task_from_external_thread(Context ctx)
IndexPartition create_partition_by_union(Context ctx, IndexSpace parent, IndexPartition handle1, IndexPartition handle2, IndexSpace color_space, PartitionKind part_kind=LEGION_COMPUTE_KIND, Color color=LEGION_AUTO_GENERATE_ID, const char *provenance=NULL)
LayoutConstraintID register_layout(const LayoutConstraintRegistrar &registrar)
LogicalPartition get_logical_partition_by_color(Context ctx, LogicalRegion parent, Color c)
Definition: legion.h:4241
Domain get_index_partition_color_space(Context ctx, IndexPartition p)
bool is_index_partition_disjoint(Context ctx, IndexPartition p)
static ProjectionID generate_static_projection_id(void)
Definition: legion.h:3618
size_t projection_args_size
Definition: legion.h:1108
ReductionOpID generate_dynamic_reduction_id(void)
PrivilegeMode get_privilege(void) const
void finish_implicit_task(Context ctx)
void destroy_lock(Context ctx, Lock l)
bool is_index_partition_complete(Context ctx, IndexPartition p)
void complete_frame(Context ctx, const char *provenance=NULL)
static void preregister_projection_functor(ProjectionID pid, ProjectionFunctor *functor)
CoherenceProperty prop
Definition: legion.h:1098
Future get_current_time_in_microseconds(Context ctx, Future precondition=Future())
Definition: legion.h:1735
void set_point(const DomainPoint &point, const UntypedBuffer &arg, bool replace=true)
Definition: legion.h:4540
void get_void_result(bool silence_warnings=false, const char *warning_string=NULL) const
VariantID register_task_variant(const TaskVariantRegistrar &registrar, VariantID vid=LEGION_AUTO_GENERATE_ID)
ShardID local_shard(Context ctx)
void get_index_space_partition_colors(Context ctx, IndexSpace sp, std::set< Color > &colors)
MappingTagID tag
Definition: legion.h:1101
unsigned get_index_partition_depth(Context ctx, IndexPartition handle)
LogicalRegion region
Definition: legion.h:1093
Grant acquire_grant(Context ctx, const std::vector< LockRequest > &requests)
Mapping::MapperContext begin_mapper_call(Context ctx, MapperID id, Processor target=Processor::NO_PROC)
IndexPartition create_partition_by_restriction(Context ctx, IndexSpace parent, IndexSpace color_space, DomainTransform transform, Domain extent, PartitionKind part_kind=LEGION_COMPUTE_KIND, Color color=LEGION_AUTO_GENERATE_ID, const char *provenance=NULL)
const std::map< int, AddressSpace > & find_forward_MPI_mapping(void)
Definition: legion_types.h:2167
static int wait_for_shutdown(void)
Domain get_index_space_domain(Context ctx, IndexSpace handle)
PhaseBarrier get_legion_arrive_phase_barrier(void) const
Definition: legion.h:3683
PhaseBarrier advance_phase_barrier(Context ctx, PhaseBarrier pb)
bool has_point(const DomainPoint &point)
void begin_static_trace(Context ctx, const std::set< RegionTreeID > *managed=NULL)
virtual bool is_exclusive(void) const
Definition: legion.h:4457
void get_void_result(const DomainPoint &point, bool silence_warnings=false, const char *warning_string=NULL) const
Future get_future(const DomainPoint &point) const
PrivilegeMode privilege
Definition: legion.h:1097
TaskID generate_dynamic_task_id(void)
DynamicCollective create_dynamic_collective(Context ctx, unsigned arrivals, ReductionOpID redop, const void *init_value, size_t init_size)
Definition: legion.h:838
void legion_wait_on_ext(void) const
Definition: legion.h:3731
IndexPartition create_partition_by_field(Context ctx, LogicalRegion handle, LogicalRegion parent, FieldID fid, IndexSpace color_space, Color color=LEGION_AUTO_GENERATE_ID, MapperID id=0, MappingTagID tag=0, PartitionKind part_kind=LEGION_DISJOINT_KIND, UntypedBuffer map_arg=UntypedBuffer(), const char *provenance=NULL)
Definition: legion.h:2134
Definition: legion.h:4508
Definition: legion.h:4014
Mapping::Mapper * get_mapper(Context ctx, MapperID id, Processor target=Processor::NO_PROC)
Definition: legion.h:4307
Color get_index_partition_color(Context ctx, IndexPartition handle)
static void register_custom_serdez_op(CustomSerdezID serdez_id, bool permit_duplicates=false)
bool is_empty(bool block=false, bool silence_warnings=false, const char *warning_string=NULL) const
bool has_logical_subregion_by_color(Context ctx, LogicalPartition parent, const DomainPoint &c)
Predicate predicate_not(Context ctx, const Predicate &p, const char *provenance=NULL)
PhysicalRegion attach_file(Context ctx, const char *file_name, LogicalRegion handle, LogicalRegion parent, const std::vector< FieldID > &field_vec, LegionFileMode mode)
void yield(Context ctx)
void advance_legion_handshake(void) const
void * get_local_task_variable_untyped(Context ctx, LocalVariableID id)
void free_field(FieldID fid, const bool unordered=false, const char *provenance=NULL)
Definition: legion.h:2075
static void initialize(int *argc, char ***argv, bool filter=false)
void arrive_dynamic_collective(Context ctx, DynamicCollective dc, const void *buffer, size_t size, unsigned count=1)
UntypedBuffer get_point(const DomainPoint &point) const
Future issue_mapping_fence(Context ctx, const char *provenance=NULL)
Definition: legion.h:88
Definition: legion.h:4335
FieldAllocator create_field_allocator(Context ctx, FieldSpace handle)
static void disable_profiling(void)
LogicalPartition partition
Definition: legion.h:1094
Definition: legion.h:9773
ReductionOpID redop
Definition: legion.h:1100
void legion_handoff_to_ext(void) const
MapperID generate_library_mapper_ids(const char *name, size_t count)
Definition: legion.h:664
size_t get_field_size(Context ctx, FieldSpace handle, FieldID fid)
IndexPartition get_index_partition(Context ctx, IndexSpace parent, Color color)
IndexPartition create_partition_by_blockify(Context ctx, IndexSpace parent, DomainPoint blocking_factor, Color color=LEGION_AUTO_GENERATE_ID, const char *provenance=NULL)
Definition: legion.h:2216
virtual bool is_invertible(void) const
Definition: legion.h:4472
ProjectionID projection
Definition: legion.h:1105
static LayoutConstraintID preregister_layout(const LayoutConstraintRegistrar &registrar, LayoutConstraintID layout_id=LEGION_AUTO_GENERATE_ID)
static int start(int argc, char **argv, bool background=false, bool supply_default_mapper=true)
static const InputArgs & get_input_args(void)
Context begin_implicit_task(TaskID top_task_id, MapperID mapper_id, Processor::Kind proc_kind, const char *task_name=NULL, bool control_replicable=false, unsigned shard_per_address_space=1, int shard_id=-1)
ProjectionID generate_library_projection_ids(const char *name, size_t count)
Definition: legion.h:1964
bool remove_point(const DomainPoint &point)
Definition: legion.h:490
static Runtime * get_runtime(Processor p=Processor::NO_PROC)
DynamicCollective advance_dynamic_collective(Context ctx, DynamicCollective dc)
Future get_predicate_future(Context ctx, const Predicate &p)
unsigned get_index_space_depth(Context ctx, IndexSpace handle)
static VariantID preregister_task_variant(const TaskVariantRegistrar &registrar, const char *task_name=NULL, VariantID vid=LEGION_AUTO_GENERATE_ID)
Definition: legion.h:3943
ShardingID generate_dynamic_sharding_id(void)
LogicalRegion get_logical_subregion_by_color(Context ctx, LogicalPartition parent, Color c)
Definition: legion.h:236
CustomSerdezID generate_dynamic_serdez_id(void)
void issue_copy_operation(Context ctx, const CopyLauncher &launcher)
void release_grant(Context ctx, Grant grant)
IndexSpace create_index_space(Context ctx, const Domain &bounds, TypeTag type_tag=0, const char *provenance=NULL)
FieldSpace create_field_space(Context ctx, const char *provenance=NULL)
Color create_cross_product_partitions(Context ctx, IndexPartition handle1, IndexPartition handle2, std::map< IndexSpace, IndexPartition > &handles, PartitionKind part_kind=LEGION_COMPUTE_KIND, Color color=LEGION_AUTO_GENERATE_ID, const char *provenance=NULL)
Definition: legion_types.h:165
bool is_valid(void) const
LogicalPartition get_logical_partition(Context ctx, LogicalRegion parent, IndexPartition handle)
void fill_fields(Context ctx, LogicalRegion handle, LogicalRegion parent, const std::set< FieldID > &fields, const T &value, Predicate pred=Predicate::TRUE_PRED)
void * projection_args
Definition: legion.h:1107
static void set_top_level_task_id(TaskID top_id)
Definition: legion.h:4115
static void legion_task_postamble(Runtime *runtime, Context ctx, const void *retvalptr=NULL, size_t retvalsize=0, bool owned=false, Realm::RegionInstance inst=Realm::RegionInstance::NO_INST)
void unmap_region(Context ctx, PhysicalRegion region)
static ShardingID generate_static_sharding_id(void)
ProjectionID generate_dynamic_projection_id(void)
Future reduce_future_map(Context ctx, const FutureMap &future_map, ReductionOpID redop, bool deterministic=false, const char *provenance=NULL)
Definition: legion.h:4066
static CustomSerdezID generate_static_serdez_id(void)
Definition: legion.h:4288
Definition: legion.h:3532
Definition: legion.h:2302