75 } 76 } 77 } 78 79 void TaskQueueStats::print(outputStream* stream, unsigned int width) const 80 { 81 #define FMT SIZE_FORMAT_W(*) 82 stream->print(FMT, width, _stats[0]); 83 for (unsigned int i = 1; i < last_stat_id; ++i) { 84 stream->print(" " FMT, width, _stats[i]); 85 } 86 #undef FMT 87 } 88 89 #ifdef ASSERT 90 // Invariants which should hold after a TaskQueue has been emptied and is 91 // quiescent; they do not hold at arbitrary times. 92 void TaskQueueStats::verify() const 93 { 94 assert(get(push) == get(pop) + get(steal), 95 err_msg("push=" SIZE_FORMAT " pop=" SIZE_FORMAT " steal=" SIZE_FORMAT, 96 get(push), get(pop), get(steal))); 97 assert(get(pop_slow) <= get(pop), 98 err_msg("pop_slow=" SIZE_FORMAT " pop=" SIZE_FORMAT, 99 get(pop_slow), get(pop))); 100 assert(get(steal) <= get(steal_attempt), 101 err_msg("steal=" SIZE_FORMAT " steal_attempt=" SIZE_FORMAT, 102 get(steal), get(steal_attempt))); 103 assert(get(overflow) == 0 || get(push) != 0, 104 err_msg("overflow=" SIZE_FORMAT " push=" SIZE_FORMAT, 105 get(overflow), get(push))); 106 assert(get(overflow_max_len) == 0 || get(overflow) != 0, 107 err_msg("overflow_max_len=" SIZE_FORMAT " overflow=" SIZE_FORMAT, 108 get(overflow_max_len), get(overflow))); 109 } 110 #endif // ASSERT 111 #endif // TASKQUEUE_STATS 112 113 int TaskQueueSetSuper::randomParkAndMiller(int *seed0) { 114 const int a = 16807; 115 const int m = 2147483647; 116 const int q = 127773; /* m div a */ 117 const int r = 2836; /* m mod a */ 118 assert(sizeof(int) == 4, "I think this relies on that"); 119 int seed = *seed0; 120 int hi = seed / q; 121 int lo = seed % q; 122 int test = a * lo - r * hi; 123 if (test > 0) 124 seed = test; 125 else 126 seed = test + m; 127 *seed0 = seed; 128 return seed; | 75 } 76 } 77 } 78 79 void TaskQueueStats::print(outputStream* stream, unsigned int width) const 80 { 81 #define FMT SIZE_FORMAT_W(*) 82 stream->print(FMT, width, _stats[0]); 83 for (unsigned int i = 1; i < last_stat_id; ++i) { 84 stream->print(" " FMT, width, _stats[i]); 85 } 86 #undef FMT 87 } 88 89 #ifdef ASSERT 90 // Invariants which should hold after a TaskQueue has been emptied and is 91 // quiescent; they do not hold at arbitrary times. 92 void TaskQueueStats::verify() const 93 { 94 assert(get(push) == get(pop) + get(steal), 95 "push=" SIZE_FORMAT " pop=" SIZE_FORMAT " steal=" SIZE_FORMAT, 96 get(push), get(pop), get(steal)); 97 assert(get(pop_slow) <= get(pop), 98 "pop_slow=" SIZE_FORMAT " pop=" SIZE_FORMAT, 99 get(pop_slow), get(pop)); 100 assert(get(steal) <= get(steal_attempt), 101 "steal=" SIZE_FORMAT " steal_attempt=" SIZE_FORMAT, 102 get(steal), get(steal_attempt)); 103 assert(get(overflow) == 0 || get(push) != 0, 104 "overflow=" SIZE_FORMAT " push=" SIZE_FORMAT, 105 get(overflow), get(push)); 106 assert(get(overflow_max_len) == 0 || get(overflow) != 0, 107 "overflow_max_len=" SIZE_FORMAT " overflow=" SIZE_FORMAT, 108 get(overflow_max_len), get(overflow)); 109 } 110 #endif // ASSERT 111 #endif // TASKQUEUE_STATS 112 113 int TaskQueueSetSuper::randomParkAndMiller(int *seed0) { 114 const int a = 16807; 115 const int m = 2147483647; 116 const int q = 127773; /* m div a */ 117 const int r = 2836; /* m mod a */ 118 assert(sizeof(int) == 4, "I think this relies on that"); 119 int seed = *seed0; 120 int hi = seed / q; 121 int lo = seed % q; 122 int test = a * lo - r * hi; 123 if (test > 0) 124 seed = test; 125 else 126 seed = test + m; 127 *seed0 = seed; 128 return seed; |