20#ifndef REALM_RUNTIME_IMPL_H
21#define REALM_RUNTIME_IMPL_H
61#include <unordered_map>
121 std::ostream &operator<<(std::ostream &os, const
Node &node);
156 size_t event_trace_block_size = 1 << 20;
157 double event_trace_exp_arrv_rate = 1e3;
160 size_t lock_trace_block_size = 1 << 20;
161 double lock_trace_exp_arrv_rate = 1e2;
180 std::string prefix =
".";
232 template <
typename K,
typename V,
typename LT = Mutex>
238 typename std::map<K, V>::const_iterator it =
map.find(key);
239 return (it !=
map.end());
242 bool put(
const K &key,
const V &value,
bool replace =
false)
245 typename std::map<K, V>::iterator it =
map.find(key);
246 if(it !=
map.end()) {
251 map.insert(std::make_pair(key, value));
256 V
get(
const K &key,
const V &defval)
const
259 typename std::map<K, V>::const_iterator it =
map.find(key);
292 size_t value_size)
const;
294 size_t *value_size)
const;
297 size_t *expected_size,
const void *desired,
298 size_t desired_size)
const;
316 const void *args,
size_t arglen,
321 size_t arglen,
bool one_per_node =
false,
326 size_t arglen = 0,
bool background =
false);
366 void add_thread(
const pthread_t *thread);
396 unsigned next_thread;
397 unsigned signaled_threads;
398 pthread_t all_threads[MAX_NUM_THREADS];
399 unsigned thread_counts[MAX_NUM_THREADS];
434 virtual void print(std::ostream &os)
const;
459 template <
typename T>
529 const void *data,
size_t datalen);
536 const void *data,
size_t datalen);
Definition barrier_impl.h:100
Definition codedesc.h:367
Definition comp_queue_impl.h:30
Definition transfer.h:524
Definition runtime_impl.h:124
unsigned dma_worker_threads
Definition runtime_impl.h:153
size_t reg_mem_size
Definition runtime_impl.h:151
size_t replheap_size
Definition runtime_impl.h:176
size_t sysmem_ipc_limit
Definition runtime_impl.h:142
bool hyperthread_sharing
Definition runtime_impl.h:167
bool pin_util_procs
Definition runtime_impl.h:145
int bitset_twolevel
Definition runtime_impl.h:173
const HardwareTopology * host_topology
Definition runtime_impl.h:194
bool use_ext_sysmem
Definition runtime_impl.h:147
bool pin_dma_threads
Definition runtime_impl.h:168
std::string lock_trace_file
Definition runtime_impl.h:178
virtual void configure_from_cmdline(std::vector< std::string > &cmdline)
int num_util_procs
Definition runtime_impl.h:139
size_t stack_size
Definition runtime_impl.h:144
size_t sysmem_size
Definition runtime_impl.h:141
int num_cpu_procs
Definition runtime_impl.h:139
bool show_reservations
Definition runtime_impl.h:165
size_t res_sysmem_size
Definition runtime_impl.h:185
long long util_bgwork_timeslice
Definition runtime_impl.h:146
CoreModuleConfig(const HardwareTopology *topo)
size_t reg_ib_mem_size
Definition runtime_impl.h:150
int active_msg_handler_threads
Definition runtime_impl.h:174
bool dma_multi_field
Definition runtime_impl.h:154
size_t bitset_chunk_size
Definition runtime_impl.h:169
friend class RuntimeImpl
Definition runtime_impl.h:126
int concurrent_io_threads
Definition runtime_impl.h:140
int num_io_procs
Definition runtime_impl.h:139
bool dummy_reservation_ok
Definition runtime_impl.h:164
size_t disk_mem_size
Definition runtime_impl.h:152
std::string event_trace_file
Definition runtime_impl.h:177
int res_num_cpus
Definition runtime_impl.h:184
bool active_msg_handler_bgwork
Definition runtime_impl.h:175
friend class CoreModule
Definition runtime_impl.h:125
bool discover_resource(void)
bool report_sparsity_leaks
Definition runtime_impl.h:188
int barrier_broadcast_radix
Definition runtime_impl.h:191
long long cpu_bgwork_timeslice
Definition runtime_impl.h:146
static Module * create_module(RuntimeImpl *runtime)
CoreModuleConfig * config
Definition runtime_impl.h:229
MemoryImpl * ext_sysmem
Definition runtime_impl.h:226
virtual void create_code_translators(RuntimeImpl *runtime)
virtual void create_processors(RuntimeImpl *runtime)
virtual void create_dma_channels(RuntimeImpl *runtime)
virtual ~CoreModule(void)
virtual void create_memories(RuntimeImpl *runtime)
static ModuleConfig * create_module_config(RuntimeImpl *runtime)
virtual void cleanup(void)
Definition custom_serdez.h:150
Definition dynamic_table.h:138
DynamicTableFreeList< DynamicTableAllocator< ET, _INNER_BITS, _LEAF_BITS, Constructor > > FreeList
Definition dynamic_table.h:153
Definition dynamic_table.h:65
Definition event_impl.h:204
Definition event_impl.h:87
Definition event_impl.h:68
Definition event_impl.h:51
static const Event NO_EVENT
The value should be usued to initialize an event handle. NO_EVENT is always in has triggered state .
Definition event.h:71
Definition event_impl.h:220
Represents the topology of the host processor cores and memory.
Definition hardware_topology.h:38
Definition ib_memory.h:54
::realm_id_t IDType
Definition id.h:32
Definition activemsg.h:399
Definition runtime_impl.h:233
V get(const K &key, const V &defval) const
Definition runtime_impl.h:256
bool exists(const K &key) const
Definition runtime_impl.h:235
bool put(const K &key, const V &value, bool replace=false)
Definition runtime_impl.h:242
LT mutex
Definition runtime_impl.h:267
std::map< K, V > map
Definition runtime_impl.h:268
Definition machine_impl.h:95
Definition module_config.h:32
ModuleConfig(const std::string &name)
Module(const std::string &_name)
Definition operation.h:158
Definition proc_impl.h:254
Definition proc_impl.h:51
Definition processor.h:37
Kind
Definition processor.h:65
::realm_task_func_id_t TaskFuncID
Definition processor.h:58
void(* TaskFuncPtr)(const void *args, size_t arglen, const void *user_data, size_t user_data_len, Processor proc)
Definition processor.h:59
Definition inst_impl.h:54
Definition repl_heap.h:30
Definition rsrv_impl.h:57
Definition runtime_impl.h:429
virtual void event_triggered(bool poisoned, TimeLimit work_until)
virtual Event get_finish_event(void) const
virtual void print(std::ostream &os) const
void defer(RuntimeImpl *_runtime, Event wait_on)
RuntimeImpl * runtime
Definition runtime_impl.h:438
Definition runtime_impl.h:271
int wait_for_shutdown(void)
SparsityMapImplWrapper * get_sparsity_impl(ID id)
bool register_custom_serdez(CustomSerdezID serdez_id, const CustomSerdezUntyped *serdez)
ReservationTableAllocator::FreeList * local_reservation_free_list
Definition runtime_impl.h:384
std::optional< uint64_t > key_value_store_local_ranks(void) const
SamplingProfiler sampling_profiler
Definition runtime_impl.h:423
EventImpl * get_event_impl(Event e)
std::optional< uint64_t > key_value_store_local_group(void) const
BackgroundWorkManager bgwork
Definition runtime_impl.h:414
SubgraphImpl * get_subgraph_impl(ID id)
REALM_INTERNAL_API_EXTERNAL_LINKAGE ProcessorImpl * get_processor_impl(ID id)
void add_proc_mem_affinity(const Machine::ProcessorMemoryAffinity &pma)
int shutdown_result_code
Definition runtime_impl.h:405
Memory next_local_memory_id(void)
ID::IDType num_local_processors
Definition runtime_impl.h:485
LockedMap< CustomSerdezID, CustomSerdezUntyped * > custom_serdez_table
Definition runtime_impl.h:374
bool run_method_called
Definition runtime_impl.h:394
std::vector< SparsityMapTableAllocator::FreeList * > local_sparsity_map_free_lists
Definition runtime_impl.h:389
void create_shared_peers(void)
Auxilary function to create Network::shared_peers using either ipc mailbox or relying on network modu...
std::vector< uint8_t > key_value_store_vtable_data
Definition runtime_impl.h:501
ReplicatedHeap repl_heap
Definition runtime_impl.h:425
Node * nodes
Definition runtime_impl.h:377
BarrierTableAllocator::FreeList * local_barrier_free_list
Definition runtime_impl.h:383
Event collective_spawn_by_kind(Processor::Kind target_kind, Processor::TaskFuncID task_id, const void *args, size_t arglen, bool one_per_node=false, Event wait_on=Event::NO_EVENT, int priority=0)
ReservationImpl * get_lock_impl(ID id)
std::vector< NetworkModule * > network_modules
Definition runtime_impl.h:495
atomic< bool > shutdown_in_progress
Definition runtime_impl.h:407
CoreReservationSet & core_reservation_set(void)
void add_code_translator(CodeTranslator *t)
bool configure_from_command_line(std::vector< std::string > &cmdline)
Runtime::KeyValueStoreVtable key_value_store_vtable
Definition runtime_impl.h:500
DeferredShutdown deferred_shutdown
Definition runtime_impl.h:440
LockedMap< ReductionOpID, ReductionOpUntyped * > reduce_op_table
Definition runtime_impl.h:373
OperationTable optable
Definition runtime_impl.h:421
CompQueueImpl * get_compqueue_impl(ID id)
bool has_key_value_store_group(void) const
void parse_command_line(std::vector< std::string > &cmdline)
LocalEventTableAllocator::FreeList * local_event_free_list
Definition runtime_impl.h:382
NetworkSegment reg_ib_mem_segment
Definition runtime_impl.h:486
bool create_configs(int argc, char **argv)
Mutex shutdown_mutex
Definition runtime_impl.h:401
size_t num_nodes
Definition runtime_impl.h:378
atomic< size_t > num_untriggered_events
Definition runtime_impl.h:376
T * get_module(const char *name) const
Definition runtime_impl.h:460
std::map< std::string, ModuleConfig * > module_configs
Definition runtime_impl.h:498
bool key_value_store_put(const void *key, size_t key_size, const void *value, size_t value_size) const
void add_processor(ProcessorImpl *p)
bool key_value_store_get(const void *key, size_t key_size, void *value, size_t *value_size) const
EventTriggerNotifier event_triggerer
Definition runtime_impl.h:416
Processor next_local_processor_id(void)
SparsityMapImplWrapper * get_available_sparsity_impl(NodeID target_node)
Event shutdown_precondition
Definition runtime_impl.h:404
Mutex::CondVar shutdown_condvar
Definition runtime_impl.h:402
void add_ib_memory(IBMemory *m)
DynamicTable< LocalEventTableAllocator > local_events
Definition runtime_impl.h:380
bool network_init(int *argc, char ***argv, const Runtime::KeyValueStoreVtable &vtable)
bool register_reduction(Event &event, ReductionOpID redop_id, const ReductionOpUntyped *redop)
Memory next_local_ib_memory_id(void)
void add_dma_channel(Channel *c)
bool shutdown_request_received
Definition runtime_impl.h:403
HardwareTopology host_topology
Definition runtime_impl.h:411
NetworkSegment reg_mem_segment
Definition runtime_impl.h:487
Event notify_register_reduction(ReductionOpID redop_id)
void add_memory(MemoryImpl *m)
ID::IDType num_local_ib_memories
Definition runtime_impl.h:485
bool shared_peers_use_network_module
Definition runtime_impl.h:427
IBMemory * get_ib_memory_impl(ID id) const
const std::vector< CodeTranslator * > & get_code_translators(void) const
void free_sparsity_impl(SparsityMapImplWrapper *impl)
std::vector< SubgraphTableAllocator::FreeList * > local_subgraph_free_lists
Definition runtime_impl.h:390
bool shutdown_initiated
Definition runtime_impl.h:406
ModuleConfig * get_module_config(const std::string &name) const
void initiate_shutdown(void)
bool share_memories(void)
Auxilary function for handling the sharing mechanism of all registered memories across the machine.
std::optional< uint64_t > key_value_store_get_int(const std::string_view &key) const
void run(Processor::TaskFuncID task_id=0, Runtime::RunStyle style=Runtime::ONE_TASK_ONLY, const void *args=0, size_t arglen=0, bool background=false)
ProcessorGroupImpl * get_procgroup_impl(ID id)
MachineImpl * machine
Definition runtime_impl.h:371
CoreReservationSet * core_reservations
Definition runtime_impl.h:413
std::vector< ProcessorGroupTableAllocator::FreeList * > local_proc_group_free_lists
Definition runtime_impl.h:391
bool module_configs_created
Definition runtime_impl.h:491
std::vector< NetworkSegment * > network_segments
Definition runtime_impl.h:496
RegionInstanceImpl * get_instance_impl(ID id)
IncomingMessageManager * message_manager
Definition runtime_impl.h:415
void finish_configure(void)
static void realm_backtrace(int signal)
bool has_key_value_store(void) const
ModuleRegistrar module_registrar
Definition runtime_impl.h:489
bool key_value_store_cas(const void *key, size_t key_size, void *expected, size_t *expected_size, const void *desired, size_t desired_size) const
Module * get_module_untyped(const char *name) const
bool request_shutdown(Event wait_on, int result_code)
CompQueueTableAllocator::FreeList * local_compqueue_free_list
Definition runtime_impl.h:385
Event collective_spawn(Processor target_proc, Processor::TaskFuncID task_id, const void *args, size_t arglen, Event wait_on=Event::NO_EVENT, int priority=0)
bool is_key_value_store_elastic(void) const
bool topology_init
Definition runtime_impl.h:412
std::vector< Module * > modules
Definition runtime_impl.h:492
MemoryImpl * get_memory_impl(ID id) const
ID::IDType num_local_memories
Definition runtime_impl.h:485
bool modules_created
Definition runtime_impl.h:490
bool register_task(Processor::TaskFuncID taskid, Processor::TaskFuncPtr taskptr)
std::unordered_map< realm_id_t, SharedMemoryInfo > remote_shared_memory_mappings
Definition runtime_impl.h:408
GenEventImpl * get_genevent_impl(Event e)
CopyAnalyzer copy_analyzer
Definition runtime_impl.h:419
BarrierImpl * get_barrier_impl(Event e)
friend class Runtime
Definition runtime_impl.h:470
std::optional< uint64_t > key_value_store_local_rank(void) const
std::unordered_map< realm_id_t, SharedMemoryInfo > local_shared_memory_mappings
Definition runtime_impl.h:409
void shutdown(Event wait_on=Event::NO_EVENT, int result_code=0)
EventCommunicator event_communicator
Definition runtime_impl.h:418
bool key_value_store_bar(void) const
std::vector< CodeTranslator * > code_translators
Definition runtime_impl.h:493
RunStyle
Definition runtime.h:257
@ ONE_TASK_ONLY
Definition runtime.h:258
Definition sampling.h:173
Definition sparsity_impl.h:199
Definition subgraph_impl.h:38
UnfairCondVar CondVar
Definition mutex.h:227
#define REALM_INTERNAL_API_EXTERNAL_LINKAGE
Definition compiler_support.h:226
Definition activemsg.h:42
T checked_cast(T2 *ptr)
Definition utils.h:162
DynamicTableAllocator< SubgraphImpl, 10, 4 > SubgraphTableAllocator
Definition runtime_impl.h:90
DynamicTableAllocator< CompQueueImpl, 10, 4 > CompQueueTableAllocator
Definition runtime_impl.h:89
GenEventImpl * get_genevent_impl(Event e)
Definition runtime_impl.h:513
UnfairMutex Mutex
Definition mutex.h:68
int NodeID
Definition nodeset.h:40
EventImpl * get_event_impl(Event e)
Definition runtime_impl.h:512
int CustomSerdezID
Definition custom_serdez.h:148
REALM_INTERNAL_API_EXTERNAL_LINKAGE RuntimeImpl * runtime_singleton
DynamicTableAllocator< BarrierImpl, 10, 4 > BarrierTableAllocator
Definition runtime_impl.h:85
DynamicTableAllocator< SparsityMapImplWrapper, 10, 4 > SparsityMapTableAllocator
Definition runtime_impl.h:88
DynamicTableAllocator< ReservationImpl, 10, 8 > ReservationTableAllocator
Definition runtime_impl.h:86
REALM_INTERNAL_API_EXTERNAL_LINKAGE RuntimeImpl * get_runtime(void)
Definition runtime_impl.h:505
::realm_reduction_op_id_t ReductionOpID
Definition event.h:38
DynamicTableAllocator< GenEventImpl, 8, 4, GenEventImpl::GenEventImplAllocator > RemoteEventTableAllocator
Definition runtime_impl.h:84
DynamicTableAllocator< ProcessorGroupImpl, 10, 4 > ProcessorGroupTableAllocator
Definition runtime_impl.h:87
BarrierImpl * get_barrier_impl(Event e)
Definition runtime_impl.h:517
DynamicTableAllocator< GenEventImpl, 11, 16, GenEventImpl::GenEventImplAllocator > LocalEventTableAllocator
Definition runtime_impl.h:82
Definition event_impl.h:292
Definition runtime_impl.h:94
std::vector< Channel * > dma_channels
Definition runtime_impl.h:107
std::vector< ProcessorImpl * > processors
Definition runtime_impl.h:106
Node & operator=(const Node &)=delete
std::vector< atomic< DynamicTable< SubgraphTableAllocator > * > > subgraphs
Definition runtime_impl.h:117
DynamicTable< CompQueueTableAllocator > compqueues
Definition runtime_impl.h:112
std::vector< atomic< DynamicTable< ProcessorGroupTableAllocator > * > > proc_groups
Definition runtime_impl.h:118
std::vector< MemoryImpl * > memories
Definition runtime_impl.h:104
DynamicTable< RemoteEventTableAllocator > remote_events
Definition runtime_impl.h:109
DynamicTable< ReservationTableAllocator > reservations
Definition runtime_impl.h:111
Node(Node &&) noexcept=delete
Node(const Node &)=delete
std::vector< IBMemory * > ib_memories
Definition runtime_impl.h:105
std::vector< atomic< DynamicTable< SparsityMapTableAllocator > * > > sparsity_maps
Definition runtime_impl.h:116
DynamicTable< BarrierTableAllocator > barriers
Definition runtime_impl.h:110
Definition runtime_impl.h:532
int result_code
Definition runtime_impl.h:533
static void handle_message(NodeID sender, const RuntimeShutdownMessage &msg, const void *data, size_t datalen)
Definition runtime_impl.h:524
static void handle_message(NodeID sender, const RuntimeShutdownRequest &msg, const void *data, size_t datalen)
Event wait_on
Definition runtime_impl.h:525
int result_code
Definition runtime_impl.h:526