18#ifndef REALM_PYTHON_INTERNAL_H
19#define REALM_PYTHON_INTERNAL_H
25#if defined(REALM_USE_OPENMP) && !defined(REALM_OPENMP_SYSTEM_RUNTIME)
31#define USE_PYGILSTATE_CALLS
35 struct PyInterpreterState;
43#ifdef USE_PYGILSTATE_CALLS
58 void get_symbol(T &fn,
const char *symbol,
bool missing_ok =
false);
69 PyObject *(*PyByteArray_FromStringAndSize)(
const char *,
Py_ssize_t);
73#ifdef USE_PYGILSTATE_CALLS
87 PyObject *(*PyThreadState_GetDict)(void);
91 PyObject *(*PyImport_ImportModule)(
const char *);
93 PyObject *(*PyModule_GetDict)(PyObject *);
95 PyObject *(*PyLong_FromUnsignedLong)(
unsigned long);
97 PyObject *(*PyObject_CallFunction)(PyObject *,
const char *, ...);
98 PyObject *(*PyObject_CallObject)(PyObject *callable, PyObject *args);
99 PyObject *(*PyObject_GetAttrString)(PyObject *,
const char *);
103 PyObject *(*Py_CompileString)(
const char *,
const char *, int);
104 PyObject *(*PyEval_EvalCode)(PyObject *, PyObject *, PyObject *);
123#ifdef REALM_USE_DLMOPEN
124 void *dlmproxy_handle;
142 const std::vector<std::string> &_import_modules,
143 const std::vector<std::string> &_init_scripts);
194#if defined(REALM_USE_OPENMP) && !defined(REALM_OPENMP_SYSTEM_RUNTIME)
Definition bytearray.h:30
Definition bytearray.h:53
Definition codedesc.h:249
unsigned gen_t
Definition event_impl.h:87
Definition event_impl.h:198
Definition python_internal.h:171
virtual void execute_on_processor(Processor p)
Definition python_internal.h:175
LocalPythonProcessor * proc
Definition python_internal.h:180
CodeDescriptor * codedesc
Definition python_internal.h:182
virtual ~TaskRegistration()
Definition python_internal.h:173
Processor::TaskFuncID func_id
Definition python_internal.h:181
ByteArray user_data
Definition python_internal.h:183
Definition python_internal.h:135
int numa_node
Definition python_internal.h:192
LocalPythonProcessor(RuntimeImpl *runtime_impl, Processor _me, int _numa_node, CoreReservationSet &crs, size_t _stack_size, const std::vector< std::string > &_import_modules, const std::vector< std::string > &_init_scripts)
virtual bool register_task(Processor::TaskFuncID func_id, CodeDescriptor &codedesc, const ByteArrayRef &user_data)
virtual void enqueue_task(Task *task)
virtual void start_threads(void)
std::map< Processor::TaskFuncID, TaskTableEntry > task_table
Definition python_internal.h:210
CoreReservation * core_rsrv
Definition python_internal.h:193
void create_interpreter(void)
void destroy_interpreter(void)
virtual void remove_from_group(ProcessorGroupImpl *group)
TaskQueue task_queue
Definition python_internal.h:212
virtual ~LocalPythonProcessor(void)
PyThreadState * master_thread
Definition python_internal.h:202
PythonInterpreter * interpreter
Definition python_internal.h:201
virtual void enqueue_tasks(Task::TaskList &tasks, size_t num_tasks)
virtual void spawn_task(Processor::TaskFuncID func_id, const void *args, size_t arglen, const ProfilingRequestSet &reqs, Event start_event, GenEventImpl *finish_event, EventImpl::gen_t finish_gen, int priority)
const std::vector< std::string > & import_modules
Definition python_internal.h:197
bool perform_task_registration(TaskRegistration *treg)
DeferredSpawnCache deferred_spawn_cache
Definition python_internal.h:214
virtual void execute_task(Processor::TaskFuncID func_id, const ByteArrayRef &task_args)
const std::vector< std::string > & init_scripts
Definition python_internal.h:198
ProfilingGauges::AbsoluteRangeGauge< int > ready_task_count
Definition python_internal.h:213
PythonThreadTaskScheduler * sched
Definition python_internal.h:200
virtual void shutdown(void)
virtual void add_to_group(ProcessorGroupImpl *group)
Definition proc_impl.h:254
Definition proc_impl.h:51
Definition processor.h:37
::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 sampling.h:111
Definition profiling.h:363
Definition python_internal.h:52
void(* Py_DecRef)(PyObject *)
Definition python_internal.h:65
void(* Py_Finalize)(void)
Definition python_internal.h:66
int(* PyTuple_SetItem)(PyObject *p, Py_ssize_t pos, PyObject *o)
Definition python_internal.h:107
void(* PyGILState_Release)(PyGILState_STATE)
Definition python_internal.h:75
void(* PyEval_InitThreads)(void)
Definition python_internal.h:71
void(* PyErr_PrintEx)(int set_sys_last_vars)
Definition python_internal.h:89
void(* PyEval_RestoreThread)(PyThreadState *)
Definition python_internal.h:81
void get_symbol(T &fn, const char *symbol, bool missing_ok=false)
PyGILState_STATE(* PyGILState_Ensure)(void)
Definition python_internal.h:74
void(* Py_InitializeEx)(int)
Definition python_internal.h:67
void * handle
Definition python_internal.h:61
Definition python_internal.h:110
PyObject * find_or_import_function(const PythonSourceImplementation *psi)
void * handle
Definition python_internal.h:122
PythonAPI * api
Definition python_internal.h:128
void import_module(const std::string &module_name)
void run_string(const std::string &script_text)
Definition python_source.h:25
Definition python_internal.h:229
virtual void execute_internal_task(InternalTask *task)
virtual void thread_ready(Thread *thread)
void python_scheduler_loop(void)
virtual bool execute_task(Task *task)
virtual void worker_terminate(Thread *switch_to)
bool interpreter_ready
Definition python_internal.h:251
PythonThreadTaskScheduler(LocalPythonProcessor *_pyproc, CoreReservation &_core_rsrv)
std::map< Thread *, PyThreadState * > pythreads
Definition python_internal.h:252
virtual Thread * worker_create(bool make_active)
LocalPythonProcessor * pyproc
Definition python_internal.h:250
virtual void thread_blocking(Thread *thread)
Definition runtime_impl.h:264
Definition openmp_threadpool.h:66
Definition activemsg.h:38
PyGILState_STATE
Definition python_internal.h:45
@ PyGILState_LOCKED
Definition python_internal.h:46
@ PyGILState_UNLOCKED
Definition python_internal.h:47
ssize_t Py_ssize_t
Definition python_internal.h:42
#define REALM_USE_OPENMP
Definition realm_defines.h:46
Definition python_internal.h:204
PyObject * python_fnptr
Definition python_internal.h:205
ByteArray user_data
Definition python_internal.h:207
Processor::TaskFuncPtr cpp_fnptr
Definition python_internal.h:206
Definition proc_impl.h:99
Definition python_internal.h:36
struct PyThreadState * next
Definition python_internal.h:38
struct PyThreadState * prev
Definition python_internal.h:37
struct PyInterpreterState * interp
Definition python_internal.h:39