Legion Runtime
 All Classes Namespaces Files Functions Variables Typedefs Macros Pages
legion_types.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 #ifndef __LEGION_TYPES_H__
17 #define __LEGION_TYPES_H__
18 
23 #include <stdio.h>
24 #include <stdlib.h>
25 #include <assert.h>
26 #include <string.h>
27 #include <stdint.h>
28 #include <limits.h>
29 
30 #include <map>
31 #include <set>
32 #include <list>
33 #include <deque>
34 #include <vector>
35 #include <typeinfo>
36 #include <type_traits>
37 
38 #include "legion/legion_config.h"
39 #include "legion/legion_template_help.h"
40 
41 // Make sure we have the appropriate defines in place for including realm
42 #include "realm.h"
43 #include "realm/dynamic_templates.h"
44 
45 // this may be set before including legion.h to eliminate deprecation warnings
46 // for just the Legion API
47 #ifndef LEGION_DEPRECATED
48 #if __cplusplus >= 201402L
49 #define LEGION_DEPRECATED(x) [[deprecated(x)]]
50 #else
51 #define LEGION_DEPRECATED(x)
52 #endif
53 #endif
54 
55 // If we're doing full LEGION_SPY then turn off event pruning
56 #ifdef LEGION_SPY
57 #ifndef LEGION_DISABLE_EVENT_PRUNING
58 #define LEGION_DISABLE_EVENT_PRUNING
59 #endif
60 #endif
61 
62 // forward declarations from bitmask.h
63 template<typename T, unsigned int MAX,
64  unsigned SHIFT, unsigned MASK> class BitMask;
65 template<typename T, unsigned int MAX,
66  unsigned SHIFT, unsigned MASK> class TLBitMask;
67 #ifdef __SSE2__
68 template<unsigned int MAX> class SSEBitMask;
69 template<unsigned int MAX> class SSETLBitMask;
70 #endif
71 #ifdef __AVX__
72 template<unsigned int MAX> class AVXBitMask;
73 template<unsigned int MAX> class AVXTLBitMask;
74 #endif
75 #ifdef __ALTIVEC__
76 template<unsigned int MAX> class PPCBitMask;
77 template<unsigned int MAX> class PPCTLBitMask;
78 #endif
79 #ifdef __ARM_NEON
80 template<unsigned int MAX> class NeonBitMask;
81 template<unsigned int MAX> class NeonTLBitMask;
82 #endif
83 template<typename DT, unsigned BLOAT, bool BIDIR> class CompoundBitMask;
84 
85 namespace BindingLib { class Utility; } // BindingLib namespace
86 
87 namespace Legion {
88 
89  typedef ::legion_error_t LegionErrorType;
90  typedef ::legion_privilege_mode_t PrivilegeMode;
91  typedef ::legion_allocate_mode_t AllocateMode;
92  typedef ::legion_coherence_property_t CoherenceProperty;
93  typedef ::legion_region_flags_t RegionFlags;
94  typedef ::legion_projection_type_t ProjectionType;
95  typedef ::legion_partition_kind_t PartitionKind;
96  typedef ::legion_external_resource_t ExternalResource;
97  typedef ::legion_timing_measurement_t TimingMeasurement;
98  typedef ::legion_dependence_type_t DependenceType;
99  typedef ::legion_mappable_type_id_t MappableType;
100  typedef ::legion_file_mode_t LegionFileMode;
101  typedef ::legion_execution_constraint_t ExecutionConstraintKind;
102  typedef ::legion_layout_constraint_t LayoutConstraintKind;
103  typedef ::legion_equality_kind_t EqualityKind;
104  typedef ::legion_dimension_kind_t DimensionKind;
105  typedef ::legion_isa_kind_t ISAKind;
106  typedef ::legion_resource_constraint_t ResourceKind;
107  typedef ::legion_launch_constraint_t LaunchKind;
108  typedef ::legion_specialized_constraint_t SpecializedKind;
109 
110  // Forward declarations for user level objects
111  // legion.h
112  class IndexSpace;
113  template<int DIM, typename T> class IndexSpaceT;
114  class IndexPartition;
115  template<int DIM, typename T> class IndexPartitionT;
116  class FieldSpace;
117  class LogicalRegion;
118  template<int DIM, typename T> class LogicalRegionT;
119  class LogicalPartition;
120  template<int DIM, typename T> class LogicalPartitionT;
121  class IndexAllocator;
122  class FieldAllocator;
123  class UntypedBuffer;
124  class ArgumentMap;
125  class Lock;
126  struct LockRequest;
127  class Grant;
128  class PhaseBarrier;
129  struct RegionRequirement;
130  struct IndexSpaceRequirement;
131  struct FieldSpaceRequirement;
132  struct TaskLauncher;
133  struct IndexTaskLauncher;
134  typedef IndexTaskLauncher IndexLauncher; // for backwards compatibility
135  struct InlineLauncher;
136  struct CopyLauncher;
137  struct AcquireLauncher;
138  struct ReleaseLauncher;
139  struct FillLauncher;
140  struct LayoutConstraintRegistrar;
141  struct TaskVariantRegistrar;
142  class Future;
143  class FutureMap;
144  class Predicate;
145  class PhysicalRegion;
146  class ExternalResources;
147  class UntypedDeferredValue;
148  template<typename>
149  class DeferredValue;
150  template<typename, bool>
151  class DeferredReduction;
152  template<typename, int, typename, bool>
153  class DeferredBuffer;
154  template<typename COORD_T>
155  class UntypedDeferredBuffer;
156  template<PrivilegeMode,typename,int,typename,typename,bool>
157  class FieldAccessor;
158  template<typename, bool, int, typename, typename, bool>
159  class ReductionAccessor;
160 #ifdef LEGION_MULTI_REGION_ACCESSOR
161  template<typename, int,typename,typename,bool,bool,int>
162  class MultiRegionAccessor;
163 #endif
164  template<typename,int,typename,typename>
166  namespace ArraySyntax {
167  template<typename, PrivilegeMode> class AccessorRefHelper;
168  template<typename> class AffineRefHelper;
169  }
170  class PieceIterator;
171  template<int,typename>
172  class PieceIteratorT;
173  template<PrivilegeMode,typename,int,typename>
174  class SpanIterator;
175  class IndexIterator;
176  template<typename T> struct ColoredPoints;
177  struct InputArgs;
179  class ProjectionFunctor;
180  class Task;
181  class Copy;
182  class InlineMapping;
183  class Acquire;
184  class Release;
185  class Close;
186  class Fill;
187  class Partition;
188  class MustEpoch;
189  class Runtime;
190  class LegionHandshake;
191  class MPILegionHandshake;
192  // For backwards compatibility
193  typedef Runtime HighLevelRuntime;
194  // Helper for saving instantiated template functions
195  struct SerdezRedopFns;
196  // Some typedefs for making things nicer for users with C++11 support
197  template<typename FT, int N, typename T = ::legion_coord_t>
198  using GenericAccessor = Realm::GenericAccessor<FT,N,T>;
199  template<typename FT, int N, typename T = ::legion_coord_t>
200  using AffineAccessor = Realm::AffineAccessor<FT,N,T>;
201  template<typename FT, int N, typename T = ::legion_coord_t>
202  using MultiAffineAccessor = Realm::MultiAffineAccessor<FT,N,T>;
203 
204  // Forward declarations for compiler level objects
205  // legion.h
206  class ColoringSerializer;
208 
209  // Forward declarations for wrapper tasks
210  // legion.h
211  class LegionTaskWrapper;
212  class LegionSerialization;
213 
214  // Forward declarations for C wrapper objects
215  // legion_c_util.h
216  class TaskResult;
217  class CObjectWrapper;
218 
219  // legion_domain.h
220  class DomainPoint;
221  class Domain;
222  class IndexSpaceAllocator;
223 
224  // legion_utilities.h
225  class Serializer;
226  class Deserializer;
227 
228  // legion_constraint.h
229  class ISAConstraint;
230  class ProcessorConstraint;
231  class ResourceConstraint;
232  class LaunchConstraint;
233  class ColocationConstraint;
234  class ExecutionConstraintSet;
235 
236  class SpecializedConstraint;
237  class MemoryConstraint;
238  class FieldConstraint;
239  class OrderingConstraint;
240  class SplittingConstraint;
241  class DimensionConstraint;
242  class AlignmentConstraint;
243  class OffsetConstraint;
244  class PointerConstraint;
245  class LayoutConstraintSet;
246  class TaskLayoutConstraintSet;
247 
248  namespace Mapping {
249  class PhysicalInstance;
250  class MapperEvent;
251  class ProfilingRequestSet;
252  class Mapper;
253  class MapperRuntime;
254  class DefaultMapper;
255  class ShimMapper;
256  class TestMapper;
257  class DebugMapper;
258  class ReplayMapper;
259 
260  // The following types are effectively overlaid on the Realm versions
261  // to allow for Legion-specific profiling measurements
262  enum ProfilingMeasurementID {
263  PMID_LEGION_FIRST = Realm::PMID_REALM_LAST,
264  PMID_RUNTIME_OVERHEAD,
265  };
266  };
267 
268  namespace Internal {
269 
270  enum OpenState {
271  NOT_OPEN = 0,
272  OPEN_READ_ONLY = 1,
273  OPEN_READ_WRITE = 2, // unknown dirty information below
274  OPEN_SINGLE_REDUCE = 3, // only one open child with reductions below
275  OPEN_MULTI_REDUCE = 4, // multiple open children with same reduction
276  // Only projection states below here
277  OPEN_READ_ONLY_PROJ = 5, // read-only projection
278  OPEN_READ_WRITE_PROJ = 6, // read-write projection
279  OPEN_READ_WRITE_PROJ_DISJOINT_SHALLOW = 7, // depth=0, children disjoint
280  OPEN_REDUCE_PROJ = 8, // reduction-only projection
281  OPEN_REDUCE_PROJ_DIRTY = 9, // same as above but already open dirty
282  };
283 
284  // redop IDs - none used in HLR right now, but 0 isn't allowed
285  enum {
286  REDOP_ID_AVAILABLE = 1,
287  };
288 
289  // Realm dependent partitioning kinds
290  enum DepPartOpKind {
291  DEP_PART_UNION = 0, // a single union
292  DEP_PART_UNIONS = 1, // many parallel unions
293  DEP_PART_UNION_REDUCTION = 2, // union reduction to a single space
294  DEP_PART_INTERSECTION = 3, // a single intersection
295  DEP_PART_INTERSECTIONS = 4, // many parallel intersections
296  DEP_PART_INTERSECTION_REDUCTION = 5, // intersection reduction to a space
297  DEP_PART_DIFFERENCE = 6, // a single difference
298  DEP_PART_DIFFERENCES = 7, // many parallel differences
299  DEP_PART_EQUAL = 8, // an equal partition operation
300  DEP_PART_BY_FIELD = 9, // create a partition from a field
301  DEP_PART_BY_IMAGE = 10, // create partition by image
302  DEP_PART_BY_IMAGE_RANGE = 11, // create partition by image range
303  DEP_PART_BY_PREIMAGE = 12, // create partition by preimage
304  DEP_PART_BY_PREIMAGE_RANGE = 13, // create partition by preimage range
305  DEP_PART_ASSOCIATION = 14, // create an association
306  DEP_PART_WEIGHTS = 15, // create partition by weights
307  };
308 
309  // Enumeration of Legion runtime tasks
310  enum LgTaskID {
311  LG_SCHEDULER_ID,
312  LG_POST_END_ID,
313  LG_TRIGGER_READY_ID,
314  LG_TRIGGER_EXECUTION_ID,
315  LG_TRIGGER_RESOLUTION_ID,
316  LG_TRIGGER_COMMIT_ID,
317  LG_DEFERRED_EXECUTION_ID,
318  LG_DEFERRED_COMPLETION_ID,
319  LG_DEFERRED_COMMIT_ID,
320  LG_DEFERRED_COLLECT_ID,
321  LG_PRE_PIPELINE_ID,
322  LG_TRIGGER_DEPENDENCE_ID,
323  LG_TRIGGER_COMPLETION_ID,
324  LG_TRIGGER_OP_ID,
325  LG_TRIGGER_TASK_ID,
326  LG_DEFER_MAPPER_SCHEDULER_TASK_ID,
327  LG_MUST_INDIV_ID,
328  LG_MUST_INDEX_ID,
329  LG_MUST_MAP_ID,
330  LG_MUST_DIST_ID,
331  LG_MUST_LAUNCH_ID,
332  LG_DEFERRED_FUTURE_SET_ID,
333  LG_DEFERRED_FUTURE_MAP_SET_ID,
334  LG_RESOLVE_FUTURE_PRED_ID,
335  LG_CONTRIBUTE_COLLECTIVE_ID,
336  LG_FUTURE_CALLBACK_TASK_ID,
337  LG_TOP_FINISH_TASK_ID,
338  LG_MAPPER_TASK_ID,
339  LG_DISJOINTNESS_TASK_ID,
340  LG_DEFER_PHYSICAL_REGISTRATION_TASK_ID,
341  LG_PART_INDEPENDENCE_TASK_ID,
342  LG_SPACE_INDEPENDENCE_TASK_ID,
343  LG_PENDING_CHILD_TASK_ID,
344  LG_ISSUE_FRAME_TASK_ID,
345  LG_MAPPER_CONTINUATION_TASK_ID,
346  LG_TASK_IMPL_SEMANTIC_INFO_REQ_TASK_ID,
347  LG_INDEX_SPACE_SEMANTIC_INFO_REQ_TASK_ID,
348  LG_INDEX_PART_SEMANTIC_INFO_REQ_TASK_ID,
349  LG_FIELD_SPACE_SEMANTIC_INFO_REQ_TASK_ID,
350  LG_FIELD_SEMANTIC_INFO_REQ_TASK_ID,
351  LG_DEFER_FIELD_INFOS_TASK_ID,
352  LG_REGION_SEMANTIC_INFO_REQ_TASK_ID,
353  LG_PARTITION_SEMANTIC_INFO_REQ_TASK_ID,
354  LG_INDEX_SPACE_DEFER_CHILD_TASK_ID,
355  LG_INDEX_PART_DEFER_CHILD_TASK_ID,
356  LG_DEFERRED_ENQUEUE_TASK_ID,
357  LG_DEFER_MAPPER_MESSAGE_TASK_ID,
358  LG_REMOTE_VIEW_CREATION_TASK_ID,
359  LG_DEFERRED_DISTRIBUTE_TASK_ID,
360  LG_DEFER_PERFORM_MAPPING_TASK_ID,
361  LG_DEFERRED_LAUNCH_TASK_ID,
362  LG_MISSPECULATE_TASK_ID,
363  LG_DEFER_FIND_COPY_PRE_TASK_ID,
364  LG_DEFER_MATERIALIZED_VIEW_TASK_ID,
365  LG_DEFER_REDUCTION_VIEW_TASK_ID,
366  LG_DEFER_PHI_VIEW_REF_TASK_ID,
367  LG_DEFER_PHI_VIEW_REGISTRATION_TASK_ID,
368  LG_TIGHTEN_INDEX_SPACE_TASK_ID,
369  LG_REMOTE_PHYSICAL_REQUEST_TASK_ID,
370  LG_REMOTE_PHYSICAL_RESPONSE_TASK_ID,
371  LG_REPLAY_SLICE_TASK_ID,
372  LG_TRANSITIVE_REDUCTION_TASK_ID,
373  LG_DELETE_TEMPLATE_TASK_ID,
374  LG_REFINEMENT_TASK_ID,
375  LG_REMOTE_REF_TASK_ID,
376  LG_DEFER_RAY_TRACE_TASK_ID,
377  LG_DEFER_RAY_TRACE_FINISH_TASK_ID,
378  LG_DEFER_SUBSET_REQUEST_TASK_ID,
379  LG_DEFER_MAKE_OWNER_TASK_ID,
380  LG_DEFER_MERGE_OR_FORWARD_TASK_ID,
381  LG_DEFER_EQ_RESPONSE_TASK_ID,
382  LG_DEFER_REMOVE_EQ_REF_TASK_ID,
383  LG_DEFER_REMOTE_REF_UPDATE_TASK_ID,
384  LG_DEFER_REMOTE_UNREGISTER_TASK_ID,
385  LG_COPY_FILL_AGGREGATION_TASK_ID,
386  LG_COPY_FILL_DELETION_TASK_ID,
387  LG_FINALIZE_EQ_SETS_TASK_ID,
388  LG_DEFERRED_COPY_ACROSS_TASK_ID,
389  LG_DEFER_REMOTE_OP_DELETION_TASK_ID,
390  LG_DEFER_REMOTE_INSTANCE_TASK_ID,
391  LG_DEFER_REMOTE_REDUCTION_TASK_ID,
392  LG_DEFER_REMOTE_UPDATE_TASK_ID,
393  LG_DEFER_REMOTE_ACQUIRE_TASK_ID,
394  LG_DEFER_REMOTE_RELEASE_TASK_ID,
395  LG_DEFER_REMOTE_COPIES_ACROSS_TASK_ID,
396  LG_DEFER_REMOTE_OVERWRITE_TASK_ID,
397  LG_DEFER_REMOTE_FILTER_TASK_ID,
398  LG_DEFER_PERFORM_TRAVERSAL_TASK_ID,
399  LG_DEFER_PERFORM_REMOTE_TASK_ID,
400  LG_DEFER_PERFORM_UPDATE_TASK_ID,
401  LG_DEFER_PERFORM_OUTPUT_TASK_ID,
402  LG_DEFER_INDIVIDUAL_MANAGER_TASK_ID,
403  LG_DEFER_COLLECTIVE_MANAGER_TASK_ID,
404  LG_DEFER_VERIFY_PARTITION_TASK_ID,
405  LG_DEFER_RELEASE_ACQUIRED_TASK_ID,
406  LG_DEFER_COPY_ACROSS_TASK_ID,
407  LG_MALLOC_INSTANCE_TASK_ID,
408  LG_FREE_INSTANCE_TASK_ID,
409  LG_YIELD_TASK_ID,
410  // this marks the beginning of task IDs tracked by the shutdown algorithm
411  LG_BEGIN_SHUTDOWN_TASK_IDS,
412  LG_RETRY_SHUTDOWN_TASK_ID = LG_BEGIN_SHUTDOWN_TASK_IDS,
413  // Message ID goes at the end so we can append additional
414  // message IDs here for the profiler and separate meta-tasks
415  LG_MESSAGE_ID,
416  LG_LAST_TASK_ID, // This one should always be last
417  };
418 
419  // Make this a macro so we can keep it close to
420  // declaration of the task IDs themselves
421 #define LG_TASK_DESCRIPTIONS(name) \
422  const char *name[LG_LAST_TASK_ID] = { \
423  "Scheduler", \
424  "Post-Task Execution", \
425  "Trigger Ready", \
426  "Trigger Execution", \
427  "Trigger Resolution", \
428  "Trigger Commit", \
429  "Deferred Execution", \
430  "Deferred Completion", \
431  "Deferred Commit", \
432  "Garbage Collection", \
433  "Prepipeline Stage", \
434  "Logical Dependence Analysis", \
435  "Trigger Completion", \
436  "Trigger Operation Mapping", \
437  "Trigger Task Mapping", \
438  "Defer Mapper Scheduler", \
439  "Must Individual Task Dependence Analysis", \
440  "Must Index Task Dependence Analysis", \
441  "Must Task Physical Dependence Analysis", \
442  "Must Task Distribution", \
443  "Must Task Launch", \
444  "Deferred Future Set", \
445  "Deferred Future Map Set", \
446  "Resolve Future Predicate", \
447  "Contribute Collective", \
448  "Future Callback", \
449  "Top Finish", \
450  "Mapper Task", \
451  "Disjointness Test", \
452  "Defer Physical Registration", \
453  "Partition Independence Test", \
454  "Index Space Independence Test", \
455  "Remove Pending Child", \
456  "Issue Frame", \
457  "Mapper Continuation", \
458  "Task Impl Semantic Request", \
459  "Index Space Semantic Request", \
460  "Index Partition Semantic Request", \
461  "Field Space Semantic Request", \
462  "Field Semantic Request", \
463  "Defer Field Infos Request", \
464  "Region Semantic Request", \
465  "Partition Semantic Request", \
466  "Defer Index Space Child Request", \
467  "Defer Index Partition Child Request", \
468  "Deferred Enqueue Task", \
469  "Deferred Mapper Message", \
470  "Remote View Creation", \
471  "Deferred Distribute Task", \
472  "Defer Task Perform Mapping", \
473  "Deferred Task Launch", \
474  "Handle Mapping Misspeculation", \
475  "Defer Find Copy Preconditions", \
476  "Defer Materialized View Registration", \
477  "Defer Reduction View Registration", \
478  "Defer Phi View Reference", \
479  "Defer Phi View Registration", \
480  "Tighten Index Space", \
481  "Remote Physical Context Request", \
482  "Remote Physical Context Response", \
483  "Replay Physical Trace", \
484  "Template Transitive Reduction", \
485  "Delete Physical Template", \
486  "Refinement", \
487  "Remove Remote References", \
488  "Defer Ray Trace", \
489  "Defer Ray Trace Finish", \
490  "Defer Subset Request", \
491  "Defer Make Owner", \
492  "Defer Merge or Forward", \
493  "Defer Equivalence Set Response", \
494  "Defer Remove Equivalence Set Expression References", \
495  "Defer Remote Reference Update", \
496  "Defer Remote Unregister", \
497  "Copy Fill Aggregation", \
498  "Copy Fill Deletion", \
499  "Finalize Equivalence Sets", \
500  "Deferred Copy Across", \
501  "Defer Remote Op Deletion", \
502  "Defer Remote Instance Request", \
503  "Defer Remote Reduction Request", \
504  "Defer Remote Update Equivalence Set", \
505  "Defer Remote Acquire", \
506  "Defer Remote Release", \
507  "Defer Remote Copy Across", \
508  "Defer Remote Overwrite Equivalence Set", \
509  "Defer Remote Filter Equivalence Set", \
510  "Defer Physical Analysis Traversal Stage", \
511  "Defer Physical Analysis Remote Stage", \
512  "Defer Physical Analysis Update Stage", \
513  "Defer Physical Analysis Output Stage", \
514  "Defer Instance Manager Registration", \
515  "Defer Reduction Manager Registration", \
516  "Defer Verify Partition", \
517  "Defer Release Acquired Instances", \
518  "Defer Copy-Across Execution for Preimages", \
519  "Malloc Instance", \
520  "Free Instance", \
521  "Yield", \
522  "Retry Shutdown", \
523  "Remote Message", \
524  };
525 
526  enum MappingCallKind {
527  GET_MAPPER_NAME_CALL,
528  GET_MAPER_SYNC_MODEL_CALL,
529  SELECT_TASK_OPTIONS_CALL,
530  PREMAP_TASK_CALL,
531  SLICE_TASK_CALL,
532  MAP_TASK_CALL,
533  SELECT_VARIANT_CALL,
534  POSTMAP_TASK_CALL,
535  TASK_SELECT_SOURCES_CALL,
536  TASK_SPECULATE_CALL,
537  TASK_REPORT_PROFILING_CALL,
538  MAP_INLINE_CALL,
539  INLINE_SELECT_SOURCES_CALL,
540  INLINE_REPORT_PROFILING_CALL,
541  MAP_COPY_CALL,
542  COPY_SELECT_SOURCES_CALL,
543  COPY_SPECULATE_CALL,
544  COPY_REPORT_PROFILING_CALL,
545  CLOSE_SELECT_SOURCES_CALL,
546  CLOSE_REPORT_PROFILING_CALL,
547  MAP_ACQUIRE_CALL,
548  ACQUIRE_SPECULATE_CALL,
549  ACQUIRE_REPORT_PROFILING_CALL,
550  MAP_RELEASE_CALL,
551  RELEASE_SELECT_SOURCES_CALL,
552  RELEASE_SPECULATE_CALL,
553  RELEASE_REPORT_PROFILING_CALL,
554  SELECT_PARTITION_PROJECTION_CALL,
555  MAP_PARTITION_CALL,
556  PARTITION_SELECT_SOURCES_CALL,
557  PARTITION_REPORT_PROFILING_CALL,
558  CONFIGURE_CONTEXT_CALL,
559  SELECT_TUNABLE_VALUE_CALL,
560  MAP_MUST_EPOCH_CALL,
561  MAP_DATAFLOW_GRAPH_CALL,
562  MEMOIZE_OPERATION_CALL,
563  SELECT_TASKS_TO_MAP_CALL,
564  SELECT_STEAL_TARGETS_CALL,
565  PERMIT_STEAL_REQUEST_CALL,
566  HANDLE_MESSAGE_CALL,
567  HANDLE_TASK_RESULT_CALL,
568  APPLICATION_MAPPER_CALL,
569  LAST_MAPPER_CALL,
570  };
571 
572 #define MAPPER_CALL_NAMES(name) \
573  const char *name[LAST_MAPPER_CALL] = { \
574  "get_mapper_name", \
575  "get_mapper_sync_model", \
576  "select_task_options", \
577  "premap_task", \
578  "slice_task", \
579  "map_task", \
580  "select_task_variant", \
581  "postmap_task", \
582  "select_task_sources", \
583  "speculate (for task)", \
584  "report profiling (for task)", \
585  "map_inline", \
586  "select_inline_sources", \
587  "report profiling (for inline)", \
588  "map_copy", \
589  "select_copy_sources", \
590  "speculate (for copy)", \
591  "report_profiling (for copy)", \
592  "select_close_sources", \
593  "report_profiling (for close)", \
594  "map_acquire", \
595  "speculate (for acquire)", \
596  "report_profiling (for acquire)", \
597  "map_release", \
598  "select_release_sources", \
599  "speculate (for release)", \
600  "report_profiling (for release)", \
601  "select partition projection", \
602  "map_partition", \
603  "select_partition_sources", \
604  "report_profiling (for partition)", \
605  "configure_context", \
606  "select_tunable_value", \
607  "map_must_epoch", \
608  "map_dataflow_graph", \
609  "memoize_operation", \
610  "select_tasks_to_map", \
611  "select_steal_targets", \
612  "permit_steal_request", \
613  "handle_message", \
614  "handle_task_result", \
615  "application mapper call", \
616  }
617 
618  // Methodology for assigning priorities to meta-tasks:
619  // Minimum and low priority are for things like profiling
620  // that we don't want to interfere with normal execution.
621  // Resource priority is reserved for tasks that have been
622  // granted resources like reservations. Running priority
623  // is the highest and guarantees that we drain out any
624  // previously running tasks over starting new ones. The rest
625  // of the priorities are classified as either 'throughput'
626  // or 'latency' sensitive. Under each of these two major
627  // categories there are four sub-priorities:
628  // - work: general work to be done
629  // - deferred: work that was already scheduled but
630  // for which a continuation had to be
631  // made so we don't want to wait behind
632  // work that hasn't started yet
633  // - messsage: a message from a remote node that we
634  // should handle sooner than our own
635  // work since work on the other node is
636  // blocked waiting on our response
637  // - response: a response message from a remote node
638  // that we should handle to unblock work
639  // on our own node
640  enum LgPriority {
641  LG_MIN_PRIORITY = INT_MIN,
642  LG_LOW_PRIORITY = -1,
643  // Throughput priorities
644  LG_THROUGHPUT_WORK_PRIORITY = 0,
645  LG_THROUGHPUT_DEFERRED_PRIORITY = 1,
646  LG_THROUGHPUT_MESSAGE_PRIORITY = 2,
647  LG_THROUGHPUT_RESPONSE_PRIORITY = 3,
648  // Latency priorities
649  LG_LATENCY_WORK_PRIORITY = 4,
650  LG_LATENCY_DEFERRED_PRIORITY = 5,
651  LG_LATENCY_MESSAGE_PRIORITY = 6,
652  LG_LATENCY_RESPONSE_PRIORITY = 7,
653  // Resource priorities
654  LG_RESOURCE_PRIORITY = 8,
655  // Running priorities
656  LG_RUNNING_PRIORITY = 9,
657  };
658 
659  enum VirtualChannelKind {
660  // The default and work virtual channels are unordered
661  DEFAULT_VIRTUAL_CHANNEL = 0, // latency priority
662  THROUGHPUT_VIRTUAL_CHANNEL = 1, // throughput priority
663  LAST_UNORDERED_VIRTUAL_CHANNEL = THROUGHPUT_VIRTUAL_CHANNEL,
664  // All the rest of these are ordered (latency-priority) channels
665  MAPPER_VIRTUAL_CHANNEL = 1,
666  TASK_VIRTUAL_CHANNEL = 2,
667  FIELD_SPACE_VIRTUAL_CHANNEL = 4,
668  REFERENCE_VIRTUAL_CHANNEL = 6,
669  UPDATE_VIRTUAL_CHANNEL = 7, // deferred-priority
670  SUBSET_VIRTUAL_CHANNEL = 8,
671  CONTEXT_VIRTUAL_CHANNEL = 9,
672  LAYOUT_CONSTRAINT_VIRTUAL_CHANNEL = 10,
673  EXPRESSION_VIRTUAL_CHANNEL = 11,
674  MIGRATION_VIRTUAL_CHANNEL = 12,
675  TRACING_VIRTUAL_CHANNEL = 13,
676  MAX_NUM_VIRTUAL_CHANNELS = 14, // this one must be last
677  };
678 
679  enum MessageKind {
680  TASK_MESSAGE,
681  STEAL_MESSAGE,
682  ADVERTISEMENT_MESSAGE,
683  SEND_REGISTRATION_CALLBACK,
684  SEND_REMOTE_TASK_REPLAY,
685  SEND_REMOTE_TASK_PROFILING_RESPONSE,
686  SEND_SHARED_OWNERSHIP,
687  SEND_INDEX_SPACE_REQUEST,
688  SEND_INDEX_SPACE_RETURN,
689  SEND_INDEX_SPACE_SET,
690  SEND_INDEX_SPACE_CHILD_REQUEST,
691  SEND_INDEX_SPACE_CHILD_RESPONSE,
692  SEND_INDEX_SPACE_COLORS_REQUEST,
693  SEND_INDEX_SPACE_COLORS_RESPONSE,
694  SEND_INDEX_SPACE_REMOTE_EXPRESSION_REQUEST,
695  SEND_INDEX_SPACE_REMOTE_EXPRESSION_RESPONSE,
696  SEND_INDEX_SPACE_GENERATE_COLOR_REQUEST,
697  SEND_INDEX_SPACE_GENERATE_COLOR_RESPONSE,
698  SEND_INDEX_SPACE_RELEASE_COLOR,
699  SEND_INDEX_PARTITION_NOTIFICATION,
700  SEND_INDEX_PARTITION_REQUEST,
701  SEND_INDEX_PARTITION_RETURN,
702  SEND_INDEX_PARTITION_CHILD_REQUEST,
703  SEND_INDEX_PARTITION_CHILD_RESPONSE,
704  SEND_INDEX_PARTITION_DISJOINT_UPDATE,
705  SEND_FIELD_SPACE_NODE,
706  SEND_FIELD_SPACE_REQUEST,
707  SEND_FIELD_SPACE_RETURN,
708  SEND_FIELD_SPACE_ALLOCATOR_REQUEST,
709  SEND_FIELD_SPACE_ALLOCATOR_RESPONSE,
710  SEND_FIELD_SPACE_ALLOCATOR_INVALIDATION,
711  SEND_FIELD_SPACE_ALLOCATOR_FLUSH,
712  SEND_FIELD_SPACE_ALLOCATOR_FREE,
713  SEND_FIELD_SPACE_INFOS_REQUEST,
714  SEND_FIELD_SPACE_INFOS_RESPONSE,
715  SEND_FIELD_ALLOC_REQUEST,
716  SEND_FIELD_SIZE_UPDATE,
717  SEND_FIELD_FREE,
718  SEND_FIELD_FREE_INDEXES,
719  SEND_FIELD_SPACE_LAYOUT_INVALIDATION,
720  SEND_LOCAL_FIELD_ALLOC_REQUEST,
721  SEND_LOCAL_FIELD_ALLOC_RESPONSE,
722  SEND_LOCAL_FIELD_FREE,
723  SEND_LOCAL_FIELD_UPDATE,
724  SEND_TOP_LEVEL_REGION_REQUEST,
725  SEND_TOP_LEVEL_REGION_RETURN,
726  INDEX_SPACE_DESTRUCTION_MESSAGE,
727  INDEX_PARTITION_DESTRUCTION_MESSAGE,
728  FIELD_SPACE_DESTRUCTION_MESSAGE,
729  LOGICAL_REGION_DESTRUCTION_MESSAGE,
730  INDIVIDUAL_REMOTE_COMPLETE,
731  INDIVIDUAL_REMOTE_COMMIT,
732  SLICE_REMOTE_MAPPED,
733  SLICE_REMOTE_COMPLETE,
734  SLICE_REMOTE_COMMIT,
735  SLICE_FIND_INTRA_DEP,
736  SLICE_RECORD_INTRA_DEP,
737  SLICE_COLLECTIVE_REQUEST,
738  SLICE_COLLECTIVE_RESPONSE,
739  DISTRIBUTED_REMOTE_REGISTRATION,
740  DISTRIBUTED_VALID_UPDATE,
741  DISTRIBUTED_GC_UPDATE,
742  DISTRIBUTED_RESOURCE_UPDATE,
743  DISTRIBUTED_CREATE_ADD,
744  DISTRIBUTED_CREATE_REMOVE,
745  DISTRIBUTED_UNREGISTER,
746  SEND_ATOMIC_RESERVATION_REQUEST,
747  SEND_ATOMIC_RESERVATION_RESPONSE,
748  SEND_BACK_LOGICAL_STATE,
749  SEND_MATERIALIZED_VIEW,
750  SEND_FILL_VIEW,
751  SEND_PHI_VIEW,
752  SEND_REDUCTION_VIEW,
753  SEND_INSTANCE_MANAGER,
754  SEND_COLLECTIVE_MANAGER,
755  SEND_COLLECTIVE_MESSAGE,
756  SEND_CREATE_TOP_VIEW_REQUEST,
757  SEND_CREATE_TOP_VIEW_RESPONSE,
758  SEND_VIEW_REQUEST,
759  SEND_VIEW_REGISTER_USER,
760  SEND_VIEW_FIND_COPY_PRE_REQUEST,
761  SEND_VIEW_FIND_COPY_PRE_RESPONSE,
762  SEND_VIEW_ADD_COPY_USER,
763  SEND_VIEW_REPLICATION_REQUEST,
764  SEND_VIEW_REPLICATION_RESPONSE,
765  SEND_VIEW_REPLICATION_REMOVAL,
766  SEND_MANAGER_REQUEST,
767  SEND_FUTURE_RESULT,
768  SEND_FUTURE_SUBSCRIPTION,
769  SEND_FUTURE_NOTIFICATION,
770  SEND_FUTURE_BROADCAST,
771  SEND_FUTURE_MAP_REQUEST,
772  SEND_FUTURE_MAP_RESPONSE,
773  SEND_MAPPER_MESSAGE,
774  SEND_MAPPER_BROADCAST,
775  SEND_TASK_IMPL_SEMANTIC_REQ,
776  SEND_INDEX_SPACE_SEMANTIC_REQ,
777  SEND_INDEX_PARTITION_SEMANTIC_REQ,
778  SEND_FIELD_SPACE_SEMANTIC_REQ,
779  SEND_FIELD_SEMANTIC_REQ,
780  SEND_LOGICAL_REGION_SEMANTIC_REQ,
781  SEND_LOGICAL_PARTITION_SEMANTIC_REQ,
782  SEND_TASK_IMPL_SEMANTIC_INFO,
783  SEND_INDEX_SPACE_SEMANTIC_INFO,
784  SEND_INDEX_PARTITION_SEMANTIC_INFO,
785  SEND_FIELD_SPACE_SEMANTIC_INFO,
786  SEND_FIELD_SEMANTIC_INFO,
787  SEND_LOGICAL_REGION_SEMANTIC_INFO,
788  SEND_LOGICAL_PARTITION_SEMANTIC_INFO,
789  SEND_REMOTE_CONTEXT_REQUEST,
790  SEND_REMOTE_CONTEXT_RESPONSE,
791  SEND_REMOTE_CONTEXT_RELEASE,
792  SEND_REMOTE_CONTEXT_FREE,
793  SEND_REMOTE_CONTEXT_PHYSICAL_REQUEST,
794  SEND_REMOTE_CONTEXT_PHYSICAL_RESPONSE,
795  SEND_COMPUTE_EQUIVALENCE_SETS_REQUEST,
796  SEND_EQUIVALENCE_SET_REQUEST,
797  SEND_EQUIVALENCE_SET_RESPONSE,
798  SEND_EQUIVALENCE_SET_SUBSET_REQUEST,
799  SEND_EQUIVALENCE_SET_SUBSET_RESPONSE,
800  SEND_EQUIVALENCE_SET_SUBSET_UPDATE,
801  SEND_EQUIVALENCE_SET_RAY_TRACE_REQUEST,
802  SEND_EQUIVALENCE_SET_RAY_TRACE_RESPONSE,
803  SEND_EQUIVALENCE_SET_MIGRATION,
804  SEND_EQUIVALENCE_SET_OWNER_UPDATE,
805  SEND_EQUIVALENCE_SET_REMOTE_REFINEMENT,
806  SEND_EQUIVALENCE_SET_REMOTE_REQUEST_INSTANCES,
807  SEND_EQUIVALENCE_SET_REMOTE_REQUEST_INVALID,
808  SEND_EQUIVALENCE_SET_REMOTE_UPDATES,
809  SEND_EQUIVALENCE_SET_REMOTE_ACQUIRES,
810  SEND_EQUIVALENCE_SET_REMOTE_RELEASES,
811  SEND_EQUIVALENCE_SET_REMOTE_COPIES_ACROSS,
812  SEND_EQUIVALENCE_SET_REMOTE_OVERWRITES,
813  SEND_EQUIVALENCE_SET_REMOTE_FILTERS,
814  SEND_EQUIVALENCE_SET_REMOTE_INSTANCES,
815  SEND_EQUIVALENCE_SET_STALE_UPDATE,
816  SEND_INSTANCE_REQUEST,
817  SEND_INSTANCE_RESPONSE,
818  SEND_EXTERNAL_CREATE_REQUEST,
819  SEND_EXTERNAL_CREATE_RESPONSE,
820  SEND_EXTERNAL_ATTACH,
821  SEND_EXTERNAL_DETACH,
822  SEND_GC_PRIORITY_UPDATE,
823  SEND_GC_REQUEST,
824  SEND_GC_RESPONSE,
825  SEND_GC_ACQUIRE,
826  SEND_GC_ACQUIRED,
827  SEND_GC_DEBUG_REQUEST,
828  SEND_GC_DEBUG_RESPONSE,
829  SEND_ACQUIRE_REQUEST,
830  SEND_ACQUIRE_RESPONSE,
831  SEND_VARIANT_BROADCAST,
832  SEND_CONSTRAINT_REQUEST,
833  SEND_CONSTRAINT_RESPONSE,
834  SEND_CONSTRAINT_RELEASE,
835  SEND_TOP_LEVEL_TASK_REQUEST,
836  SEND_TOP_LEVEL_TASK_COMPLETE,
837  SEND_MPI_RANK_EXCHANGE,
838  SEND_LIBRARY_MAPPER_REQUEST,
839  SEND_LIBRARY_MAPPER_RESPONSE,
840  SEND_LIBRARY_TRACE_REQUEST,
841  SEND_LIBRARY_TRACE_RESPONSE,
842  SEND_LIBRARY_PROJECTION_REQUEST,
843  SEND_LIBRARY_PROJECTION_RESPONSE,
844  SEND_LIBRARY_TASK_REQUEST,
845  SEND_LIBRARY_TASK_RESPONSE,
846  SEND_LIBRARY_REDOP_REQUEST,
847  SEND_LIBRARY_REDOP_RESPONSE,
848  SEND_LIBRARY_SERDEZ_REQUEST,
849  SEND_LIBRARY_SERDEZ_RESPONSE,
850  SEND_REMOTE_OP_REPORT_UNINIT,
851  SEND_REMOTE_OP_PROFILING_COUNT_UPDATE,
852  SEND_REMOTE_TRACE_UPDATE,
853  SEND_REMOTE_TRACE_RESPONSE,
854  SEND_REMOTE_TRACE_EQ_REQUEST,
855  SEND_REMOTE_TRACE_EQ_RESPONSE,
856  SEND_SHUTDOWN_NOTIFICATION,
857  SEND_SHUTDOWN_RESPONSE,
858  LAST_SEND_KIND, // This one must be last
859  };
860 
861 #define LG_MESSAGE_DESCRIPTIONS(name) \
862  const char *name[LAST_SEND_KIND] = { \
863  "Task Message", \
864  "Steal Message", \
865  "Advertisement Message", \
866  "Send Registration Callback", \
867  "Send Remote Task Replay", \
868  "Send Remote Task Profiling Response", \
869  "Send Shared Ownership", \
870  "Send Index Space Request", \
871  "Send Index Space Return", \
872  "Send Index Space Set", \
873  "Send Index Space Child Request", \
874  "Send Index Space Child Response", \
875  "Send Index Space Colors Request", \
876  "Send Index Space Colors Response", \
877  "Send Index Space Remote Expression Request", \
878  "Send Index Space Remote Expression Response", \
879  "Send Index Space Generate Color Request", \
880  "Send Index Space Generate Color Response", \
881  "Send Index Space Release Color", \
882  "Send Index Partition Notification", \
883  "Send Index Partition Request", \
884  "Send Index Partition Return", \
885  "Send Index Partition Child Request", \
886  "Send Index Partition Child Response", \
887  "Send Index Partition Disjoint Update", \
888  "Send Field Space Node", \
889  "Send Field Space Request", \
890  "Send Field Space Return", \
891  "Send Field Space Allocator Request", \
892  "Send Field Space Allocator Response", \
893  "Send Field Space Allocator Invalidation", \
894  "Send Field Space Allocator Flush", \
895  "Send Field Space Allocator Free", \
896  "Send Field Space Infos Request", \
897  "Send Field Space Infos Response", \
898  "Send Field Alloc Request", \
899  "Send Field Size Update", \
900  "Send Field Free", \
901  "Send Field Free Indexes", \
902  "Send Field Space Layout Invalidation", \
903  "Send Local Field Alloc Request", \
904  "Send Local Field Alloc Response", \
905  "Send Local Field Free", \
906  "Send Local Field Update", \
907  "Send Top Level Region Request", \
908  "Send Top Level Region Return", \
909  "Index Space Destruction", \
910  "Index Partition Destruction", \
911  "Field Space Destruction", \
912  "Logical Region Destruction", \
913  "Individual Remote Complete", \
914  "Individual Remote Commit", \
915  "Slice Remote Mapped", \
916  "Slice Remote Complete", \
917  "Slice Remote Commit", \
918  "Slice Find Intra-Space Dependence", \
919  "Slice Record Intra-Space Dependence", \
920  "Slice Collective Instance Request", \
921  "Slice Collective Instance Response", \
922  "Distributed Remote Registration", \
923  "Distributed Valid Update", \
924  "Distributed GC Update", \
925  "Distributed Resource Update", \
926  "Distributed Create Add", \
927  "Distributed Create Remove", \
928  "Distributed Unregister", \
929  "Send Atomic Reservation Request", \
930  "Send Atomic Reservation Response", \
931  "Send Back Logical State", \
932  "Send Materialized View", \
933  "Send Fill View", \
934  "Send Phi View", \
935  "Send Reduction View", \
936  "Send Instance Manager", \
937  "Send Collective Instance Manager", \
938  "Send Collective Instance Message", \
939  "Send Create Top View Request", \
940  "Send Create Top View Response", \
941  "Send View Request", \
942  "Send View Register User", \
943  "Send View Find Copy Preconditions Request", \
944  "Send View Find Copy Preconditions Response", \
945  "Send View Add Copy User", \
946  "Send View Replication Request", \
947  "Send View Replication Response", \
948  "Send View Replication Removal", \
949  "Send Manager Request", \
950  "Send Future Result", \
951  "Send Future Subscription", \
952  "Send Future Notification", \
953  "Send Future Broadcast", \
954  "Send Future Map Future Request", \
955  "Send Future Map Future Response", \
956  "Send Mapper Message", \
957  "Send Mapper Broadcast", \
958  "Send Task Impl Semantic Req", \
959  "Send Index Space Semantic Req", \
960  "Send Index Partition Semantic Req", \
961  "Send Field Space Semantic Req", \
962  "Send Field Semantic Req", \
963  "Send Logical Region Semantic Req", \
964  "Send Logical Partition Semantic Req", \
965  "Send Task Impl Semantic Info", \
966  "Send Index Space Semantic Info", \
967  "Send Index Partition Semantic Info", \
968  "Send Field Space Semantic Info", \
969  "Send Field Semantic Info", \
970  "Send Logical Region Semantic Info", \
971  "Send Logical Partition Semantic Info", \
972  "Send Remote Context Request", \
973  "Send Remote Context Response", \
974  "Send Remote Context Release", \
975  "Send Remote Context Free", \
976  "Send Remote Context Physical Request", \
977  "Send Remote Context Physical Response", \
978  "Compute Equivalence Sets Request", \
979  "Send Equivalence Set Request", \
980  "Send Equivalence Set Response", \
981  "Send Equivalence Set Subset Request", \
982  "Send Equivalence Set Subset Response", \
983  "Send Equivalence Set Subset Update", \
984  "Send Equivalence Set Ray Trace Request", \
985  "Send Equivalence Set Ray Trace Response", \
986  "Send Equivalence Set Migration", \
987  "Send Equivalence Set Owner Update", \
988  "Send Equivalence Set Remote Refinement", \
989  "Send Equivalence Set Remote Request Instances", \
990  "Send Equivalence Set Remote Request Invalid", \
991  "Send Equivalence Set Remote Updates", \
992  "Send Equivalence Set Remote Acquires", \
993  "Send Equivalence Set Remote Releases", \
994  "Send Equivalence Set Remote Copies Across", \
995  "Send Equivalence Set Remote Overwrites", \
996  "Send Equivalence Set Remote Filters", \
997  "Send Equivalence Set Remote Instances", \
998  "Send Equivalence Set Stale Update", \
999  "Send Instance Request", \
1000  "Send Instance Response", \
1001  "Send External Create Request", \
1002  "Send External Create Response", \
1003  "Send External Attach", \
1004  "Send External Detach", \
1005  "Send GC Priority Update", \
1006  "Send GC Request", \
1007  "Send GC Response", \
1008  "Send GC Acquire Request", \
1009  "Send GC Acquire Response", \
1010  "Send GC Debug Request", \
1011  "Send GC Debug Response", \
1012  "Send Acquire Request", \
1013  "Send Acquire Response", \
1014  "Send Task Variant Broadcast", \
1015  "Send Constraint Request", \
1016  "Send Constraint Response", \
1017  "Send Constraint Release", \
1018  "Top Level Task Request", \
1019  "Top Level Task Complete", \
1020  "Send MPI Rank Exchange", \
1021  "Send Library Mapper Request", \
1022  "Send Library Mapper Response", \
1023  "Send Library Trace Request", \
1024  "Send Library Trace Response", \
1025  "Send Library Projection Request", \
1026  "Send Library Projection Response", \
1027  "Send Library Task Request", \
1028  "Send Library Task Response", \
1029  "Send Library Redop Request", \
1030  "Send Library Redop Response", \
1031  "Send Library Serdez Request", \
1032  "Send Library Serdez Response", \
1033  "Remote Op Report Uninitialized", \
1034  "Remote Op Profiling Count Update", \
1035  "Send Remote Trace Update", \
1036  "Send Remote Trace Response", \
1037  "Send Remote Trace Equivalence Sets Request", \
1038  "Send Remote Trace Equivalence Sets Response", \
1039  "Send Shutdown Notification", \
1040  "Send Shutdown Response", \
1041  };
1042 
1043  // Runtime task numbering
1044  enum {
1045  LG_INITIALIZE_TASK_ID = Realm::Processor::TASK_ID_PROCESSOR_INIT,
1046  LG_SHUTDOWN_TASK_ID = Realm::Processor::TASK_ID_PROCESSOR_SHUTDOWN,
1047  LG_TASK_ID = Realm::Processor::TASK_ID_FIRST_AVAILABLE,
1048 #ifdef LEGION_SEPARATE_META_TASKS
1049  LG_LEGION_PROFILING_ID = LG_TASK_ID+LG_LAST_TASK_ID+LAST_SEND_KIND,
1050  LG_STARTUP_TASK_ID = LG_TASK_ID+LG_LAST_TASK_ID+LAST_SEND_KIND+1,
1051  LG_ENDPOINT_TASK_ID = LG_TASK_ID+LG_LAST_TASK_ID+LAST_SEND_KIND+2,
1052  LG_APP_PROC_TASK_ID = LG_TASK_ID+LG_LAST_TASK_ID+LAST_SEND_KIND+3,
1053  LG_TASK_ID_AVAILABLE = LG_APP_PROC_TASK_ID+LG_LAST_TASK_ID,
1054 #else
1055  LG_LEGION_PROFILING_ID = LG_TASK_ID+1,
1056  LG_STARTUP_TASK_ID = LG_TASK_ID+2,
1057  LG_ENDPOINT_TASK_ID = LG_TASK_ID+3,
1058  LG_APP_PROC_TASK_ID = LG_TASK_ID+4,
1059  LG_TASK_ID_AVAILABLE = LG_TASK_ID+5,
1060 #endif
1061  };
1062 
1063  enum RuntimeCallKind {
1064  PACK_BASE_TASK_CALL,
1065  UNPACK_BASE_TASK_CALL,
1066  TASK_PRIVILEGE_CHECK_CALL,
1067  CLONE_TASK_CALL,
1068  COMPUTE_POINT_REQUIREMENTS_CALL,
1069  EARLY_MAP_REGIONS_CALL,
1070  INTRA_TASK_ALIASING_CALL,
1071  ACTIVATE_SINGLE_CALL,
1072  DEACTIVATE_SINGLE_CALL,
1073  SELECT_INLINE_VARIANT_CALL,
1074  INLINE_CHILD_TASK_CALL,
1075  PACK_SINGLE_TASK_CALL,
1076  UNPACK_SINGLE_TASK_CALL,
1077  PACK_REMOTE_CONTEXT_CALL,
1078  HAS_CONFLICTING_INTERNAL_CALL,
1079  FIND_CONFLICTING_CALL,
1080  FIND_CONFLICTING_INTERNAL_CALL,
1081  CHECK_REGION_DEPENDENCE_CALL,
1082  FIND_PARENT_REGION_REQ_CALL,
1083  FIND_PARENT_REGION_CALL,
1084  CHECK_PRIVILEGE_CALL,
1085  TRIGGER_SINGLE_CALL,
1086  INITIALIZE_MAP_TASK_CALL,
1087  FINALIZE_MAP_TASK_CALL,
1088  VALIDATE_VARIANT_SELECTION_CALL,
1089  MAP_ALL_REGIONS_CALL,
1090  INITIALIZE_REGION_TREE_CONTEXTS_CALL,
1091  INVALIDATE_REGION_TREE_CONTEXTS_CALL,
1092  CREATE_INSTANCE_TOP_VIEW_CALL,
1093  LAUNCH_TASK_CALL,
1094  ACTIVATE_MULTI_CALL,
1095  DEACTIVATE_MULTI_CALL,
1096  SLICE_INDEX_SPACE_CALL,
1097  CLONE_MULTI_CALL,
1098  MULTI_TRIGGER_EXECUTION_CALL,
1099  PACK_MULTI_CALL,
1100  UNPACK_MULTI_CALL,
1101  ACTIVATE_INDIVIDUAL_CALL,
1102  DEACTIVATE_INDIVIDUAL_CALL,
1103  INDIVIDUAL_PERFORM_MAPPING_CALL,
1104  INDIVIDUAL_RETURN_VIRTUAL_CALL,
1105  INDIVIDUAL_TRIGGER_COMPLETE_CALL,
1106  INDIVIDUAL_TRIGGER_COMMIT_CALL,
1107  INDIVIDUAL_POST_MAPPED_CALL,
1108  INDIVIDUAL_PACK_TASK_CALL,
1109  INDIVIDUAL_UNPACK_TASK_CALL,
1110  INDIVIDUAL_PACK_REMOTE_COMPLETE_CALL,
1111  INDIVIDUAL_UNPACK_REMOTE_COMPLETE_CALL,
1112  POINT_ACTIVATE_CALL,
1113  POINT_DEACTIVATE_CALL,
1114  POINT_TASK_COMPLETE_CALL,
1115  POINT_TASK_COMMIT_CALL,
1116  POINT_PACK_TASK_CALL,
1117  POINT_UNPACK_TASK_CALL,
1118  POINT_TASK_POST_MAPPED_CALL,
1119  REMOTE_TASK_ACTIVATE_CALL,
1120  REMOTE_TASK_DEACTIVATE_CALL,
1121  REMOTE_UNPACK_CONTEXT_CALL,
1122  INDEX_ACTIVATE_CALL,
1123  INDEX_DEACTIVATE_CALL,
1124  INDEX_COMPUTE_FAT_PATH_CALL,
1125  INDEX_EARLY_MAP_TASK_CALL,
1126  INDEX_DISTRIBUTE_CALL,
1127  INDEX_PERFORM_MAPPING_CALL,
1128  INDEX_COMPLETE_CALL,
1129  INDEX_COMMIT_CALL,
1130  INDEX_PERFORM_INLINING_CALL,
1131  INDEX_CLONE_AS_SLICE_CALL,
1132  INDEX_HANDLE_FUTURE,
1133  INDEX_RETURN_SLICE_MAPPED_CALL,
1134  INDEX_RETURN_SLICE_COMPLETE_CALL,
1135  INDEX_RETURN_SLICE_COMMIT_CALL,
1136  SLICE_ACTIVATE_CALL,
1137  SLICE_DEACTIVATE_CALL,
1138  SLICE_APPLY_VERSION_INFO_CALL,
1139  SLICE_DISTRIBUTE_CALL,
1140  SLICE_PERFORM_MAPPING_CALL,
1141  SLICE_LAUNCH_CALL,
1142  SLICE_MAP_AND_LAUNCH_CALL,
1143  SLICE_PACK_TASK_CALL,
1144  SLICE_UNPACK_TASK_CALL,
1145  SLICE_CLONE_AS_SLICE_CALL,
1146  SLICE_HANDLE_FUTURE_CALL,
1147  SLICE_CLONE_AS_POINT_CALL,
1148  SLICE_ENUMERATE_POINTS_CALL,
1149  SLICE_MAPPED_CALL,
1150  SLICE_COMPLETE_CALL,
1151  SLICE_COMMIT_CALL,
1152  REALM_SPAWN_META_CALL,
1153  REALM_SPAWN_TASK_CALL,
1154  REALM_CREATE_INSTANCE_CALL,
1155  REALM_ISSUE_COPY_CALL,
1156  REALM_ISSUE_FILL_CALL,
1157  REGION_TREE_LOGICAL_ANALYSIS_CALL,
1158  REGION_TREE_LOGICAL_FENCE_CALL,
1159  REGION_TREE_VERSIONING_ANALYSIS_CALL,
1160  REGION_TREE_ADVANCE_VERSION_NUMBERS_CALL,
1161  REGION_TREE_INITIALIZE_CONTEXT_CALL,
1162  REGION_TREE_INVALIDATE_CONTEXT_CALL,
1163  REGION_TREE_PREMAP_ONLY_CALL,
1164  REGION_TREE_PHYSICAL_REGISTER_ONLY_CALL,
1165  REGION_TREE_PHYSICAL_REGISTER_USERS_CALL,
1166  REGION_TREE_PHYSICAL_PERFORM_CLOSE_CALL,
1167  REGION_TREE_PHYSICAL_CLOSE_CONTEXT_CALL,
1168  REGION_TREE_PHYSICAL_COPY_ACROSS_CALL,
1169  REGION_TREE_PHYSICAL_REDUCE_ACROSS_CALL,
1170  REGION_TREE_PHYSICAL_CONVERT_MAPPING_CALL,
1171  REGION_TREE_PHYSICAL_FILL_FIELDS_CALL,
1172  REGION_TREE_PHYSICAL_ATTACH_EXTERNAL_CALL,
1173  REGION_TREE_PHYSICAL_DETACH_EXTERNAL_CALL,
1174  REGION_NODE_REGISTER_LOGICAL_USER_CALL,
1175  REGION_NODE_CLOSE_LOGICAL_NODE_CALL,
1176  REGION_NODE_SIPHON_LOGICAL_CHILDREN_CALL,
1177  REGION_NODE_SIPHON_LOGICAL_PROJECTION_CALL,
1178  REGION_NODE_PERFORM_LOGICAL_CLOSES_CALL,
1179  REGION_NODE_FIND_VALID_INSTANCE_VIEWS_CALL,
1180  REGION_NODE_FIND_VALID_REDUCTION_VIEWS_CALL,
1181  REGION_NODE_ISSUE_UPDATE_COPIES_CALL,
1182  REGION_NODE_SORT_COPY_INSTANCES_CALL,
1183  REGION_NODE_ISSUE_GROUPED_COPIES_CALL,
1184  REGION_NODE_ISSUE_UPDATE_REDUCTIONS_CALL,
1185  REGION_NODE_PREMAP_REGION_CALL,
1186  REGION_NODE_REGISTER_REGION_CALL,
1187  REGION_NODE_CLOSE_STATE_CALL,
1188  CURRENT_STATE_RECORD_VERSION_NUMBERS_CALL,
1189  CURRENT_STATE_ADVANCE_VERSION_NUMBERS_CALL,
1190  PHYSICAL_STATE_CAPTURE_STATE_CALL,
1191  PHYSICAL_STATE_APPLY_PATH_ONLY_CALL,
1192  PHYSICAL_STATE_APPLY_STATE_CALL,
1193  PHYSICAL_STATE_MAKE_LOCAL_CALL,
1194  MATERIALIZED_VIEW_FIND_LOCAL_PRECONDITIONS_CALL,
1195  MATERIALIZED_VIEW_FIND_LOCAL_COPY_PRECONDITIONS_CALL,
1196  MATERIALIZED_VIEW_FILTER_PREVIOUS_USERS_CALL,
1197  MATERIALIZED_VIEW_FILTER_CURRENT_USERS_CALL,
1198  MATERIALIZED_VIEW_FILTER_LOCAL_USERS_CALL,
1199  REDUCTION_VIEW_PERFORM_REDUCTION_CALL,
1200  REDUCTION_VIEW_PERFORM_DEFERRED_REDUCTION_CALL,
1201  REDUCTION_VIEW_PERFORM_DEFERRED_REDUCTION_ACROSS_CALL,
1202  REDUCTION_VIEW_FIND_COPY_PRECONDITIONS_CALL,
1203  REDUCTION_VIEW_FIND_USER_PRECONDITIONS_CALL,
1204  REDUCTION_VIEW_FILTER_LOCAL_USERS_CALL,
1205  PHYSICAL_TRACE_EXECUTE_CALL,
1206  PHYSICAL_TRACE_PRECONDITION_CHECK_CALL,
1207  PHYSICAL_TRACE_OPTIMIZE_CALL,
1208  LAST_RUNTIME_CALL_KIND, // This one must be last
1209  };
1210 
1211 #define RUNTIME_CALL_DESCRIPTIONS(name) \
1212  const char *name[LAST_RUNTIME_CALL_KIND] = { \
1213  "Pack Base Task", \
1214  "Unpack Base Task", \
1215  "Task Privilege Check", \
1216  "Clone Base Task", \
1217  "Compute Point Requirements", \
1218  "Early Map Regions", \
1219  "Intra-Task Aliasing", \
1220  "Activate Single", \
1221  "Deactivate Single", \
1222  "Select Inline Variant", \
1223  "Inline Child Task", \
1224  "Pack Single Task", \
1225  "Unpack Single Task", \
1226  "Pack Remote Context", \
1227  "Has Conflicting Internal", \
1228  "Find Conflicting", \
1229  "Find Conflicting Internal", \
1230  "Check Region Dependence", \
1231  "Find Parent Region Requirement", \
1232  "Find Parent Region", \
1233  "Check Privilege", \
1234  "Trigger Single", \
1235  "Initialize Map Task", \
1236  "Finalized Map Task", \
1237  "Validate Variant Selection", \
1238  "Map All Regions", \
1239  "Initialize Region Tree Contexts", \
1240  "Invalidate Region Tree Contexts", \
1241  "Create Instance Top View", \
1242  "Launch Task", \
1243  "Activate Multi", \
1244  "Deactivate Multi", \
1245  "Slice Index Space", \
1246  "Clone Multi Call", \
1247  "Multi Trigger Execution", \
1248  "Pack Multi", \
1249  "Unpack Multi", \
1250  "Activate Individual", \
1251  "Deactivate Individual", \
1252  "Individual Perform Mapping", \
1253  "Individual Return Virtual", \
1254  "Individual Trigger Complete", \
1255  "Individual Trigger Commit", \
1256  "Individual Post Mapped", \
1257  "Individual Pack Task", \
1258  "Individual Unpack Task", \
1259  "Individual Pack Remote Complete", \
1260  "Individual Unpack Remote Complete", \
1261  "Activate Point", \
1262  "Deactivate Point", \
1263  "Point Task Complete", \
1264  "Point Task Commit", \
1265  "Point Task Pack", \
1266  "Point Task Unpack", \
1267  "Point Task Post Mapped", \
1268  "Remote Task Activate", \
1269  "Remote Task Deactivate", \
1270  "Remote Unpack Context", \
1271  "Index Activate", \
1272  "Index Deactivate", \
1273  "Index Compute Fat Path", \
1274  "Index Early Map Task", \
1275  "Index Distribute", \
1276  "Index Perform Mapping", \
1277  "Index Complete", \
1278  "Index Commit", \
1279  "Index Perform Inlining", \
1280  "Index Clone As Slice", \
1281  "Index Handle Future", \
1282  "Index Return Slice Mapped", \
1283  "Index Return Slice Complete", \
1284  "Index Return Slice Commit", \
1285  "Slice Activate", \
1286  "Slice Deactivate", \
1287  "Slice Apply Version Info", \
1288  "Slice Distribute", \
1289  "Slice Perform Mapping", \
1290  "Slice Launch", \
1291  "Slice Map and Launch", \
1292  "Slice Pack Task", \
1293  "Slice Unpack Task", \
1294  "Slice Clone As Slice", \
1295  "Slice Handle Future", \
1296  "Slice Cone as Point", \
1297  "Slice Enumerate Points", \
1298  "Slice Mapped", \
1299  "Slice Complete", \
1300  "Slice Commit", \
1301  "Realm Spawn Meta", \
1302  "Realm Spawn Task", \
1303  "Realm Create Instance", \
1304  "Realm Issue Copy", \
1305  "Realm Issue Fill", \
1306  "Region Tree Logical Analysis", \
1307  "Region Tree Logical Fence", \
1308  "Region Tree Versioning Analysis", \
1309  "Region Tree Advance Version Numbers", \
1310  "Region Tree Initialize Context", \
1311  "Region Tree Invalidate Context", \
1312  "Region Tree Premap Only", \
1313  "Region Tree Physical Register Only", \
1314  "Region Tree Physical Register Users", \
1315  "Region Tree Physical Perform Close", \
1316  "Region Tree Physical Close Context", \
1317  "Region Tree Physical Copy Across", \
1318  "Region Tree Physical Reduce Across", \
1319  "Region Tree Physical Convert Mapping", \
1320  "Region Tree Physical Fill Fields", \
1321  "Region Tree Physical Attach External", \
1322  "Region Tree Physical Detach External", \
1323  "Region Node Register Logical User", \
1324  "Region Node Close Logical Node", \
1325  "Region Node Siphon Logical Children", \
1326  "Region Node Siphon Logical Projection", \
1327  "Region Node Perform Logical Closes", \
1328  "Region Node Find Valid Instance Views", \
1329  "Region Node Find Valid Reduction Views", \
1330  "Region Node Issue Update Copies", \
1331  "Region Node Sort Copy Instances", \
1332  "Region Node Issue Grouped Copies", \
1333  "Region Node Issue Update Reductions", \
1334  "Region Node Premap Region", \
1335  "Region Node Register Region", \
1336  "Region Node Close State", \
1337  "Logical State Record Verison Numbers", \
1338  "Logical State Advance Version Numbers", \
1339  "Physical State Capture State", \
1340  "Physical State Apply Path Only", \
1341  "Physical State Apply State", \
1342  "Physical State Make Local", \
1343  "Materialized View Find Local Preconditions", \
1344  "Materialized View Find Local Copy Preconditions", \
1345  "Materialized View Filter Previous Users", \
1346  "Materialized View Filter Current Users", \
1347  "Materialized View Filter Local Users", \
1348  "Reduction View Perform Reduction", \
1349  "Reduction View Perform Deferred Reduction", \
1350  "Reduction View Perform Deferred Reduction Across", \
1351  "Reduction View Find Copy Preconditions", \
1352  "Reduction View Find User Preconditions", \
1353  "Reduction View Filter Local Users", \
1354  "Physical Trace Execute", \
1355  "Physical Trace Precondition Check", \
1356  "Physical Trace Optimize", \
1357  };
1358 
1359  enum SemanticInfoKind {
1360  INDEX_SPACE_SEMANTIC,
1361  INDEX_PARTITION_SEMANTIC,
1362  FIELD_SPACE_SEMANTIC,
1363  FIELD_SEMANTIC,
1364  LOGICAL_REGION_SEMANTIC,
1365  LOGICAL_PARTITION_SEMANTIC,
1366  TASK_SEMANTIC,
1367  };
1368 
1369  // legion_types.h
1370  class LocalLock;
1371  class AutoLock;
1372  class AutoTryLock;
1373  class LgEvent; // base event type for legion
1374  class ApEvent; // application event
1375  class ApUserEvent; // application user event
1376  class ApBarrier; // application barrier
1377  class RtEvent; // runtime event
1378  class RtUserEvent; // runtime user event
1379  class RtBarrier;
1380 
1381  // legion_utilities.h
1382  struct RegionUsage;
1383  template<typename T> class Fraction;
1384  template<typename T, unsigned LOG2MAX> class BitPermutation;
1385 
1386  // Forward declarations for runtime level objects
1387  // runtime.h
1388  class Collectable;
1389  class FieldAllocatorImpl;
1390  class ArgumentMapImpl;
1391  class FutureImpl;
1392  class FutureMapImpl;
1393  class PhysicalRegionImpl;
1394  class ExternalResourcesImpl;
1395  class PieceIteratorImpl;
1396  class GrantImpl;
1397  class PredicateImpl;
1398  class LegionHandshakeImpl;
1399  class ProcessorManager;
1400  class MemoryManager;
1401  class VirtualChannel;
1402  class MessageManager;
1403  class ShutdownManager;
1404  class TaskImpl;
1405  class VariantImpl;
1406  class LayoutConstraints;
1407  class ProjectionFunction;
1408  class Runtime;
1409  // A small interface class for handling profiling responses
1410  struct ProfilingResponseBase;
1412  public:
1413  virtual void handle_profiling_response(
1414  const ProfilingResponseBase *base,
1415  const Realm::ProfilingResponse &response,
1416  const void *orig, size_t orig_length) = 0;
1417  };
1419  public:
1421  : handler(h) { }
1422  public:
1423  ProfilingResponseHandler *const handler;
1424  };
1425 
1426  // legion_ops.h
1427  class Provenance;
1428  class Operation;
1429  class SpeculativeOp;
1430  class Memoizable;
1431  class MapOp;
1432  class CopyOp;
1433  class IndexCopyOp;
1434  class PointCopyOp;
1435  class FenceOp;
1436  class FrameOp;
1437  class CreationOp;
1438  class DeletionOp;
1439  class InternalOp;
1440  class CloseOp;
1441  class MergeCloseOp;
1442  class PostCloseOp;
1443  class VirtualCloseOp;
1444  class AcquireOp;
1445  class ReleaseOp;
1446  class DynamicCollectiveOp;
1447  class FuturePredOp;
1448  class NotPredOp;
1449  class AndPredOp;
1450  class OrPredOp;
1451  class MustEpochOp;
1452  class PendingPartitionOp;
1453  class DependentPartitionOp;
1454  class PointDepPartOp;
1455  class FillOp;
1456  class IndexFillOp;
1457  class PointFillOp;
1458  class AttachOp;
1459  class IndexAttachOp;
1460  class PointAttachOp;
1461  class DetachOp;
1462  class IndexDetachOp;
1463  class PointDetachOp;
1464  class TimingOp;
1465  class TunableOp;
1466  class AllReduceOp;
1467  class ExternalMappable;
1468  class RemoteOp;
1469  class RemoteMapOp;
1470  class RemoteCopyOp;
1471  class RemoteCloseOp;
1472  class RemoteAcquireOp;
1473  class RemoteReleaseOp;
1474  class RemoteFillOp;
1475  class RemotePartitionOp;
1476  class RemoteReplayOp;
1477  class RemoteSummaryOp;
1478 
1479  // legion_tasks.h
1480  class ExternalTask;
1481  class TaskOp;
1482  class RemoteTaskOp;
1483  class SingleTask;
1484  class MultiTask;
1485  class IndividualTask;
1486  class PointTask;
1487  class IndexTask;
1488  class SliceTask;
1489  class RemoteTask;
1490 
1491  // legion_context.h
1492  class TaskContext;
1493  class InnerContext;;
1494  class TopLevelContext;
1495  class RemoteContext;
1496  class LeafContext;
1497 
1498  // legion_trace.h
1499  class LegionTrace;
1500  class StaticTrace;
1501  class DynamicTrace;
1502  class TraceCaptureOp;
1503  class TraceCompleteOp;
1504  class TraceReplayOp;
1505  class TraceBeginOp;
1506  class TraceSummaryOp;
1507  class PhysicalTrace;
1508  class TraceViewSet;
1509  class TraceConditionSet;
1510  class PhysicalTemplate;
1511  class Instruction;
1512  class GetTermEvent;
1513  class CreateApUserEvent;
1514  class TriggerEvent;
1515  class MergeEvent;
1516  class AssignFenceCompletion;
1517  class IssueCopy;
1518  class IssueFill;
1519  class IssueAcross;
1520  class GetOpTermEvent;
1521  class SetOpSyncEvent;
1522  class SetEffects;
1523  class CompleteReplay;
1524  class AcquireReplay;
1525  class ReleaseReplay;
1526 
1527  // region_tree.h
1528  class RegionTreeForest;
1529  class CopyAcrossExecutor;
1530  class CopyAcrossUnstructured;
1531  class IndexSpaceExpression;
1532  class IndexSpaceExprRef;
1533  class IndexSpaceOperation;
1534  template<int DIM, typename T> class IndexSpaceOperationT;
1535  template<int DIM, typename T> class IndexSpaceUnion;
1536  template<int DIM, typename T> class IndexSpaceIntersection;
1537  template<int DIM, typename T> class IndexSpaceDifference;
1538  class ExpressionTrieNode;
1539  class IndexTreeNode;
1540  class IndexSpaceNode;
1541  template<int DIM, typename T> class IndexSpaceNodeT;
1542  class IndexPartNode;
1543  template<int DIM, typename T> class IndexPartNodeT;
1544  class FieldSpaceNode;
1545  class RegionTreeNode;
1546  class RegionNode;
1547  class PartitionNode;
1548  class ColorSpaceIterator;
1549  template<int DIM, typename T> class ColorSpaceIteratorT;
1550 
1551  class RegionTreeContext;
1552  class RegionTreePath;
1553  class PathTraverser;
1554  class NodeTraverser;
1555 
1556  class ProjectionEpoch;
1557  class LogicalState;
1558  class EquivalenceSet;
1559  class VersionManager;
1560  class VersionInfo;
1561  class RayTracer;
1562 
1563  class Collectable;
1564  class Notifiable;
1565  class ReferenceMutator;
1566  class LocalReferenceMutator;
1567  class ImplicitReferenceTracker;
1568  class DistributedCollectable;
1569  class LayoutDescription;
1570  class InstanceManager; // base class for all instances
1571  class CopyAcrossHelper;
1572  class LogicalView; // base class for instance and reduction
1573  class InstanceKey;
1574  class InstanceView;
1575  class CollectableView; // pure virtual class
1576  class DeferredView;
1577  class MaterializedView;
1578  class FillView;
1579  class PhiView;
1580  class MappingRef;
1581  class InstanceRef;
1582  class InstanceSet;
1583  class InnerTaskView;
1584  class VirtualManager;
1585  class PhysicalManager;
1586  class IndividualManager;
1587  class CollectiveManager;
1588  class ReductionView;
1589  class InstanceBuilder;
1590 
1591  class RegionAnalyzer;
1592  class RegionMapper;
1593 
1594  struct GenericUser;
1595  struct LogicalUser;
1596  struct PhysicalUser;
1597  struct LogicalTraceInfo;
1598  struct PhysicalTraceInfo;
1599  class LogicalCloser;
1600  class TreeCloseImpl;
1601  class TreeClose;
1602  struct CloseInfo;
1603  struct FieldDataDescriptor;
1604  struct PendingRemoteExpression;
1605 
1606  // legion_spy.h
1607  class TreeStateLogger;
1608 
1609  // legion_profiling.h
1610  class LegionProfiler;
1611  class LegionProfInstance;
1612 
1613  // mapper_manager.h
1614  class MappingCallInfo;
1615  class MapperManager;
1616  class SerializingManager;
1617  class ConcurrentManager;
1618  typedef Mapping::MapperEvent MapperEvent;
1619  typedef Mapping::ProfilingMeasurementID ProfilingMeasurementID;
1620 
1621  // Nasty global variable for TLS support of figuring out
1622  // our context implicitly
1623  extern __thread TaskContext *implicit_context;
1624  // Same thing for the runtime
1625  extern __thread Runtime *implicit_runtime;
1626  // Another nasty global variable for tracking the fast
1627  // reservations that we are holding
1628  extern __thread AutoLock *local_lock_list;
1629  // One more nasty global variable that we use for tracking
1630  // the provenance of meta-task operations for profiling
1631  // purposes, this has no bearing on correctness
1632  extern __thread ::legion_unique_id_t implicit_provenance;
1633  // Use this to track if we're inside of a registration
1634  // callback function which we know to be deduplicated
1635  enum RegistrationCallbackMode {
1636  NO_REGISTRATION_CALLBACK = 0,
1637  LOCAL_REGISTRATION_CALLBACK = 1,
1638  GLOBAL_REGISTRATION_CALLBACK = 2,
1639  };
1640  extern __thread unsigned inside_registration_callback;
1641  // This data structure tracks references to any live
1642  // temporary index space expressions that have been
1643  // handed back by the region tree inside the execution
1644  // of a meta-task or a runtime API call. It also tracks
1645  // changes to remote distributed collectable that can be
1646  // delayed and batched together.
1647  extern __thread ImplicitReferenceTracker *implicit_reference_tracker;
1648 
1653  template<typename T>
1654  struct LgTaskArgs {
1655  public:
1656  LgTaskArgs(::legion_unique_id_t uid)
1657  : provenance(uid), lg_task_id(T::TASK_ID) { }
1658  public:
1659  // In this order for alignment reasons
1660  const ::legion_unique_id_t provenance;
1661  const LgTaskID lg_task_id;
1662  };
1663 
1664 #define FRIEND_ALL_RUNTIME_CLASSES \
1665  friend class Legion::Runtime; \
1666  friend class Internal::Runtime; \
1667  friend class Internal::PhysicalRegionImpl; \
1668  friend class Internal::ExternalResourcesImpl; \
1669  friend class Internal::TaskImpl; \
1670  friend class Internal::ProcessorManager; \
1671  friend class Internal::MemoryManager; \
1672  friend class Internal::Operation; \
1673  friend class Internal::SpeculativeOp; \
1674  friend class Internal::MapOp; \
1675  friend class Internal::CopyOp; \
1676  friend class Internal::IndexCopyOp; \
1677  friend class Internal::PointCopyOp; \
1678  friend class Internal::FenceOp; \
1679  friend class Internal::DynamicCollectiveOp; \
1680  friend class Internal::FuturePredOp; \
1681  friend class Internal::CreationOp; \
1682  friend class Internal::DeletionOp; \
1683  friend class Internal::CloseOp; \
1684  friend class Internal::MergeCloseOp; \
1685  friend class Internal::PostCloseOp; \
1686  friend class Internal::VirtualCloseOp; \
1687  friend class Internal::AcquireOp; \
1688  friend class Internal::ReleaseOp; \
1689  friend class Internal::PredicateImpl; \
1690  friend class Internal::NotPredOp; \
1691  friend class Internal::AndPredOp; \
1692  friend class Internal::OrPredOp; \
1693  friend class Internal::MustEpochOp; \
1694  friend class Internal::PendingPartitionOp; \
1695  friend class Internal::DependentPartitionOp; \
1696  friend class Internal::PointDepPartOp; \
1697  friend class Internal::FillOp; \
1698  friend class Internal::IndexFillOp; \
1699  friend class Internal::PointFillOp; \
1700  friend class Internal::AttachOp; \
1701  friend class Internal::IndexAttachOp; \
1702  friend class Internal::PointAttachOp; \
1703  friend class Internal::DetachOp; \
1704  friend class Internal::IndexDetachOp; \
1705  friend class Internal::PointDetachOp; \
1706  friend class Internal::TimingOp; \
1707  friend class Internal::TunableOp; \
1708  friend class Internal::AllReduceOp; \
1709  friend class Internal::TraceSummaryOp; \
1710  friend class Internal::ExternalMappable; \
1711  friend class Internal::ExternalTask; \
1712  friend class Internal::TaskOp; \
1713  friend class Internal::SingleTask; \
1714  friend class Internal::MultiTask; \
1715  friend class Internal::IndividualTask; \
1716  friend class Internal::PointTask; \
1717  friend class Internal::IndexTask; \
1718  friend class Internal::SliceTask; \
1719  friend class Internal::RegionTreeForest; \
1720  friend class Internal::IndexSpaceNode; \
1721  friend class Internal::IndexPartNode; \
1722  friend class Internal::FieldSpaceNode; \
1723  friend class Internal::RegionTreeNode; \
1724  friend class Internal::RegionNode; \
1725  friend class Internal::PartitionNode; \
1726  friend class Internal::LogicalView; \
1727  friend class Internal::InstanceView; \
1728  friend class Internal::DeferredView; \
1729  friend class Internal::ReductionView; \
1730  friend class Internal::MaterializedView; \
1731  friend class Internal::FillView; \
1732  friend class Internal::LayoutDescription; \
1733  friend class Internal::InstanceManager; \
1734  friend class Internal::IndividualManager; \
1735  friend class Internal::CollectiveManager; \
1736  friend class Internal::TreeStateLogger; \
1737  friend class Internal::MapperManager; \
1738  friend class Internal::InstanceRef; \
1739  friend class Internal::LegionHandshakeImpl; \
1740  friend class Internal::ArgumentMapImpl; \
1741  friend class Internal::FutureMapImpl; \
1742  friend class Internal::TaskContext; \
1743  friend class Internal::InnerContext; \
1744  friend class Internal::TopLevelContext; \
1745  friend class Internal::RemoteContext; \
1746  friend class Internal::LeafContext; \
1747  friend class Internal::InstanceBuilder; \
1748  friend class BindingLib::Utility; \
1749  friend class CObjectWrapper;
1750 
1751 #define LEGION_EXTERN_LOGGER_DECLARATIONS \
1752  extern Realm::Logger log_run; \
1753  extern Realm::Logger log_task; \
1754  extern Realm::Logger log_index; \
1755  extern Realm::Logger log_field; \
1756  extern Realm::Logger log_region; \
1757  extern Realm::Logger log_inst; \
1758  extern Realm::Logger log_variant; \
1759  extern Realm::Logger log_allocation; \
1760  extern Realm::Logger log_migration; \
1761  extern Realm::Logger log_prof; \
1762  extern Realm::Logger log_garbage; \
1763  extern Realm::Logger log_spy; \
1764  extern Realm::Logger log_shutdown; \
1765  extern Realm::Logger log_tracing;
1766 
1767  }; // Internal namespace
1768 
1769  // Typedefs that are needed everywhere
1770  typedef Realm::Runtime RealmRuntime;
1771  typedef Realm::Machine Machine;
1772  typedef Realm::Memory Memory;
1773  typedef Realm::Processor Processor;
1774  typedef Realm::ProcessorGroup ProcessorGroup;
1775  typedef Realm::CodeDescriptor CodeDescriptor;
1776  typedef Realm::Reservation Reservation;
1777  typedef Realm::CompletionQueue CompletionQueue;
1778  typedef ::legion_reduction_op_id_t ReductionOpID;
1779  typedef Realm::ReductionOpUntyped ReductionOp;
1780  typedef ::legion_custom_serdez_id_t CustomSerdezID;
1781  typedef Realm::CustomSerdezUntyped SerdezOp;
1782  typedef Realm::Machine::ProcessorMemoryAffinity ProcessorMemoryAffinity;
1783  typedef Realm::Machine::MemoryMemoryAffinity MemoryMemoryAffinity;
1784  typedef Realm::DynamicTemplates::TagType TypeTag;
1785  typedef Realm::Logger Logger;
1786  typedef ::legion_coord_t coord_t;
1787  typedef std::map<CustomSerdezID,
1788  const Realm::CustomSerdezUntyped *> SerdezOpTable;
1789  typedef std::map<Realm::ReductionOpID,
1790  const Realm::ReductionOpUntyped *> ReductionOpTable;
1791  typedef void (*SerdezInitFnptr)(const ReductionOp*, void *&, size_t&);
1792  typedef void (*SerdezFoldFnptr)(const ReductionOp*, void *&,
1793  size_t&, const void*);
1794  typedef std::map<Realm::ReductionOpID, SerdezRedopFns> SerdezRedopTable;
1795  typedef ::legion_projection_type_t HandleType;
1796  typedef ::legion_address_space_t AddressSpace;
1797  typedef ::legion_task_priority_t TaskPriority;
1798  typedef ::legion_task_priority_t RealmPriority;
1799  typedef ::legion_garbage_collection_priority_t GCPriority;
1800  typedef ::legion_color_t Color;
1801  typedef ::legion_field_id_t FieldID;
1802  typedef ::legion_trace_id_t TraceID;
1803  typedef ::legion_mapper_id_t MapperID;
1804  typedef ::legion_context_id_t ContextID;
1805  typedef ::legion_instance_id_t InstanceID;
1806  typedef ::legion_index_space_id_t IndexSpaceID;
1807  typedef ::legion_index_partition_id_t IndexPartitionID;
1808  typedef ::legion_index_tree_id_t IndexTreeID;
1809  typedef ::legion_field_space_id_t FieldSpaceID;
1810  typedef ::legion_generation_id_t GenerationID;
1811  typedef ::legion_type_handle TypeHandle;
1812  typedef ::legion_projection_id_t ProjectionID;
1813  typedef ::legion_sharding_id_t ShardingID;
1814  typedef ::legion_region_tree_id_t RegionTreeID;
1815  typedef ::legion_distributed_id_t DistributedID;
1816  typedef ::legion_address_space_t AddressSpaceID;
1817  typedef ::legion_tunable_id_t TunableID;
1818  typedef ::legion_local_variable_id_t LocalVariableID;
1819  typedef ::legion_mapping_tag_id_t MappingTagID;
1820  typedef ::legion_semantic_tag_t SemanticTag;
1821  typedef ::legion_variant_id_t VariantID;
1822  typedef ::legion_code_descriptor_id_t CodeDescriptorID;
1823  typedef ::legion_unique_id_t UniqueID;
1824  typedef ::legion_version_id_t VersionID;
1825  typedef ::legion_projection_epoch_id_t ProjectionEpochID;
1826  typedef ::legion_task_id_t TaskID;
1827  typedef ::legion_layout_constraint_id_t LayoutConstraintID;
1828  typedef ::legion_replication_id_t ReplicationID;
1829  typedef ::legion_shard_id_t ShardID;
1830  typedef ::legion_internal_color_t LegionColor;
1831  typedef void (*RegistrationCallbackFnptr)(Machine machine,
1832  Runtime *rt, const std::set<Processor> &local_procs);
1833  typedef void (*RegistrationWithArgsCallbackFnptr)(
1834  const RegistrationCallbackArgs &args);
1835  typedef LogicalRegion (*RegionProjectionFnptr)(LogicalRegion parent,
1836  const DomainPoint&, Runtime *rt);
1837  typedef LogicalRegion (*PartitionProjectionFnptr)(LogicalPartition parent,
1838  const DomainPoint&, Runtime *rt);
1839  typedef bool (*PredicateFnptr)(const void*, size_t,
1840  const std::vector<Future> futures);
1841  typedef void (*RealmFnptr)(const void*,size_t,
1842  const void*,size_t,Processor);
1843  // Magical typedefs
1844  // (don't forget to update ones in old HighLevel namespace in legion.inl)
1845  typedef Internal::TaskContext* Context;
1846  // Anothing magical typedef
1847  namespace Mapping {
1848  typedef Internal::MappingCallInfo* MapperContext;
1849  typedef Internal::InstanceManager* PhysicalInstanceImpl;
1850  };
1851 
1852  namespace Internal {
1853  // The invalid color
1854  const LegionColor INVALID_COLOR = LLONG_MAX;
1855  // This is only needed internally
1856  typedef Realm::RegionInstance PhysicalInstance;
1857  typedef Realm::CopySrcDstField CopySrcDstField;
1858  typedef unsigned long long IndexSpaceExprID;
1859  typedef std::pair<unsigned, DomainPoint> TraceLocalID;
1860  // Helper for encoding templates
1862  public Realm::DynamicTemplates::ListProduct2<Realm::DIMCOUNTS,
1863  Realm::DIMTYPES> {
1864  typedef Realm::DynamicTemplates::ListProduct2<Realm::DIMCOUNTS,
1865  Realm::DIMTYPES> SUPER;
1866  public:
1867  template<int N, typename T> __CUDA_HD__
1868  static inline constexpr TypeTag encode_tag(void) {
1869 #if __cplusplus >= 201402L
1870  constexpr TypeTag type =
1871  SUPER::template encode_tag<Realm::DynamicTemplates::Int<N>, T>();
1872  static_assert(type != 0, "All types should be non-zero for Legion");
1873  return type;
1874 #else
1875  return SUPER::template encode_tag<Realm::DynamicTemplates::Int<N>, T>();
1876 #endif
1877  }
1878  template<int N, typename T>
1879  static inline void check_type(const TypeTag t) {
1880 #ifdef DEBUG_LEGION
1881 #ifndef NDEBUG
1882  const TypeTag t1 = encode_tag<N,T>();
1883 #endif
1884  assert(t1 == t);
1885 #endif
1886  }
1887  struct DimHelper {
1888  public:
1889  template<typename N, typename T>
1890  static inline void demux(int *result) { *result = N::N; }
1891  };
1892  static inline int get_dim(const TypeTag t) {
1893  int result = 0;
1894  SUPER::demux<DimHelper>(t, &result);
1895  return result;
1896  }
1897  };
1898  // Pull some of the mapper types into the internal space
1899  typedef Mapping::Mapper Mapper;
1900  typedef Mapping::PhysicalInstance MappingInstance;
1901  // A little bit of logic here to figure out the
1902  // kind of bit mask to use for FieldMask
1903 
1904 // The folowing macros are used in the FieldMask instantiation of BitMask
1905 // If you change one you probably have to change the others too
1906 #define LEGION_FIELD_MASK_FIELD_TYPE uint64_t
1907 #define LEGION_FIELD_MASK_FIELD_SHIFT 6
1908 #define LEGION_FIELD_MASK_FIELD_MASK 0x3F
1909 #define LEGION_FIELD_MASK_FIELD_ALL_ONES 0xFFFFFFFFFFFFFFFF
1910 
1911 #if defined(__AVX__)
1912 #if (LEGION_MAX_FIELDS > 256)
1913  typedef AVXTLBitMask<LEGION_MAX_FIELDS> FieldMask;
1914 #elif (LEGION_MAX_FIELDS > 128)
1915  typedef AVXBitMask<LEGION_MAX_FIELDS> FieldMask;
1916 #elif (LEGION_MAX_FIELDS > 64)
1917  typedef SSEBitMask<LEGION_MAX_FIELDS> FieldMask;
1918 #else
1919  typedef BitMask<LEGION_FIELD_MASK_FIELD_TYPE,LEGION_MAX_FIELDS,
1920  LEGION_FIELD_MASK_FIELD_SHIFT,
1921  LEGION_FIELD_MASK_FIELD_MASK> FieldMask;
1922 #endif
1923 #elif defined(__SSE2__)
1924 #if (LEGION_MAX_FIELDS > 128)
1925  typedef SSETLBitMask<LEGION_MAX_FIELDS> FieldMask;
1926 #elif (LEGION_MAX_FIELDS > 64)
1927  typedef SSEBitMask<LEGION_MAX_FIELDS> FieldMask;
1928 #else
1929  typedef BitMask<LEGION_FIELD_MASK_FIELD_TYPE,LEGION_MAX_FIELDS,
1930  LEGION_FIELD_MASK_FIELD_SHIFT,
1931  LEGION_FIELD_MASK_FIELD_MASK> FieldMask;
1932 #endif
1933 #elif defined(__ALTIVEC__)
1934 #if (LEGION_MAX_FIELDS > 128)
1935  typedef PPCTLBitMask<LEGION_MAX_FIELDS> FieldMask;
1936 #elif (LEGION_MAX_FIELDS > 64)
1937  typedef PPCBitMask<LEGION_MAX_FIELDS> FieldMask;
1938 #else
1939  typedef BitMask<LEGION_FIELD_MASK_FIELD_TYPE,LEGION_MAX_FIELDS,
1940  LEGION_FIELD_MASK_FIELD_SHIFT,
1941  LEGION_FIELD_MASK_FIELD_MASK> FieldMask;
1942 #endif
1943 #elif defined(__ARM_NEON)
1944 #if (LEGION_MAX_FIELDS > 128)
1945  typedef NeonTLBitMask<LEGION_MAX_FIELDS> FieldMask;
1946 #elif (LEGION_MAX_FIELDS > 64)
1947  typedef NeonBitMask<LEGION_MAX_FIELDS> FieldMask;
1948 #else
1949  typedef BitMask<LEGION_FIELD_MASK_FIELD_TYPE,LEGION_MAX_FIELDS,
1950  LEGION_FIELD_MASK_FIELD_SHIFT,
1951  LEGION_FIELD_MASK_FIELD_MASK> FieldMask;
1952 #endif
1953 #else
1954 #if (LEGION_MAX_FIELDS > 64)
1955  typedef TLBitMask<LEGION_FIELD_MASK_FIELD_TYPE,LEGION_MAX_FIELDS,
1956  LEGION_FIELD_MASK_FIELD_SHIFT,
1957  LEGION_FIELD_MASK_FIELD_MASK> FieldMask;
1958 #else
1959  typedef BitMask<LEGION_FIELD_MASK_FIELD_TYPE,LEGION_MAX_FIELDS,
1960  LEGION_FIELD_MASK_FIELD_SHIFT,
1961  LEGION_FIELD_MASK_FIELD_MASK> FieldMask;
1962 #endif
1963 #endif
1964  typedef BitPermutation<FieldMask,LEGION_FIELD_LOG2> FieldPermutation;
1965  typedef Fraction<unsigned long> InstFrac;
1966 #undef LEGION_FIELD_MASK_FIELD_SHIFT
1967 #undef LEGION_FIELD_MASK_FIELD_MASK
1968 
1969  // Similar logic as field masks for node masks
1970 
1971 // The following macros are used in the NodeMask instantiation of BitMask
1972 // If you change one you probably have to change the others too
1973 #define LEGION_NODE_MASK_NODE_TYPE uint64_t
1974 #define LEGION_NODE_MASK_NODE_SHIFT 6
1975 #define LEGION_NODE_MASK_NODE_MASK 0x3F
1976 #define LEGION_NODE_MASK_NODE_ALL_ONES 0xFFFFFFFFFFFFFFFF
1977 
1978 #if defined(__AVX__)
1979 #if (LEGION_MAX_NUM_NODES > 256)
1980  typedef AVXTLBitMask<LEGION_MAX_NUM_NODES> NodeMask;
1981 #elif (LEGION_MAX_NUM_NODES > 128)
1982  typedef AVXBitMask<LEGION_MAX_NUM_NODES> NodeMask;
1983 #elif (LEGION_MAX_NUM_NODES > 64)
1984  typedef SSEBitMask<LEGION_MAX_NUM_NODES> NodeMask;
1985 #else
1986  typedef BitMask<LEGION_NODE_MASK_NODE_TYPE,LEGION_MAX_NUM_NODES,
1987  LEGION_NODE_MASK_NODE_SHIFT,
1988  LEGION_NODE_MASK_NODE_MASK> NodeMask;
1989 #endif
1990 #elif defined(__SSE2__)
1991 #if (LEGION_MAX_NUM_NODES > 128)
1992  typedef SSETLBitMask<LEGION_MAX_NUM_NODES> NodeMask;
1993 #elif (LEGION_MAX_NUM_NODES > 64)
1994  typedef SSEBitMask<LEGION_MAX_NUM_NODES> NodeMask;
1995 #else
1996  typedef BitMask<LEGION_NODE_MASK_NODE_TYPE,LEGION_MAX_NUM_NODES,
1997  LEGION_NODE_MASK_NODE_SHIFT,
1998  LEGION_NODE_MASK_NODE_MASK> NodeMask;
1999 #endif
2000 #elif defined(__ALTIVEC__)
2001 #if (LEGION_MAX_NUM_NODES > 128)
2002  typedef PPCTLBitMask<LEGION_MAX_NUM_NODES> NodeMask;
2003 #elif (LEGION_MAX_NUM_NODES > 64)
2004  typedef PPCBitMask<LEGION_MAX_NUM_NODES> NodeMask;
2005 #else
2006  typedef BitMask<LEGION_NODE_MASK_NODE_TYPE,LEGION_MAX_NUM_NODES,
2007  LEGION_NODE_MASK_NODE_SHIFT,
2008  LEGION_NODE_MASK_NODE_MASK> NodeMask;
2009 #endif
2010 #elif defined(__ARM_NEON)
2011 #if (LEGION_MAX_NUM_NODES > 128)
2012  typedef NeonTLBitMask<LEGION_MAX_NUM_NODES> NodeMask;
2013 #elif (LEGION_MAX_NUM_NODES > 64)
2014  typedef NeonBitMask<LEGION_MAX_NUM_NODES> NodeMask;
2015 #else
2016  typedef BitMask<LEGION_NODE_MASK_NODE_TYPE,LEGION_MAX_NUM_NODES,
2017  LEGION_NODE_MASK_NODE_SHIFT,
2018  LEGION_NODE_MASK_NODE_MASK> NodeMask;
2019 #endif
2020 #else
2021 #if (LEGION_MAX_NUM_NODES > 64)
2022  typedef TLBitMask<LEGION_NODE_MASK_NODE_TYPE,LEGION_MAX_NUM_NODES,
2023  LEGION_NODE_MASK_NODE_SHIFT,
2024  LEGION_NODE_MASK_NODE_MASK> NodeMask;
2025 #else
2026  typedef BitMask<LEGION_NODE_MASK_NODE_TYPE,LEGION_MAX_NUM_NODES,
2027  LEGION_NODE_MASK_NODE_SHIFT,
2028  LEGION_NODE_MASK_NODE_MASK> NodeMask;
2029 #endif
2030 #endif
2031  typedef CompoundBitMask<NodeMask,1/*bloat*/,true/*bidir*/> NodeSet;
2032 
2033 #undef LEGION_NODE_MASK_NODE_SHIFT
2034 #undef LEGION_NODE_MASK_NODE_MASK
2035 
2036 // The following macros are used in the ProcessorMask instantiation of BitMask
2037 // If you change one you probably have to change the others too
2038 #define LEGION_PROC_MASK_PROC_TYPE uint64_t
2039 #define LEGION_PROC_MASK_PROC_SHIFT 6
2040 #define LEGION_PROC_MASK_PROC_MASK 0x3F
2041 #define LEGION_PROC_MASK_PROC_ALL_ONES 0xFFFFFFFFFFFFFFFF
2042 
2043 #if defined(__AVX__)
2044 #if (LEGION_MAX_NUM_PROCS > 256)
2045  typedef AVXTLBitMask<LEGION_MAX_NUM_PROCS> ProcessorMask;
2046 #elif (LEGION_MAX_NUM_PROCS > 128)
2047  typedef AVXBitMask<LEGION_MAX_NUM_PROCS> ProcessorMask;
2048 #elif (LEGION_MAX_NUM_PROCS > 64)
2049  typedef SSEBitMask<LEGION_MAX_NUM_PROCS> ProcessorMask;
2050 #else
2051  typedef BitMask<LEGION_PROC_MASK_PROC_TYPE,LEGION_MAX_NUM_PROCS,
2052  LEGION_PROC_MASK_PROC_SHIFT,
2053  LEGION_PROC_MASK_PROC_MASK> ProcessorMask;
2054 #endif
2055 #elif defined(__SSE2__)
2056 #if (LEGION_MAX_NUM_PROCS > 128)
2057  typedef SSETLBitMask<LEGION_MAX_NUM_PROCS> ProcessorMask;
2058 #elif (LEGION_MAX_NUM_PROCS > 64)
2059  typedef SSEBitMask<LEGION_MAX_NUM_PROCS> ProcessorMask;
2060 #else
2061  typedef BitMask<LEGION_PROC_MASK_PROC_TYPE,LEGION_MAX_NUM_PROCS,
2062  LEGION_PROC_MASK_PROC_SHIFT,
2063  LEGION_PROC_MASK_PROC_MASK> ProcessorMask;
2064 #endif
2065 #elif defined(__ALTIVEC__)
2066 #if (LEGION_MAX_NUM_PROCS > 128)
2067  typedef PPCTLBitMask<LEGION_MAX_NUM_PROCS> ProcessorMask;
2068 #elif (LEGION_MAX_NUM_PROCS > 64)
2069  typedef PPCBitMask<LEGION_MAX_NUM_PROCS> ProcessorMask;
2070 #else
2071  typedef BitMask<LEGION_PROC_MASK_PROC_TYPE,LEGION_MAX_NUM_PROCS,
2072  LEGION_PROC_MASK_PROC_SHIFT,
2073  LEGION_PROC_MASK_PROC_MASK> ProcessorMask;
2074 #endif
2075 #elif defined(__ARM_NEON)
2076 #if (LEGION_MAX_NUM_PROCS > 128)
2077  typedef NeonTLBitMask<LEGION_MAX_NUM_PROCS> ProcessorMask;
2078 #elif (LEGION_MAX_NUM_PROCS > 64)
2079  typedef NeonBitMask<LEGION_MAX_NUM_PROCS> ProcessorMask;
2080 #else
2081  typedef BitMask<LEGION_PROC_MASK_PROC_TYPE,LEGION_MAX_NUM_PROCS,
2082  LEGION_PROC_MASK_PROC_SHIFT,
2083  LEGION_PROC_MASK_PROC_MASK> ProcessorMask;
2084 #endif
2085 #else
2086 #if (LEGION_MAX_NUM_PROCS > 64)
2087  typedef TLBitMask<LEGION_PROC_MASK_PROC_TYPE,LEGION_MAX_NUM_PROCS,
2088  LEGION_PROC_MASK_PROC_SHIFT,
2089  LEGION_PROC_MASK_PROC_MASK> ProcessorMask;
2090 #else
2091  typedef BitMask<LEGION_PROC_MASK_PROC_TYPE,LEGION_MAX_NUM_PROCS,
2092  LEGION_PROC_MASK_PROC_SHIFT,
2093  LEGION_PROC_MASK_PROC_MASK> ProcessorMask;
2094 #endif
2095 #endif
2096 
2097 #undef PROC_SHIFT
2098 #undef PROC_MASK
2099 
2100  // Legion derived event types
2101  class LgEvent : public Realm::Event {
2102  public:
2103  static const LgEvent NO_LG_EVENT;
2104  public:
2105  LgEvent(void) noexcept { id = 0; }
2106  LgEvent(const LgEvent &rhs) = default;
2107  explicit LgEvent(const Realm::Event e) { id = e.id; }
2108  public:
2109  inline LgEvent& operator=(const LgEvent &rhs) = default;
2110  public:
2111  // Override the wait method so we can have our own implementation
2112  inline void wait(void) const;
2113  inline void wait_faultaware(bool &poisoned) const;
2114  };
2115 
2116  class PredEvent : public LgEvent {
2117  public:
2118  static const PredEvent NO_PRED_EVENT;
2119  public:
2120  PredEvent(void) noexcept : LgEvent() { }
2121  PredEvent(const PredEvent &rhs) = default;
2122  explicit PredEvent(const Realm::UserEvent &e) : LgEvent(e) { }
2123  public:
2124  inline PredEvent& operator=(const PredEvent &rhs) = default;
2125  inline operator Realm::UserEvent() const
2126  { Realm::UserEvent e; e.id = id; return e; }
2127  };
2128 
2129  class ApEvent : public LgEvent {
2130  public:
2131  static const ApEvent NO_AP_EVENT;
2132  public:
2133  ApEvent(void) noexcept : LgEvent() { }
2134  ApEvent(const ApEvent &rhs) = default;
2135  explicit ApEvent(const Realm::Event &e) : LgEvent(e) { }
2136  explicit ApEvent(const PredEvent &e) { id = e.id; }
2137  public:
2138  inline ApEvent& operator=(const ApEvent &rhs) = default;
2139  inline bool has_triggered_faultignorant(void) const
2140  { bool poisoned = false;
2141  return has_triggered_faultaware(poisoned); }
2142  inline void wait_faultignorant(void) const
2143  { bool poisoned = false; LgEvent::wait_faultaware(poisoned); }
2144  // TODO: enable this to ensure we are always checking for faults
2145 #if 0
2146  private:
2147  // Make these private because we always want to be conscious of faults
2148  // when testing or waiting on application events
2149  inline bool has_triggered(void) const { return LgEvent::has_triggered(); }
2150  inline void wait(void) const { LgEvent::wait(); }
2151 #endif
2152  };
2153 
2154  class ApUserEvent : public ApEvent {
2155  public:
2156  static const ApUserEvent NO_AP_USER_EVENT;
2157  public:
2158  ApUserEvent(void) noexcept : ApEvent() { }
2159  ApUserEvent(const ApUserEvent &rhs) = default;
2160  explicit ApUserEvent(const Realm::UserEvent &e) : ApEvent(e) { }
2161  public:
2162  inline ApUserEvent& operator=(const ApUserEvent &rhs) = default;
2163  inline operator Realm::UserEvent() const
2164  { Realm::UserEvent e; e.id = id; return e; }
2165  };
2166 
2167  class ApBarrier : public ApEvent {
2168  public:
2169  static const ApBarrier NO_AP_BARRIER;
2170  public:
2171  ApBarrier(void) noexcept : ApEvent(), timestamp(0) { }
2172  ApBarrier(const ApBarrier &rhs) = default;
2173  explicit ApBarrier(const Realm::Barrier &b)
2174  : ApEvent(b), timestamp(b.timestamp) { }
2175  public:
2176  inline ApBarrier& operator=(const ApBarrier &rhs) = default;
2177  inline operator Realm::Barrier() const
2178  { Realm::Barrier b; b.id = id;
2179  b.timestamp = timestamp; return b; }
2180  public:
2181  Realm::Barrier::timestamp_t timestamp;
2182  };
2183 
2184  class RtEvent : public LgEvent {
2185  public:
2186  static const RtEvent NO_RT_EVENT;
2187  public:
2188  RtEvent(void) noexcept : LgEvent() { }
2189  RtEvent(const RtEvent &rhs) = default;
2190  explicit RtEvent(const Realm::Event &e) : LgEvent(e) { }
2191  explicit RtEvent(const PredEvent &e) { id = e.id; }
2192  public:
2193  inline RtEvent& operator=(const RtEvent &rhs) = default;
2194  };
2195 
2196  class RtUserEvent : public RtEvent {
2197  public:
2198  static const RtUserEvent NO_RT_USER_EVENT;
2199  public:
2200  RtUserEvent(void) noexcept : RtEvent() { }
2201  RtUserEvent(const RtUserEvent &rhs) = default;
2202  explicit RtUserEvent(const Realm::UserEvent &e) : RtEvent(e) { }
2203  public:
2204  inline RtUserEvent& operator=(const RtUserEvent &rhs) = default;
2205  inline operator Realm::UserEvent() const
2206  { Realm::UserEvent e; e.id = id; return e; }
2207  };
2208 
2209  class RtBarrier : public RtEvent {
2210  public:
2211  static const RtBarrier NO_RT_BARRIER;
2212  public:
2213  RtBarrier(void) noexcept : RtEvent(), timestamp(0) { }
2214  RtBarrier(const RtBarrier &rhs) = default;
2215  explicit RtBarrier(const Realm::Barrier &b)
2216  : RtEvent(b), timestamp(b.timestamp) { }
2217  public:
2218  inline RtBarrier& operator=(const RtBarrier &rhs) = default;
2219  inline operator Realm::Barrier() const
2220  { Realm::Barrier b; b.id = id;
2221  b.timestamp = timestamp; return b; }
2222  public:
2223  Realm::Barrier::timestamp_t timestamp;
2224  };
2225 
2226  // Local lock for accelerating lock taking
2227  class LocalLock {
2228  public:
2229  inline LocalLock(void) { }
2230  public:
2231  inline LocalLock(const LocalLock &rhs)
2232  {
2233  // should never be called
2234  assert(false);
2235  }
2236  inline ~LocalLock(void) { }
2237  public:
2238  inline LocalLock& operator=(const LocalLock &rhs)
2239  {
2240  // should never be called
2241  assert(false);
2242  return *this;
2243  }
2244  private:
2245  // These are only accessible via AutoLock
2246  friend class AutoLock;
2247  friend class AutoTryLock;
2248  inline RtEvent lock(void) { return RtEvent(wrlock()); }
2249  inline RtEvent wrlock(void) { return RtEvent(reservation.wrlock()); }
2250  inline RtEvent rdlock(void) { return RtEvent(reservation.rdlock()); }
2251  inline bool trylock(void) { return reservation.trylock(); }
2252  inline bool trywrlock(void) { return reservation.trywrlock(); }
2253  inline bool tryrdlock(void) { return reservation.tryrdlock(); }
2254  inline void unlock(void) { reservation.unlock(); }
2255  private:
2256  inline void advise_sleep_entry(Realm::UserEvent guard)
2257  { reservation.advise_sleep_entry(guard); }
2258  inline void advise_sleep_exit(void)
2259  { reservation.advise_sleep_exit(); }
2260  protected:
2261  Realm::FastReservation reservation;
2262  };
2263 
2265  // AutoLock
2267  // An auto locking class for taking a lock and releasing it when
2268  // the object goes out of scope
2269  class AutoLock {
2270  public:
2271  inline AutoLock(LocalLock &r, int mode = 0, bool excl = true)
2272  : local_lock(r), previous(Internal::local_lock_list),
2273  exclusive(excl), held(true)
2274  {
2275 #ifdef DEBUG_REENTRANT_LOCKS
2276  if (previous != NULL)
2277  previous->check_for_reentrant_locks(&local_lock);
2278 #endif
2279  if (exclusive)
2280  {
2281  RtEvent ready = local_lock.wrlock();
2282  while (ready.exists())
2283  {
2284  ready.wait();
2285  ready = local_lock.wrlock();
2286  }
2287  }
2288  else
2289  {
2290  RtEvent ready = local_lock.rdlock();
2291  while (ready.exists())
2292  {
2293  ready.wait();
2294  ready = local_lock.rdlock();
2295  }
2296  }
2297  Internal::local_lock_list = this;
2298  }
2299  protected:
2300  // Helper constructor for AutoTryLock
2301  inline AutoLock(int mode, bool excl, LocalLock &r)
2302  : local_lock(r), previous(Internal::local_lock_list),
2303  exclusive(excl), held(false)
2304  {
2305 #ifdef DEBUG_REENTRANT_LOCKS
2306  if (previous != NULL)
2307  previous->check_for_reentrant_locks(&local_lock);
2308 #endif
2309  }
2310  public:
2311  AutoLock(const AutoLock &rhs) = delete;
2312  inline ~AutoLock(void)
2313  {
2314  if (held)
2315  {
2316 #ifdef DEBUG_LEGION
2317  assert(Internal::local_lock_list == this);
2318 #endif
2319  local_lock.unlock();
2320  Internal::local_lock_list = previous;
2321  }
2322  else
2323  assert(Internal::local_lock_list == previous);
2324  }
2325  public:
2326  AutoLock& operator=(const AutoLock &rhs) = delete;
2327  public:
2328  inline void release(void)
2329  {
2330 #ifdef DEBUG_LEGION
2331  assert(held);
2332  assert(Internal::local_lock_list == this);
2333 #endif
2334  local_lock.unlock();
2335  Internal::local_lock_list = previous;
2336  held = false;
2337  }
2338  inline void reacquire(void)
2339  {
2340 #ifdef DEBUG_LEGION
2341  assert(!held);
2342  assert(Internal::local_lock_list == previous);
2343 #endif
2344 #ifdef DEBUG_REENTRANT_LOCKS
2345  if (previous != NULL)
2346  previous->check_for_reentrant_locks(&local_lock);
2347 #endif
2348  if (exclusive)
2349  {
2350  RtEvent ready = local_lock.wrlock();
2351  while (ready.exists())
2352  {
2353  ready.wait();
2354  ready = local_lock.wrlock();
2355  }
2356  }
2357  else
2358  {
2359  RtEvent ready = local_lock.rdlock();
2360  while (ready.exists())
2361  {
2362  ready.wait();
2363  ready = local_lock.rdlock();
2364  }
2365  }
2366  Internal::local_lock_list = this;
2367  held = true;
2368  }
2369  public:
2370  inline void advise_sleep_entry(Realm::UserEvent guard) const
2371  {
2372  if (held)
2373  local_lock.advise_sleep_entry(guard);
2374  if (previous != NULL)
2375  previous->advise_sleep_entry(guard);
2376  }
2377  inline void advise_sleep_exit(void) const
2378  {
2379  if (held)
2380  local_lock.advise_sleep_exit();
2381  if (previous != NULL)
2382  previous->advise_sleep_exit();
2383  }
2384 #ifdef DEBUG_REENTRANT_LOCKS
2385  inline void check_for_reentrant_locks(LocalLock *to_acquire) const
2386  {
2387  assert(to_acquire != &local_lock);
2388  if (previous != NULL)
2389  previous->check_for_reentrant_locks(to_acquire);
2390  }
2391 #endif
2392  protected:
2393  LocalLock &local_lock;
2394  AutoLock *const previous;
2395  const bool exclusive;
2396  bool held;
2397  };
2398 
2399  // AutoTryLock is an extension of AutoLock that supports try lock
2400  class AutoTryLock : public AutoLock {
2401  public:
2402  inline AutoTryLock(LocalLock &r, int mode = 0, bool excl = true)
2403  : AutoLock(mode, excl, r)
2404  {
2405  if (exclusive)
2406  ready = local_lock.wrlock();
2407  else
2408  ready = local_lock.rdlock();
2409  held = !ready.exists();
2410  if (held)
2411  Internal::local_lock_list = this;
2412  }
2413  AutoTryLock(const AutoTryLock &rhs) = delete;
2414  public:
2415  AutoTryLock& operator=(const AutoTryLock &rhs) = delete;
2416  public:
2417  // Allow an easy test for whether we got the lock or not
2418  inline bool has_lock(void) const { return held; }
2419  inline RtEvent try_next(void) const { return ready; }
2420  protected:
2421  RtEvent ready;
2422  };
2423 
2424  // Special method that we need here for waiting on events
2425 
2426  //--------------------------------------------------------------------------
2427  inline void LgEvent::wait(void) const
2428  //--------------------------------------------------------------------------
2429  {
2430  // Save the context locally
2431  Internal::TaskContext *local_ctx = Internal::implicit_context;
2432  // Save the task provenance information
2433  UniqueID local_provenance = Internal::implicit_provenance;
2434  // Save whether we are in a registration callback
2435  unsigned local_callback = Internal::inside_registration_callback;
2436  // Save the reference tracker that we have
2437  ImplicitReferenceTracker *local_tracker = implicit_reference_tracker;
2438  Internal::implicit_reference_tracker = NULL;
2439  // Check to see if we have any local locks to notify
2440  if (Internal::local_lock_list != NULL)
2441  {
2442  // Make a copy of the local locks here
2443  AutoLock *local_lock_list_copy = Internal::local_lock_list;
2444  // Set this back to NULL until we are done waiting
2445  Internal::local_lock_list = NULL;
2446  // Make a user event and notify all the thread locks
2447  const Realm::UserEvent done = Realm::UserEvent::create_user_event();
2448  local_lock_list_copy->advise_sleep_entry(done);
2449  // Now we can do the wait
2450  if (!Processor::get_executing_processor().exists())
2451  Realm::Event::external_wait();
2452  else
2453  Realm::Event::wait();
2454  // When we wake up, notify that we are done and exited the wait
2455  local_lock_list_copy->advise_sleep_exit();
2456  // Trigger the user-event
2457  done.trigger();
2458  // Restore our local lock list
2459  Internal::local_lock_list = local_lock_list_copy;
2460  }
2461  else // Just do the normal wait
2462  {
2463  if (!Processor::get_executing_processor().exists())
2464  Realm::Event::external_wait();
2465  else
2466  Realm::Event::wait();
2467  }
2468  // Write the context back
2469  Internal::implicit_context = local_ctx;
2470  // Write the provenance information back
2471  Internal::implicit_provenance = local_provenance;
2472  // Write the registration callback information back
2473  Internal::inside_registration_callback = local_callback;
2474 #ifdef DEBUG_LEGION
2475  assert(Internal::implicit_reference_tracker == NULL);
2476 #endif
2477  // Write the local reference tracker back
2478  Internal::implicit_reference_tracker = local_tracker;
2479  }
2480 
2481  //--------------------------------------------------------------------------
2482  inline void LgEvent::wait_faultaware(bool &poisoned) const
2483  //--------------------------------------------------------------------------
2484  {
2485  // Save the context locally
2486  Internal::TaskContext *local_ctx = Internal::implicit_context;
2487  // Save the task provenance information
2488  UniqueID local_provenance = Internal::implicit_provenance;
2489  // Save whether we are in a registration callback
2490  unsigned local_callback = Internal::inside_registration_callback;
2491  // Save the reference tracker that we have
2492  ImplicitReferenceTracker *local_tracker = implicit_reference_tracker;
2493  Internal::implicit_reference_tracker = NULL;
2494  // Check to see if we have any local locks to notify
2495  if (Internal::local_lock_list != NULL)
2496  {
2497  // Make a copy of the local locks here
2498  AutoLock *local_lock_list_copy = Internal::local_lock_list;
2499  // Set this back to NULL until we are done waiting
2500  Internal::local_lock_list = NULL;
2501  // Make a user event and notify all the thread locks
2502  const Realm::UserEvent done = Realm::UserEvent::create_user_event();
2503  local_lock_list_copy->advise_sleep_entry(done);
2504  // Now we can do the wait
2505  if (!Processor::get_executing_processor().exists())
2506  Realm::Event::external_wait_faultaware(poisoned);
2507  else
2508  Realm::Event::wait_faultaware(poisoned);
2509  // When we wake up, notify that we are done and exited the wait
2510  local_lock_list_copy->advise_sleep_exit();
2511  // Trigger the user-event
2512  done.trigger();
2513  // Restore our local lock list
2514  Internal::local_lock_list = local_lock_list_copy;
2515  }
2516  else // Just do the normal wait
2517  {
2518  if (!Processor::get_executing_processor().exists())
2519  Realm::Event::external_wait_faultaware(poisoned);
2520  else
2521  Realm::Event::wait_faultaware(poisoned);
2522  }
2523  // Write the context back
2524  Internal::implicit_context = local_ctx;
2525  // Write the provenance information back
2526  Internal::implicit_provenance = local_provenance;
2527  // Write the registration callback information back
2528  Internal::inside_registration_callback = local_callback;
2529 #ifdef DEBUG_LEGION
2530  assert(Internal::implicit_reference_tracker == NULL);
2531 #endif
2532  // Write the local reference tracker back
2533  Internal::implicit_reference_tracker = local_tracker;
2534  }
2535 
2536  }; // namespace Internal
2537 
2538  // A class for preventing serialization of Legion objects
2539  // which cannot be serialized
2540  template<typename T>
2542  public:
2543  inline size_t legion_buffer_size(void);
2544  inline size_t legion_serialize(void *buffer);
2545  inline size_t legion_deserialize(const void *buffer);
2546  };
2547 
2548 }; // Legion namespace
2549 
2550 // now that we have things like LgEvent defined, we can include accessor.h to
2551 // pick up ptr_t, which is used for compatibility-mode Coloring and friends
2552 #include "legion/accessor.h"
2553 
2554 namespace Legion {
2555  typedef LegionRuntime::Accessor::ByteOffset ByteOffset;
2556 
2557  typedef std::map<Color,ColoredPoints<ptr_t> > Coloring;
2558  typedef std::map<Color,Domain> DomainColoring;
2559  typedef std::map<Color,std::set<Domain> > MultiDomainColoring;
2560  typedef std::map<DomainPoint,ColoredPoints<ptr_t> > PointColoring;
2561  typedef std::map<DomainPoint,Domain> DomainPointColoring;
2562  typedef std::map<DomainPoint,std::set<Domain> > MultiDomainPointColoring;
2563 };
2564 
2565 #endif // __LEGION_TYPES_H__
Definition: legion.h:376
Definition: legion_types.h:1535
Definition: legion_types.h:167
Definition: legion.h:3894
Definition: legion.h:3375
Definition: legion_types.h:1543
Definition: legion.h:303
Definition: legion_domain.h:260
Definition: legion_types.h:2269
Definition: legion.h:9792
Definition: legion_types.h:1549
Definition: legion_types.h:1536
Definition: legion_types.h:1537
Definition: legion.h:4572
Definition: legion_types.h:1383
Definition: legion.h:4267
Definition: legion_types.h:2209
Definition: legion.h:3300
Definition: legion.h:4094
Definition: legion_types.h:1887
Definition: legion.h:3340
Definition: legion.h:4137
Definition: legion.h:3829
Definition: legion.h:4278
Definition: legion_types.h:2184
Definition: legion_types.h:1411
Definition: legion_types.h:168
Definition: legion_types.h:2101
Definition: legion.h:4208
Definition: legion.h:4163
Definition: legion_types.h:2541
Definition: legion.h:4181
Definition: legion_types.h:1541
Definition: legion_domain.h:132
Definition: legion_types.h:1534
Definition: legion_types.h:1418
Definition: legion.h:4241
Definition: legion_types.h:2154
Definition: legion_types.h:2116
Definition: legion_types.h:2400
Definition: legion_types.h:83
Definition: legion_types.h:2167
Definition: legion.h:4014
Definition: legion_c_util.h:39
Definition: legion_types.h:64
Definition: legion.h:4335
Definition: legion_types.h:2196
Definition: legion.h:9773
Definition: legion_types.h:1384
Definition: legion_types.h:2227
Definition: legion_types.h:2129
Definition: legion_types.h:66
Definition: legion_types.h:1654
Definition: legion_types.h:1861
Definition: legion.h:236
Definition: legion_types.h:165
Definition: legion.h:4115
Definition: legion.h:4066
Definition: legion.h:4288