Commit ed179109 authored by Mccaskey, Alex's avatar Mccaskey, Alex
Browse files

updating readme, setting up rpath for qcor compiler wrapper


Signed-off-by: Mccaskey, Alex's avatarAlex McCaskey <mccaskeyaj@ornl.gov>
parent 37c63f22
Pipeline #44124 passed with stages
in 2 minutes and 15 seconds
......@@ -34,6 +34,60 @@ $ mkdir build && cd build
$ cmake .. -DXACC_DIR=~/.xacc (or wherever you installed XACC)
$ make install
```
Update your PATH to ensure that the ```qcor``` compiler is available.
```bash
$ export PATH=$PATH:$HOME/.xacc/bin
```
To target IBM, Rigetti, or TNQVM, please also build the
corresponding XACC plugins. See https://xacc.readthedocs.io/en/latest/plugins.html.
\ No newline at end of file
corresponding XACC plugins. See https://xacc.readthedocs.io/en/latest/plugins.html.
## Example Usage
Here we demonstrate how to program, compile, and run the Deuteron H2 VQE problem. Create
the following file
```cpp
#include "qcor.hpp"
int main() {
// Initialize the QCOR Runtime
qcor::Initialize({"--accelerator", "tnqvm"});
// Create an Optimizer, default is NLOpt COBYLA
auto optimizer = qcor::getOptimizer("nlopt");
// Create the Deuteron Observable
const std::string deuteronH2 =
R"deuteronH2((5.907,0) + (-2.1433,0) X0 X1 + (-2.1433,0) Y0 Y1 + (.21829,0) Z0 + (-6.125,0) Z1)deuteronH2";
PauliOperator op;
op.fromString(deuteronH2);
// Schedule an asynchronous VQE execution
// with the given quantum kernel ansatz
auto future = qcor::submit([&](qcor::qpu_handler &qh) {
qh.vqe(
[&](double t0) {
X(0);
Ry(t0, 1);
CX(1, 0);
},
op, optimizer);
});
// Get and print the results
auto results = future.get();
results->print();
}
```
To compile this with QCOR, run the following
```bash
$ qcor deuteron.cpp -o deuteron
```
This will create the ```deuteron``` quantum-classical binary executable.
Now just run
```bash
$ ./deuteron
```
\ No newline at end of file
......@@ -15,5 +15,11 @@ target_include_directories(${LIBRARY_NAME}
${XACC_INCLUDE_ROOT}/cppmicroservices4)
target_link_libraries(${LIBRARY_NAME}
PUBLIC ${CLANG_LIBS} ${XACC_LIBRARIES} qcor)
if(APPLE)
set_target_properties(${LIBRARY_NAME} PROPERTIES INSTALL_RPATH "@loader_path")
set_target_properties(${LIBRARY_NAME} PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
else()
set_target_properties(${LIBRARY_NAME} PROPERTIES INSTALL_RPATH "$ORIGIN")
set_target_properties(${LIBRARY_NAME} PROPERTIES LINK_FLAGS "-shared")
endif()
install(TARGETS ${LIBRARY_NAME} DESTINATION lib)
......@@ -19,7 +19,7 @@ target_include_directories(
${LIBRARY_NAME}
PUBLIC . .. ${CMAKE_BUILD_DIR}/runtime/nlopt-optimizers/nlopt/src/api)
target_link_libraries(${LIBRARY_NAME} PUBLIC nlopt)
target_link_libraries(${LIBRARY_NAME} PUBLIC nlopt CppMicroServices)
set(_bundle_name qcor_runtime_nlopt)
set_target_properties(${LIBRARY_NAME}
......
......@@ -3,6 +3,7 @@ import argparse
import sys
import subprocess
def parse_args(args):
parser = argparse.ArgumentParser(description="QCOR Quantum-Classical C++ Compiler.",
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
......@@ -26,7 +27,7 @@ def parse_args(args):
def main(argv=None):
opts = parse_args(sys.argv[1:])
command = ["@CLANG_COMPILER@", '-std=c++11', '-Xclang', '-load', '-Xclang', '@CMAKE_INSTALL_PREFIX@/lib/libqcor-ast-plugin.so',
command = ["@CLANG_COMPILER@", '-std=c++11', '-Wl,-rpath,@CMAKE_INSTALL_PREFIX@/lib', '-Xclang', '-load', '-Xclang', '@CMAKE_INSTALL_PREFIX@/lib/libqcor-ast-plugin.so',
'-Xclang', '-add-plugin', '-Xclang', 'enable-quantum']
if opts.accelerator:
command += ['-plugin-arg-enable-quantum', '-Xclang', 'accelerator', '-Xclang',
......
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