src/share/vm/utilities/taskqueue.hpp

changeset 1
2d8a650513c2
parent 0
f90c822e73f8
child 25
873fd82b133d
equal deleted inserted replaced
0:f90c822e73f8 1:2d8a650513c2
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.
23 */ 29 */
24 30
25 #ifndef SHARE_VM_UTILITIES_TASKQUEUE_HPP 31 #ifndef SHARE_VM_UTILITIES_TASKQUEUE_HPP
26 #define SHARE_VM_UTILITIES_TASKQUEUE_HPP 32 #define SHARE_VM_UTILITIES_TASKQUEUE_HPP
27 33
586 } 592 }
587 593
588 template<class T, MEMFLAGS F> bool 594 template<class T, MEMFLAGS F> bool
589 GenericTaskQueueSet<T, F>::steal_best_of_2(uint queue_num, int* seed, E& t) { 595 GenericTaskQueueSet<T, F>::steal_best_of_2(uint queue_num, int* seed, E& t) {
590 if (_n > 2) { 596 if (_n > 2) {
591 uint k1 = queue_num; 597 if(UseNUMASteal) {
592 while (k1 == queue_num) k1 = TaskQueueSetSuper::randomParkAndMiller(seed) % _n; 598 uint i = 10;
593 uint k2 = queue_num; 599 uint k = queue_num;
594 while (k2 == queue_num || k2 == k1) k2 = TaskQueueSetSuper::randomParkAndMiller(seed) % _n; 600 while ((k == queue_num || (k - queue_num) > 3 || (queue_num - k) > 3) && i > 0) {
595 // Sample both and try the larger. 601 i--;
596 uint sz1 = _queues[k1]->size(); 602 k = TaskQueueSetSuper::randomParkAndMiller(seed) % _n;
597 uint sz2 = _queues[k2]->size(); 603 }
598 if (sz2 > sz1) return _queues[k2]->pop_global(t); 604 if(i > 0) {
599 else return _queues[k1]->pop_global(t); 605 return _queues[k]->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 }
600 } else if (_n == 2) { 625 } else if (_n == 2) {
601 // Just try the other one. 626 // Just try the other one.
602 uint k = (queue_num + 1) % 2; 627 uint k = (queue_num + 1) % 2;
603 return _queues[k]->pop_global(t); 628 return _queues[k]->pop_global(t);
604 } else { 629 } else {

mercurial