20#ifndef REALM_THREADS_H
21#define REALM_THREADS_H
29#ifdef REALM_USE_USER_THREADS
94 template <
typename T,
void (T::*START_MTHD)(
void)>
98 void (*entry_wrapper)(
void *),
103#ifdef REALM_USE_USER_THREADS
104 static Thread *create_user_thread_untyped(
void *target,
void (*entry_wrapper)(
void *),
115 template <
typename T,
void (T::*START_MTHD)(
void)>
120#ifdef REALM_USE_USER_THREADS
123 template <
typename T,
void (T::*START_MTHD)(
void)>
182#ifdef REALM_USE_USER_THREADS
186 static void user_switch(
Thread *switch_to);
190 static bool test_user_switch_support(
size_t stack_size = 1 << 20);
193 template <
typename CONDTYPE>
215 template <
class CONDTYPE>
237 PAPICounters *papi_counters;
400 std::map<CoreReservation *, CoreReservation::Allocation *>
allocations;
421 std::map<int, size_t> event_codes;
422 std::vector<long long> event_counts;
436#include "realm/threads.inl"
ptrdiff_t alt_stack_size
Definition threads.h:326
CoreReservationParameters & set_alt_stack_size(ptrdiff_t new_alt_stack_size)
CoreUsage ldst_usage
Definition threads.h:323
CoreUsage fpu_usage
Definition threads.h:322
CoreReservationParameters & set_max_stack_size(ptrdiff_t new_max_stack_size)
CoreReservationParameters & set_ldst_usage(CoreUsage new_ldst_usage)
CoreReservationParameters & set_fpu_usage(CoreUsage new_fpu_usage)
static const int NUMA_DOMAIN_DONTCARE
Definition threads.h:313
static const ptrdiff_t ALTSTACK_SIZE_DEFAULT
Definition threads.h:316
CoreUsage alu_usage
Definition threads.h:321
ptrdiff_t max_stack_size
Definition threads.h:324
int num_cores
Definition threads.h:318
static const ptrdiff_t STACK_SIZE_DEFAULT
Definition threads.h:314
int numa_domain
Definition threads.h:319
CoreUsage
Definition threads.h:306
@ CORE_USAGE_SHARED
Definition threads.h:309
@ CORE_USAGE_NONE
Definition threads.h:307
@ CORE_USAGE_EXCLUSIVE
Definition threads.h:310
@ CORE_USAGE_MINIMAL
Definition threads.h:308
ptrdiff_t max_heap_size
Definition threads.h:325
CoreReservationParameters & set_alu_usage(CoreUsage new_alu_usage)
CoreReservationParameters & set_num_cores(int new_num_cores)
CoreReservationParameters & set_numa_domain(int new_numa_domain)
CoreReservationParameters(void)
static const ptrdiff_t HEAP_SIZE_DEFAULT
Definition threads.h:315
CoreReservationParameters & set_max_heap_size(ptrdiff_t new_max_heap_size)
bool satisfy_reservations(bool dummy_reservation_ok=false)
CoreReservationSet(const HardwareTopology *_cm)
void report_reservations(std::ostream &os) const
const HardwareTopology * get_core_map(void) const
std::map< CoreReservation *, CoreReservation::Allocation * > allocations
Definition threads.h:400
const HardwareTopology * cm
Definition threads.h:399
~CoreReservationSet(void)
void add_reservation(CoreReservation &rsrv)
virtual void notify_allocation(const CoreReservation &rsrv)=0
virtual ~NotificationListener(void)
Definition threads.h:354
CoreReservation(const std::string &_name, CoreReservationSet &crs, const CoreReservationParameters &_params)
std::list< NotificationListener * > listeners
Definition threads.h:378
Allocation * allocation
Definition threads.h:372
friend std::ostream & operator<<(std::ostream &stream, const CoreReservation &core_resv)
bool set_affinity(int begin=-1, int end=-1)
CoreReservationParameters params
Definition threads.h:369
void add_listener(NotificationListener *listener)
std::string name
Definition threads.h:368
void notify_listeners(void)
void unlock(void)
Definition threads.h:431
void lock(void)
Definition threads.h:430
Represents the topology of the host processor cores and memory.
Definition hardware_topology.h:38
Definition operation.h:32
Definition profiling.h:393
static const ptrdiff_t STACK_SIZE_DEFAULT
Definition threads.h:275
ptrdiff_t alt_stack_size
Definition threads.h:281
ThreadLaunchParameters & set_stack_size(ptrdiff_t new_stack_size)
ptrdiff_t stack_size
Definition threads.h:279
ThreadLaunchParameters & set_heap_size(ptrdiff_t new_heap_size)
static const ptrdiff_t ALTSTACK_SIZE_DEFAULT
Definition threads.h:277
static const ptrdiff_t HEAP_SIZE_DEFAULT
Definition threads.h:276
ThreadLaunchParameters(void)
ThreadLaunchParameters & set_alt_stack_size(ptrdiff_t new_alt_stack_size)
ptrdiff_t heap_size
Definition threads.h:280
bool try_update_thread_state(Thread *thread, Thread::State old_state, Thread::State new_state)
virtual void thread_terminating(Thread *thread)=0
virtual void thread_blocking(Thread *thread)=0
virtual ~ThreadScheduler(void)
virtual void thread_starting(Thread *thread)=0
Thread::State update_thread_state(Thread *thread, Thread::State new_state)
virtual void set_thread_priority(Thread *thread, int new_priority)=0
virtual void thread_ready(Thread *thread)=0
ExceptionHandlerPresence(void)
~ExceptionHandlerPresence(void)
Thread::State update_state(Thread::State new_state)
atomic< int > signal_count
Definition threads.h:232
int exception_handler_count
Definition threads.h:231
friend class ThreadWaker
Definition threads.h:216
State
Definition threads.h:132
@ STATE_RUNNING
Definition threads.h:135
@ STATE_CREATED
Definition threads.h:133
@ STATE_ALERTED
Definition threads.h:138
@ STATE_BLOCKING
Definition threads.h:136
@ STATE_BLOCKED
Definition threads.h:137
@ STATE_FINISHED
Definition threads.h:140
@ STATE_DELETED
Definition threads.h:141
@ STATE_READY
Definition threads.h:139
@ STATE_STARTUP
Definition threads.h:134
void record_perf_counters(ProfilingMeasurementCollection &pmc)
static Thread * create_kernel_thread(T *target, const ThreadLaunchParameters ¶ms, CoreReservation &rsrv, ThreadScheduler *_scheduler=0)
void set_priority(int new_priority)
void process_signals(void)
Operation * get_operation(void) const
atomic< State > state
Definition threads.h:228
Signal
Definition threads.h:147
@ TSIG_INTERRUPT
Definition threads.h:150
@ TSIG_NONE
Definition threads.h:148
@ TSIG_SHOW_BACKTRACE
Definition threads.h:149
static void wait_for_condition(const CONDTYPE &cond, bool &poisoned)
static Thread * self(void)
static void thread_entry_wrapper(void *obj)
virtual void detach(void)=0
static Thread * create_kernel_thread_untyped(void *target, void(*entry_wrapper)(void *), const ThreadLaunchParameters ¶ms, CoreReservation &rsrv, ThreadScheduler *_scheduler)
void start_perf_counters(void)
Thread(ThreadScheduler *_scheduler)
bool try_update_state(Thread::State old_state, Thread::State new_state)
bool exceptions_permitted(void) const
std::deque< Signal > signal_queue
Definition threads.h:234
Mutex signal_mutex
Definition threads.h:233
void stop_operation(Operation *op)
ThreadScheduler * scheduler
Definition threads.h:229
virtual void alert_thread(void)=0
void signal(Signal sig, bool asynchronous)
void setup_perf_counters(const ProfilingMeasurementCollection &pmc)
Operation * current_op
Definition threads.h:230
virtual void join(void)=0
void stop_perf_counters(void)
void start_operation(Operation *op)
Definition activemsg.h:38