class TaskQueueSetSuper; class TerminatorTerminator; class Thread;
/* *Providesataskterminationprotocol. * *ThisisanenhancedimplementationofGoogle'sOWSTworkstealingtasktermination *protocol(OWSTstandsforOptimizedWorkStealingThreads). * *Itisdescribedinthepaper: *"WessamHassanein.2016.UnderstandingandimprovingJVMGCwork *stealingatthedatacenterscale.InProceedingsofthe2016ACM *SIGPLANInternationalSymposiumonMemoryManagement(ISMM2016).ACM, *NewYork,NY,USA,46-54.DOI:https://doi.org/10.1145/2926697.2926706" * *Insteadofadedicatedspin-master,ourimplementationwillletspin-master *relinquishtherolebeforeitgoestosleep/wait,allowingnewlyarrived *threadstocompetefortherole. *Theintentionofaboveenhancementistoreducespin-master'slatencyon *detectingnewtasksforstealingandterminationcondition.
*/ class TaskTerminator : public CHeapObj<mtGC> { class DelayContext {
uint _yield_count; // Number of hard spin loops done since last yield
uint _hard_spin_count; // Number of iterations in the current hard spin loop.
uint _hard_spin_limit;
// Prepare for return from offer_termination. Gives up the spin master token // and wakes up up to tasks threads waiting on _blocker (the default value // means to wake up everyone). void prepare_for_return(Thread* this_thread, size_t tasks = SIZE_MAX);
// If we should exit current termination protocol bool exit_termination(size_t tasks, TerminatorTerminator* terminator);
size_t tasks_in_queue_set() const;
// Perform one iteration of spin-master work. void do_delay_step(DelayContext& delay_context);
// The current thread has no work, and is ready to terminate if everyone // else is. If returns "true", all threads are terminated. If returns // "false", available work has been observed in one of the task queues, // so the global task is not complete. bool offer_termination() { return offer_termination(NULL);
}
// As above, but it also terminates if the should_exit_termination() // method of the terminator parameter returns true. If terminator is // NULL, then it is ignored. bool offer_termination(TerminatorTerminator* terminator);
// Reset the terminator, so that it may be reused again. // The caller is responsible for ensuring that this is done // in an MT-safe manner, once the previous round of use of // the terminator is finished. void reset_for_reuse(); // Same as above but the number of parallel threads is set to the // given number. void reset_for_reuse(uint n_threads);
};
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.