Skip to content

Commit

Permalink
fix Thrust seg fault
Browse files Browse the repository at this point in the history
  • Loading branch information
doichanj committed Dec 8, 2023
1 parent e5626df commit 259aecb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/simulators/density_matrix/densitymatrix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,12 @@ void DensityMatrix<data_t>::initialize_from_vector(list_t &&vec) {

template <typename data_t>
void DensityMatrix<data_t>::transpose() {
const size_t rows = BaseMatrix::num_rows();
const int_t rows = BaseMatrix::num_rows();
#pragma omp parallel for if (BaseVector::num_qubits_ > \
BaseVector::omp_threshold_ && \
BaseVector::omp_threads_ > 1) \
num_threads(BaseVector::omp_threads_)
for (uint_t i = 0; i < rows; i++) {
for (int_t i = 0; i < rows; i++) {
for (uint_t j = i + 1; j < rows; j++) {
const uint_t pos_a = i * rows + j;
const uint_t pos_b = j * rows + i;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class State : public QuantumState::State<chstate_t> {
// Apply a sequence of operations to the cicuit. For each operation,
// we loop over the terms in the decomposition in parallel
template <typename InputIterator>
void apply_ops_stab(InputIterator first, InputIterator last,
void apply_ops(InputIterator first, InputIterator last,
ExperimentResult &result, RngEngine &rng,
bool final_ops = false);

Expand Down Expand Up @@ -341,11 +341,11 @@ bool State::check_measurement_opt(InputIterator first,
//-------------------------------------------------------------------------
void State::apply_op(const Operations::Op &op, ExperimentResult &result,
RngEngine &rng, bool final_op) {
apply_ops_stab(&op, &op + 1, result, rng, final_op);
apply_ops(&op, &op + 1, result, rng, final_op);
}

template <typename InputIterator>
void State::apply_ops_stab(InputIterator first, InputIterator last,
void State::apply_ops(InputIterator first, InputIterator last,
ExperimentResult &result, RngEngine &rng,
bool final_ops) {
std::pair<bool, size_t> stabilizer_opts = check_stabilizer_opt(first, last);
Expand Down
3 changes: 3 additions & 0 deletions src/simulators/statevector/qubitvector_thrust.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,7 @@ uint_t QubitVectorThrust<data_t>::chunk_setup(int chunk_bits, int num_qubits,

if (chunk_manager_->chunk_bits() == chunk_bits &&
chunk_manager_->num_qubits() == num_qubits) {
chunk_manager_->MapChunk(chunk_, 0);
chunk_.set_chunk_index(chunk_index_);
return num_local_chunks;
}
Expand Down Expand Up @@ -903,6 +904,7 @@ uint_t QubitVectorThrust<data_t>::chunk_setup(int chunk_bits, int num_qubits,

// mapping/setting chunk
chunk_.set_chunk_index(chunk_index_);
chunk_manager_->MapChunk(chunk_, 0);

return num_chunks_allocated;
}
Expand Down Expand Up @@ -930,6 +932,7 @@ QubitVectorThrust<data_t>::chunk_setup(const QubitVectorThrust<data_t> &base,

// mapping/setting chunk
chunk_manager_ = base.chunk_manager_;
chunk_manager_->MapChunk(chunk_, 0);

return 0;
}
Expand Down

0 comments on commit 259aecb

Please sign in to comment.