diff --git a/src/qirxacc/XaccQuantum.cc b/src/qirxacc/XaccQuantum.cc index 0c5be59..5f97d5e 100644 --- a/src/qirxacc/XaccQuantum.cc +++ b/src/qirxacc/XaccQuantum.cc @@ -51,9 +51,7 @@ XaccQuantum::XaccQuantum(std::ostream& os, xacc::setIsPyApi(); // Create accelerator - accelerator_ = xacc::getAccelerator(accel_name); - QIREE_VALIDATE(accelerator_, << "failed to create accelerator"); - accelerator_->updateConfiguration({{"shots", static_cast(shots)}}); + set_accelerator_and_shots(accel_name, shots); // TODO: bit order is accelerator-dependent? endian_ = Endianness::little; @@ -76,6 +74,17 @@ XaccQuantum::~XaccQuantum() xacc::Finalize(); } +//---------------------------------------------------------------------------// +/*! + * Update the XACC accelerator and shot count. + */ +void XaccQuantum::set_accelerator_and_shots( + std::string const& accel_name, size_type shots) { + accelerator_ = xacc::getAccelerator(accel_name); + QIREE_VALIDATE(accelerator_, << "failed to create accelerator"); + accelerator_->updateConfiguration({{"shots", static_cast(shots)}}); +} + //---------------------------------------------------------------------------// /*! * Prepare to build a quantum circuit for an entry point. diff --git a/src/qirxacc/XaccQuantum.hh b/src/qirxacc/XaccQuantum.hh index 3e67cfd..29e143d 100644 --- a/src/qirxacc/XaccQuantum.hh +++ b/src/qirxacc/XaccQuantum.hh @@ -58,6 +58,13 @@ class XaccQuantum final : virtual public QuantumNotImpl, size_type num_qubits() const { return num_qubits_; } //!@} + //!@{ + //! \name Mutators + // Update the XACC accelerator and shot count + void set_accelerator_and_shots( + std::string const& accel_name, size_type shots); + //!@} + //!@{ //! \name Quantum interface // Prepare to build a quantum circuit for an entry point