COIPIPELINE Engine::get_pipeline(void) { Thread* thread = (Thread*) thread_getspecific(mic_thread_key); if (thread == 0) { thread = new Thread(&m_proc_number); thread_setspecific(mic_thread_key, thread); } COIPIPELINE pipeline = thread->get_pipeline(m_index); if (pipeline == 0) { COIRESULT res; int proc_num; #ifndef TARGET_WINNT proc_num = __sync_fetch_and_add(&m_proc_number, 1); #else // TARGET_WINNT proc_num = _InterlockedIncrement(&m_proc_number); #endif // TARGET_WINNT if (proc_num > COI_PIPELINE_MAX_PIPELINES) { LIBOFFLOAD_ERROR(c_coipipe_max_number, COI_PIPELINE_MAX_PIPELINES); LIBOFFLOAD_ABORT; } // create pipeline for this thread res = COI::PipelineCreate(m_process, 0, mic_stack_size, &pipeline); check_result(res, c_pipeline_create, m_index, res); thread->set_pipeline(m_index, pipeline); } return pipeline; }
AutoSet& Engine::get_auto_vars(void) { Thread* thread = (Thread*) thread_getspecific(mic_thread_key); if (thread == 0) { thread = new Thread(&m_proc_number); thread_setspecific(mic_thread_key, thread); } return thread->get_auto_vars(); }
uint64_t Engine::get_thread_id(void) { Thread* thread = (Thread*) thread_getspecific(mic_thread_key); if (thread == 0) { thread = new Thread(&m_proc_number); thread_setspecific(mic_thread_key, thread); } return reinterpret_cast<uint64_t>(thread); }
void xpush_context(xcontext_t *context) { xcontext_t *top_context; thread_once(&exception_stack_key_once, *exception_stack_alloc); top_context = (xcontext_t *)thread_getspecific(exception_stack_key); context->next = top_context; thread_setspecific(exception_stack_key, context); context->handled = true; context->in_finally = false; }
void xpop_context() { xcontext_t *top_cxt, *context; thread_once(&exception_stack_key_once, *exception_stack_alloc); top_cxt = (xcontext_t *)thread_getspecific(exception_stack_key); context = top_cxt->next; thread_setspecific(exception_stack_key, context); if (!top_cxt->handled) { if (context) { xraise_context(context, top_cxt->excode, top_cxt->msg); } else { XEXIT(ERROR_TYPES[top_cxt->excode], top_cxt->msg); } } }
void xraise(int excode, const char *const msg) { xcontext_t *top_context; thread_once(&exception_stack_key_once, *exception_stack_alloc); top_context = (xcontext_t *)thread_getspecific(exception_stack_key); if (!top_context) { XEXIT(ERROR_TYPES[excode], msg); } else if (!top_context->in_finally) { xraise_context(top_context, excode, msg); } else if (top_context->handled) { top_context->msg = msg; top_context->excode = excode; top_context->handled = false; } }