src/share/vm/utilities/taskqueue.hpp

changeset 25
873fd82b133d
parent 1
2d8a650513c2
child 133
a087cf8abe24
equal deleted inserted replaced
24:d2be62fdfa50 25:873fd82b133d
18 * 18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any 20 * or visit www.oracle.com if you need additional information or have any
21 * questions. 21 * questions.
22 * 22 *
23 */
24
25 /*
26 * This file has been modified by Loongson Technology in 2015. These
27 * modifications are Copyright (c) 2015 Loongson Technology, and are made
28 * available on the same license terms set forth above.
29 */ 23 */
30 24
31 #ifndef SHARE_VM_UTILITIES_TASKQUEUE_HPP 25 #ifndef SHARE_VM_UTILITIES_TASKQUEUE_HPP
32 #define SHARE_VM_UTILITIES_TASKQUEUE_HPP 26 #define SHARE_VM_UTILITIES_TASKQUEUE_HPP
33 27
592 } 586 }
593 587
594 template<class T, MEMFLAGS F> bool 588 template<class T, MEMFLAGS F> bool
595 GenericTaskQueueSet<T, F>::steal_best_of_2(uint queue_num, int* seed, E& t) { 589 GenericTaskQueueSet<T, F>::steal_best_of_2(uint queue_num, int* seed, E& t) {
596 if (_n > 2) { 590 if (_n > 2) {
597 if(UseNUMASteal) { 591 uint k1 = queue_num;
598 uint i = 10; 592 while (k1 == queue_num) k1 = TaskQueueSetSuper::randomParkAndMiller(seed) % _n;
599 uint k = queue_num; 593 uint k2 = queue_num;
600 while ((k == queue_num || (k - queue_num) > 3 || (queue_num - k) > 3) && i > 0) { 594 while (k2 == queue_num || k2 == k1) k2 = TaskQueueSetSuper::randomParkAndMiller(seed) % _n;
601 i--; 595 // Sample both and try the larger.
602 k = TaskQueueSetSuper::randomParkAndMiller(seed) % _n; 596 uint sz1 = _queues[k1]->size();
603 } 597 uint sz2 = _queues[k2]->size();
604 if(i > 0) { 598 if (sz2 > sz1) return _queues[k2]->pop_global(t);
605 return _queues[k]->pop_global(t); 599 else return _queues[k1]->pop_global(t);
606 }
607 else {
608 while (k == queue_num) {
609 k = TaskQueueSetSuper::randomParkAndMiller(seed) % _n;
610 }
611 return _queues[k]->pop_global(t);
612 }
613 }
614 else{
615 uint k1 = queue_num;
616 while (k1 == queue_num) k1 = TaskQueueSetSuper::randomParkAndMiller(seed) % _n;
617 uint k2 = queue_num;
618 while (k2 == queue_num || k2 == k1) k2 = TaskQueueSetSuper::randomParkAndMiller(seed) % _n;
619 // Sample both and try the larger.
620 uint sz1 = _queues[k1]->size();
621 uint sz2 = _queues[k2]->size();
622 if (sz2 > sz1) return _queues[k2]->pop_global(t);
623 else return _queues[k1]->pop_global(t);
624 }
625 } else if (_n == 2) { 600 } else if (_n == 2) {
626 // Just try the other one. 601 // Just try the other one.
627 uint k = (queue_num + 1) % 2; 602 uint k = (queue_num + 1) % 2;
628 return _queues[k]->pop_global(t); 603 return _queues[k]->pop_global(t);
629 } else { 604 } else {

mercurial