Unverified Commit 84eaaff9 authored by Mccaskey, Alex's avatar Mccaskey, Alex Committed by GitHub

Merge pull request #234 from tnguyen-ornl/tnguyen/uga-example

Added an example to load QASM example
parents 9ca16736 254208e8
Pipeline #112742 passed with stage
in 68 minutes and 33 seconds
......@@ -38,3 +38,7 @@ target_link_libraries(qaoa_qubo PRIVATE xacc xacc-quantum-gate)
add_executable(quantum_phase_estimation quantum_phase_estimation.cpp)
target_link_libraries(quantum_phase_estimation PRIVATE xacc xacc-quantum-gate)
add_executable(phase_estimation_qasm phase_estimation_10q.cpp)
target_link_libraries(phase_estimation_qasm PRIVATE xacc xacc-quantum-gate)
target_compile_definitions(phase_estimation_qasm PRIVATE QASM_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}/resources")
#include "xacc.hpp"
int main(int argc, char **argv) {
xacc::Initialize(argc, argv);
// State-vector simulator: "aer", "qpp"
auto accelerator = xacc::getAccelerator("aer");
auto compiler = xacc::getCompiler("staq");
const std::string QASM_SRC_FILE = std::string(QASM_SOURCE_DIR) + "/qasm_src.txt";
// Read source file:
std::ifstream inFile;
std::stringstream strStream;
strStream << inFile.rdbuf();
const std::string qasmSrcStr = strStream.str();
// Compile:
auto IR = compiler->compile(qasmSrcStr);
auto program = IR->getComposites()[0];
std::cout << "Number of instructions: " << program->nInstructions() << "\n";
// Allocate some qubits and execute:
auto buffer = xacc::qalloc(10);
accelerator->execute(buffer, program);
\ No newline at end of file
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment