Skip to content

Commit 34ed8f3

Browse files
authored
Revert "Q-IRIS related changes to expose QIREE-QSIM and QIREE-XACC APIs to IRIS" (#26)
Revert "Q-IRIS related changes to expose QIREE-QSIM and QIREE-XACC APIs to IR…" This reverts commit eb1c21e.
1 parent eb1c21e commit 34ed8f3

File tree

5 files changed

+114
-206
lines changed

5 files changed

+114
-206
lines changed

app/CMakeLists.txt

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,8 @@ if(QIREE_USE_QSIM)
2222
qiree_add_executable(qir-qsim
2323
qir-qsim.cc
2424
)
25-
qiree_add_library(qir.qsim.lib SHARED
26-
qir-qsim-lib.cc
27-
)
28-
target_link_libraries(qir.qsim.lib
29-
PUBLIC QIREE::qiree QIREE::qirqsim
30-
PRIVATE CLI11::CLI11
31-
)
3225
target_link_libraries(qir-qsim
33-
PUBLIC QIREE::qiree QIREE::qirqsim qir.qsim.lib
26+
PUBLIC QIREE::qiree QIREE::qirqsim
3427
PRIVATE CLI11::CLI11
3528
)
3629
endif()
@@ -43,15 +36,8 @@ if(QIREE_USE_XACC)
4336
qiree_add_executable(qir-xacc
4437
qir-xacc.cc
4538
)
46-
qiree_add_library(qir.xacc.lib SHARED
47-
qir-xacc-lib.cc
48-
)
49-
target_link_libraries(qir.xacc.lib
50-
PUBLIC QIREE::qiree QIREE::qirxacc
51-
PRIVATE CLI11::CLI11
52-
)
5339
target_link_libraries(qir-xacc
54-
PUBLIC QIREE::qiree QIREE::qirxacc qir.xacc.lib
40+
PUBLIC QIREE::qiree QIREE::qirxacc
5541
PRIVATE CLI11::CLI11
5642
)
5743
endif()

app/qir-qsim-lib.cc

Lines changed: 0 additions & 81 deletions
This file was deleted.

app/qir-qsim.cc

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// See the top-level COPYRIGHT file for details.
44
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
55
//---------------------------------------------------------------------------//
6-
//! \file app/qir-qsim.cc
6+
//! \file qir-xacc/qir-xacc.cc
77
//---------------------------------------------------------------------------//
88
#include <cstdlib>
99
#include <iostream>
@@ -18,14 +18,57 @@
1818

1919
using namespace std::string_view_literals;
2020

21-
int parse_input(int argc, char* argv[]);
21+
namespace qiree
22+
{
23+
namespace app
24+
{
2225
//---------------------------------------------------------------------------//
26+
void run(std::string const& filename, int num_shots)
27+
{
28+
// Load the input
29+
Executor execute{Module{filename}};
30+
31+
// Set up qsim
32+
QsimQuantum sim(std::cout, 0);
33+
QsimDefaultRuntime rt(std::cout, sim);
34+
ResultDistribution distribution;
35+
36+
// Run several time = shots (default 1)
37+
for (int i = 0; i < num_shots; i++)
38+
{
39+
execute(sim, rt);
40+
distribution.accumulate(rt.result());
41+
}
42+
43+
std::cout << distribution.to_json() << std::endl;
44+
}
45+
46+
//---------------------------------------------------------------------------//
47+
} // namespace app
48+
} // namespace qiree
2349

2450
//---------------------------------------------------------------------------//
2551
/*!
2652
* Execute and run.
2753
*/
2854
int main(int argc, char* argv[])
2955
{
30-
return parse_input(argc, argv);
56+
int num_shots{1};
57+
std::string filename;
58+
59+
CLI::App app;
60+
61+
auto* filename_opt
62+
= app.add_option("--input,-i,input", filename, "QIR input file");
63+
filename_opt->required();
64+
65+
auto* nshot_opt
66+
= app.add_option("-s,--shots", num_shots, "Number of shots");
67+
nshot_opt->capture_default_str();
68+
69+
CLI11_PARSE(app, argc, argv);
70+
71+
qiree::app::run(filename, num_shots);
72+
73+
return EXIT_SUCCESS;
3174
}

app/qir-xacc-lib.cc

Lines changed: 0 additions & 103 deletions
This file was deleted.

app/qir-xacc.cc

Lines changed: 66 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// See the top-level COPYRIGHT file for details.
44
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
55
//---------------------------------------------------------------------------//
6-
//! \file app/qir-xacc.cc
6+
//! \file qir-xacc/qir-xacc.cc
77
//---------------------------------------------------------------------------//
88
#include <cstdlib>
99
#include <iostream>
@@ -22,13 +22,76 @@
2222

2323
using namespace std::string_view_literals;
2424

25-
int parse_input(int argc, char* argv[]);
25+
namespace qiree
26+
{
27+
namespace app
28+
{
29+
//---------------------------------------------------------------------------//
30+
void run(std::string const& filename,
31+
std::string const& accel_name,
32+
int num_shots,
33+
bool print_accelbuf,
34+
bool group_tuples)
35+
{
36+
// Load the input
37+
Executor execute{Module{filename}};
38+
39+
// Set up XACC
40+
XaccQuantum xacc(std::cout, accel_name, num_shots);
41+
std::unique_ptr<RuntimeInterface> rt;
42+
if (group_tuples)
43+
{
44+
rt = std::make_unique<XaccTupleRuntime>(
45+
std::cout, xacc, print_accelbuf);
46+
}
47+
else
48+
{
49+
rt = std::make_unique<XaccDefaultRuntime>(
50+
std::cout, xacc, print_accelbuf);
51+
}
52+
53+
// Run
54+
execute(xacc, *rt);
55+
}
56+
57+
//---------------------------------------------------------------------------//
58+
} // namespace app
59+
} // namespace qiree
2660

2761
//---------------------------------------------------------------------------//
2862
/*!
2963
* Execute and run.
3064
*/
3165
int main(int argc, char* argv[])
3266
{
33-
return parse_input(argc, argv);
67+
int num_shots{1024};
68+
std::string accel_name;
69+
std::string filename;
70+
bool no_print_accelbuf{false};
71+
bool group_tuples{false};
72+
73+
CLI::App app;
74+
auto* filename_opt
75+
= app.add_option("--input,-i,input", filename, "QIR input file");
76+
filename_opt->required();
77+
auto* accel_opt
78+
= app.add_option("-a,--accelerator", accel_name, "Accelerator name");
79+
accel_opt->required();
80+
auto* nshot_opt
81+
= app.add_option("-s,--shots", num_shots, "Number of shots");
82+
nshot_opt->capture_default_str();
83+
app.add_flag("--no-print-xacc-accelbuf",
84+
no_print_accelbuf,
85+
"Do not print XACC AcceleratorBuffer");
86+
app.add_flag("--group-tuples",
87+
group_tuples,
88+
"Print per-tuple/per-array measurement statistics rather "
89+
"than per-qubit");
90+
91+
CLI11_PARSE(app, argc, argv);
92+
93+
qiree::app::run(
94+
filename, accel_name, num_shots, !no_print_accelbuf, group_tuples);
95+
96+
return EXIT_SUCCESS;
3497
}

0 commit comments

Comments
 (0)