8022784: TaskQueue misses minimal documentation and references for analysis

Add appropriate documentation and references to publication to allow easier analysis of the TaskQueue implementation.

Reviewed-by: dholmes, ehelin
This commit is contained in:
Thomas Schatzl 2013-08-21 10:32:02 +02:00
parent 4fe3c66318
commit ae7845053f

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -132,6 +132,8 @@ void TaskQueueStats::reset() {
} }
#endif // TASKQUEUE_STATS #endif // TASKQUEUE_STATS
// TaskQueueSuper collects functionality common to all GenericTaskQueue instances.
template <unsigned int N, MEMFLAGS F> template <unsigned int N, MEMFLAGS F>
class TaskQueueSuper: public CHeapObj<F> { class TaskQueueSuper: public CHeapObj<F> {
protected: protected:
@ -249,7 +251,36 @@ public:
TASKQUEUE_STATS_ONLY(TaskQueueStats stats;) TASKQUEUE_STATS_ONLY(TaskQueueStats stats;)
}; };
//
// GenericTaskQueue implements an ABP, Aurora-Blumofe-Plaxton, double-
// ended-queue (deque), intended for use in work stealing. Queue operations
// are non-blocking.
//
// A queue owner thread performs push() and pop_local() operations on one end
// of the queue, while other threads may steal work using the pop_global()
// method.
//
// The main difference to the original algorithm is that this
// implementation allows wrap-around at the end of its allocated
// storage, which is an array.
//
// The original paper is:
//
// Arora, N. S., Blumofe, R. D., and Plaxton, C. G.
// Thread scheduling for multiprogrammed multiprocessors.
// Theory of Computing Systems 34, 2 (2001), 115-144.
//
// The following paper provides an correctness proof and an
// implementation for weakly ordered memory models including (pseudo-)
// code containing memory barriers for a Chase-Lev deque. Chase-Lev is
// similar to ABP, with the main difference that it allows resizing of the
// underlying storage:
//
// Le, N. M., Pop, A., Cohen A., and Nardell, F. Z.
// Correct and efficient work-stealing for weak memory models
// Proceedings of the 18th ACM SIGPLAN symposium on Principles and
// practice of parallel programming (PPoPP 2013), 69-80
//
template <class E, MEMFLAGS F, unsigned int N = TASKQUEUE_SIZE> template <class E, MEMFLAGS F, unsigned int N = TASKQUEUE_SIZE>
class GenericTaskQueue: public TaskQueueSuper<N, F> { class GenericTaskQueue: public TaskQueueSuper<N, F> {