20#ifndef REALM_RUNTIME_IMPL_H
21#define REALM_RUNTIME_IMPL_H
59#include <unordered_map>
64 class ProcessorGroupImpl;
68 class RegionInstanceImpl;
75 typedef DynamicTableAllocator<GenEventImpl, 11, 16, GenEventImpl::GenEventImplAllocator>
115 std::ostream &operator<<(
std::ostream &os, const
Node &node);
133 int num_cpu_procs = 1, num_util_procs = 1, num_io_procs = 0;
134 int concurrent_io_threads = 1;
135 size_t sysmem_size = 512 << 20;
136 size_t sysmem_ipc_limit = 0;
138 size_t stack_size = 2 << 20;
139 bool pin_util_procs =
false;
140 long long cpu_bgwork_timeslice = 0, util_bgwork_timeslice = 0;
141 bool use_ext_sysmem =
true;
144 size_t reg_ib_mem_size = 0;
145 size_t reg_mem_size = 0;
146 size_t disk_mem_size = 0;
147 unsigned dma_worker_threads = 0;
149 size_t event_trace_block_size = 1 << 20;
150 double event_trace_exp_arrv_rate = 1e3;
153 size_t lock_trace_block_size = 1 << 20;
154 double lock_trace_exp_arrv_rate = 1e2;
157 bool dummy_reservation_ok =
true;
158 bool show_reservations =
false;
160 bool hyperthread_sharing =
true;
161 bool pin_dma_threads =
false;
162 size_t bitset_chunk_size = 32 << 10;
166 int bitset_twolevel = -1024;
167 int active_msg_handler_threads = 0;
168 bool active_msg_handler_bgwork =
true;
169 size_t replheap_size = 16 << 20;
173 std::string prefix =
".";
177 int res_num_cpus = 0;
178 size_t res_sysmem_size = 0;
181 bool report_sparsity_leaks =
false;
184 int barrier_broadcast_radix = 4;
225 template <
typename K,
typename V,
typename LT = Mutex>
231 typename std::map<K, V>::const_iterator it = map.find(key);
232 return (it != map.end());
235 bool put(
const K &key,
const V &value,
bool replace =
false)
238 typename std::map<K, V>::iterator it = map.find(key);
239 if(it != map.end()) {
244 map.insert(std::make_pair(key, value));
249 V
get(
const K &key,
const V &defval)
const
252 typename std::map<K, V>::const_iterator it = map.find(key);
285 size_t value_size)
const;
287 size_t *value_size)
const;
290 size_t *expected_size,
const void *desired,
291 size_t desired_size)
const;
309 const void *args,
size_t arglen,
310 Event wait_on = Event::NO_EVENT,
int priority = 0);
314 size_t arglen,
bool one_per_node =
false,
315 Event wait_on = Event::NO_EVENT,
int priority = 0);
319 size_t arglen = 0,
bool background =
false);
359 void add_thread(
const pthread_t *thread);
389 unsigned next_thread;
390 unsigned signaled_threads;
391 pthread_t all_threads[MAX_NUM_THREADS];
392 unsigned thread_counts[MAX_NUM_THREADS];
405 bool topology_init =
false;
417 bool shared_peers_use_network_module =
true;
424 virtual void print(std::ostream &os)
const;
449 template <
typename T>
452 Module *mod = get_module_untyped(name);
454 return checked_cast<T *>(mod);
519 const void *data,
size_t datalen);
526 const void *data,
size_t datalen);
Definition barrier_impl.h:100
Definition codedesc.h:367
Definition comp_queue_impl.h:30
Definition runtime_impl.h:118
std::string lock_trace_file
Definition runtime_impl.h:171
virtual void configure_from_cmdline(std::vector< std::string > &cmdline)
CoreModuleConfig(const HardwareTopology *topo)
std::string event_trace_file
Definition runtime_impl.h:170
bool discover_resource(void)
Definition runtime_impl.h:190
static Module * create_module(RuntimeImpl *runtime)
CoreModuleConfig * config
Definition runtime_impl.h:222
MemoryImpl * ext_sysmem
Definition runtime_impl.h:219
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
Definition dynamic_table.h:105
Definition dynamic_table.h:65
Definition event_impl.h:85
Definition event_impl.h:66
Definition event_impl.h:49
Definition event_impl.h:198
Represents the topology of the host processor cores and memory.
Definition hardware_topology.h:38
Definition ib_memory.h:30
::realm_id_t IDType
Definition id.h:32
Definition activemsg.h:345
Definition runtime_impl.h:226
V get(const K &key, const V &defval) const
Definition runtime_impl.h:249
bool exists(const K &key) const
Definition runtime_impl.h:228
bool put(const K &key, const V &value, bool replace=false)
Definition runtime_impl.h:235
LT mutex
Definition runtime_impl.h:260
std::map< K, V > map
Definition runtime_impl.h:261
Definition machine_impl.h:94
Definition module_config.h:32
Definition operation.h:155
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
Definition inst_impl.h:54
Definition repl_heap.h:30
Definition rsrv_impl.h:57
Definition runtime_impl.h:419
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:428
Definition runtime_impl.h:264
int wait_for_shutdown(void)
SparsityMapImplWrapper * get_sparsity_impl(ID id)
bool register_custom_serdez(CustomSerdezID serdez_id, const CustomSerdezUntyped *serdez)
std::optional< uint64_t > key_value_store_local_ranks(void) const
SamplingProfiler sampling_profiler
Definition runtime_impl.h:413
EventImpl * get_event_impl(Event e)
std::optional< uint64_t > key_value_store_local_group(void) const
BackgroundWorkManager bgwork
Definition runtime_impl.h:407
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:398
Memory next_local_memory_id(void)
LockedMap< CustomSerdezID, CustomSerdezUntyped * > custom_serdez_table
Definition runtime_impl.h:367
bool run_method_called
Definition runtime_impl.h:387
std::vector< SparsityMapTableAllocator::FreeList * > local_sparsity_map_free_lists
Definition runtime_impl.h:382
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:491
ReplicatedHeap repl_heap
Definition runtime_impl.h:415
Node * nodes
Definition runtime_impl.h:370
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:485
atomic< bool > shutdown_in_progress
Definition runtime_impl.h:400
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:490
DeferredShutdown deferred_shutdown
Definition runtime_impl.h:430
LockedMap< ReductionOpID, ReductionOpUntyped * > reduce_op_table
Definition runtime_impl.h:366
OperationTable optable
Definition runtime_impl.h:411
CompQueueImpl * get_compqueue_impl(ID id)
bool has_key_value_store_group(void) const
void parse_command_line(std::vector< std::string > &cmdline)
NetworkSegment reg_ib_mem_segment
Definition runtime_impl.h:476
bool create_configs(int argc, char **argv)
Mutex shutdown_mutex
Definition runtime_impl.h:394
size_t num_nodes
Definition runtime_impl.h:371
atomic< size_t > num_untriggered_events
Definition runtime_impl.h:369
T * get_module(const char *name) const
Definition runtime_impl.h:450
std::map< std::string, ModuleConfig * > module_configs
Definition runtime_impl.h:488
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:409
Processor next_local_processor_id(void)
SparsityMapImplWrapper * get_available_sparsity_impl(NodeID target_node)
Event shutdown_precondition
Definition runtime_impl.h:397
Mutex::CondVar shutdown_condvar
Definition runtime_impl.h:395
void add_ib_memory(IBMemory *m)
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:396
HardwareTopology host_topology
Definition runtime_impl.h:404
NetworkSegment reg_mem_segment
Definition runtime_impl.h:477
Event notify_register_reduction(ReductionOpID redop_id)
void add_memory(MemoryImpl *m)
ID::IDType num_local_ib_memories
Definition runtime_impl.h:475
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:383
bool shutdown_initiated
Definition runtime_impl.h:399
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:364
CoreReservationSet * core_reservations
Definition runtime_impl.h:406
std::vector< ProcessorGroupTableAllocator::FreeList * > local_proc_group_free_lists
Definition runtime_impl.h:384
bool module_configs_created
Definition runtime_impl.h:481
std::vector< NetworkSegment * > network_segments
Definition runtime_impl.h:486
RegionInstanceImpl * get_instance_impl(ID id)
IncomingMessageManager * message_manager
Definition runtime_impl.h:408
void finish_configure(void)
static void realm_backtrace(int signal)
bool has_key_value_store(void) const
ModuleRegistrar module_registrar
Definition runtime_impl.h:479
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)
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
std::vector< Module * > modules
Definition runtime_impl.h:482
MemoryImpl * get_memory_impl(ID id) const
bool modules_created
Definition runtime_impl.h:480
bool register_task(Processor::TaskFuncID taskid, Processor::TaskFuncPtr taskptr)
std::unordered_map< realm_id_t, SharedMemoryInfo > remote_shared_memory_mappings
Definition runtime_impl.h:401
GenEventImpl * get_genevent_impl(Event e)
BarrierImpl * get_barrier_impl(Event e)
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:402
void shutdown(Event wait_on=Event::NO_EVENT, int result_code=0)
bool key_value_store_bar(void) const
std::vector< CodeTranslator * > code_translators
Definition runtime_impl.h:483
RunStyle
Definition runtime.h:257
Definition sampling.h:173
Definition sparsity_impl.h:199
Definition subgraph_impl.h:38
#define REALM_INTERNAL_API_EXTERNAL_LINKAGE
Definition compiler_support.h:218
Definition activemsg.h:38
DynamicTableAllocator< SubgraphImpl, 10, 4 > SubgraphTableAllocator
Definition runtime_impl.h:84
DynamicTableAllocator< CompQueueImpl, 10, 4 > CompQueueTableAllocator
Definition runtime_impl.h:83
GenEventImpl * get_genevent_impl(Event e)
Definition runtime_impl.h:503
int NodeID
Definition nodeset.h:40
EventImpl * get_event_impl(Event e)
Definition runtime_impl.h:502
int CustomSerdezID
Definition custom_serdez.h:148
DynamicTableAllocator< GenEventImpl, 10, 7, GenEventImpl::GenEventImplAllocator > RemoteEventTableAllocator
Definition runtime_impl.h:78
REALM_INTERNAL_API_EXTERNAL_LINKAGE RuntimeImpl * runtime_singleton
DynamicTableAllocator< BarrierImpl, 10, 4 > BarrierTableAllocator
Definition runtime_impl.h:79
DynamicTableAllocator< SparsityMapImplWrapper, 10, 4 > SparsityMapTableAllocator
Definition runtime_impl.h:82
DynamicTableAllocator< ReservationImpl, 10, 8 > ReservationTableAllocator
Definition runtime_impl.h:80
REALM_INTERNAL_API_EXTERNAL_LINKAGE RuntimeImpl * get_runtime(void)
Definition runtime_impl.h:495
::realm_reduction_op_id_t ReductionOpID
Definition event.h:38
DynamicTableAllocator< ProcessorGroupImpl, 10, 4 > ProcessorGroupTableAllocator
Definition runtime_impl.h:81
BarrierImpl * get_barrier_impl(Event e)
Definition runtime_impl.h:507
DynamicTableAllocator< GenEventImpl, 11, 16, GenEventImpl::GenEventImplAllocator > LocalEventTableAllocator
Definition runtime_impl.h:76
Definition indexspace.h:1279
Definition event_impl.h:263
Definition runtime_impl.h:88
std::vector< Channel * > dma_channels
Definition runtime_impl.h:101
std::vector< ProcessorImpl * > processors
Definition runtime_impl.h:100
Node & operator=(const Node &)=delete
std::vector< atomic< DynamicTable< SubgraphTableAllocator > * > > subgraphs
Definition runtime_impl.h:111
DynamicTable< CompQueueTableAllocator > compqueues
Definition runtime_impl.h:106
std::vector< atomic< DynamicTable< ProcessorGroupTableAllocator > * > > proc_groups
Definition runtime_impl.h:112
std::vector< MemoryImpl * > memories
Definition runtime_impl.h:98
DynamicTable< RemoteEventTableAllocator > remote_events
Definition runtime_impl.h:103
DynamicTable< ReservationTableAllocator > reservations
Definition runtime_impl.h:105
Node(Node &&) noexcept=delete
Node(const Node &)=delete
std::vector< IBMemory * > ib_memories
Definition runtime_impl.h:99
std::vector< atomic< DynamicTable< SparsityMapTableAllocator > * > > sparsity_maps
Definition runtime_impl.h:110
DynamicTable< BarrierTableAllocator > barriers
Definition runtime_impl.h:104
Definition runtime_impl.h:522
int result_code
Definition runtime_impl.h:523
static void handle_message(NodeID sender, const RuntimeShutdownMessage &msg, const void *data, size_t datalen)
Definition runtime_impl.h:514
static void handle_message(NodeID sender, const RuntimeShutdownRequest &msg, const void *data, size_t datalen)
Event wait_on
Definition runtime_impl.h:515
int result_code
Definition runtime_impl.h:516