@@ -97,12 +97,8 @@ void ProcessBankTask::operator()(const tbb::blocked_range<size_t> &range) const
97
97
98
98
// std::atomic allows for multi-threaded accumulation and who cares about floats when you are just
99
99
// counting things
100
- std::vector<std::atomic_uint32_t > y_temp (spectrum.dataY ().size ());
101
- // std::vector<uint32_t> y_temp(spectrum.dataY().size());
102
-
103
- // task group allows for separate of disk read from processing
104
- tbb::task_group_context tgroupcontext; // needed by parallel_reduce
105
- tbb::task_group tgroup (tgroupcontext);
100
+ // std::vector<std::atomic_uint32_t> y_temp(spectrum.dataY().size())
101
+ std::vector<uint32_t > y_temp (spectrum.dataY ().size ());
106
102
107
103
// create object so bank calibration can be re-used
108
104
std::unique_ptr<BankCalibration> calibration = nullptr ;
@@ -187,16 +183,12 @@ void ProcessBankTask::operator()(const tbb::blocked_range<size_t> &range) const
187
183
188
184
// Non-blocking processing of the events
189
185
const tbb::blocked_range<size_t > range_info (0 , event_time_of_flight->size (), m_grainsize_event);
190
- tbb::parallel_reduce (range_info, task, tgroupcontext );
186
+ tbb::parallel_reduce (range_info, task);
191
187
192
- // Atomically accumulate results into shared y_temp to combine local histograms
193
- for (size_t i = 0 ; i < y_temp.size (); ++i) {
194
- y_temp[i].fetch_add (task.y_temp [i], std::memory_order_relaxed);
195
- }
188
+ // Accumulate results into shared y_temp to combine local histograms
189
+ std::transform (y_temp.begin (), y_temp.end (), task.y_temp .begin (), y_temp.begin (), std::plus<uint32_t >());
196
190
}
197
191
198
- tgroup.wait ();
199
-
200
192
// copy the data out into the correct spectrum
201
193
auto &y_values = spectrum.dataY ();
202
194
std::copy (y_temp.cbegin (), y_temp.cend (), y_values.begin ());
0 commit comments