Skip to content

Commit

Permalink
Extended stabilizer simulator no longer shares RngEngine amongst stat…
Browse files Browse the repository at this point in the history
…es when ops are applied in parallel
  • Loading branch information
eliotheinrich committed Nov 7, 2023
1 parent e31ff65 commit d693556
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -463,17 +463,24 @@ template <typename InputIterator>
void State::apply_ops_parallel(InputIterator first, InputIterator last,
ExperimentResult &result, RngEngine &rng) {
const int_t NUM_STATES = BaseState::qreg_.get_num_states();

std::vector<size_t> rng_seeds(NUM_STATES);
for (int_t i = 0; i < NUM_STATES; i++) {
rng_seeds[i] = size_t(rng.rand_int(0ULL, 18446744073709551615ULL));
}

#pragma omp parallel for if (BaseState::qreg_.check_omp_threshold() && \
BaseState::threads_ > 1) \
num_threads(BaseState::threads_)
for (int_t i = 0; i < NUM_STATES; i++) {
if (!BaseState::qreg_.check_eps(i)) {
continue;
}
RngEngine local_rng(rng_seeds[i]);
for (auto it = first; it != last; it++) {
switch (it->type) {
case Operations::OpType::gate:
apply_gate(*it, rng, i);
apply_gate(*it, local_rng, i);
break;
case Operations::OpType::barrier:
case Operations::OpType::qerror_loc:
Expand Down

0 comments on commit d693556

Please sign in to comment.