Skip to content

Commit

Permalink
Update qubitvector to use Transformer class for apply_matrix and appl…
Browse files Browse the repository at this point in the history
…y_diagonal_matrix

Updates indexes to only use omp parallel if threads > 1, not > 0.
  • Loading branch information
chriseclectic committed Sep 29, 2020
1 parent 5ba5a2d commit 03f9465
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 325 deletions.
12 changes: 6 additions & 6 deletions src/simulators/statevector/indexes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ inline void apply_lambda(const size_t start,
const uint_t omp_threads,
Lambda&& func) {

#pragma omp parallel if (omp_threads > 0) num_threads(omp_threads)
#pragma omp parallel if (omp_threads > 1) num_threads(omp_threads)
{
#pragma omp for
for (int_t k = int_t(start); k < int_t(stop); k++) {
Expand All @@ -197,7 +197,7 @@ inline void apply_lambda(const size_t start,
const int_t END = stop >> NUM_QUBITS;
auto qubits_sorted = qubits;
std::sort(qubits_sorted.begin(), qubits_sorted.end());
#pragma omp parallel if (omp_threads > 0) num_threads(omp_threads)
#pragma omp parallel if (omp_threads > 1) num_threads(omp_threads)
{
#pragma omp for
for (int_t k = int_t(start); k < END; k++) {
Expand All @@ -222,7 +222,7 @@ inline void apply_lambda(const size_t start,
auto qubits_sorted = qubits;
std::sort(qubits_sorted.begin(), qubits_sorted.end());

#pragma omp parallel if (omp_threads > 0) num_threads(omp_threads)
#pragma omp parallel if (omp_threads > 1) num_threads(omp_threads)
{
#pragma omp for
for (int_t k = int_t(start); k < END; k+=gap) {
Expand Down Expand Up @@ -254,7 +254,7 @@ inline std::complex<double> apply_reduction_lambda(const size_t start,
// Reduction variables
double val_re = 0.;
double val_im = 0.;
#pragma omp parallel reduction(+:val_re, val_im) if (omp_threads > 0) num_threads(omp_threads)
#pragma omp parallel reduction(+:val_re, val_im) if (omp_threads > 1) num_threads(omp_threads)
{
#pragma omp for
for (int_t k = int_t(start); k < int_t(stop); k++) {
Expand All @@ -279,7 +279,7 @@ std::complex<double> apply_reduction_lambda(const size_t start,
// Reduction variables
double val_re = 0.;
double val_im = 0.;
#pragma omp parallel reduction(+:val_re, val_im) if (omp_threads > 0) num_threads(omp_threads)
#pragma omp parallel reduction(+:val_re, val_im) if (omp_threads > 1) num_threads(omp_threads)
{
#pragma omp for
for (int_t k = int_t(start); k < END; k++) {
Expand Down Expand Up @@ -308,7 +308,7 @@ std::complex<double> apply_reduction_lambda(const size_t start,
// Reduction variables
double val_re = 0.;
double val_im = 0.;
#pragma omp parallel reduction(+:val_re, val_im) if (omp_threads > 0) num_threads(omp_threads)
#pragma omp parallel reduction(+:val_re, val_im) if (omp_threads > 1) num_threads(omp_threads)
{
#pragma omp for
for (int_t k = int_t(start); k < END; k++) {
Expand Down
Loading

0 comments on commit 03f9465

Please sign in to comment.