93 template <typename T> 94 T WorkerDataArray<T>::sum() const { 95 T s = 0; 96 for (uint i = 0; i < _length; ++i) { 97 if (get(i) != uninitialized()) { 98 s += get(i); 99 } 100 } 101 return s; 102 } 103 104 template <typename T> 105 void WorkerDataArray<T>::set_all(T value) { 106 for (uint i = 0; i < _length; i++) { 107 _data[i] = value; 108 } 109 } 110 111 template <class T> 112 void WorkerDataArray<T>::print_summary_on(outputStream* out, bool print_sum) const { 113 uint start = 0; 114 while (get(start) == uninitialized()) { 115 assert(start < _length, "Printing unused WorkerDataArray."); 116 start++; 117 } 118 T min = get(start); 119 T max = min; 120 T sum = 0; 121 uint active_threads = 0; 122 for (uint i = start; i < _length; ++i) { 123 T value = get(i); 124 if (value != uninitialized()) { 125 max = MAX2(max, value); 126 min = MIN2(min, value); 127 sum += value; 128 active_threads++; 129 } 130 } 131 T diff = max - min; 132 assert(active_threads != 0, "Must be since we found a used value for the start index"); 133 double avg = sum / (double) active_threads; 134 WDAPrinter::summary(out, title(), min, avg, max, diff, sum, print_sum); 135 } 136 137 template <class T> 138 void WorkerDataArray<T>::print_details_on(outputStream* out) const { 139 WDAPrinter::details(this, out); 140 } 141 142 template <typename T> 143 void WorkerDataArray<T>::reset() { 144 set_all(uninitialized()); 145 if (_thread_work_items != NULL) { 146 _thread_work_items->reset(); 147 } 148 } 149 150 template <> 151 inline size_t WorkerDataArray<size_t>::uninitialized() const { 152 return (size_t)-1; 153 } 154 155 template <> 156 inline double WorkerDataArray<double>::uninitialized() const { 157 return -1.0; 158 } 159 160 #endif // SHARE_VM_GC_G1_WORKERDATAARRAY_INLINE_HPP | 93 template <typename T> 94 T WorkerDataArray<T>::sum() const { 95 T s = 0; 96 for (uint i = 0; i < _length; ++i) { 97 if (get(i) != uninitialized()) { 98 s += get(i); 99 } 100 } 101 return s; 102 } 103 104 template <typename T> 105 void WorkerDataArray<T>::set_all(T value) { 106 for (uint i = 0; i < _length; i++) { 107 _data[i] = value; 108 } 109 } 110 111 template <class T> 112 void WorkerDataArray<T>::print_summary_on(outputStream* out, bool print_sum) const { 113 out->print("%-25s", title()); 114 uint start = 0; 115 while (start < _length && get(start) == uninitialized()) { 116 start++; 117 } 118 if (start < _length) { 119 T min = get(start); 120 T max = min; 121 T sum = 0; 122 uint active_threads = 0; 123 for (uint i = start; i < _length; ++i) { 124 T value = get(i); 125 if (value != uninitialized()) { 126 max = MAX2(max, value); 127 min = MIN2(min, value); 128 sum += value; 129 active_threads++; 130 } 131 } 132 T diff = max - min; 133 assert(active_threads != 0, "Must be since we found a used value for the start index"); 134 double avg = sum / (double) active_threads; 135 WDAPrinter::summary(out, min, avg, max, diff, sum, print_sum); 136 out->print_cr(", Workers: %d", active_threads); 137 } else { 138 // No data for this phase. 139 out->print_cr(" skipped"); 140 } 141 } 142 143 template <class T> 144 void WorkerDataArray<T>::print_details_on(outputStream* out) const { 145 WDAPrinter::details(this, out); 146 } 147 148 template <typename T> 149 void WorkerDataArray<T>::reset() { 150 set_all(uninitialized()); 151 if (_thread_work_items != NULL) { 152 _thread_work_items->reset(); 153 } 154 } 155 156 #endif // SHARE_VM_GC_G1_WORKERDATAARRAY_INLINE_HPP |