Commit 64acc1de authored by Mccaskey, Alex's avatar Mccaskey, Alex
Browse files

Merge branch 'master' into mccaskey/antlr-python

parents d61651b6 36bef826
......@@ -11,7 +11,10 @@
* Alexander J. McCaskey - initial API and implementation
*******************************************************************************/
#include "XACC.hpp"
#include <pybind11/pybind11.h>
#include "IRGenerator.hpp"
#include <pybind11/complex.h>
#include <pybind11/numpy.h>
#include <pybind11/stl.h>
#include <pybind11/stl_bind.h>
#include <pybind11/eigen.h>
......@@ -97,6 +100,10 @@ PYBIND11_MODULE(_pyxacc, m) {
py::class_<xacc::IRPreprocessor, std::shared_ptr<xacc::IRPreprocessor>> (m, "IRPreprocesor", "").def("process", &xacc::IRPreprocessor::process, "");
py::class_<xacc::AcceleratorBufferPostprocessor, std::shared_ptr<xacc::AcceleratorBufferPostprocessor>> (m, "AcceleratorBufferPostprocessor", "").def("process", &xacc::AcceleratorBufferPostprocessor::process, "");
py::class_<xacc::IRGenerator, std::shared_ptr<xacc::IRGenerator>>(m, "IRGenerator", "")
.def("generate", (std::shared_ptr<xacc::Function> (xacc::IRGenerator::*)(
std::vector<xacc::InstructionParameter>)) &xacc::IRGenerator::generate, py::return_value_policy::reference, "");
// Expose the Kernel
py::class_<xacc::Kernel<>, std::shared_ptr<xacc::Kernel<>>>(m, "Kernel", "The XACC Kernel is the "
"executable functor that executes XACC IR on the desired Accelerator.")
......@@ -202,7 +209,10 @@ PYBIND11_MODULE(_pyxacc, m) {
"Return the Compiler of given name.");
m.def("getIRPreprocessor", (std::shared_ptr<xacc::IRPreprocessor> (*)(const std::string&))
&xacc::getService<IRPreprocessor>, py::return_value_policy::reference,
"Return the Compiler of given name.");
"Return the IRPreprocessor of given name.");
m.def("getIRGenerator", (std::shared_ptr<xacc::IRGenerator> (*)(const std::string&))
&xacc::getService<IRGenerator>, py::return_value_policy::reference,
"Return the IRGenerator of given name.");
m.def("setOption", &xacc::setOption, "Set an XACC framework option.");
m.def("getOption", &xacc::getOption, "Get an XACC framework option.");
m.def("optionExists", &xacc::optionExists, "Set an XACC framework option.");
......@@ -235,6 +245,13 @@ PYBIND11_MODULE(_pyxacc, m) {
return xacc::getService<IRProvider>("gate")->createIR();
}, "Convenience function for creating a new GateIR.");
gatesub.def("getState",
[](std::shared_ptr<Accelerator> acc, std::shared_ptr<Function> f) {
auto results = acc->getAcceleratorState(f);
Eigen::VectorXcd ret = Eigen::Map<Eigen::VectorXcd>(results.data(), results.size());
return ret;
}, "Compute and return the state after execution of the given program on the given accelerator.");
}
......@@ -13,6 +13,7 @@
#ifndef QUANTUM_AQC_ACCELERATOR_AQCACCELERATORBUFFER_HPP_
#define QUANTUM_AQC_ACCELERATOR_AQCACCELERATORBUFFER_HPP_
#include <numeric>
#include "AcceleratorBuffer.hpp"
#include "Embedding.hpp"
......
......@@ -71,7 +71,7 @@ if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU" OR "${CMAKE_CXX_COMPILER_ID}" MATCH
endif()
elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" AND APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
add_subdirector(antlr)
add_subdirectory(antlr)
elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" AND CMAKE_SYSTEM_NAME MATCHES "Linux")
execute_process(
COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE CLANG_VERSION)
......
Subproject commit 1d10cf0e87d355bddb46590b32cdc16fdbd221ad
Subproject commit 326160cc9bc6cd0ad42ba342bffee20f0ab665f5
......@@ -149,7 +149,8 @@ public:
return allocatedBuffers[varid];
} else {
auto tmpBuffer = createBuffer(varid, 100);
XACCLogger::instance()->info("Could not find AcceleratorBuffer with id " + varid + ", creating one with 100 bits.");
XACCLogger::instance()->info("Could not find AcceleratorBuffer with id " +
varid + ", creating one with 100 bits.");
storeBuffer(varid, tmpBuffer);
return tmpBuffer;
}
......@@ -196,6 +197,19 @@ public:
return 0.0;
}
/**
* Return a representation of the state of the Accelerator after execution of
* the given program Function instance. For quantum computation this is
* the wave vector.
*
* This is meant to be overrided by subclasses.
*
* @param program The program to execute
* @return wf A list of complex coefficients
*/
virtual const std::vector<std::complex<double>> getAcceleratorState(std::shared_ptr<Function> program)
{ return std::vector<std::complex<double>>{}; }
/**
* Given user-input command line options, perform
* some operation. Returns true if runtime should exit,
......@@ -208,6 +222,11 @@ public:
return false;
}
/**
* Return true if this Accelerator is a remotely hosted resource.
*
* @return remote True if this is a remote Accelerator
*/
virtual bool isRemote() {
return false;
}
......
......@@ -46,6 +46,10 @@ public:
std::vector<InstructionParameter> parameters = std::vector<
InstructionParameter> { }) = 0;
virtual std::shared_ptr<Function> generate(
std::vector<InstructionParameter> parameters = std::vector<
InstructionParameter> { }) {return generate(nullptr,parameters);}
/**
* The destructor
*/
......
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