Skip to content

Commit 66e7d86

Browse files
GuyStenpaulromano
andauthored
Remove several TODOs related to C++17 support (#3574)
Co-authored-by: Paul Romano <[email protected]>
1 parent ed433fe commit 66e7d86

File tree

3 files changed

+11
-18
lines changed

3 files changed

+11
-18
lines changed

src/bank.cpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,9 @@ void sort_fission_bank()
7979

8080
// Perform exclusive scan summation to determine starting indices in fission
8181
// bank for each parent particle id
82-
int64_t tmp = simulation::progeny_per_particle[0];
83-
simulation::progeny_per_particle[0] = 0;
84-
for (int64_t i = 1; i < simulation::progeny_per_particle.size(); i++) {
85-
int64_t value = simulation::progeny_per_particle[i - 1] + tmp;
86-
tmp = simulation::progeny_per_particle[i];
87-
simulation::progeny_per_particle[i] = value;
88-
}
89-
90-
// TODO: C++17 introduces the exclusive_scan() function which could be
91-
// used to replace everything above this point in this function.
82+
std::exclusive_scan(simulation::progeny_per_particle.begin(),
83+
simulation::progeny_per_particle.end(),
84+
simulation::progeny_per_particle.begin(), 0);
9285

9386
// We need a scratch vector to make permutation of the fission bank into
9487
// sorted order easy. Under normal usage conditions, the fission bank is

src/event.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "openmc/event.h"
2+
23
#include "openmc/material.h"
34
#include "openmc/simulation.h"
45
#include "openmc/timer.h"
@@ -73,17 +74,17 @@ void process_calculate_xs_events(SharedArray<EventQueueItem>& queue)
7374
{
7475
simulation::time_event_calculate_xs.start();
7576

76-
// TODO: If using C++17, perform a parallel sort of the queue
77-
// by particle type, material type, and then energy, in order to
78-
// improve cache locality and reduce thread divergence on GPU. Prior
79-
// to C++17, std::sort is a serial only operation, which in this case
80-
// makes it too slow to be practical for most test problems.
77+
// TODO: If using C++17, we could perform a parallel sort of the queue by
78+
// particle type, material type, and then energy, in order to improve cache
79+
// locality and reduce thread divergence on GPU. However, the parallel
80+
// algorithms typically require linking against an additional library (Intel
81+
// TBB). Prior to C++17, std::sort is a serial only operation, which in this
82+
// case makes it too slow to be practical for most test problems.
8183
//
8284
// std::sort(std::execution::par_unseq, queue.data(), queue.data() +
8385
// queue.size());
8486

8587
int64_t offset = simulation::advance_particle_queue.size();
86-
;
8788

8889
#pragma omp parallel for schedule(runtime)
8990
for (int64_t i = 0; i < queue.size(); i++) {

src/hdf5_interface.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,7 @@ void get_name(hid_t obj_id, std::string& name)
225225
{
226226
size_t size = 1 + H5Iget_name(obj_id, nullptr, 0);
227227
name.resize(size);
228-
// TODO: switch to name.data() when using C++17
229-
H5Iget_name(obj_id, &name[0], size);
228+
H5Iget_name(obj_id, name.data(), size);
230229
}
231230

232231
int get_num_datasets(hid_t group_id)

0 commit comments

Comments
 (0)