Skip to content

Commit 19be22e

Browse files
committed
Move initialization and finalization of SQC to runtime service
1 parent fbff507 commit 19be22e

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

src/providers/sqc_backend.hpp

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ namespace providers {
3131
/// @brief Backend class using SQC.
3232
class SQCBackend : public BackendV2 {
3333
private:
34-
sqcInitOptions* init_options_;
3534
/// @note A circuit data will be built via qiskit-cpp, not SQC.
3635
/// A `qc_handle_` field is just used for an interface between qiskit-cpp and SQC.
3736
sqcQC* qc_handle_;
@@ -47,24 +46,16 @@ class SQCBackend : public BackendV2 {
4746
/// @param backend_name a resource name for backend.
4847
SQCBackend(const std::string name)
4948
: name_(name),
50-
init_options_(NULL),
5149
qc_handle_(NULL),
5250
backend_type_(SQC_RPC_SCHED_QC_TYPE_IBM_DACC),
5351
{
54-
init_options_ = sqcMallocInitOptions();
55-
init_options_->use_qiskit = 1; // only ibm_dacc is supported
56-
if(sqcInitialize(init_options_) != E_SUCCESS) {
57-
std::cerr << "Failed to initialize SQC" << std::endl;
58-
}
52+
5953
qc_handle_ = sqcQuantumCircuit(0);
6054
}
6155

62-
SQCBackend(const SQCBackend& other) = delete;
63-
64-
~SQCBackend() {
56+
~SQCBackend()
57+
{
6558
sqcDestroyQuantumCircuit(qc_handle_);
66-
sqcFinalize(init_options_);
67-
sqcFreeInitOptions(init_options_);
6859
}
6960

7061
/// @brief Return a target properties for this backend.

src/service/qiskit_runtime_service_sqc.hpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,26 @@ namespace service {
2424

2525
class QiskitRuntimeService {
2626
private:
27+
sqcInitOptions* init_options_;
28+
2729
public:
2830
/// @brief Create a new runtime service class
2931
QiskitRuntimeService()
32+
: init_options_(NULL)
3033
{
34+
init_options_ = sqcMallocInitOptions();
35+
init_options_->use_qiskit = 1; // only ibm_dacc is supported
36+
if(sqcInitialize(init_options_) != E_SUCCESS) {
37+
std::cerr << "Failed to initialize SQC" << std::endl;
38+
}
3139
}
3240

41+
QiskitRuntimeService(QiskitRuntimeService const&) = delete;
42+
3343
~QiskitRuntimeService()
3444
{
45+
sqcFinalize(init_options_);
46+
sqcFreeInitOptions(init_options_);
3547
}
3648

3749
/// @brief create a new backend object

0 commit comments

Comments
 (0)