Skip to content

Commit

Permalink
Add constexpr std::size_t indices for amrex::get
Browse files Browse the repository at this point in the history
We had MSVC (only on Windows) compile errors and this commit tries to fix them.
  • Loading branch information
n01r committed Mar 26, 2024
1 parent 555fada commit 75aa701
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/particles/diagnostics/ReducedBeamCharacteristics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ namespace impactx::diagnostics
using PType = typename ImpactXParticleContainer::SuperParticleType;

// numbers of same type reduction operations in first concurrent batch
constexpr size_t num_red_ops_1_sum = 7; // summation
constexpr size_t num_red_ops_1_min = 6; // minimum
constexpr size_t num_red_ops_1_max = 6; // maximum
constexpr std::size_t num_red_ops_1_sum = 7; // summation
constexpr std::size_t num_red_ops_1_min = 6; // minimum
constexpr std::size_t num_red_ops_1_max = 6; // maximum

// prepare reduction operations for calculation of mean and min/max values in 6D phase space
amrex::TypeMultiplier<amrex::ReduceOps,
Expand Down Expand Up @@ -115,7 +115,8 @@ namespace impactx::diagnostics
* px_min, py_min, pt_min
*/
amrex::constexpr_for<0, num_red_ops_1_min> ([&](auto i) {
values_per_rank_min[i] = amrex::get<i + num_red_ops_1_sum>(r1);
constexpr std::size_t idx = i + num_red_ops_1_sum;
values_per_rank_min[i] = amrex::get<idx>(r1);
});

std::vector<amrex::ParticleReal> values_per_rank_max(num_red_ops_1_max);
Expand All @@ -125,7 +126,8 @@ namespace impactx::diagnostics
* px_max, py_max, pt_max
*/
amrex::constexpr_for<0, num_red_ops_1_max> ([&](auto i) {
values_per_rank_max[i] = amrex::get<i + num_red_ops_1_sum + num_red_ops_1_min>(r1);
constexpr std::size_t idx = i + num_red_ops_1_sum + num_red_ops_1_min;
values_per_rank_max[i] = amrex::get<idx>(r1);
});

// reduced sum over mpi ranks (allreduce)
Expand All @@ -143,7 +145,7 @@ namespace impactx::diagnostics
);

// number of reduction operations in second concurrent batch
constexpr size_t num_red_ops_2 = 10;
constexpr std::size_t num_red_ops_2 = 10;
// prepare reduction operations for calculation of mean square and correlation values
amrex::TypeMultiplier<amrex::ReduceOps, amrex::ReduceOpSum[num_red_ops_2]> reduce_ops_2;
using ReducedDataT2 = amrex::TypeMultiplier<amrex::ReduceData, amrex::ParticleReal[num_red_ops_2]>;
Expand Down

0 comments on commit 75aa701

Please sign in to comment.