src/share/vm/utilities/taskqueue.hpp

changeset 1
2d8a650513c2
parent 0
f90c822e73f8
child 25
873fd82b133d
     1.1 --- a/src/share/vm/utilities/taskqueue.hpp	Wed Apr 27 01:25:04 2016 +0800
     1.2 +++ b/src/share/vm/utilities/taskqueue.hpp	Fri Apr 29 00:06:10 2016 +0800
     1.3 @@ -22,6 +22,12 @@
     1.4   *
     1.5   */
     1.6  
     1.7 +/*
     1.8 + * This file has been modified by Loongson Technology in 2015. These
     1.9 + * modifications are Copyright (c) 2015 Loongson Technology, and are made
    1.10 + * available on the same license terms set forth above.
    1.11 + */
    1.12 +
    1.13  #ifndef SHARE_VM_UTILITIES_TASKQUEUE_HPP
    1.14  #define SHARE_VM_UTILITIES_TASKQUEUE_HPP
    1.15  
    1.16 @@ -588,15 +594,34 @@
    1.17  template<class T, MEMFLAGS F> bool
    1.18  GenericTaskQueueSet<T, F>::steal_best_of_2(uint queue_num, int* seed, E& t) {
    1.19    if (_n > 2) {
    1.20 -    uint k1 = queue_num;
    1.21 -    while (k1 == queue_num) k1 = TaskQueueSetSuper::randomParkAndMiller(seed) % _n;
    1.22 -    uint k2 = queue_num;
    1.23 -    while (k2 == queue_num || k2 == k1) k2 = TaskQueueSetSuper::randomParkAndMiller(seed) % _n;
    1.24 -    // Sample both and try the larger.
    1.25 -    uint sz1 = _queues[k1]->size();
    1.26 -    uint sz2 = _queues[k2]->size();
    1.27 -    if (sz2 > sz1) return _queues[k2]->pop_global(t);
    1.28 -    else return _queues[k1]->pop_global(t);
    1.29 +    if(UseNUMASteal) {
    1.30 +      uint i = 10;
    1.31 +      uint k = queue_num;
    1.32 +      while ((k == queue_num || (k - queue_num) > 3 || (queue_num - k) > 3) && i > 0) {
    1.33 +        i--;
    1.34 +        k = TaskQueueSetSuper::randomParkAndMiller(seed) % _n;
    1.35 +      }
    1.36 +      if(i > 0) {
    1.37 +        return _queues[k]->pop_global(t);
    1.38 +      }
    1.39 +      else {
    1.40 +         while (k == queue_num) { 
    1.41 +           k = TaskQueueSetSuper::randomParkAndMiller(seed) % _n;
    1.42 +         }
    1.43 +         return _queues[k]->pop_global(t);
    1.44 +      }
    1.45 +    }
    1.46 +    else{
    1.47 +      uint k1 = queue_num;
    1.48 +      while (k1 == queue_num) k1 = TaskQueueSetSuper::randomParkAndMiller(seed) % _n;
    1.49 +      uint k2 = queue_num;
    1.50 +      while (k2 == queue_num || k2 == k1) k2 = TaskQueueSetSuper::randomParkAndMiller(seed) % _n;
    1.51 +      // Sample both and try the larger.
    1.52 +      uint sz1 = _queues[k1]->size();
    1.53 +      uint sz2 = _queues[k2]->size();
    1.54 +      if (sz2 > sz1) return _queues[k2]->pop_global(t);
    1.55 +      else return _queues[k1]->pop_global(t);
    1.56 +    }
    1.57    } else if (_n == 2) {
    1.58      // Just try the other one.
    1.59      uint k = (queue_num + 1) % 2;

mercurial